From olli at secnetix.de Mon Nov 12 09:59:36 2001 From: olli at secnetix.de (Oliver Fromme) Date: Mon, 12 Nov 2001 14:59:36 +0000 (UTC) Subject: string manipulation question References: Message-ID: <9soo4o$c23$1@isp-m-srv06.izb.net> AT&T News wrote: > I have a string (line) that might contain, for example *any* *one* of the > patterns or words "whale" , "cat". > How do I elegantly set a variable say "animal" depending upon what word is > there. I.e I want > animal = "MAMMAL" if line contains the word "whale" > or > animal = "FELINE" if line contains the word "cat". > > is there a elegant way to code the above construct, I have 10 of these > patterns/keywords that can be found in a line. I thought of using a > dictionary for the keyword patterns, but the pattern/keyword does not have > any known context in the line. Don't know if this is what you want, but it seems to match your description, and I think it's fairly "elegant" ... >>> words = {"whale": "MAMMAL", "cat": "FELINE"} >>> def find_animal(line): ... return filter(lambda (key, val): key in line.split(), words.items())[0][1] ... >>> find_animal("My cat has white feet.") 'FELINE' >>> find_animal("There's a whale in my bath tube.") 'MAMMAL' You'll probably want to split that long line somehow, and also catch IndexError exceptions (which are raised if none of the words occur in the line). Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From maxm at normik.dk Thu Nov 22 05:06:05 2001 From: maxm at normik.dk (Max M) Date: Thu, 22 Nov 2001 11:06:05 +0100 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> "the Spinning Spider" wrote in message news:9tia10$43o$1 at dahlia.singnet.com.sg... > I notice there doesn't seem to be much mention about PHP by Python people > whenever they mention other languages, > e.g.,see http://www.python.org/doc/Comparisons.html. I think you will find that the general concensus is that Python is a "complete" language. Which PHP is not. Python can be used for both web scripting and, shell scripting, application development, small tools and gui apps. And is very good at all of them. Wheras PHP is only useable for scripting web pages. Furthermore PHP kind of forces you to write web-apps in one way with presentation and logic mixed. Also when your web-apps can do all the standard fare that is the staple of PHP you will suddenly need some feature that's not available in PHP. Then it is much easier to use the Python standard library to roll your own solution. > Or is it because PHP is incomparable against Python? They can certainly be compared, but once you know Python you are less likely to use PHP for much. That said, I have often used PHP for simple form mail and database views. It's often installed by default at customers isp's. So it's faster to whip something up in it, rather than trying to get Python to as cgi. > Will Python be too intellectually challenging, like Java? No ... Python will fit your brain, and you can basically do the same as with Java. Regards Max M From zope at thewebsons.com Sun Nov 18 14:30:29 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sun, 18 Nov 2001 11:30:29 -0800 Subject: RANSOM DEMAND: Image Held Hostage! In-Reply-To: <001d01c17066$adf3dda0$0101010a@local> References: <5.1.0.14.0.20011118100745.00a12170@thewebsons.com> Message-ID: <5.1.0.14.0.20011118113012.00a079f0@thewebsons.com> Perfect. Thank you! BenO At 01:24 PM 11/18/01 -0600, you wrote: >----- Original Message ----- >From: "Ben Ocean" > > > > I need a way to size up images via script. Now, in that inferior scripting > > language known as PHP, *they* have such a tool: getimagesize(). > >When you say "size up" you mean to retrieve the image dimensions? All this >time I thought you wanted to *resize* the images! > > > Can it be > > that God's gift to scripting languages, Python, can't compete here? If >it's > > true that PHP has one up on us here, how can I write a script that bridges > > this dastardly gap? > >There are two options that come to mind... the Pythonware Imaging Library >at pythonware.com, and the GDmodule (which I currently maintain) at >http://newcenturycomputers.net/projects/gdmodule.html > >Using GDmodule, you'd say > > import gd > img = gd.image("filename.goes.here.jpg") > print img.size() > >to print the tuple of (x,y) dimensions of the picture. > >Actually changing the size would be harder, requiring allocation of a new >empty image of the correct size, followed by using the img.copyResizedTo() >method. From nomad*** at ***freemail.absa.co.za Fri Nov 9 08:50:07 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Fri, 09 Nov 2001 15:50:07 +0200 Subject: Python and UMLStudio Message-ID: Hi, I use UMLStudio from pragsoft every now and again to build UML as it has a nice code generation (and reverse engineering) system that uses a LISP like scripting language for creating the source files and/or documentation. However, it is only shipped with scripts for creating Ada95, C++, Corba IDL and Java source files. Due to this I was thinking that I'd sit down someday to hack out a Python generation script. But before I do this (ans possibly re-invent the wheel in a language new to me), has anyone already done it? Does anyone know of a Python code generation script for PragSoft's UMLStudio? If noone knows what I'm on about, you can run UMLStudio is freeware mode for small projects. Check out www,pragsoft.com (and no, I don't have any vested interest in the company.) TIA -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From db3l at fitlinxx.com Thu Nov 29 01:34:29 2001 From: db3l at fitlinxx.com (David Bolen) Date: 29 Nov 2001 01:34:29 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> Message-ID: Gerhard =?unknown-8bit?Q?H=E4ring?= writes: > If this is because it's a Micro$oft shop, Visual Source"safe" is a reasonable > version control software. Btw. CVS also has deficiencies like no history of > meta-operations like file moving/renaming, etc. (minor MS-bash .. Definitely agree on the CVS shortcomings, but but at least CVS handles branching reasonably) (...) > Or use CVSNT (http://www.cvsnt.org/), which is a native win32 CVS server (and > client). I'd agree on both of the above points. We're primarily an MS-shop and most of our source is in SourceSafe (it really does integrate the best with the MS tools and certainly provides a nicer interface for most MS-based developers). But we also keep some of our large network projects in CVS. Partially because the team working on them are Unix-background and familiar with it but partially since it's really appropriate in some cases (such as tracking internal versions of third party sources). While stock CVS can compile under Cygwin (which we also use), the nice things about CVSNT is that it easily runs as a service without any shims, and that it supports NT authentication. So you run it on your server, and then use :ntserver:.... as your CVSPATH and it uses the existing NT authentication system. > There are also nice CVS GUIs for Windows: http://www.cvsgui.org/ and my > favourite http://www.cvsgui.org/TortoiseCVS/index.shtml which is an Explorer > plug-in that let's you use CVS from the standard Windows Explorer. >From my perspective, I haven't been overly enthusiastic about WinCVS (the cvsgui link), at least not enough to try to promote its use. It's not bad, but I found the command line much more productive. Haven't seen the Explorer plug in, so I'll have to check that out. To the original poster - regardless of SourceSafe or CVS, get something. Doing any professional development without source code control is working without a net. The benefits are great and the overhead relatively small. I can't imagine not using one even for the smallest of my own personal projects at this point, simply because it provides so much in terms of functionality over the course of development. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From ee_fhw at stu.ust.hk Sun Nov 4 04:55:17 2001 From: ee_fhw at stu.ust.hk (Calvin) Date: Sun, 04 Nov 2001 17:55:17 +0800 Subject: Solving Partial Differential equation in Python Message-ID: <3BE51085.90702@stu.ust.hk> Greetings, Did anyone have the experience in solving a PDE numerically in Python. The PDE is a Euler-Lagrange equation. In fact it is a simulation of LCD modeling. I search the web and find many libraries like Numeric Python. But I cannot find any library aim at solving PDE. So I think I have to design my own Algorithm. Could anyone help me. -Calvin From db3l at fitlinxx.com Mon Nov 12 23:45:51 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Nov 2001 23:45:51 -0500 Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: Peter Hansen writes: > I just created two million-integer lists with "[0] * 1000000" and > compared them, then reassigned the second name to reference the > first list and compared again. There was a noticeable pause during > both compares (with "=="). > > Comparing two lists with different lengths *does* return > "immediately". > > -empirically-yr's On the non-empirical front, I peeked at the listobject.c source for its list_richcompare function and no, there doesn't appear to be any shortcut check for having both lists refer to the same object (at least in the latest CVS source). It does do the length check (for == and !=), but otherwise it's the full recursion with the generic comparison applied to each element. It would be an easy optimization to add, although I'm wondering how much benefit typical real-life code would see. -- -- 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 at vegeta.ath.cx Wed Nov 14 20:10:13 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 15 Nov 2001 01:10:13 GMT Subject: Python Vim Module - works References: Message-ID: Andrei Kulakov graced us by uttering: > I'm sorry if this is a dumb question, but what's the purpose of this? Andrei Kulakov graced us again by uttering: > I just don't understand what is the > purpose, i.e. what would be a useful application of this module? > > I'm asking because I love vim and I used python vim module and if > someone finds this thing useful, I might too.. I can't seem to say what I mean, so let the author speak for himself: In correspondence, Tim Hammerquist wrote: > Jonathan Gardner wrote: > > The main idea that drove me to this insanity was getting a way to edit > > files with vim and also to incorporate some kind of IDE with it. For > > instance, Wouldn't It Be Great If (TM): You could edit Python classes > > outside of the script, and see your changes immediately inserted into the > > file? WIBGI you could connect your debugger (which cannot run inside Vim) > > to Vim and have it highlight lines and show error messages? WIBGI you could > > actually CHOOSE which editor you used for all the day-to-day stuff? This is > > all the first step towards it. > > > > All that I implemented at this point is the code to allow you to send > > messages to a vim session. In the future, I will implement some code to get > > the responses. And then maybe I'll be able to build an interface to allow > > you to work directly with buffers, etc... > > > > Jonathan > > WIBGI is one of major driving forces of software development (as opposed > to a suit's request..."It would be great if you could...for me. > Thanks.") > > This will also allow Vim to offer the flexibility Emacs loves to claim, > but without the monolithic size. Yay! =) > > Tim Hammerquist -- All mail clients suck. This one just sucks less. -- Michael Elkins on mutt From phr-n2001d at nightsong.com Mon Nov 5 16:15:16 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 13:15:16 -0800 Subject: PDF->Text converter/extractor References: <3be6fa21$1@sol.wohnheim.uni-ulm.de> Message-ID: <7xelncq5qz.fsf@ruckus.brouhaha.com> "Igor Stroh" writes: > though I didnt find anything yet, perhaps there is someone who already > had the same problem and solved it by writing an own PDF parser? :) I'm > too lazy to start reading the specs of PDF and try to write the thingy by > myself :) I think there's a Postscript to text converter somewhere based on Ghostscript. PDF's are just compressed Postscript so it should be straightforward to modify the Postscript to text converter to handle PDF's, if it hasn't been done already. From mwh at python.net Thu Nov 8 05:06:43 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 8 Nov 2001 10:06:43 GMT Subject: Fatal Python error: ceval: tstate mix-up References: Message-ID: gb at cs.unc.edu writes: > I just started (sporadically) getting the above message followed by > "The instruction at "0x77a7b0fc" referenced memory at "0x0000000c", > the memory could not be "read" in my python/wxpython-based imap email > client. I recently added a thread to handle posting messages to the > smtp server in the background. I'm careful not to touch the GUI from > the sending thread. > > This is with python 2.1 on Windows 2000 with wxpython 2.3. > > Any clues on how to track this down? The "Fatal Python error" part > makes it sound like an internal bug... As far as I can tell, this is only likely to happen if you are executing Python code without holding the global interpreter lock. This is probably going to be a bug in wxPython, but I'm not sure. Have you got the latest version of such? This is just guesswork; take with a pinch of salt. HTH, M. -- This is an off-the-top-of-the-head-and-not-quite-sober suggestion, so is probably technically laughable. I'll see how embarassed I feel tomorrow morning. -- Patrick Gosling, ucam.comp.misc From mgkiourt at otenet.gr Thu Nov 22 07:26:26 2001 From: mgkiourt at otenet.gr (mgkiourt) Date: Thu, 22 Nov 2001 14:26:26 +0200 Subject: Director 8.5 of Macromedia Message-ID: <9tiqt2$2td5$1@ulysses.noc.ntua.gr> Are python or javascript scripting options for Director 8.5? Thanks.Mike From eric at enthought.com Sat Nov 24 00:14:55 2001 From: eric at enthought.com (eric jones) Date: Sat, 24 Nov 2001 05:14:55 GMT Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <3BFC0365.21FB6AA1@alcyone.com> Message-ID: > Python is not a very good choice for genetic programming. Its syntax is > too complicated, especially if we take into account that it is > indentation sensitive. I think using the abstract syntax tree (AST) for the genome might be a fruitful alternative to working with standard (human readable) Python code. Jermey Hylton discussed a new-ish module called 'parser' at the last Python conference that allows you to convert code strings to ASTs, manipulate the boogers, and run them. I thought this was so cool, I ran home and found a problem that could use it. The result, scipy.compiler, uses the AST to help translate Numeric expressions from Python to faster C++ expressions that are compiled and run on the fly. As far as GP is concerned, I haven't tried it yet, but I think the AST makes a nice chromosome. You can create AST's from lists, futz around with them till your hearts content (crossover, mutation), and evaluate them. That pretty much covers the needs of GAs (or GPs or whatever). Bytecode might work too, but I've never messed with it (and it doesn't include the grammatical info like the AST). As for GA/GP in Python, scipy.ga is a genetic algorithm library that supports both string and tree chromosomes. The tree chromosomes were designed specifically for language based (grammatically based, or whatever you want to call it) genetic optimization. It was used for designing electronic circuits and antennas using simple languages (CFGs defined in Python) that described how components of the systems could be connected. Everything but the computational engine for antenna analysis (and maybe parts of the circuit analysis) was written in Python. Let me know if your interested in papers on the stuff. By the way, I think you could define a sub-set of Python to be used in the chromosomes by defining a simpler grammar in the tools available in scipy.ga, but again I haven't explored this avenue at all. If it worked, that would mitigate issues with Python's language complexity. The genetic programming aspects of scipy.ga haven't been talked about much, and the entire library is short on documentation. It does, however, have most of the needed tools and has served me very well. I'd like to add pareto optimization and a string genome suitable for traveling salesman type problems, but other than that, its main deficiencies are documentation, unit testing, and a few architectural warts. Take a look, maybe it'll be of some help. I'd love to see someone have at optimizing python code with ASTs. see ya, eric > > This is why languages such as LISP are used for genetic programming; > their syntax is simple and it's easy to verify if a program is legal or > not and to keep it legal while performing genetic operations (mutation, > crossover, etc.). > > I myself in the past have used stack-based languages which are promising > since even the constraint on program legality is dropped, provided you > make certain concessions such as allowing a bottomless operand stack, > having the key variables of the simulation available by means of special > operators, etc. With a suitable choice for environment, every sequence > of legal operators is itself a legal program. > > -- > Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ > __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE > / \ Laws are silent in time of war. > \__/ Cicero > Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ > An Esperanto reference for English speakers. From Gareth.McCaughan at pobox.com Thu Nov 29 19:51:14 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 30 Nov 2001 00:51:14 +0000 Subject: Python evangelists unite! References: Message-ID: brucehapman at hotmail.com wrote: > Okay, I was extolling the benefits of Python to a friend of mine. He > took strong exception to Python's OO model. > > ME: Python's great--you can add members to instances OR classes > on-the-fly! > FRIEND: Why would you want to do that? > ME: Uh... > FRIEND: Besides, that's awful Object Orientation. If I start adding > attributes to an instance of a class, it ceases to be an instance of > that class. If I create a bunch of instances of the same class, they > should be the same; they should have the same members. Twaddle. They should provide the same interface. What members they have is completely irrelevant to that, unless those members are part of the interface you specify. (It so happens that in Python there isn't really an in-language mechanism for saying what's part of the interface and what isn't, but that doesn't mean your objects don't have interfaces.) And, of course, there's no law that says Python's objects are only to be used for "proper" elegant OO programming. They have other uses. :-) > ME: Yeah, but with dynamicism, I can add a new pane to a GUI > while it's running. I just change an instance to include a new pane, > and... > FRIEND: That's pretty cool, but it's not a reason, in and of itself, > to make a language so dynamic. There must be some advantage to being > able to add attributes during runtime. What are they? > ME: Uh... > FRIEND: And another thing! What's with encapsulation? There's no > private!?!?!? Here's an entry from my personal quotes file. It's about CLOS (the Common Lisp Object System), which in most respects is a very different beast from Python's object system; but they have a similar attitude to encapsulation. ... it's just that in C++ and the like, you don't trust _anybody_, and in CLOS you basically trust everybody. the practical result is that thieves and bums use C++ and nice people use CLOS. -- Erik Naggum Someone who can't write well-formed OO programs without a mechanism like "private" has serious problems with their ability to write comments, or their ability to write other documentation, or their discipline, or something. Besides, in C++ at least, you can say #define private public #include "my-class.h" #undef private Yow! > ME: > > So, I need some help. I've checked out c.l.p and some on-line > articles, and I just can't find good practicle examples of a program > that adds members to instances (or classes) at runtime. Anybody got > any? I don't want to have to start avoiding my friend.... The main advantage isn't the ability to add members at runtime as such. That's just a side-effect of the fact that you don't need explicit declarations of what can go in a class. And *that*'s good for three reasons. - Less repetitetition. Don't you just hate having to write the same thing twice in C and C++? Programming's bad enough for the wrists without having to write a pile of redundant code. - Handy for exploratory programming, where you sit at an interactive prompt and play with things. If you suddenly realise that you can make something go 10 times faster by cacheing a crucial piece of information inside your objects, it's nice that you can just add it and have it work. I suppose that *is* adding members at runtime, actually, but I suspect it's not the sort you had in mind. - One handy Python idiom is using an empty class definition to provide things like "structs" in C. class Empty: pass stuff = Empty() stuff.largest_prime = 44 stuff.modulus = -1 # etc Having said that being able to add members at runtime isn't quite the point, let me sort-of-contradict that by describing something slightly icky I do in a program I use at work. I'm collecting data from a sensor, and I want to be able to do various bits of processing on the data. But not every packet of data needs all the processing done on it. And, once all the processing is done, I then want to stash a large number of data-packets into a pickle for later use by another program. I don't want my pickles to be hundreds of megabytes long. So, my class looks a little like this: class Packet: def __init__(self, data): self._data = data self._processed = 0 def ensure_processed(self): self._squares = map(operator.mul, self._data, self._data) self._average = reduce(operator.add, self._data) / len(self._data) self._sumsofquares = reduce(operator.add, self._Squares) # blah blah blah self._processed = 1 def minimize(self): try: del self._squares del self._sumofsquares # blah blah except: pass my_packets = build_many_packets(100000) do_hairy_stuff_with_packets(my_packets) map(Packet.minimize, my_packets) cPickle.dump(open("data.pickled", "w")) (Only a little like that; what it actually does is a lot more complicated.) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From werme at mediaone.net Thu Nov 29 21:04:59 2001 From: werme at mediaone.net (Ric Werme) Date: Fri, 30 Nov 2001 02:04:59 GMT Subject: New updates needed for an old computer language humor piece Message-ID: The following wandered into my mail box for the first time in a year or two. Since I've been learning a bit of Python this year, it seems to me an update is needed. For Logo, perhaps: Draw a foot, draw a gun, but the bullet comes out the handle and misses the foot altogether. -Ric Werme -------------------------------------------------- THE PROGRAMMER'S QUICK GUIDE TO THE LANGUAGES The proliferation of modern programming languages (all of which seem to have stolen countless features from one another) sometimes makes it difficult to remember what language you're currently using. This handy reference is offered as a public service to help programmers who find themselves in such a dilemma. TASK: Shoot yourself in the foot. C: You shoot yourself in the foot. C++: You accidentally create a dozen instances of yourself and shoot them all in the foot. Providing emergency medical assistance is impossible since you can't tell which are bitwise copies and which are just pointing at others and saying, "That's me, over there." FORTRAN: You shoot yourself in each toe, iteratively, until you run out of toes, then you read in the next foot and repeat. If you run out of bullets, you continue with the attempts to shoot yourself anyways because you have no exception-handling capability. Pascal: The compiler won't let you shoot yourself in the foot. Ada: After correctly packing your foot, you attempt to concurrently load the gun, pull the trigger, scream, and shoot yourself in the foot. When you try, however, you discover you can't because your foot is of the wrong type. COBOL: Using a COLT 45 HANDGUN, AIM gun at LEG.FOOT, THEN place ARM.HAND.FINGER on HANDGUN.TRIGGER and SQUEEZE. THEN return HANDGUN to HOLSTER. CHECK whether shoelace needs to be re-tied. LISP: You shoot yourself in the appendage which holds the gun with which you shoot yourself in the appendage which holds the gun with which you shoot yourself in the appendage which holds the gun with which you shoot yourself in the appendage which holds the gun with which you shoot yourself in the appendage which holds the gun with which you shoot yourself in the appendage which holds... FORTH: Foot in yourself shoot. Prolog: You tell your program that you want to be shot in the foot. The program figures out how to do it, but the syntax doesn't permit it to explain it to you. BASIC: Shoot yourself in the foot with a water pistol. On large systems, continue until entire lower body is waterlogged. Visual Basic: You'll really only appear to have shot yourself in the foot, but you'll have had so much fun doing it that you won't care. HyperTalk: Put the first bullet of gun into foot left of leg of you. Answer the result. Motif: You spend days writing a UIL description of your foot, the bullet, its trajectory, and the intricate scrollwork on the ivory handles of the gun. When you finally get around to pulling the trigger, the gun jams. APL: You shoot yourself in the foot, then spend all day figuring out how to do it in fewer characters. SNOBOL: If you succeed, shoot yourself in the left foot. If you fail, shoot yourself in the right foot. Unix: % ls foot.c foot.h foot.o toe.c toe.o % rm * .o rm:.o no such file or directory % ls % Concurrent Euclid: You shoot yourself in somebody else's foot. 370 JCL: You send your foot down to MIS and include a 400-page document explaining exactly how you want it to be shot. Three years later, your foot comes back deep-fried. Paradox: Not only can you shoot yourself in the foot, your users can, too. Access: You try to point the gun at your foot, but it shoots holes in all your Borland distribution diskettes instead. Revelation: You're sure you're going to be able to shoot yourself in the foot, just as soon as you figure out what all these nifty little bullet-thingies are for. Assembler: You try to shoot yourself in the foot, only to discover you must first invent the gun, the bullet, the trigger, and your foot. Modula2: After realizing that you can't actually accomplish anything in this language, you shoot yourself in the head. -- "When we allow fundamental freedoms to be sacrificed in the name of real or perceived emergency, we invariably regret it. -- Thurgood Marshall Ric Werme | werme at nospam.mediaone.net http://people.ne.mediaone.net/werme | ^^^^^^^ delete From AdrianLeu at kelseus.com Thu Nov 15 06:16:28 2001 From: AdrianLeu at kelseus.com (Adrian Leu) Date: 15 Nov 2001 03:16:28 -0800 Subject: re. module References: <993ae4ca.0111140731.3c11e6d5@posting.google.com> <9su44o$163aq9$1@ID-11957.news.dfncis.de> Message-ID: <993ae4ca.0111150316.4e3bd6c2@posting.google.com> "Emile van Sebille" wrote in message news:<9su44o$163aq9$1 at ID-11957.news.dfncis.de>... > "Adrian Leu" wrote in message > news:993ae4ca.0111140731.3c11e6d5 at posting.google.com... > > I am trying to figure out a solution for the following: > > > > import re > > > > text = 'name_0 goto place' > > string = 'name|name_0|name_1' > > > > pattern = re.compile(string, re.I) > > d = pattern.search(text) > > return d.group(0) > > > > The problem is that my program will return 'name' to this. What I want > > is for the search to return a match (if it exists) only after looking > > at the whole string (name_0 in this case). I.e. in my example I would > > like the program to return 'name_0' not 'name'. > > > > Any ideas how I could do that? > > > > Also match the space character that follows the identifier? NO, just match the string. From jeff at ccvcorp.com Fri Nov 9 13:03:46 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 09 Nov 2001 10:03:46 -0800 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> Message-ID: <3BEC1A81.6D8766B@ccvcorp.com> Robert Amesz wrote: > I wrote: > > [something] > > Ignore previous post: I read 'raw_input' where it actually said > 'input'. My mistake. > > Robert Amesz Though actually, the use of input() is generally not a very good idea, and it would be safer to use raw_input() and then convert from strings if needed. In this case, it's not needed, and the raw_input result would be better off being compared as a string. (For those who don't know... since input() evaluates whatever's typed as a valid Python expression, it is possible for unpredictable (and even malicious) things to happen, depending on just what is entered. raw_input() evaluates nothing and simply returns a string, which can then be manipulated in whatever way you like, such as converting it to an int or float or whatever, as needed, thus plugging a security hole and likely source of unpredictable exceptions. Thus, unless you really *need* the power of input(), it's almost always preferable to use raw_input() instead.) Jeff Shannon Technician/Programmer Credit International From christophertavares at earthlink.net Fri Nov 16 22:00:00 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Sat, 17 Nov 2001 03:00:00 GMT Subject: Regular Expression Help Needed References: Message-ID: "David A McInnis" wrote in message news:mailman.1005960683.29958.python-list at python.org... > Ok, I am not very good at regular expressions, so any help is greatly > appreciated. > > Here is the situation. > > I have a database table that contains a text field. This text field may or > may not contain email addresses. I know how to read the content of field to > a string. Now what I need is a regular expression that I could use to > identify any email addresses in the string. Since the email can be in mixed > case, I need a solution that is case insensitive. > > So, there may be one or more email addresses in the string. When I find > one, I need to added it to a list variable and look for other addresses in > the string. > > Thanks, > > David McInnis > Get a copy of _Mastering Regular Expressions_, by Jeffrey Friedl, from O'Reilly press. The regular expression you want is in the back. Be warned - it's over 4000 characters long, and it still doesn't work in all cases. Email addresses are not a regular language, and therefore cannot be completely matched by regular expressions. -Chris From horatio at qpsf.edu.au Wed Nov 14 18:47:20 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Thu, 15 Nov 2001 09:47:20 +1000 (EST) Subject: Scientific Libraries in Python In-Reply-To: Message-ID: On Wed, 14 Nov 2001, Travis Oliphant wrote: > Please expand what you mean by all of this. I'm not sure I understand > your concern with the package design of scipy. The package design is fine - see below for mild concerns on names, but I have no issues at all with the actual structure. > We are trying to get there. Quite so. My preferred option would be to merge other code bases (and their maintainers) _into_ SciPy in order to get a single unified library. The SciPy project, with the infrastructure it's built up, seems to be the best shot at doing this. If we are going to put all the eggs in one basket, it might as well be the best basket. > Please make your voice heard on the scipy list. One of the design > decisions that has been made is to use all lowercase letters for names > in the package to improve consistency. Hmm. I would respectfully submit that it would be better to be consistent with Numeric (which uses Names.With.Capitals) and Scientific Python (which Also.Does.That). The first reason is that Numeric is already part of the package structure of SciPy, and it's not going to change, and partial consistency is not consistency at all. The second reason is to lower the energy barrier for a merge of Scientific Python into SciPy. If the change is made, the second-level packages (Scientific.MPI, Scientific.Statistics, and their siblings) may be moved straight across without messing about. It is understood by me that such changes in the namespace give rise to bad karma among a library's users. But the benefits outweigh the costs if it is done _now_ rather than waiting until SciPy hits 1.0 and everything is set in igneous rock. > Am I hearing that you don't like the top-level name "scipy" Say rather that I like the name "Scientific" more. A merge between SciPy and Scientific Python involves choosing a name to keep and a name to discard. Scientific fits my brain better, which makes it the more Pythonic choice, and so the one to keep. That said, I would live with scary_devil_monastery as the top-level package name if doing so would buy me a complete scientific computing library in one place. The unification is the priority, the names are not. > Glad to see the dicussion, Me also. Now all I need to do is figure out how to attract Konrad Hinsen's viewpoint on all this... and possibly even some users of these libraries? Cheers, AHD From leovd at pacbell.net Fri Nov 9 13:43:41 2001 From: leovd at pacbell.net (Ray Van Dolson) Date: Fri, 09 Nov 2001 18:43:41 GMT Subject: Help extending BaseHandler from urllib2 Message-ID: I'm trying to extend the BaseHandler class from urllib2 to handle 302 redirects in a different way. I need to grab the cookies from the page and send them after being redirected. Should be easy enough right? Well I'm running into a problem. Here's my class: from urllib2 import BaseHandler, Request, urlopen class DotsterHandler(BaseHandler): def default_open(self, req): print "Executing custom thingy" return urlopen(req) def http_error_302(self, req, fp, code, msg, hdrs): """Hopefully this function will handle a 302 redirect properly. We need to maintain any cookies we receive.""" print "Another custom thingy..." if hdrs.has_key('location'): newurl = hdrs['location'] elif hdrs.has_key('uri'): newurl = hdrs['uri'] else: return nil = fp.read() fp.close() newurl = urlparse.urljoin(req.get_full_url(), newurl) if hdrs.has_key('set-cookie'): cookie = hdrs['set-cookie'] new = Request(newurl) new.add_header('Cookie', cookie) return self.parent.open(new) And the test program: import DotsterHandler import urllib2 import urllib def main(): """The main function""" # First, create the DotsterHandler dh = DotsterHandler.DotsterHandler() # Now create the OpenerDirector object and add dh as its handler od = urllib2.OpenerDirector() od.add_handler(dh) # Construct our request req = urllib2.Request \ ("https://www.dotster.com/account/login/login.asp") req.add_data(urllib.urlencode({'Acct_Name': 'user', 'Password': \ 'pass'})) # Now let's try opening this with our OpenerDirector... a = od.open(req) # Did it work? print a if __name__ == '__main__': main() I notice that while my custom default_open() method is called (from DotsterHandler), but once the 302 page is received, the standard 302 handler from urllib2 is called instead of my custom one. Is there something wrong with the way I'm doing this? Thanks for any help. From uwe at rocksport.de Tue Nov 27 15:56:34 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 27 Nov 2001 20:56:34 GMT Subject: wxPython: problems with doubleclick Message-ID: <9u0um2$b9p93$1@hades.rz.uni-sb.de> Hi, I nearly finished my first "paint-program" under wxPython. There is just a little problem: I use wxFileDialog in order to load data. When I select a file with a double-click, the second click is buffered, that is, the file is opened and the buffered click yields painting in the canvas... How can I avoid this behavior ? Is there a possibility to empty this mouse click buffer ??? Greetings, Uwe. -- Dr. rer. nat. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From francois-regis.chalaoux at sanofi-synthelabo.com Thu Nov 15 05:39:43 2001 From: francois-regis.chalaoux at sanofi-synthelabo.com (copter24) Date: 15 Nov 2001 02:39:43 -0800 Subject: shutil.rmtree bug ? Message-ID: <85e27928.0111150239.464505e@posting.google.com> Hi, With win nt4 and Python 2.1, why shutil.rmtree(path, 0) does not raise an exception when there is effectivly one ? Any idea ? FR From pinard at iro.umontreal.ca Mon Nov 26 16:01:46 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 26 Nov 2001 16:01:46 -0500 Subject: vCard parser anywhere ? In-Reply-To: <9tu7ue$75m$1@norfair.nerim.net> References: <9trh93$o1e$1@norfair.nerim.net> <9tu7ue$75m$1@norfair.nerim.net> Message-ID: [Gillou] > I'm gonna take some aspirin, learn some lisp and make it pythonic. Just make sure you make the result of your works available to others! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From asn1 at rd.francetelecom.com Mon Nov 5 04:32:32 2001 From: asn1 at rd.francetelecom.com (Olivier Dubuisson) Date: 5 Nov 2001 01:32:32 -0800 Subject: ASN1 & GDMO compiler References: <9rmod3$1ts0$1@news2.ipartners.pl> Message-ID: <70aaeb1e.0111050132.787ae305@posting.google.com> Martin von Loewis wrote in message news:... > "Pete" writes: > > > Does anyone know about py module that compiles ASN1 and GDMO files into > > C++/Java sources? > > Can you please explain why you want such a thing? Would you accept > arbitrary C++ output? Then I have one for you: > > print "int main(){}" > > :-) > > If you are interested in ASN.1 compilers, I suggest using SNACC. A lot of other ASN.1 tools are referenced at: http://asn1.elibel.tm.fr/links/#tools -- Olivier DUBUISSON france telecom R&D _ DTL/MSV - 22307 Lannion Cedex - France ( ) tel: +33 2 96 05 38 50 - fax: +33 2 96 05 39 45 / \/ -------------------------------------- \_/\ Site ASN.1 : http://asn1.elibel.tm.fr/ From jerry at sky.net.ua Thu Nov 15 03:44:27 2001 From: jerry at sky.net.ua (Serg) Date: Thu, 15 Nov 2001 10:44:27 +0200 Subject: Problems compiling python under Win (VS6.0) Message-ID: <3bf381b5$1@skynet> When compiling python under Visual Stdio files missing reported: python src 2.2b1 files: tcl.h db.h expat.h zlib.h Python is taken from python site. What to do? What is that? -- Keep in touch. Your partner Maltsev. From news at mindlace.net Thu Nov 15 18:05:08 2001 From: news at mindlace.net (emf) Date: 15 Nov 2001 17:05:08 -0600 Subject: shelve Message-ID: <3BF44886.9070604@mindlace.net> # I don't understand why bar isn't being updated, # or what I need to do to make it be updated... import shelve class foo: def __init__(self): self.bar = 0 class spam: def __init__(self): self.shelf = shelve.open('test') self.shelf['a'] = foo() def addOne(self): self.shelf['a'].bar = 1 def printA(self): print self.shelf['a'].bar if __name__ == '__main__': b = spam() b.addOne() b.printA() From just at letterror.com Tue Nov 6 18:35:25 2001 From: just at letterror.com (Just van Rossum) Date: Wed, 07 Nov 2001 00:35:25 +0100 Subject: Yahoo Groups archive of python-list wiped - what happened? References: Message-ID: <3BE878FA.103DA334@letterror.com> Hamish Lawson wrote: > > The Yahoo Groups archive of python-list seems to have started over > with message #1 dated 5 November 2001, losing all messages before > that. Does anyone know what happened? > > http://groups.yahoo.com/group/python-list/messages/1 Ouch, it's a disaster for my irregular stats page: http://starship.python.net/~just/comp.lang.python/ I haven't updated it in a few months, but it looks like I can't update it the way I used to, if at all. I hope it's a temporary glitch, and not that they've simply wiped their archives... Just From max at alcyone.com Tue Nov 20 13:29:16 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 20 Nov 2001 10:29:16 -0800 Subject: sscanf ? References: Message-ID: <3BFAA0FC.EB3CB91B@alcyone.com> Bruce Edge wrote: > I know about all the regex stuff, but I have the format string that > was > used to generate a string, which I'd like to use to decompose it back > into it's source data: > > fmtstr = "%02d.%02d" > > str = fmtstr % ( x, y ) > > # Now get x any y back using only str and fmtstr: > > (x, y ) = ? x, y = map(int, str.split('.')) -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From andreas at mtg.co.at Sun Nov 4 06:29:29 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Sun, 4 Nov 2001 12:29:29 +0100 Subject: Exception handling wart in Python In-Reply-To: References: Message-ID: <200111041129.fA4BTXE13465@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Samstag, 3. November 2001 00:08 schrieben Sie: > To actually *wait* for most common exceptions to happen is definitely one > strategy. But somehow I don't feel that this is a "scientific" (for the > lack of the better word) way of doing it. > > Regarding the binding problem with: > > a, b = c(d) > > This really goes to the issue of generic programming. It seems like every > function in Python is generic, but in reality it is not so. In the real But Python treats all names only as references to objects. Sometimes this happen to be function objects. So while you are quite right in assuming that there are some functions that make only sense with certain parameter types, this doesn't help anyway, because any name might be rebound. So on the surface, a=int(b) make only sense for type(b)==types.StringType and a should be afterwards type(a)==types.IntegerType. But infact int might be bound to completly something else. One case that happens quite often in my code is local variables and parameters named "str". > world (in Python) there is a class of functions that can be and truly are > generic, and there is a much bigger class of functions (in Python) that > really only make sense with particular data types. Perhaps, it would be a > good idea to give the exception flow checker tool some hints in the source > code about the function being generic or not. That way you can avoid the > problem of seemingly being asked to handle *all* possible exceptions in > generic functions. Or, perhaps, it might be a good idea to assume that > all generic functions do not belong inside class objects. Perhaps only > class object methods should be checked for exception handling? Class object methods are just function objects as any other. ;) Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE75SabHJdudm4KnO0RAiFzAJ0Vq9nW83tACp4POKkcETeB1avuVACZAa8e FOPKC9kYK1VRZwEBIWOTbSs= =fenj -----END PGP SIGNATURE----- From uwe at rocksport.de Tue Nov 6 10:58:59 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 6 Nov 2001 15:58:59 GMT Subject: count in 'for ... in ...' References: <9s90mr$osk$00$1@news.t-online.com> Message-ID: <9s91c3$94mgs$1@hades.rz.uni-sb.de> Achim Domma wrote: | Hi, | if I have a list of strings and want to display with a count in front of it | I usualy do something like: | for i in range(len(my_list)): | print i,". ",my_list[i] | but I think the | for s in my_list: | print ... What about the following ? idx=0 for s in my_list: print idx,".",s idx+=1 Greetings, Uwe -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From glauco.silva at iti.gov.br Tue Nov 6 12:12:19 2001 From: glauco.silva at iti.gov.br (Glauco Silva) Date: Tue, 6 Nov 2001 15:12:19 -0200 Subject: help - Create dll Message-ID: <004001c166e6$3192cca0$107290c8@iti.gov.br> Hi , How can i create a dll file ( C dynamic library) from windows to be imported by python . Thank you Glauco -------------- next part -------------- An HTML attachment was scrubbed... URL: From dlharris at mail.usyd.edu.au Sun Nov 25 06:30:11 2001 From: dlharris at mail.usyd.edu.au (Dave Harrison) Date: Sun, 25 Nov 2001 22:30:11 +1100 Subject: query about file objects and popen3() Message-ID: <20011125223011.A21298@dave@isetroc.com> I am writing a wrapper script for another program and im using popen3 to call that program, which then returns me the tuple of 3 file objects, the first two of which are std::out and std::err now under some circumstances obviously the output I need to process is in std::out and other times std::err ... I need to know how I can test a file object to find out if it is empty or not ? the std::out ouput, if there, will always be the same format so I will be string splitting it the std::err output will just be dumped to screen but I need to be able to differentiate the two Thanks Dave From gmcm at hypernet.com Wed Nov 14 17:08:41 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 14 Nov 2001 22:08:41 GMT Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: Message-ID: Dave wrote: > On 14 Nov 2001, Stephen wrote: > >> I've been trying to benchmark socket server and can't seem to get it >> past serving 200 requests per second. > [snip] > > Thread-per-request servers can't scale up too high (although it might > be interesting to see what stackless + microthreads would do). You'll > need to use the asynchronous I/O support (see the select module for > lower level stuff, asyncore/asynchat for slightly higher stuff). About 3 years ago, I wrote a Python message-slinger as a drop-in replacement for my client's C code. It did around 600 msgs / sec (vs <200 / sec for the client's code). That was Python 1.4 on 3 year old hardware. So 1000 / sec is quite possible, but you'll never get there with blocking sockets. - Gordon From thomas at gatsoft.no Thu Nov 8 07:53:29 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Thu, 08 Nov 2001 12:53:29 GMT Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: "Oleg Broytmann" wrote in message news:mailman.1005218719.27461.python-list at python.org... > On Thu, Nov 08, 2001 at 11:00:52AM +0000, Geert-Jan Giezeman wrote: > > I am trying to create a shelve from a table of 1100 by 1100 floating > > point numbers, which I want to store as 1100 lists of length 1100, > > indexed by a key. Unfortunately, I get an error when I try to create > > this: > > bsddb.error; (22, Invalid argument) > > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.099.htp > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > I've experienced this problem if I don't close the db-connection after using it. Be sure that you call close before ending the script/program. Thomas From marcoxa at cs.nyu.edu Tue Nov 20 16:35:50 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 20 Nov 2001 16:35:50 -0500 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> <3BF9D791.BEA22D61@engcorp.com> <3bfab7ae_3@mk-nntp-1.news.uk.worldonline.com> Message-ID: "Morten W. Petersen" writes: > On Tue, 20 Nov 2001, Sandy Norton wrote: > > > "Morten W. Petersen" wrote in message > > news:Pine.LNX.4.21.0111201815190.6229-100000 at bcryachts.atsat.com... > > > > > One of Python's advantages is a consistent (simple) design, (not counting > > > small quirks like 'def function(): return 1' and 'function = > > > lambda: 1'. Consistent design says 'less complexity' in my ears, along > > > the same lines of the simpleness (ease of maintenance, readability, > > > portability) of a python application if it can always be coded in Python. > > > > Excuse my curiosity but what's quirky about 'def function(): return 1' and > > 'function = > > lambda: 1'? > > (I'm posting to the newsgroup as well, didn't notice you posted to > both the newsgroup and me.) > > Curiosity is good. :-) > > In Lisp, functions can be built this way: > > cl-user(3): (defun multiply (argument) (* argument argument)) > multiply > cl-user(4): (multiply 3) > 9 > cl-user(5): > > Where the last evaluated value is returned. > > In Python, there is: > > def multiply(argument): > return argument * argument > > Or (using anonymous functions): > > multiply = lambda argument: argument * argument > > Where the lambda has the implicit return-of-last-expression (no return > needed), while functions do not. In Common Lisp the last expression of an execution thread is the one returned. The macro `return' and the special operator `return-from' are usable for non-local exits. As per the above example You can do cl-prompt> (defun multiply (n1 &rest ns) (apply '* n1 ns)) multiply cl-prompt> (multiply 1 2 3 4) 24 And you can do cl-prompt> (defvar multiply (lambda (n1 &rest ns) (apply '* n1 ns))) multiply Same story (well almost :) ). Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From weeang at hotmail.com Tue Nov 27 22:27:17 2001 From: weeang at hotmail.com (weeang) Date: 27 Nov 2001 19:27:17 -0800 Subject: how to call external functions from python Message-ID: hi, i need help on the following: 1) find all files in inbox directory and zip them 2) move the zipped file to outbox 3) copy the zipped file to a remote directory pls help on the following as i m very new to python, and could not find the exact help that i need in the faq, help, etc. i m using python 2.1, using windows for my initial testing. however, i will subsequently use the script on a linux box instead. thanx & brgds, weeang From colinmeeks at rogers.com Fri Nov 23 14:46:46 2001 From: colinmeeks at rogers.com (Colin Meeks) Date: Fri, 23 Nov 2001 19:46:46 GMT Subject: HTTPLIB - Problem retrieving a page Message-ID: I am running the following code to retrieve pages and strip out some details, however I have noticed that some sites do not work, even though the correct URL is given. I can verify it works by testing it in my browser. The below code gives a 404 error. The code is here ------------------------------------- import urlparse, httplib, urllib UseURL='http://www.meeks.ca/index.htm' y=urlparse.urlparse(UseURL) usesite=y[1] useparameters=y[2] if useparameters=='': useparameters='/' h=httplib.HTTP(usesite) h.putrequest('GET',useparameters) h.putheader('Accept','text/html') h.putheader('Accept', 'text/plain') h.endheaders() errcode, errmsg, headers=h.getreply() x=h.getfile().read() h.close() --------------------------------- The site above is just one many that do not work. Can anybody tell me a way to work round this. Colin --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.286 / Virus Database: 152 - Release Date: 09/10/2001 From cliechti at gmx.net Tue Nov 20 13:34:53 2001 From: cliechti at gmx.net (Chris Liechti) Date: 20 Nov 2001 19:34:53 +0100 Subject: os.kill........ References: <9te2g4$sma$1@mail1.wg.waii.com> Message-ID: [posted and mailed] Martin Franklin wrote in news:9te2g4$sma$1 at mail1.wg.waii.com: > Hi, > > I'm looking for a way of determining if a process is still running > (having spawned it from a python app), I have come up with os.kill(PID, > 0) this will raise an exception if the process does not exist, and do > nothing if the process does exist. The sig of zero does not _seem_ to > affect it (at least not on my linux box) > > My question is..... is this an OK way of doing this? do I have any > other _pure_ python options..... > > > Regards > Martin from "man 7 signal" SIGHUP 1 A Hangup detected on controlling terminal or death of controlling process SIGINT 2 A Interrupt from keyboard SIGQUIT 3 C Quit from keyboard SIGILL 4 C Illegal Instruction SIGABRT 6 C Abort signal from abort(3) SIGFPE 8 C Floating point exception SIGKILL 9 AEF Kill signal SIGSEGV 11 C Invalid memory reference SIGPIPE 13 A Broken pipe: write to pipe with no readers SIGALRM 14 A Timer signal from alarm(2) SIGTERM 15 A Termination signal a frendly question to quit is sent by signal 9 and an unfrendly, forced kill of a process can be done with signal 15. as i understand signal 0 only _checks_ if a process is exiting. chris -- Chris From tony.mcdonald at ncl.ac.uk Fri Nov 2 03:23:35 2001 From: tony.mcdonald at ncl.ac.uk (Tony McDonald) Date: Fri, 02 Nov 2001 08:23:35 GMT Subject: Freeware Python editor References: Message-ID: In article , "Tim Peters" wrote: > >> FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS > > [Delaney, Timothy] > > The PSU failed! A post about the PSU escaped to the world in its > > entirety! > > > > We are fre > > In case the intended word was "free", I'd like to point out that there are > different philosophies about free software, only one is correct, and > c.l.py's mission is to educate the world about which one that is. Don't > forget that extremism in defense of freedom is no vice. > > just-following-orders-but-don't-feel-good-about-it-ly y'rs - tim > > this ng is so cool - what starts off with one guy pointing out a windows python editor rapidly runs off into GNU-space, which is countered by a Monty-defence shield, which is beaten back and looks to be failing until a wise time-traveller returns to spread the good news that we're all actually helping to save the planet, nay, the universe! terrific! :) tone. From jord.elver at virgin.net Sat Nov 10 19:55:59 2001 From: jord.elver at virgin.net (Jordan Elver) Date: Sun, 11 Nov 2001 00:55:59 +0000 Subject: Newbie: Using MySQL Message-ID: <200111110056.fAB0u0V02578@localhost.localdomain> Hi, First post to the list :-) Could someone point me in the right direction for MySQL using Python tutorials etc. I've tried using the MySQLdb module (I think) and I cannot connect. I know that the server is running and that the passwords are correct? db = MySQLdb.Connect(host=db_host, user=db_user, passwd=db_passwd, db=db_db) Thanks for any help. Jord -- Jordan Elver http://www.jordanelver.co.uk "Only wimps use tape backup: _real_ men just upload their important stuff on ftp, and let the rest of the world mirror it ;)" --- Linus Torvalds From daniel.dittmar at sap.com Wed Nov 21 04:31:15 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Wed, 21 Nov 2001 10:31:15 +0100 Subject: deleting directory tree References: Message-ID: <9tfs93$aod$1@news1.wdf.sap-ag.de> > Can someone explain what os.removedirs() does? I needed a function to remove > a directory and all its files and subdirectories, and ended up writing one. > It seems that there should be such a function in os, but I drew a blank. Use shutil.rmtree (). Daniel From peter at engcorp.com Thu Nov 22 01:07:28 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 22 Nov 2001 01:07:28 -0500 Subject: redirecting sys.stdout and threads References: Message-ID: <3BFC9620.EF571437@engcorp.com> Chris Liechti wrote: > > the standard way to redirect outputs of print statements is to assign an > other file to sys.stdout and/or sys.stderr. the editors (idle, pythonwin, > wxWindows pyshell, etc.) are an example for this. > > but what can you do if more than one thread wants to use redirection? The way I handled this was to write a redirector object (I called it the Doppleganger class) which can be installed in place of sys.stdout. When the write() method of the Doppleganger was called, it would check to see if the current thread object had a predefined name which referenced a Redirector object with another write() method. If it did, it would pass the data on to that object's write() method. Otherwise it would just print to the original stdout. This allowed creation of, among other things, a redirector which wrote to a socket, and one which wrote to a log file, depending on what object a particular had installed as its redirector. There might be easier methods, but after I noted that the interpreter (apparently) records sys.stdout *on startup* and uses that one reference for all subsequent print statements (effectively "fixing" destination of printed output), I saw no other choice. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From gh_pythonlist at gmx.de Sat Nov 17 19:07:09 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 18 Nov 2001 01:07:09 +0100 Subject: ssl error In-Reply-To: References: Message-ID: <20011118010707.A1054@lilith.hqd-internal> On Sat, Nov 17, 2001 at 01:40:22PM -0600, Reid Nichol wrote: > I got a client/server app that I am triing to build and am having problems. > [snip] The Python builtin SSL doesn't support servers, but only SSL clients. On my homepage (see sig), you can find a short, unfinished overview of the available alternatives. Use the "Python/SSL" link. I'd probably go for M2Crypto. HTH, Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From eppstein at ics.uci.edu Thu Nov 15 11:32:49 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 15 Nov 2001 08:32:49 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: In article , Skip Montanaro wrote: > I think I would still write the above as > > for rowcount in [0, step, ... table.getRowCount()]: > > That would get you the sequence > > 0, 1*step, 2*step, ... (table.getRowCount()-1)*step > > and is more flexible than your proposal. There's no reason you couldn't > have > > for f in [0.0, 1.0, ... sys.maxint]: > > to enumerate floats up to but not including sys.maxint (care needs to be > taken to not to compound errors). > > You could also build character sequences I think: > > for c in ["a", "b", ... "z"]: You seem to be inconsistent here about whether you want these ranges to be open or closed on the right. I think closed is the only reasonable choice for this syntax. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From lac at strakt.com Thu Nov 15 05:59:38 2001 From: lac at strakt.com (Laura Creighton) Date: Thu, 15 Nov 2001 11:59:38 +0100 Subject: IsPython really O-O? In-Reply-To: Message from adamspitz@bigfoot.com (Adam Spitz) of "14 Nov 2001 12:13:08 PST." <87f44f44.0111141213.4778982c@posting.google.com> References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <87f44f44.0111141213.4778982c@posting.google.com> Message-ID: <200111151059.fAFAxcua019337@ratthing-b246.strakt.com> (I've always wanted to ask this:) The Design Patterns Smalltalk Companion (p 214) discussing Proxy states: 'Since the problem lies in Proxy's subclass relation to object, one way to solve it would be to dissolve this relationship. How is this possible? Subclass Proxy off nil' Do people actually do this. Pardon this phrasing, but isn't it, ah, 'evil'? I'm way to scared to use it, though of course I had to write one just to see it. Laura Creighton From sholden at holdenweb.com Thu Nov 29 15:15:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 15:15:09 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C053AA4.97246A72@ccvcorp.com> Message-ID: "Huaiyu Zhu" wrote... [Jeff Shannon and Huaiyu go back and forth ...] > > So the ideal world is all spaces, no tabs. It is then not a big leap to > allow tab as a shorthand to replace the number of spaces used as indent. > Just because I can hear Peter banging his head on the desk from here, let me agree wholeheartedly with your first sentence, and point out that in your second sentence you fall again into the error of assuming that a tab will always represent a fixed number of spaces. I suspect this may be a language problem, and that when you say "replace the number of spaces used as indent", you might really mean "replace the number of spaces that will take you to a particular indent level". Perhaps this is a fine distinction, and one which need not be made for tabs which occur at the start of a line. But, mix spaces in, or other characters, and a tab should NOT be treated as equal to any fixed number of spaces. Outlook Express does that (hit TAB and it always puts 4 spaces in, don't ask me why) [see?] [that was a second TAB] and it's horrible. but-since-outlook-express-throws-tabs-away-anyway-what- else-should-we-expect-ly y'rs - steve -- http://www.holdenweb.com/ From maxm at mxm.dk Sun Nov 25 18:12:26 2001 From: maxm at mxm.dk (maxm) Date: Mon, 26 Nov 2001 00:12:26 +0100 Subject: WINDOWS USERS???? References: <3C0151C3.2903A9F5@verizon.net> Message-ID: <%TeM7.7220$TN1.727727@news000.worldonline.dk> "Power-Tech" wrote in message news:3C0151C3.2903A9F5 at verizon.net... > I've downloaded the regular Python and had some problems running the .py > files, Inside the editor in PythonWin you should be able to pres "F5" and have your program run. > today I found > that "ActivePython" should be the best download for windows users.... > Can anyone throw some light on this? It is indeed a very god distribution of Python for Windows. > Is this group too advanced for me? It's probably as advanced as you want it to be ;-) regards Max M From aaldv97 at student.remove-this-part.vxu.se Tue Nov 6 18:07:52 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Wed, 7 Nov 2001 00:07:52 +0100 Subject: Teaching python (programming) to children References: Message-ID: <9s9qie$rer$1@news.lth.se> > > Python is without doubt a very good language, but it's not good for the > > beginner because they will pick up bad practices, mostly because of the > > loose type paradigm. > > And what bad practices would those be? Having a non-declarative language as a first choice is bad, teaches them to write sloppy code. Having dynamically typed language such as Python does even more damage to the understanding of how to write good code, thankfully python types are strong which helps to avoid part of the problem. > > For teaching programming I strongly belive that Ada95 is by far the best > > Ugh. At least teach them something that they can use elsewhere. ;-) Ada is used quite a lot, especially in the military and general embeded markets, and it's a gigant in realtime system programming. Ada is fantastic, with it I write inline Assembly(can even do inline Fortran, C, C++, etc, etc), combine it with Python, Java, etc, etc. > > teaches the students how to write good code > > Define "good" code, please. Ada is very strict, so sloppy code is very rare, sloppy written code is bad code, because it's hard to maintain, debug and extend. Ada a high level OO language that still remains close to hardware, while code is still portable across platforms, what more can you ask for? People underestimate Ada95 because they either don't know jack about Ada or just know Ada83, use the right tool for the right job, you can after all use Ada with Python. :-) From skip at pobox.com Thu Nov 15 04:58:18 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 15 Nov 2001 10:58:18 +0100 Subject: PEP 276 Simple Iterator for ints In-Reply-To: References: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> <15346.13388.182098.148832@beluga.mojam.com> Message-ID: <15347.37306.434110.686740@beluga.mojam.com> Rainer> One thing bothers me about the Haskell syntax: using it to Rainer> generate sequences of less than three elements just looks wrong. Rainer> [1, 2, ... 3] # This is obviously [1, 2, 3]. Rainer> [1, 2, ... 2] # What is this? [1, 2]? Rainer> [1, 2, ... 1] # [1]? Rainer> [1, 2, ... 0] # []? So, just don't use it for lists less than four elements... ;-) If you are using it in a variable context, I can see that you might not know at the time you write the code whether the list will be < length 4: s = raw_input("Your name please: ") for i in [0, 1, ... len(s)]: print s[i] I imagine the Haskell folks have solved this problem already. My suggestion would be that it would be equivalent to the obvious range() call: [0, 1, ... x] ==> range(0, x, 1) Rainer> Another thing that bothers me is that I'm it's not obvious how Rainer> the elements are evaluated. This is not an issue in Haskell, Rainer> but it is in Python: Rainer> def f(n): Rainer> print n Rainer> return n Rainer> for i in [f(0), f(1), ... f(5)]: pass Rainer> I assume that this prints 0, 1, and 5. That makes sense from Rainer> one perspective, but doesn't make sense at all from another Rainer> perspective. Another example: Rainer> for i in [g() + 0, g() + 1, ... g() + 13]: pass Rainer> How often is 'g' called? Once? 3 times? 14 times? In the examples you listed, f() and g() would be called three times. You have no idea if they are idempotent or not, so you can't call them more or less than given. Besides, the range iterator couldn't get built until you know what each of its three parameters are. You have to call the functions to build the iterator, at which point you have no notion that functions are involved. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From max at alcyone.com Thu Nov 22 14:00:17 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 22 Nov 2001 11:00:17 -0800 Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: <3BFD4B40.14B52F54@alcyone.com> Erik Johnson wrote: > I have a list of single character strings. A couple of people were > kind enough to clue me in to the best way to turn this back to a > string: > > s = "".join(l) > > This works fine, but it seems syntactically backwards to me: > > # s = l.join("") > > makes much more sense to me. The thingy I want to do something to is > my > list. I am just trying to learn Python, so no doubt there will be some > Python things I will just have to get used to, but is there a logical > reason why it was implemented as a string method rather than a list > method? Does it seem backwards to you or does it make intuitive sense > to > you? Comments? It may seem a little strange at first, but it makes sense in terms of what's going on here. What you want to do is string processing, so it's much more natural that the method belongs in a string instead of in a list. Since the only thing that's a string here is the delimiter, that's why you have the "".join(l) notation. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From timr at probo.com Sun Nov 25 18:55:32 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 25 Nov 2001 15:55:32 -0800 Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> <3BFFF06A.F7A3C69@tundraware.com> Message-ID: Tim Daneliuk wrote: > >This is not a problem, but an intentional design point in both operating >systems. You do not want a random user process to be able to fiddle with >the runtime environments of other users. This is intentionally possible >only by an act of system administration... > >It is a bit unclear exactly what the original poster was trying to >accomplish, ... I thought his goal was clear, and actually quite reasonable: he'd like to modify the environment of his processes parent, so that succeeding processes inherit his changes. He's not trying to change another user's environment, he's just trying to use the environment to pass data from one program to another in the same session. It is a common goal, although unachievable without a certain amount of magic. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From logiplexsoftware at earthlink.net Fri Nov 2 15:43:29 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 12:43:29 -0800 Subject: Underscore data hiding (was python development practices?) In-Reply-To: References: Message-ID: <01110212432904.09296@logiplex1.logiplex.net> On Friday 02 November 2001 12:34, mmillikan at vfa.com wrote: > Your cat is not fixed? He was in a kayaking accident and didn't have insurance. I figure later on I'll just use a dent-puller and some bondo, sand him down and he'll be good as new. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From osuchw at ecn.ab.ca Sat Nov 10 04:42:48 2001 From: osuchw at ecn.ab.ca (waldekO) Date: 10 Nov 2001 01:42:48 -0800 Subject: Active Directory and ActivePython2.1 References: Message-ID: "alan runyan" wrote in message news:... > I'm trying to use ldap search filters w/ Python against Active Directory and > things are jiving. I can get it to work w/ ASP no problem. All help would > be *greatly* appreciated. > > my problemed Python Script > adsi = win32com.client.Dispatch('ADsNameSpaces') > ldap=adsi.getobject('', 'LDAP:') > ldapQuery=';(objectClass=Person);ADsPath,cn;root' > myDSObject = ldap.OpenDSObject(ldapQuery,'username','password', 1) > > I get: > Traceback (most recent call last): > File "E:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301, in > RunScript > exec codeObject in __main__.__dict__ > File "E:\ZOPE\Extensions\adsi.py", line 37, in ? > File ">", line 2, in OpenDSObject > com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', > 'Unspecified error\r\n', None, 0, -2147467259), None) > > in VBScript/ASP > > Set conn = server.createobject("ADODB.Connection") > conn.Provider = "ADSDSOObject" > conn.Open "ADs Provider" > Set rs = > conn.Execute(";(objectClass=Person);ADsPath,objectClass > ,cn;subtree") > > am I doing some glaringly wrong? > > any comments greatly appreciated > ~runyaga I do not know enough about adsi to be of real help here but why don't you try to Dispatch "ADODB.Connection" in Python script the same way you do it in VBS waldekO From krissepu at vip.fi Fri Nov 30 04:22:46 2001 From: krissepu at vip.fi (pekka niiranen) Date: Fri, 30 Nov 2001 09:22:46 GMT Subject: Python OPC -wrapper for data collection, anyone seen it ? Message-ID: <3C07501E.3040807@vip.fi> Has anybody seen OPC -wrapper done in python ? In industry OPC -servers are breaking thru. It is a microsoft based technoloqy to gather process information. Many Control System manufacturers have their own OPC -servers. There exists a visual basic wrapper -library so that one write VB - programs to enquire data from OPC -server.Wrapper done to python would be cool. Mark Hammond was not interested, but I am not giving up yet... -pekka- From eppstein at ics.uci.edu Wed Nov 28 00:59:42 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 27 Nov 2001 21:59:42 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> Message-ID: In article <3C04768A.CFDC1CE8 at engcorp.com>, Peter Hansen wrote: > > > -1 for being ambiguous to newbies. > > > > The same could be said for 'for i in range(5)', since 'i in range(5)' is an > > expression that is roughly equivalent to '0 <= i < 5'. > > But range() can be looked up. You can type range(5) at the interactive > prompt (where a newbie would live) and see [0, 1, 2, 3, 4] and infer > immediately that you are stepping through the items one at a time. > Typing 0 <= i < 5 at the prompt gives you either 0 or 1, or NameError: > name 'i' is not defined. Not helpful for a newbie. How would the newbie know to type "range(5)" instead of "i in range(5)"? > (Note: I'm not exactly interested in dumbing a language down to the > point where anyone can understand it without learning something from a > tutorial or the reference. When you phrase it that way, I'm not either -- what does it mean to dumb down a language? -- but I would be interested in changes that allow non-Python-literate programmers to understand my code without having to dig through a manual. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From marcoxa at cs.nyu.edu Fri Nov 16 10:47:38 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 16 Nov 2001 10:47:38 -0500 Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <7xg07fwn6l.fsf@ruckus.brouhaha.com> <3BF49DE9.95DC02FA@earthlink.net> Message-ID: "Ben Wolfson" writes: > In article <3BF49DE9.95DC02FA at earthlink.net>, "Hans Nowak" > wrote: > > > Aight, here's a wild-assed idea, unrelated to the proposal... since > > Python > > and Lisp are both dynamic languages, would it be possible to write a > > Python-to-Lisp translator, and then compile the Lisp code using one of > > those efficient Lisp compilers? > > I've often thought that would be a neat project, but I don't know any > Lisp and hardly any Scheme. > Time to learn: http://www.alu.org. Common Lisp has very good compilers both commercial and free (CMUCL - http://www.cons.org - is Public Domain). Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From ngreco at softhome.net Mon Nov 12 09:12:09 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Mon, 12 Nov 2001 11:12:09 -0300 Subject: Fw: Re: IsPython really O-O? In-Reply-To: <29e28c51.0111120245.3ecf070f@posting.google.com> References: <29e28c51.0111120245.3ecf070f@posting.google.com> Message-ID: <20011112111209.57213780.ngreco@softhome.net> On 12 Nov 2001 02:45:08 -0800 cimarron+google at taylors.org (Cimarron Taylor) wrote: > Nahuel Greco wrote in message > news:... > > On Sat, 10 Nov 2001 20:13:47 -0500 > > wrote: > > All the objects created (in your "box", the ST) are "persistent" by default, > > when you close the ambient/box, the next time that you open it, are there. > > There isnt a distinction between "Create the program" and "Use it", you > > always play with live objects. > > Yikes! How do you make this scale? Is better that what you think, is easy and fast for example to add 500.000 objects to an ST OrderedCollection, and query them (if are not used, are paged to disk). You can use also more machines, or a OODBMS. Is like saying "how do you make linux scale if you can have sooo many files" :) > Suppose you have a hundred developers. That has the similar work responsability division problems that with another system. > Suppose one of them changes a method. Do all the other developers immediately > see the change? What do you do about changes in data formats? There are some systems like "cvs" for ST, but are frequently not used, because the ST teams are small (coz more productive) in general, working with XP practices (XP origin was in ST, same design patterns) and with frequents "vocabulary meetings". What do you mean with "data formats"? Also, in ST you read the 80% of the time, and type the 20%, is possible to know the whole system, and one of the XP practice is the work rotation. > How do you > ever maintain changes to a production system if anyone can change anything at > any time? > If you give the production system to someone, you can lock it :) Its similar to giving the source. - Nahuel Greco Web Development - Open Source - - http://www.codelarvs.com.ar Game Programming - Research - - Freelance coding / sysadmin Networking. The answer is 42. - From headroom02 at gmx.de Sun Nov 18 17:14:17 2001 From: headroom02 at gmx.de (Gernot) Date: Sun, 18 Nov 2001 23:14:17 +0100 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> <9t3p3q$rvl$1@scotsman.ed.ac.uk> Message-ID: <9t9c0b$4i8$06$1@news.t-online.com> "Eddie Corns" schrieb im Newsbeitrag news:9t3p3q$rvl$1 at scotsman.ed.ac.uk... > "Gernot" writes: > [deleted] > > I think you've correctly worked out that AND is equivalent to the nested if > statements but it's not clear from the example what you're trying to do. > If you are in fact trying to evaluate input from the user you need to choose a > representation for true and false (such as 't' and 'f') and make explicit > tests for these. > If the input is just for testing and you're trying to understand how myand > works, then you just need to think of 'x' and 'y' as _expressions_, which will > be evaluated to true or false in the right context (I can't think of another > way of saying this as a hint rather than giving the answer outright). That?s right, but I did not have the idea on my own, some students opened my eyes, they gave me this program (it is done with your idea): ####################### def truth (): return "oneword" != "anotherword" def antitruth (): return "oneword" == "anotherword" def myand (a,b): if (a == truth()): if (b == truth()): return truth() else: return antitruth() else: return antitruth() def myor (a,b): if (a == truth()): return truth() else: if (b == truth()): return truth() else: return antitruth() def mynot (a): if (a == truth()): return antitruth() else: return truth() def usethistoprint (a): if (a == truth()): print "True" else: print "False" ########################## I think, that is pretty implementation, I hope I will be able to do this on my own, soon. Thank you for your comment. Gernot From phd at phd.pp.ru Wed Nov 28 04:06:58 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 12:06:58 +0300 Subject: smtplib help In-Reply-To: ; from grante@visi.com on Tue, Nov 27, 2001 at 06:03:10PM +0000 References: <83wv0ds4pk.fsf@panacea.canonical.org> Message-ID: <20011128120658.D4239@phd.pp.ru> On Tue, Nov 27, 2001 at 06:03:10PM +0000, Grant Edwards wrote: > In article , Oleg Broytmann wrote: > > On Mon, Nov 26, 2001 at 02:38:15PM -0500, Kragen Sitaker wrote: > >> Have you tried running the code on an operating system that doesn't suck? > > > > Have you ever saw a piece of software that does not suck? :( > > Paraphrasing Michael Elkins: The author of excellent... well, least horrid mail user agent, mutt. This is also oft attributed to different persons in *BSD camp. > "All software sucks. Some software just sucks less." I know and I agree. Though I personnaly do all my best to write software that does not sucks, I never succeeded. Something inherently wrong with software in general. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dalke at dalkescientific.com Sun Nov 18 14:33:12 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sun, 18 Nov 2001 12:33:12 -0700 Subject: GetImageSize References: Message-ID: <9t92cq$jqb$1@slb6.atl.mindspring.net> Ben Ocean: >In PHP there is a library function called getimagesize(). What is the >equivalent in python? There are many possible answers. You probably want to install PIL (see http://www.secretlabs.com/products/pil/index.htm ). With it, you open the image (with Image.open) and get the 'size' attribute, which the tuple of (width, height). You could call external programs like ImageMagick or the pbmutils to get the image size. On IRIX, for .rgb files you can use imgfile.getsizes and for jpeg the jpeg module. Assuming they were built. In wxPython use wxImage's GetWidth and GetHeight. But in the core library there isn't any built-in function for this. Andrew dalke at dalkescientific.com From gyekye_7 at yahoo.com Tue Nov 6 01:13:43 2001 From: gyekye_7 at yahoo.com (Kojo Duncan) Date: Tue, 06 Nov 2001 06:13:43 GMT Subject: Help Help Help Message-ID: <3be77f95@152.65.161.36> I'm taking a computer science course and I really need help understanding python. If you know of any easy to follow tutorials, great emphasis on easy to follow, please send me a reply on gyekye_7 at yahoo.com . Thanks. Here's a lil practice question for you python gurus out there. Write a program that lists all prime numbers less than a prime number a user inputs. Post on site for all to see. From peter at engcorp.com Mon Nov 12 21:32:17 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 12 Nov 2001 21:32:17 -0500 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111121415.3c6f18ed@posting.google.com> <3BF071C9.9EAF5B6C@engcorp.com> Message-ID: <3BF08631.356D2DE0@engcorp.com> Peter Hansen wrote: > > Why not try writing out a spreadsheet which *does* have a link > in it, as both an XLS files and a CSV file? Examine them and > figure out what Excel does to save the links. Read the CSV > file back in (after renaming to XLS maybe) and see if the link > survives the trip. If it does, you should be able to figure > it out from that, or go on the web and find some docs on > Excel's file formats... Just checked. Text files don't preserve the links, which is obvious in hind-sight, and true XLS files are monster ugly binary files you wouldn't want to write yourself anyway. If you need the links, if I were you I'd learn to use COM. :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nt_colonel at hotmail.com Thu Nov 8 10:52:38 2001 From: nt_colonel at hotmail.com (T Malcolm) Date: 8 Nov 2001 07:52:38 -0800 Subject: WSC in python clears method arguments Message-ID: I'm calling a WSC written in Python from a VBS script that is task scheduled. This WSC is a "friendly" interface to the Python ftp library. All is well, except for one quirk. When I call methods on the WSC, it will clear the variable I pass as an argument. Example vbs client script(where objFTP is an instance of the Python WSC): ---- strRemotePath = rs.Fields("RemotePath").Value 'strRemotePath has a value here objFTP.cwd(strRemotePath) 'strRemotePath is now a nullstring, the cwd command has succeeded. ---- Python code in WSC (objFTP is an instance of FTP imported from ftplib): ---- def cwd(RemotePath, FTP=objFTP): FTP.cwd(RemotePath) ---- I had to use the FTP=objFTP as an argument because I couldn't reference objFTP in the function from the "global" namespace where it resides (another quirk?). Anyway, does anybody have any idea how I can get this thing to quit "eating" my variable values? -- Tom From chrishbarker at home.net Thu Nov 1 14:28:22 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 01 Nov 2001 11:28:22 -0800 Subject: Problem with imported variable References: Message-ID: <3BE1A256.E93D0BE5@home.net> carole valentin wrote: > I have a little question: > I have 2 classes "Class1" and "Class2" and several > functions in each class. The Class1 is in the file > "File1" and the Class2 is in another file "File2". At > the beginning of the File1, I import the File2: > from File2 import * > > In the Class2, I create a variable with a specific > value. When the program is running, I modify the value > of this variable in the other class (Class1) and then > I want to read the new value of the variable farther > in the code of the Class2. > The problem is that the value does not change in the > File2 (Class2). Moreover, as the 2 classes are not in > the same files, the global statement does not change > the problem. > Does someone have an idea? > Thanks for your help! Someone else may be able to figure out what you want to do, but I'm lost. Try posting a very small version of your attempt to do what you want, and we'll probably be able to help you. One question: when you say "I modify the value of this variable in the other class (Class1) and then I want to read the new value of the variable farther in the code of the Class2" are you talking about changing a class variable or an instance variable? -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From khirmint at hotmail.com Mon Nov 19 19:05:41 2001 From: khirmint at hotmail.com (Ken) Date: Mon, 19 Nov 2001 16:05:41 -0800 Subject: Two questions about Python.. Message-ID: <3BF99E55.2C300858@hotmail.com> I'm looking into using Python for a project, and was wondering how does Python rank up against other scripting languages for speed? I assume its not as fast as something like C, which isn't an option as I need a scripting language. Second question is, does Python have a robust exception handling system? Ie.. if a program loads a module and that module has a logic error in it, can the program recover? Or will it crash? From quinn at chunder.ugcs.caltech.edu Fri Nov 30 21:36:59 2001 From: quinn at chunder.ugcs.caltech.edu (Quinn Dunkan) Date: 1 Dec 2001 02:36:59 GMT Subject: A modest indentation proposal References: Message-ID: On Fri, 30 Nov 2001 14:35:41 -0800, Erann Gat wrote: >Now from here on how the story goes is up to you. If you simply insist >that the problem doesn't exist you will lose, at least in the short run, >because for the moment "they" *just know* that it's a problem (in much the >same way that they *just know* that C++ *isn't* a problem). If, on the >other hand, you can show that the community recognizes the problem and has >a solution then you win. You are the community. It's up to you. I don't personally lose or gain anything if some company does or doesn't use python. It's cool if they do, but it's their own gain or loss (was that back-to-back chiasmus?). I can't speak for others, but for me personally to "recognize the problem" would be dishonest, because I don't. While I'd be perfectly willing to recognize a horse as a cat if it would make some suits happy, I wouldn't be willing to go beyond that and start feeding my horse cat food. I'd be willing to write a little paper that says "Whenever I want to cut and paste large hunks of code but leave it as a mis-indented unreadable mess, or write my program all on one line to make it faster, I use the Official Frobozz Magic Python Mangler, which translates \{ into INDENT tokens and \} into DEDENT tokens." I wouldn't, however, be willing to *actually* use the OFMPM, because one of the reasons I like python is not having to put lots of \{ \} in my code, and not having to read it in other people's code. I could lie and say I did, though, if it would help you out. If you want the OFMPM, it's basically like pindent.py. If the change you want can be solved with an external tool, then pindent.py is official enough to come in the std distribution. Using pindent.py wouldn't be "Erann's Hack". And if *you* think typing "# end for" is too much work, well, as you said what you think is irrelevant, it's what "they" think. And historically they don't seem to mind excessive verbosity. If that's not enough, and you think there needs to be a fundamental change to the language syntax, then I'd guess there's no chance of that happening. Changing how blocks are delimited is hardly a "tiny, inconsequential change". People read other people's code and work on other people's projects, so there's no such thing as an optional feature. Did you manage to convince the lispers that the compilers should support an optional ()-less infix syntax to make your boss happy? They'd probably say "so write a read macro" :) From ej at ee.duke.edu Sat Nov 10 14:03:02 2001 From: ej at ee.duke.edu (eric) Date: Sat, 10 Nov 2001 14:03:02 -0500 Subject: Proposal for a modified import mechanism. References: <3BED6E5B.8E142057@arakne.com> Message-ID: <033301c16a1a$59c1c690$c300a8c0@ericlaptop> I have to agree with Prabhu on this one. The current behavior of import, while fine for standard modules and even simple packages with a single level, is sub-optimal for packages that contain sub-packages. The proposed behavior solves the problem. Handling the packaging issues in SciPy was difficult, and even resulted in a (not always popular) decision to build and overwrite the Numeric package on machines that install SciPy. Prabhu's import doesn't resolve all the issues (I think packages may just be difficult...), but it would have solved this one. The proposed import allows us to put our own version of Numeric in the top SciPy directory. Then all SciPy sub-packages would grab this one instead of an existing site-packages/Numeric. That makes SciPy self-contained and allows people to try it out without worrying that it might break their current installation. There are other solutions to this problem, but Prabhu's fix is by far the easiest and most robust. Prabhu's import also has some other nice benefits. Some of the sub-packages in SciPy are useful outside of SciPy. Also sometimes it is easier to develop a packages outside of the SciPy framework. It would be nice to be able to develop a module or package 'foo' outside of SciPy and then move it into SciPy at a later date. However, every SciPy sub-package that referred to foo prior to its inclusion in SciPy now has to be updated from 'import foo' to 'import scipy.foo'. These kind of issues make it very painful and time consuming to rearrange package structures or move modules and sub-packages in and out of the package. Simplifying this will improves package development. > I'm personnally against anything that enlarges the search path uselessly; Hopefully I've explained why it is useful for complex packages. > because the obvious reason of increased name space collision, increased > run-time overhead etc... I'm missing something here because I don't understand why this increases name space collision. If the objection is to the fact that SciPy can have a version of Numeric in it that masks a Numeric installed in site-packages, I guess I consider this a feature, not a bug. Afterall, this is already the behavior for single level packages, extending it to multi-level packages seems natural. If this isn't your objection, please explain. The current runtime overhead isn't so bad. Prabhu sent me a few numbers on the SciPy import (which contains maybe 10-15 nested packages). I attached them below -- the overhead is less than 10%. It should be negligible for standard modules as only packages are really affected (right Prabhu?). $ python >>> import time >>> s = time.time (); import scipy; print time.time()-s 1.37971198559 >>> $ python >>> import my_import >>> import time >>> s = time.time (); import scipy; print time.time()-s 1.48667407036 There may be technical issues under the covers that make this hairier than it appears, but, from the standpoint of someone working on a large multi-level package, it looks like a good idea. see ya, eric ----- Original Message ----- From: "Frederic Giacometti" To: Cc: ; ; Sent: Saturday, November 10, 2001 1:13 PM Subject: Re: Proposal for a modified import mechanism. > > > > > > I'd like to ask the Python developers if they'd consider > > > > (a) changing the way the current import works to do what I > > proposed, or, > > > > (b) add a new keyword like 'rimport' (or something) that does this > > recursive search through parent packages and loads modules. This > > was actually suggested by Gordon McMillan. Gordon actually > > suggested something stronger -- import only supports absolute > > names, rimport is relative import and rrimport is a recursive > > relative import. But this would break the current import since > > import currently aupports some relative lookup. So maybe import > > and rimport is a workable solution? > > I'd rather introduce a __parent__ module attribute (in addition to the > existing __name__) so that, for instance, the following would do your job: > > from __parent__.__parent__.toto import something > > In its spirit, this is similar to the '..' of the file systems. > > For top-level modules, __parent__ would be None. > > I'm personnally against anything that enlarges the search path uselessly; > because the obvious reason of increased name space collision, increased > run-time overhead etc... > > Frederic Giacometti > > > From sdm7g at Virginia.EDU Fri Nov 9 10:48:19 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 9 Nov 2001 10:48:19 -0500 (EST) Subject: iters on ints? (reducing the need for range/xrange) In-Reply-To: Message-ID: On Thu, 8 Nov 2001 James_Althoff at i2.com wrote: > On the other hand, 2.2 takes us away from the concept of "suggesting a > sequence" in the context of for-loops. Instead, the new for-loops are > *iterator*-protocol based (not *sequence*-protocol based). They iterate > over something that *is* or *can return* an iterator object. > > So under the proposed scenario, if one looks at 10 and asks "if 10 were to > return an iterator, what would that iterator iterate over?", then it seems > that range(10) would be a more *useful* answer than a sequence of one > element 10. > I wouldn't be against 'iter(10)' returning an iterator but having 10 BE an iterator is too much of a surprise. Besides: for i in 10: is just too close to: for i in 10,: What would a newbie guess: for i in 1,10: means? ( I like 'for i in 1..10:' better. ) -- Steve From marcoxa at cs.nyu.edu Tue Nov 13 10:09:40 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 13 Nov 2001 10:09:40 -0500 Subject: Are there any list comparison optimizations in Python? References: Message-ID: jbperez808 at yahoo.com (Jonathan P.) writes: > >>> x=[1,2,3] > >>> y=x > > >>> xlist=[x,1,2,3] > >>> ylist=[y,1,2,3] > > >>> xlist==ylist > > >>> xlist.remove(x) # these 2 statements not executed one after > >>> xlist.remove(y) # the other but representing different cases > >>> ylist.remove(x) > > One of Python's most convenient high-level features is automatic list > comparison by value and recursively. > > Does it know to optimize the compare if it has already been determined > that two items share a reference to the same object by not doing a > value compare on them anymore? > > And will this apply to both the comparison and remove() calls above? Interesting concept. In Common Lisp you can program it in the language. A first cut/draft could be. (defun equal* (l1 l2) (cond ((eql l1 l2) t) ((null l1) nil) ((null l2) nil) ((equal* (first l1) (first l2)) (equal* (rest l1) (rest l2))))) Of course, there is nothing in the ANSI spec that forbids an implmentor to build EQUAL and EQUALP in this way (actually I assume this is the way things are built - have not checked though). Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From h4rv3st at web.de Wed Nov 7 10:20:34 2001 From: h4rv3st at web.de (Daniel T. Bender) Date: Wed, 7 Nov 2001 16:20:34 +0100 Subject: Games Programmed in Python References: <9sahq0$qi1$1@slb6.atl.mindspring.net> Message-ID: <9sbjg5$121foi$1@ID-22517.news.dfncis.de> schrieb im > x-no-archive: yes > > Could somebody direct me to some examples of games programmed in Python? actually, there is a pretty cool game called 'Severance: Blade Of Darkness' that makes heavy use of Python. http://www.codemastersusa.com/blade/Index3.html From gmcm at hypernet.com Tue Nov 6 08:45:14 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 06 Nov 2001 13:45:14 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> Message-ID: John S. Yates, Jr. wrote: > On 5 Nov 2001 13:53:28 GMT, amk at localhost.debian.org (A.M. Kuchling) > wrote: > >>Not at all. Stackless would have ramifications not just for a few >>files in the core, but also for all the extension modules that come >>with Python and for all the authors of third-party extension modules. > > Is this because those extension modules would break? Or because they > would be sub-optimal until they took advantage of continuations? You can't create a continuation in one execution of the interpreter and use it in another. Recursions of the interpreter are very common in Python - basically, anytime you execute Python code from C. Stackless fixes some of these cases (turning recursion into iteration), but leaves most of them untouched. In practice, it's not much of a problem - on the Stackless list, I think I've seen two or three posts from people trying to create continuations inside an __init__ (which doesn't work). It turns out to be easy to work around. But making Python *truly* stackless means getting rid of all recursions, and that is an enormous task. If you don't do that, you've got a language feature that doesn't work in some apparently random set of circumstances. There is still hope, I think, that something more general than Generators but less ambitious than Stackless will find it's way into the core. - Gordon From eddie at holyrood.ed.ac.uk Mon Nov 26 11:16:20 2001 From: eddie at holyrood.ed.ac.uk (Eddie Corns) Date: Mon, 26 Nov 2001 16:16:20 +0000 (UTC) Subject: Pls. help me recreate shell trick References: <3BFE4A90.1C0F1E0C@divalsim.it> <9tlmi5$s5d$1@news1.wdf.sap-ag.de> <9tmmeq$4e6$2@peabody.colorado.edu> <3C024109.389A43A@divalsim.it> Message-ID: <9ttpsk$c65$1@scotsman.ed.ac.uk> Nicola Musatti writes: >Thanks to both Fernando and Daniel for your suggestions. However, I >probably didn't explain myself very clearly. My aim is not only to >provide display only, debug mode for external commands, but also for >possibly disrupting Python statements. One example could be: >import shutil >shutil.copyfile(src,dest) A very simple minded solution: def protect (func, *args): if debug: print '!!Calling',func.__name__,'with',args else: apply (func, args) Then just use: protect (shutil.copy, src, dest) after setting debug. It would be trivial to add code to ask the user whether to go ahead and do the command as well. Eddie From tjreedy at home.com Mon Nov 26 21:54:20 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 27 Nov 2001 02:54:20 GMT Subject: function operators References: <3C02F6A3.941CCB5E@earthlink.net> Message-ID: "Hans Nowak" wrote in message news:3C02F6A3.941CCB5E at earthlink.net... > # composable_functions.py > > from __future__ import nested_scopes > > class ComposableFunction: > > def __init__(self, f): > self.f = f ... Does 2.2 allow one to inherit from type 'function'? So one could do this without extra level on indirection? Terry J. Reedy From cuiod-tec at web.de Tue Nov 27 02:06:38 2001 From: cuiod-tec at web.de (Jens Gelhaar) Date: 26 Nov 2001 23:06:38 -0800 Subject: question: metaclass and C - a new general style References: <3c02343d@netnews.web.de> Message-ID: Hi, > Martin wrote > I recommend to use the existing Don Beaudry hook. If you specify a > the class name, the base classes, and the class dictionary; its return > value is the newly-created class. > > In this hook, you can easily invoke __metainit__ yourself. I dont like this hook for serveral reasons. When I read some postings about the metaclass stuff and see some implementation. There is no wonder, why so many people dont understand these matter and there for can not use it. I dont like to create an class and make instance of it, to get callable object and use it as ancestor. If you work with helper classes, it get even more confusing. Then you have an method helper class and so on. It is difficult to get it right in UML and if you try to follow a debug trace you get grey hairs. It would be much more obvious, if you define a class with an __metainit__ (however you call it) and you have normal inheritance AND and way to control the inheritance. These would be sufficient for the most cases and everyone could understand AND read the code. What do you thing about it? Yesterday evening I dove in the source code and found a simple way, just 8 lines in classobject.c Jens From jtdubs at eos.ncsu.edu Thu Nov 15 15:48:16 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Thu, 15 Nov 2001 15:48:16 -0500 Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> Message-ID: <9t19j8$bij$1@uni00nw.unity.ncsu.edu> "Peter Bismuti" wrote in message news:3bf4240d$1 at 207.229.64.20... > I want to pass a function as an argument but don't want to have to define it > globally. > I think the proper terminology for this is "anonymous". > > The way I *don't* want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) > > > I'm guessing this can't be done because of Python's indenting syntax. > In ECMAscript you can send a function as an argument that is defined on the > fly such as: > > callMyFunction( new Function(){ blah blah }) > > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? > > Thanks > > If it's a short function than you can use lambda syntax as follows: mul = lambda x, y : x * y This defines a function called mul that takes two arguments, x and y, and returns their product. The generic form is: lambda args : value So, you can do this: functionToCall( lambda x : x + 1 ) Hope that helps. Have fun, Justin From chrishbarker at home.net Thu Nov 29 14:13:15 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 11:13:15 -0800 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> <9u37pb$7dk$1@slb7.atl.mindspring.net> <13285ea2.0111290447.57be5009@posting.google.com> Message-ID: <3C0688CB.B8FB019E@home.net> "J.Jacob" wrote: > But, i managed to get a nice speedup ! And a surprising result. > This version takes 101 seconds in my test program. > This took 76 seconds for the test, a big improvement ! > This also takes 76 seconds doing the test. > This version takes 94 seconds. > This version takes 90.4 seconds. > Taking 68.7 seconds. you took a whole lot of time to get from 101 seconds to 68.7 seconds. I would venture top guess that if 68.7 seconds were "fast enough" then 101 seconds would probably be fast enough as well. Personally, I look for a factor of 5 to 10 speed-up at least in order for it to worth a lot of effort to optimize. By the way, your original code: for j in range(self.nh): sum = 0.0 for i in range(self.ni): sum = sum + self.ai[i] * self.wi[i][j] Are you sure you want to re-set sum inside the j loop? you are re-defining it, so unless you store it, you are only going to get the sum of the last row, which makes it pretty silly to loop through the whole mess. Anyway, here is the code for Numeric. You must be using some pretty slow hardware, or massive arrays to get times as long as you get! With and without Numeric: with loops it took 39.060000 seconds with Numeric it took 2.480000 seconds Now that is a speed-up that is worth it! The truth is that Python will never do numeric work quickly without the Numeric module. It might be less time to figure out how to install Numeric than to try to optimize raw Python for limited gain. Here is the Numeric code, which is also nice and clean, compact and easy to read: from Numeric import * import RandomArray import time nh = 5000 ni = 1000 ai = RandomArray.uniform(0,100,(ni,)) wi = RandomArray.uniform(0,100,(nh,ni)) start = time.clock() for j in range(nh): total = 0.0 for i in range(ni): total = total + ai[i] * wi[j][i] print "with loops it took %f seconds"%(time.clock()-start) start = time.clock() totals = sum((ai*wi),1) # this is an array of each row total print "with Numeric it took %f seconds"%(time.clock()-start) grand_total = sum((ai*wi).flat) # this is the sum of all of them -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From ed at iterunet.com Wed Nov 7 01:12:35 2001 From: ed at iterunet.com (Edy Lie) Date: Wed, 7 Nov 2001 14:12:35 +0800 Subject: Class Message-ID: <9sah0q$hki$1@newton3.pacific.net.sg> Hi I have setup a class but in the code i could not use it. Anyone care to explain ? #!/usr/local/bin/python import sys class DataBase: def __init__(self, Plan, Domain, Email, Name): self.UserPlan = Plan self.UserDomain = Domain self.UserEmail = Email self.UserName = Name print '1. Adding New User' print '2. Search New User' print '3. View All User' print '4. Exit' choice = input("Please choose an option: ") if choice == 1: print 'Adding New User\n' add = DataBase() add.UserPlan = input("Username: ") add.UserDomain = raw_input("Domain: ") add.UserEmail = raw_input("Email: ") add.UserName = raw_input("Name: ") elif choice == 2: print 'Search New User\n' elif choice == 3: print 'View All User\n' elif choice == 4: print 'Exit program ...' sys.exit() else: print 'Wrong input' sys.exit() From ajs at ix.netcom.com Tue Nov 27 21:04:57 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Tue, 27 Nov 2001 21:04:57 -0500 Subject: Copy operator (was list.remove for Noivces) Message-ID: <000f01c177b1$1abb8c20$a9e1fea9@carol> Jeff Shannon wrote: >>Arthur Siegel wrote: >> How about this one. A copy operator - <=> or something. So now > >all the world is on notice from day one = is different that <=>. >> Which do you mean? >Well, Python already *does* have several ways to indicate copying, though not specifically in a single simple operator like that. >list2 = list1[:] #create a copy >import copy >list2 = copy.copy(list1) #copies a list >list2 = copy.deepcopy(list1) #even better Except not having grokked the difference between copy and deepcopy, I am aware -as to the list2=list[:], just recently aware. >Yes, beginners are likely to get bitten by a few things. This will happen >regardless of what language they use. Trust me, it's a lot easier to track down >an assignment/copy error, or the list.reverse() gotcha, than to track down the >bugs caused by referencing free()'d memory in C... Don't doubt it for a moment. >I don't think that changing the language to avoid these will help matters much. What if we could help matters marginally, at no real cost? Turns out I am not the first to suggest a copy operator on the list. It was suggested in the course of discussions by some folks focused on numerics. But though I would defend the position with some vehemence that a copy operator would be a significant improvement for Python as a beginners/learners language - it is clearly not a discussion worth having if there are overriding design reasons it does not make sense. The issue of copy vs. deepcopy is one issue that came up in previous discussions. How significant is that? Are there other significant issues involved? Certainly no backwards compatibility issues arise, and those who find it superfluous can ignore its existence. I don't doubt that there is significantly more to the issue than my view allows me. But if I could find some way to demonstrate (not saying that I necessarily could find a way to do so convincingly) that it would indeed make Python better equipped for beginners/learners - is there a shot it would find acceptance by the community? Art From tdelaney at avaya.com Tue Nov 6 23:19:04 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 7 Nov 2001 15:19:04 +1100 Subject: Q: Feature Wish: "%" Extension Message-ID: > From: Paul Rubin [mailto:phr-n2001d at nightsong.com] > > grante at visi.com (Grant Edwards) writes: > > Don't all c.o.l.p threads eventually end up being about integer > > division? ;) > > > > It could be worse, in most other newsgroups all threads end up > > being about Hitler... > > Godwins law, thread over! You have compared integer division > to Hitler. ;-) No - Godwin's law does not apply, as there was no actual comparison to Hitler or Nazis, or suggestions of anyone being such. Tim Delaney From peter at engcorp.com Wed Nov 28 18:28:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 18:28:50 -0500 Subject: Database in a simple ascii file References: <3C04F826.CB408C9D@engcorp.com> Message-ID: <3C057332.7865BFC0@engcorp.com> Fredrik Lundh wrote: > > Peter Hansen wrote: > > If you are really concerned about performance, you will > > always be able to get more than a 10 times speedup by > > switching to a compiled language over Python. > > always? Definitely not always. Sometimes it is clearer to be absolute, if somewhat untruthful... (Otherwise I would have had to say something like, in the sort of situation you are encountering, given the sort of code one would tend to write in that situation, and considering the context in other ways, you could probably expect to get somewhere between 1 and 300 times speed improvement by rewriting the application in a compiled language, depending on the language chosen, although the overall speedup would be somewhat less if you chose to profile your code and optimize only the performance-critical portions.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From greg at cosc.canterbury.ac.nz Sun Nov 4 21:30:38 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Mon, 05 Nov 2001 15:30:38 +1300 Subject: List transpose method References: <3BE1DD41.C58238FE@home.com> <9rsn3s$vjpde$1@ID-11957.news.dfncis.de> <3BE21EED.AD3A150A@home.com> Message-ID: <3BE5F9CE.D3C46DBA@cosc.canterbury.ac.nz> Don O'Donnell wrote: > > Emile van Sebille wrote: > > > > Cool. I hadn't realized that zip could be used for more than two sequences. > > Yep. Although the zipper metaphor gets a bit streched.\ :-) You've just made me try to imagine a physical zipper with more than two "sides" to it. An interesting mechanical challenge... -- 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 tyler at tylereaves.com Sat Nov 24 21:13:16 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Sun, 25 Nov 2001 02:13:16 GMT Subject: A permutation on permutations References: Message-ID: <0tYL7.3272$WC1.370559@newsread2.prod.itd.earthlink.net> Arthur Siegel wrote: > Was able to find nice stuff on the python-list archives > as to list permutations, list reversal, and removing > duplicates from lists. > > My problem is to combine them. > > I am feeding control points to a curve function, and > want all permutations that result in unique curves. > For this purpose a sequence is duplicative > of its reverse, i.e. [1,2,3,4] == [4,3,2,1], etc. > Would [1,3,2,4] be a duplicate? From jdadson at ix.netcom.com Fri Nov 2 14:41:56 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 02 Nov 2001 19:41:56 GMT Subject: A better way to send mail? References: Message-ID: <3BE2F6E9.FFF40050@ix.netcom.com> David Brady wrote: > > Hello all, > > Python promotes marital harmony. > > I came across an interesting problem the other day, > and used Python to solve it. My wife always wants to > know what the weather is going to be like, and works > in a place where she can receive e-mail with image > attachments but is not allowed to access the web. Not allowed to access the web at work? Oh my god, your wife works in a Dickens novel! Does the boss allow her only one lump of coal a day to heat her squalid cubicle? Jive "I work to surf. I surf to work." From gward at python.net Mon Nov 12 10:26:12 2001 From: gward at python.net (Greg Ward) Date: Mon, 12 Nov 2001 10:26:12 -0500 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) In-Reply-To: <20011112175357.F26476@phd.pp.ru> References: <20011112175357.F26476@phd.pp.ru> Message-ID: <20011112102612.A1723@gerg.ca> On 12 November 2001, Oleg Broytmann said: > Can it handle multiple arguments for an option? > > --file outfile1 outfile2 No, but Optik supports callback options so you can easily do it yourself. Something like this: def process_many (option, opt, value, parser, nargs): if len(parser.args) < nargs: raise OptionValueError( "%s option requires %d arguments" % (opt, nargs)) setattr(parser.values, option.dest, parser.args[0:nargs]) del parser.args[0:nargs] [...] parser = OptionParser(...) parser.add_option("--file", action="callback", dest="filenames", callback=process_many, callback_args=(2,)) Completely off the top of my head, untested, YMMV, RTFM for more info, etc. etc. Alternately, you could add a new action, eg. "store_many", to the Option class. (Well, to your own Option subclass.) That would be more general, and might make it easier to put Optik's type system to use -- eg. you could have one "store_many" option that expects two strings, and another that expects 3 floats. If you add a "file" type (where type-checking means "check that this file exists"), you could make one that expects two files. See extending.txt, or just bug me again and maybe I'll do it. > Or mix options and arguments? > > --file outfile infile -q Not yet; I deliberately punted on this because most other Unix command-line parsing libraries are lazy and don't bother to scan all arguments for options. (I think scanning all arguments is the preferred behaviour, but for historical reasons it should probably be optional behaviour. I could be wrong...) However, the main loop in OptionParser.parse_args() is pretty simple: (args, tail_args) = self._split_args(args) [...] while args: arg = args[0] try: if arg[0:2] == "--": self._process_long_opt(args, values) elif arg[0] == "-": self._process_short_opts(args, values) else: # To add the ability to intersperse options with # positional arguments, change this. break except (BadOptionError, OptionValueError), err: self.error(err.msg) (_split_args() just looks for "-" and "--" args, to force a halt to option-parsing.) > Handle multiple args with the same name? > > --file outfile1 -f outfile2 Yes, but just what happens in this case depends on the action you use. I'm assuming --file and -f are synonomous, ie. parser.add_option("-f", "--file", ...) is how you defined them. If you did parser.add_option("-f", "--file", action="store", type="string", dest="file") then the most recent option seen takes effect, and options.file == "outfile2" But if you did parser.add_option("-f", "--file", action="append", type="string", dest="file") (note the different action), then all occurences of -f or --file build up, and options.file == ["outfile1", "outfile2"] In other words, you're free to define the Right Thing for your application, and Optik will Do The Right Thing. That's why I used "flexible" in the description. Greg -- Greg Ward - programmer-at-large gward at python.net http://starship.python.net/~gward/ Things are never as bad as they seem -- they're worse. From James_Althoff at i2.com Wed Nov 28 16:20:29 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 13:20:29 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: David Eppstein wrote: >or even (with Perl-like conciseness) > if i in 5: (Assuming that the above was meant as a ding and not a compliment ;-) Even if for rowindex in table.rowcount: has "Perl-like conciseness", you have to admit at least that it doesn't add any Perl-like line noise. Jim From chrishbarker at home.net Tue Nov 6 12:47:10 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 06 Nov 2001 09:47:10 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> Message-ID: <3BE8221E.52F65193@home.net> Jive Dadson wrote: > > You can bet that this has been proposed by people new to Python again > > and again and again ... > > What does that tell you? As others have mentioned, it means that when people come to Python with experience with other languages, they immediately start proposing that Python add their favorite features from their previous language. > > ... and I can promise you that this is one thing that > > is very well cemented in. If there is one thing that makes Python > > Python, is that it is a highly dynamic language. THat is not going to > > change. > > You must have misunderstood what I wrote. I'm not proposing anything > that would make it "lowly dynamic". While you did propose that "option explicit" was optional, that essentially creates two dialects of the language, which is frowned upon, unless it's temorary (see various from __future__ options) And, yes you are proposing a reduction in dynamisism. Would this be legal? option explicit class dummy_class: pass spam = dummy_class() spam.eggs = 5 Python currently allows you to dynamically add attributes to a class instance. some people consider that dangerous, but it really is part of the dynamic nature of Python. Anyway, I in no way intend or intended to argue the merits of your proposal, what I am saying is that it is highly unlikely that it would ever get added to Python. > There's a pragmatic reason I'm asking for this feature. One of our > customers has suggested that we implement scripting using Python. I've > looked into Python, and I am very impressed with what I see. But I > would have grave misgivings giving it to customers with variable > declarations the way they are now. Clearly you have these misgivings, and based on your experience with other languages, you think this is important, but you have probably figured out from this thread that there are a whole lot of people using Python out there that do not see this as a big issue at all. A bug is a bug, and this feature would only catch very few bugs. While this is a pretty limited proposal, there have been many, many proposals for features that would help the compiler catch minor bugs for you. The consensus among most Python users is that they add little value. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From daniel.dittmar at sap.com Mon Nov 26 09:17:28 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 26 Nov 2001 15:17:28 +0100 Subject: Pls. help me recreate shell trick References: <3BFE4A90.1C0F1E0C@divalsim.it> <9tlmi5$s5d$1@news1.wdf.sap-ag.de> <9tmmeq$4e6$2@peabody.colorado.edu> <3C024109.389A43A@divalsim.it> Message-ID: <9ttito$t0$1@news1.wdf.sap-ag.de> > My aim is not only to > provide display only, debug mode for external commands, but also for > possibly disrupting Python statements. One example could be: > > import shutil > shutil.copyfile(src,dest) class TracingProxy: trace = 0 execute = 1 def __init__ (self, callable): self.callable = callable def __call__ (self, *args): if self.trace: printableArgs = map (repr, args) argString = string.join (printableArgs, ', ') print self.callable.__name__, '(', argString, ') =>', if self.execute: result = apply (self.callable, args) else: result = 'SKIPPED' if self.trace: print result return result def __getattr__ (self, attrname): """get any attributes from proxied object""" return getattr (self.callable, attrname) Use as: copyfile = TracingProxy (shutil.copyfile) copyfile (src, dest) You can switch the 'trace' and 'execute' flags either globally in class TracingProxy or per callable object. You can use another routine besides repr () to convert arguments to strings - say to limit string sizes. Exercise: create a class ModuleProxy which takes a module in its __init__ method and creates a TracableProxy for each module method. Daniel From bernhard at intevation.de Mon Nov 5 07:42:45 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 5 Nov 2001 12:42:45 GMT Subject: Freeware Python editor References: <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> <3BE11391.BF044772@alcyone.com> <3BE18A02.76FE1AB@alcyone.com> <3BE1C6E9.89BCDE7F@alcyone.com> Message-ID: <9s61g5$1136nf$6@ID-89274.news.dfncis.de> Erik: IMHO Oleg's clarification attempt is sometimes justified. The term "freeware" still creates confusion for people no deep into the subjects. From my experience people do not think or act like it has well defined meaning. Some often made mistake is to mistake it for "Free Software". I have learned more about it from the historical part of the thread. Bernhard In article <3BE1C6E9.89BCDE7F at alcyone.com>, Erik Max Francis writes: > Oleg Broytmann wrote: > >> I m saying this third or fourth time - it was not a complain, just >> a >> clarification: the editor is "freeware", but not "free". > > Look at the Subject of this thread. The original poster _said_ it was > freeware. > -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From logiplexsoftware at earthlink.net Thu Nov 15 17:01:21 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 15 Nov 2001 14:01:21 -0800 Subject: Is it a job for Thread or Process? In-Reply-To: <3BF4462D.18995.122E154@localhost> References: <3BF4462D.18995.122E154@localhost> Message-ID: <01111514012100.01371@logiplex1.logiplex.net> On Thursday 15 November 2001 13:48, A wrote: > Hello, > In my Python script I would like to start one function of this script > in a different thread or process? > That function sends an email. > Can you please give me an example how I can start a new thread > or process under Win32 systems? > > Is it better to use a new thread or a new process for this task? > Thank you for help. > Ladislav I usually use threads, as they are very simple under Python: import threading import time def mythread(killevent): while not killevent.isSet(): print "thread running" time.sleep(2) killevent = threading.Event() thread = threading.Thread(None, mythread, "", (killevent,)) thread.start() # start the thread time.sleep(6) # let the thread run a little while killevent.set() # tell it to stop thread.join() # wait for it to actually exit This demonstrates the basics for starting and stopping a thread (Python has no direct method for stopping a thread, hence the event). Good luck, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From prabhu at aero.iitm.ernet.in Sun Nov 4 01:37:50 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 4 Nov 2001 12:07:50 +0530 Subject: Python packages - problems, pitfalls. Message-ID: <15332.57918.232705.721124@monster.linux.in> hi, Recently I discovered that there is some very unfortunate behaviour with python packages. Lets say I have a directory 'pkg' that is the root of a package. Inside this directory I have a sub-package, called sub. So its something like: pkg/ __init__.py a.py sub/ __init__.py b.py Now, from b I'd expect to be able to import 'a' straight away. Say in b.py I do import a This will not work! I know why it happens but shouldn't Python be smart enough to avoid such problems? Why I consider this a major problem is that the importing of a sub-package depends on where its parent package is!! So if pkg is no longer the root of the package and say its put inside another BigPkg then to make pkg's sub packages work you'd have to edit *all* the sub packages and change every reference to pkg.a to BigPkg.pkg.a. This is a huge pain. One way around this is to do something like this inside sub's __init__.py: import os __path__.append(os.path.dirname(__path__[0])) This however will cause the module a to be loaded several times! Once as pkg.a and once as pkg.sub.a!! Imagine what would happen if you had many such sub-packages. One way around this would be for import to see if the importee (the imported package) (1) is in the same directory (no problem, this already works) (2) is part of a the same package that the importer (the code that does the import) belongs to. If so look in the parent packages directory first. (3) Keep doing (2) untill you are out of all parent packages. Something like walking a tree. (4) If all this fails, search for modules in sys.path. I did some prelimiary searching and came upon the import-sig which led me on to imputil. I also found that knee.py does something to eliminate such problems. However, I find that (1) imputil isn't documented enough (at all?) and I can't really find neat examples that illustrate its usage. (2) I don't know if using imputil is recommended and what the problems are with using it etc. (3) knee.py warns me saying """ This code is intended to be read, not executed. However, it does work -- all you need to do to enable it is "import knee".""" I know that I can experiment, read the source, grok it all and look for solutions but at the moment don't have much time for it. I'd like to know what you folks think. Are there better ways to get around this packaging problem? Is this a know problem that folks are working on?? Why is it that Python does not deal with this issue more sensibly? Thanks! prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 From dalke at dalkescientific.com Sat Nov 17 11:48:24 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sat, 17 Nov 2001 09:48:24 -0700 Subject: identity = lambda x: x -- a Pythonic idiom? References: Message-ID: <9t64fv$305$1@nntp9.atl.mindspring.net> George Demmy: >identity = lambda x: x # like this in practice (lazy) > >def identity(x): # Pythonic -- shows up in profiler, etc > return x > >data = filter(identity, crufty_list) Isn't this the same as operator.truth? Andrew dalke at dalkescientific.com From bh at intevation.de Fri Nov 2 13:48:36 2001 From: bh at intevation.de (Bernhard Herzog) Date: 02 Nov 2001 19:48:36 +0100 Subject: Unpacking extension (Re: A small inconsistency in syntax?) References: <6q1yjkvpi6.fsf@abnoba.intevation.de> <52e5ab5f.0110310816.30e9f47f@posting.google.com> <6qhesfsi72.fsf@abnoba.intevation.de> <52e5ab5f.0111011240.2bc402f8@posting.google.com> Message-ID: <6qpu71ggaj.fsf@abnoba.intevation.de> me at mikerobin.com (Michael Robin) writes: > Bernhard Herzog wrote in message news:<6qhesfsi72.fsf at abnoba.intevation.de>... > > me at mikerobin.com (Michael Robin) writes: > > > > > I'd think there's no reason to disallow it. > > > Although in Python the comma operator creates tuples > > > rather than the parens, for many it looks as if > > > a,b = seq > > > is just shorthand for > > > (a,b) = seq > > > > This version would not be removed. You need some kind of grouping to > > support nested unpackings. > > I don't think I ever suggested it would be removed. Well, you said (as quoted above) that you see no reason to disallow it and then went on to give an example with parentheses instead of square brackets. It looked to me as if you thought that I proposed that the parenthesized version be disallowed too. Sorry if I misread that. > As per my previous post, one could view "tuple unpacking" as either > (a) A degenerate (though very useful) form of unification or, (b) a > seperate language feature totally unto itself, resembling > multiple-value binding -- although it is less general than unification > and more general than retrieving multiple values from a fn. (Although > it is commonly used for the latter.) > > If your view is (b) then "a, b = foo" would be the preferred and only > syntax, but because *the shape of the LHS matters* (as in "a, [b, (c, > d)] = foo") some form of nesting is reqired in the LHS; That's pretty much my view of sequence unpacking, yes,.. > therefore it makes sense to allow [] along with (), ... but I don't see the "therefore". All that matters is the sequenceness of the RHS, not the actual types. > especially since it is more > self-documenting if, in fact, you are unpacking a list rather than a > tuple in a particular portion of the structure to be unpacked (meaning > that you can modify it after unpacking it, etc). The list only exists on the RHS. On the LHS you only have the items of the list and whether they're mutable has nothing to do with the fact that they were pulled from a list. Perhaps I'm misunderstanding you here, though. > (And hey, let's give > future type-inference systems, human or machine, as much information > as they can get.) Well, as long as the current semantics of sequence unpacking aren't changed, it doesn't matter whether you use list or tuple syntax on the LHS. The information a type-inference system can get from it is the same in both cases. Changing this so that it does make a difference whether you use () or [] would actually be a step back in Python's development, but you're not advocating that, I think. > > > Also, given that lists are mutable and tuples are > > > not, the list notation makes some kind of sense, > > > even though you're rebinding the names in the LHS > > > rather than creating a list, per se. > > > > In my eyes the mutability of the RHS doesn't enter into it. All that > > matters is that it's a sequence of the right length. > > I belive I said LHS, not RHS, as we were on the topic of the syntax of > the name list As I read it, the LHS only applied to the names, but not necessarily the tuples/lists and since the mutability can only apply to the RHS anyway I thought you were talking about the mutability of the sequence on the right. There's not actual sequence object that you're assigning into on the LHS, after all, and mutability is a property of objects. > - but in any case > I agree - I never said it mattered. The point was > that orinarilly "aList = RHS" is allowed, but > "aTuple = RHS" is not; I assume you mean something like seq[0] = value which would work if seq is a list but not if it's a tuple because one is mutable but the other isn't... > therefore []'s "make some > kind of sense", given that the syntax for unpacking > is identical to assiging to a literal sequence, and > that, in fact, you are causing a side-effect. ...and thus [] would make more sense because it looks like you're modifying the contents of a list. I suppose that one can look at it that way. I think of something like a, b = seq more as a shortcut for (modulo slight differences): a = seq[0] b = seq[1] basically, I think of the LHS as a sequence of assignment targets, but not as sequence object (that's also more or less the way it's described in the language reference). How do others think about this? > If unpacking works "for all kinds of sequences with length 2" (your > words), why wouldn't the LHS follow suit? If I don't care what kind of sequence it is, why shuld I try to distinguish between two of them? > (At least for literals - I'm > not suggesting you should be able to do: > someObjectThatImplements_setitem_() = > somethingThatImplements_getitem_or_iter() > - but wait... :) (No, seriously - way to dangerous...)) What would that mean? Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From dalke at dalkescientific.com Wed Nov 14 14:39:40 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Wed, 14 Nov 2001 12:39:40 -0700 Subject: Parser Generators: which is best? References: <3BF297E2.4D900A75@divalsim.it> Message-ID: <9suhbs$pao$1@slb4.atl.mindspring.net> Nicola Musatti: >I came across Aaron >Watters's kw(j)Parsing and John Aycock's SPARK. Before I make my choice >I'd like to know about experiences with these or other tools. I've worked with both kwParsing and SPARK. I found SPARK easier to use by quite a bit. I've not compared the performance between them. Andrew From mwh at python.net Wed Nov 28 06:53:00 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 28 Nov 2001 11:53:00 GMT Subject: decoding floats References: <9u2buq$jo9$1@news.sns-felb.debis.de> Message-ID: "Nico Hartmann" writes: > Hi there, > > I look for a way to decode and encode float values into byte arrays. >>> import array >>> a = array.array('f') >>> a.append(42.42) >>> a.tostring() '\x14\xae)B' Something like this? See http://python.sourceforge.net/devel-docs/lib/module-array.html for more info. Cheers, M. -- > so python will fork if activestate starts polluting it? 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. -- Brian Quinlan, comp.lang.python From tdelaney at avaya.com Sun Nov 4 19:26:08 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 5 Nov 2001 11:26:08 +1100 Subject: Freeware Python editor Message-ID: > From: DeepBlue [mailto:DeepBlue at DeepBlue.org] > "Magnus Lie Hetland" wrote in message > news:9rulu9$n2m$1 at tyfon.itea.ntnu.no... > > "Oleg Broytmann" wrote in message > > news:mailman.1004711703.24605.python-list at python.org... > > [snip] > > > And after you've modified it - do you have > > > rights to distribute it to your friends? > > > > I hope you are not claiming that what you said above is > something peculiar > > to Free (as in Gnu/FSF) Software? It would also apply to Open Source > > software. (And, yes, people would be allowed to make non-open-source > > software based on it, and _that_ software might not be free in any > > sense.) > > > This is contested. check the issue with Virtual Dub. An open source > project. > Someone used the code to produce an **unopen application. > Virtual Dub guy > does not like and he is threatening to sue. > What you describe is called theft. Actually, Avery Lee had licensed VirtualDub under the GPL. Vidomi had produced software which used code from VirtualDub and had not released the source according to the requirements of the licenses. Vidomi tried to pull a fast one (perhaps not intentionally) by having the GPL code in a dynamically-linked library that was required for correct operation of their software. They thought they could get away with it because it was dynamically linked. However, the important part was that their software could not work properly without the GPL code - hence it was an integral part. The issue has now been resolved to the satisfaction of Vidomi, Avery and the FSF. Just trying to reduce the FUD. Personally, I am not overly in favour of the GPL (I think it reduces the likelihood of code being reused) and much prefer BSD-style licenses. However, I will respect whatever license someone chooses to put their code under - even if that means that I will not use their (possibly very useful) code. Tim Delaney From maxm at mxm.dk Mon Nov 12 12:56:18 2001 From: maxm at mxm.dk (maxm) Date: Mon, 12 Nov 2001 18:56:18 +0100 Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: "Dave Butler" wrote in message news:4OTH7.461273$ME2.55093623 at typhoon.kc.rr.com... > Any explanations? Is PythonWin a stable platform for using Tkinter? My guess is that you have some kind of incompatibility somewhere. I have not written many apps under Tkinter, but I have easily written more complicated programs than that (500 Hello- I have a multiline file of the format: : Some Name = data : Another Name = data : etc = data: Each line consists of 20 tagnames and associated data. Some of the tagnames have spaces in them though most don't. There is a space on each side of the equal sign and on each side of the colon which acts as a field seperator. I only need the data associated with 7 out of the 20 tagnames. I was thinking about removing the whitespace from the line and then seeking the tagnames that I am interested in. This strikes me as sort of brute force and I would like some help in formulating an approach that is a bit more elegant. Thank you. Jim jstcyr at mediaone.net From phd at phd.pp.ru Wed Nov 28 11:48:19 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 19:48:19 +0300 Subject: doesNotUnderstand ? In-Reply-To: <3C051246.9C15125E@corest.com>; from core.lists.python@core-sdi.com on Wed, Nov 28, 2001 at 01:35:18PM -0300 References: <3C051246.9C15125E@corest.com> Message-ID: <20011128194819.E8311@phd.pp.ru> On Wed, Nov 28, 2001 at 01:35:18PM -0300, Gerardo Richarte wrote: > Is there a way to intercept the activation of messages which are > not implemented? There is, but I recommend to test if the object understands the "message" (method, in Python termins): if hasattr(object, "seelctAll"): result = object.selectAll() If you really want to "intercept" an error: Python does it using try-except operator. If an object does not implement a "message", this is AttributeError: try: result = object.selectAll() except AttributeError: result = default Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From lac at strakt.com Fri Nov 9 11:08:45 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 9 Nov 2001 17:08:45 +0100 Subject: Tkinter scrollbar question Message-ID: <200111091608.fA9G8ju3009597@ratthing-b246.strakt.com> I can't seem to get my scrollbar to work. I have a class Table: These lines are in its __init__ self.yscrollbar = Tkinter.Scrollbar(self, orient='vertical') self.yscrollbar.pack(side='right', fill='y') self.yscrollbar.config(command=self.yview) This is the method yview: def yview(self, delta): if int(delta) == 1: self.move_everybody_up() if int(delta) == -1: self.move_everybody_down() move_everybody_up() and move_everybody_down() work as expected. Right now, you can click on the scroll bar and the table scrolls by one row, exactly as ordered. All the work gets done in a method called loadTable. The problem happened when I added these lines: print 'start %d, size %d, total %d' % ( self.vr_start, self.vr_size, self.totalLineCount) low = float(self.vr_start)/self.totalLineCount high = float(self.vr_start + self.vr_size)/self.totalLineCount print 'low is: %f, high is: %f' % (low, high) sb=self.yscrollbar.get() print 'sb is:' , sb self.yscrollbar.set(low, high) # this definitely is the problem lac at ratthing-b246:$ python Table.py start 4, size 6, total 12 low is: 0.333333, high is: 0.833333 sb is: (0.0, 0.0, 0.0, 0.0) Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", line 1289, in __call__ return apply(self.func, args) TypeError: yview() takes exactly 2 arguments (4 given) ---------------------------- What am I doing wrong? Where are the _4_ arguments coming from? Changing the name to yyview did not help matters. A google search lead me to: http://groups.google.com/groups?q=Tkinter+scrollbar+set++group:comp.lang.python&hl=en&rnum=4&selm=slrn9k6ldn.nn.matt%40happy-hour.mondoinfo.com That talks about backwards compatibility of the scrollbar's get method returning a tuple of 4, not 2, just after you create it. So I added lines to check that, and yes, indeed, I get a tuple of 4 (as you just saw). Is this a coincidence? Thanks very much, Laura Creighton From huaiyu at gauss.almadan.ibm.com Tue Nov 27 19:13:11 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 28 Nov 2001 00:13:11 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: On Tue, 27 Nov 2001 18:34:18 +0000 (UTC), Marcin 'Qrczak' Kowalczyk wrote: >Let's suppose I'm editing a file written by somebody else. I want to >insert a statement so I hit Enter at the end of a line. The editor >automatically indents the new line. Later it causes SyntaxError >because the file happened to use tabs and I've set my editor to use >spaces for indentation. An easy and brutal solution is to mandate that tab is the only indent charactor. A better long term solution is to write a smarter python-mode for your editor. > >Who is at fault? My poor editor which is unable to guess tab / space >convention used in the file and adapt to it automatically? The original >author who used tabs at all? Me because I didn't convert the file to >spaces before editing? The fault is at the utilities that on the one hand think tab could be equivalent to some spaces but on the other hand cannot guess exactly how many. If guessing is difficult, don't guess. Huaiyu From r.b.rigilink at chello.nl Mon Nov 5 16:38:46 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Mon, 05 Nov 2001 21:38:46 GMT Subject: Program very slow to finish References: Message-ID: <3BE706ED.1264548E@chello.nl> Hi Tim, Thanks for your comprehensive answer. I hope you'll bear with me, for I'm looking for some clarification Tim Peters wrote: > > [Roeland Rengelink] > > I'm pretty sure this is a problem with the garbage collector, I did some > > measurements showing bad (O(n**2)) performance when collecting large > > numbers of objects at once (as happens when your dicts are deleted at > > the end of your program). I filed a bug report (#477963) on it. See: > > > > > 70&atid=105470> > > > > for more details > > I expect you're just measuring your platform's cache performance. Here's > the output from running on a Win98SE box w/ 256MB RAM (I'll leave out the > creation times because they aren't interesting; note too that time.time() on > Windows has poor precision, so the numbers are mostly nonsense for the > smallest dicts): > > size: 10000, destruction: 0.00 (usec/elem) > size: 20000, destruction: 2.50 (usec/elem) > size: 50000, destruction: 1.20 (usec/elem) > size: 100000, destruction: 1.10 (usec/elem) > size: 200000, destruction: 1.10 (usec/elem) > size: 400000, destruction: 1.25 (usec/elem) > size: 600000, destruction: 1.37 (usec/elem) > size: 800000, destruction: 1.45 (usec/elem) > size: 1000000, destruction: 1.54 (usec/elem) > Here are my numbers again, just for comparison (and I do think you're showing an increase in destruction time too, just not as bad) The algo: - create dictionary d with N 7-char keys - execute d=None All times in micro-seconds per item. For the code see end of this post. (Linux 2.2.14, 128M RAM, Cel 333 MHz) size: 10000, creation: 31.00, destruction: 1.49 size: 20000, creation: 31.10, destruction: 1.57 size: 50000, creation: 32.77, destruction: 1.76 size: 100000, creation: 32.00, destruction: 1.92 size: 200000, creation: 32.59, destruction: 2.38 size: 500000, creation: 32.12, destruction: 4.35 size: 1000000, creation: 32.25, destruction: 10.47 If it's cache misses, I'd expect: T = t_f + p*t_m where: T -- destruction time per element, t_f -- fixed cost of freeing an element t_m -- additional cost in case of cache miss p -- probability of cache miss and p = (1-m/M) with m some fraction of the cache size, and M proportional to the problem size. Hence, I'd expect the destruction time per element to go asymptotically to some value T=t_f+t_m. Also, for the same reason that you'd expect cache misses on destruction (elements are not in the same order in the dict as order in which they are created) wouldn't you expect a proportional number of cache misses upon insertion in the dictionary? I don't see evidence for that in the creation times. Now, this may be a very naive argument. But, hey, I'm an astronomer, not a computer scientist > So buy more RAM <0.5 wink>. > Well, I did state in my bug report that everything fitted nicely in main memory. For comparison here are the numbers when this test _does_ require virtual memory: size: 1500000, creation: 254.03, destruction: 31.04 I promise that if I ever run into this in a real-world situation I'll buy more RAM ;) > This is the code that deallocates dicts: > > for (ep = mp->ma_table; fill > 0; ep++) { > if (ep->me_key) { > --fill; > Py_DECREF(ep->me_key); > Py_XDECREF(ep->me_value); > } > } > > That is, it's a single scan over the key+value pairs, decrementing the > refcounts on each. Note that while a left-to-right scan of the container is > cache-friendly, dicts work hard to "randomize" the offsets at which keys are > stored, so the memory pointed to *by* ep->me_key (containing your string > objects) has no useful relation to the order in which you created your > string objects: you're going to get mountains of cache misses during > deallocation. > > It's a mystery why deallocation takes so much longer than allocation when > things go bad (look at it: the deallocation code is dead simple). I > tracked down one of those long ago in hideous detail, and it turned out to > be due to the platform free() trashing like mad trying to coalesce adjacent > free'd areas. You've convinced/reassured me that it can't be Python. I'm not convinced it's the cache. That basically leaves free(). I'm curious if anybody else has seen this behaviour. I hope some more people try this Again, thanks for your answer, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" -- import time def make_dict(n): d = {} for i in xrange(n): s = '%7.7i' % i d[s] = 1 return d def time_it(n): t1 = time.time() d = make_dict(n) t2 = time.time() d = None t3 = time.time() return t1, t2, t3 if __name__ == '__main__': s = "size: %7i, creation: %5.2f, destruction: %5.2f" for i in [1, 2, 5, 10, 20, 50, 100]: n = i*10000 t1, t2, t3 = time_it(n) print s % (n, (t2-t1)/n*1e6, (t3-t2)/n*1e6) From elmar.hoefner at uibk.ac.at Wed Nov 28 11:01:18 2001 From: elmar.hoefner at uibk.ac.at (Elmar =?ISO-8859-1?Q?H=F6fner?=) Date: Wed, 28 Nov 2001 17:01:18 +0100 Subject: Installing Python > 2.1: make fails in posixmodule.c References: <9u2g7u$5i5al$1@ID-113469.news.dfncis.de> Message-ID: <9u31it$60iuf$1@ID-113469.news.dfncis.de> Michael Hudson wrote: > Didn't look hard enough: > > http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=440522 Oops, you're right. Although I spent quite a time searching, I oversaw it. This link helped me, now it compiles. > > I'm pretty that fix went into 2.1.1 though. Which version are you > compiling? 2.1.1 and current CVS don't have PRIO_PROCESS at line > 1145. > > Try current CVS? Tell us which version you're compiling? I tried at first 2.1.1 [error in line 1102], 2.2a4 [line 1145], 2.0.1 [which did compile, but gave me other problems] and at last 2.2b2. None of the mentioned [exept 2.0.1] compiled without patching. I didn't try CVS, though. Thanks for your help, Elmar From opengeometry at yahoo.ca Tue Nov 13 14:54:32 2001 From: opengeometry at yahoo.ca (William Park) Date: Tue, 13 Nov 2001 19:54:32 GMT Subject: Scientific Libraries in Python References: Message-ID: Horatio Davis wrote: > On Sun, 11 Nov 2001, William Park wrote: >> Simply including the Fortran/C libraries (and their wrappers) as part >> of Python distribution wouldn't be a problem, other than licenses. >> But, so far, nobody made that decision or see the need for it. > > Not all people want to use Python for scientific computing. So, > putting such specialized codes in the standard library would be > pushing "batteries included" a little far. > > What I am advocating is a standard extension library for doing > scientific computing in Python, in the same way that Numeric is the > de-facto standard extension library for doing number crunching in > Python. > > Of course, this thread has seen no comment yet from the authors of > scipy and Scientific Python (which seem to be the two key codebases), > or the other software projects which build on these. There might be > some perfectly obvious reason why this is a horribly bad idea... Most of the time, I just want access to library routines, especially higher functions, matrix system, and differential equations. It would allow me spend time working on the problem, not scavenging around to find libraries. -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From marfadeu at gmx.de Sun Nov 25 15:15:18 2001 From: marfadeu at gmx.de (Markus Faust) Date: Sun, 25 Nov 2001 21:15:18 +0100 Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: <9trjho$h0i$05$1@news.t-online.com> Have a look at PROTON, a very good freeware editor you'll find at http://www.meybohm.de/ Markus From gordon.scott at peregrine.com Wed Nov 14 17:57:48 2001 From: gordon.scott at peregrine.com (Gordon Scott) Date: Wed, 14 Nov 2001 14:57:48 -0800 Subject: minidom/pulldom examples? Message-ID: Hey All, I'm tinkering around with XML and Python2.1.1 and was wondering if someone could point me in the direction of examples or tutorials using minidom.py and pulldom.py? From tim.one at home.com Sun Nov 4 15:50:29 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 15:50:29 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: <7xk7x7ey9i.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > I did notice that Algorithm X from Knuth vol. 2 for extended GCD > gives negative answers in Python if you code it straight from the book. > It was easy to correct so I didn't analyze it carefully but I think > floor-mod may have had something to do with it. Note that Knuth's description of X begins with "Given nonnegative integers u and v, ...". So if you pass any negative ints, all bets are off. Algorithm A has the same restriction. This is as literal a translation as I can dream up: def X(u, v): """Return (u1, u2, u3) s.t. u*u1 + v*u2 == u3 == gcd(u, v). Assumes u and v are non-negative. """ u1, u2, u3 = 1, 0, u v1, v2, v3 = 0, 1, v while v3: q = u3 / v3 # or u3//v3 under __future__ division t = u1-v1*q, u2-v2*q, u3-v3*q u1, u2, u3 = v1, v2, v3 v1, v2, v3 = t assert u*u1 + v*u2 == u3 return u1, u2, u3 If v > 0, then u3 > 0 upon return; if v < 0, then u3 < 0. Those aren't hard to show, relying on flooring division. I expect the easiest way to extend it to all ints is just to add if u3 < 0: u1, u2, u3 = -u1, -u2, -u3 before the assert. From logiplexsoftware at earthlink.net Fri Nov 9 15:11:11 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 12:11:11 -0800 Subject: Module for reading CSV data In-Reply-To: References: Message-ID: <01110912111100.01360@logiplex1.logiplex.net> On Friday 09 November 2001 11:20, David A McInnis wrote: > Is there a module for reading CSV files into a dictionary? Or is there a > builtin that is used in conjunction with readlines()? > > The first row of my csv file contains field names. > How do you plan on storing the data in a dictionary? What would be the dictionary key? Is this what you're looking for? l = [ ['a', 'b', 'c', 'd', 'e'], # this is the column names [1, 2, 3, 4, 5], # some data [6, 7, 8, 9, 10], ] d = {} for h in range(len(l[0])): d[l[0][h]] = [row[h] for row in l] The result is a dictionary (d) keyed on the column name ('a', 'b', 'c'...) with each item containing a list of data. Hope this helps. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From bernie at pacific.net.hk Mon Nov 19 05:57:00 2001 From: bernie at pacific.net.hk (Bernie) Date: Mon, 19 Nov 2001 10:57:00 GMT Subject: Question on default value of __init__ References: <3BF8D3BC.105F0536@pacific.net.hk> Message-ID: <3BF8E5A4.DBB9D679@pacific.net.hk> Silly, silly me. Did not get the hint the first time round. Thanks Bernie Martin von Loewis wrote: > > Bernie writes: > > > When I run test.py, an instance of foo is created. Is this the > > default behavior in Python for default value? > > Yes, default values are created when the function is defined. This is > the way Python works; it is not just the default. > > > Are there any way to delay the creation of foo() until bar() is > > created. > > > def __init__( self, param=foo()): > > assert isinstance( param, foo), '"in" must be an instance of foo' > > pass > > You should write it like this > > def __init__(self, param = None): > if param is None: > param = foo() > else: > assert isinstance(param, foo), '"in" must be an instance of foo' > > HTH, > Martin From thomas.heller at ion-tof.com Tue Nov 13 16:04:31 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 13 Nov 2001 22:04:31 +0100 Subject: COM server created with py2exe fails if CLSCTX_INPROC_SERVER References: <30f17542.0111130925.713c2aa5@posting.google.com> Message-ID: <9ss1t7$15edub$1@ID-59885.news.dfncis.de> "Lu Ruguaya" wrote in message news:30f17542.0111130925.713c2aa5 at posting.google.com... > I tried Thomas Heller's example changing > _reg_clsctx_ to pythoncom.CLSCTX_INPROC_SERVER > (his example uses CLSCTX_LOCAL_SERVER) > > It registers OK, but when I tried to use it from > a VB client I get the following error: > > "Unexpected Python Error: exceptions.AttributeError: '__main__' module > has no attribute 'HelloWorld' > > If I use LOCAL_SERVER, then it works like a champ. > > It obviously relates to the code: > if hasattr(sys, 'importers'): > # In the py2exe-packed version, specify the module.class > # to use. In the python script version, python is able > # to figure it out itself. > _reg_class_spec_ = "__main__.HelloWorld" > > Any suggestions? Currently you cannot create inproc COM servers with py2exe, point. Thomas From maxm at normik.dk Wed Nov 7 05:41:00 2001 From: maxm at normik.dk (Max M) Date: Wed, 7 Nov 2001 11:41:00 +0100 Subject: integer to ascii References: Message-ID: <3be90fbc$0$232$edfadb0f@dspool01.news.tele.dk> "harry" wrote in message news:VX7G7.18181$5e2.4403261 at news1.telusplanet.net... > instead of '5' as the output, how do i make the output as '23' -> string > concatnation instead of integer. There are a few ways of doing it: rows = `2` ( or rows = '%d' % 2 ) columns = str(3) joined = rows + columns or rows = 2 columns = 3 joined = `rows` + str(columns) all depending on how you want to use you variables afterwards. regards Max M From dalke at dalkescientific.com Sat Nov 17 12:01:20 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sat, 17 Nov 2001 10:01:20 -0700 Subject: Regular Expression Help Needed References: Message-ID: <9t658a$fu6$1@slb6.atl.mindspring.net> William Park wrote [on auto-detecting email addresses using regexps] >What's wrong with '[\w.]+@\w+(\.\w+)*' ? The host name has to allow a '-' (it's A-Za-z90-9 and '-', but not '_' as \w allows). I am dalke at dalkescientific.com. See the period at the end? You don't want to grab that in your regexp. Nor should you grab two '.'s in a row. The local address part (before the '@') could have '-' and many other characters not included in the '[\w.]' you give. Eg, is there anyone still using bang path notation? (With '!'s as extra routing information.) Andrew dalke at dalkescientific.com From rossini at blindglobe.net Thu Nov 15 19:58:29 2001 From: rossini at blindglobe.net (A.J. Rossini) Date: 16 Nov 2001 00:58:29 GMT Subject: Scientific Libraries in Python References: <9t1iqq$es0$2@peabody.colorado.edu> <3BF45CAF.9983E26A@home.net> Message-ID: <9t1obl$quv$0@216.39.145.92> And for laughs, there is always RSPython at www.omegahat.org, useful for embedding an extremely powerful statistics/data analysis language within python. best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ -------------- FHCRC: M-W: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: T-Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX Rosen: (Mullins' Lab) Fridays, and I'm unreachable except by email. From phr-n2001d at nightsong.com Wed Nov 28 00:31:08 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 27 Nov 2001 21:31:08 -0800 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> Message-ID: <7xelmjbgwz.fsf@ruckus.brouhaha.com> Peter Hansen writes: > > Depends. If only one person is working on the project, CVS is overkill. > > > > If lots of people are working on it, it's a good idea. > > My opinion: a good idea if only one person is working on it. > > Mandatory if more than one work on it. CVS is a layer over RCS that lets multiple people work on the same files at the same time, and automatically merges their changes at check-in. I don't see any point to it for a one person project. RCS is a lot simpler. I use RCS for one-person projects and couldn't live without it. But I haven't found a reason to deal with the increased complexity of CVS. Is there one? From max at alcyone.com Thu Nov 22 00:47:12 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 21 Nov 2001 21:47:12 -0800 Subject: RogueLike Games in Python References: Message-ID: <3BFC9160.24AFA11A@alcyone.com> "A. Keyton Weissinger" wrote: > Anyone know of any written completely (i.e. not just partially) in > Python? > > Thanks in advance... I don't believe there are any, although there are a few in progress. You can check in rec.games.roguelike.development for more information. As a side note about the sad level of understanding of Python in the world, there was a thread in that newsgroup about how BASIC would be a superior choice for creating a Roguelike than Python ... -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From calves at coelce.com.br Thu Nov 1 06:26:23 2001 From: calves at coelce.com.br (Alves, Carlos Alberto - Coelce) Date: Thu, 1 Nov 2001 08:26:23 -0300 Subject: starting externel program (win32) Message-ID: <29A97D00F387D411AC7900902770E14802505DE7@lcoeexc01.coelce.net> I don't know the details,but I think COM objects could resolve this problem. Carlos Alberto COELCE/DPRON-Departamento de Projetos e Obras Norte Fone: 677- 2228 e-mail: calves at coelce.com.br \|||/ (o o) --ooo0-(_)-0ooo-- -----Original Message----- From: stojek at part-gmbh.de [mailto:stojek at part-gmbh.de] Sent: Thursday, November 01, 2001 7:28 AM To: python-list at python.org Subject: starting externel program (win32) Hi, from a script I want to start an external program (win32). This should be done in a way that is equivalent to typing the name and options at the dos prompt. The program must not be influenced by exiting the script. Do I have to use system(), spawnv() or spawnve() or something else? Any traps? Tanks Marcus -- http://mail.python.org/mailman/listinfo/python-list -------------- next part -------------- An HTML attachment was scrubbed... URL: From whitaker at best.com Mon Nov 26 20:28:42 2001 From: whitaker at best.com (Russell Whitaker) Date: 26 Nov 2001 17:28:42 -0800 Subject: Problems inst. yapsnmp 0.7.4 under SunOS 5.8 Message-ID: Hi, I posted this to the yapsnmp forum on sourceforge early last week; no response yet: "https://sourceforge.net/forum/forum.php?thread_id=257226&forum_id=66582" [Detail in the message above] Short form: I'm unable to install yapsnmp 0.7.4 under this environment: - SunOS 2.8 - Python 2.1.1 - gcc 2.95.3 - net-snmp 4.2.2 ... even when re-making and installing net-snmp (formerly ucd-snmp) without linking in OpenSSL libs (an argument to 'configure' for net-snmp). Any help based on this information and the longer detail in the Sourceforge forum posting would be greatly appreciated. Thanks, Russell From mlh at idi.ntnu.no Thu Nov 1 18:59:49 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 2 Nov 2001 00:59:49 +0100 Subject: Learning Python References: <20011101180300.21692.00000997@mb-mr.aol.com> Message-ID: <9rsnlm$fp9$1@tyfon.itea.ntnu.no> Try python.org, and see if you can find any promising links on the first page. (Hint: "Python for beginners" and "Introductions to Python" seem like natural choices... :) -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net "BHS3133" wrote: > What is a good tutorial for learning Python? From brian at rk-speed-rugby.dk Thu Nov 1 02:16:22 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 01 Nov 2001 08:16:22 +0100 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> Message-ID: Erik Max Francis writes: > Freeware, in particular, has a well-defined meaning, whether you like it > or not. Unfortunately, it is my experience that non-open-source freeware at a point in time if successful will go shareware. Freeware is just kept like that until enough users has it, whereafter the current version is quickly removed from the net and substituted by a new shareware version. Not that I expect this is the intention of Randy pointing out the editor. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From aa at bb.cc Mon Nov 5 08:55:10 2001 From: aa at bb.cc (Károly Ladvánszky) Date: Mon, 5 Nov 2001 14:55:10 +0100 Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> Message-ID: <3be696e4$1_2@corp-goliath.newsgroups.com> Hi Edy, I completely agree with you that it is both more efficient and more entartaining to learn a programming language through working on a useful task. If you are a student, I'd advise you pick up an interesting math problem and work on it using Python. I'm sure your teacher will be happy to help you find something. This way you will make progress in both math and Python. Good luck, K?roly P.S. Set theory could be a good candidate. As far as I know, Pyhton has no set handling module. Consider building a Set class based on Python's universal list structure, add functions for union, intersection etc.. Do not forget that a list can contain almost anything, not just simply data types. "Edy Lie" az al?bbiakat ?rta a k?vetkez? ?zenetben: news:9s5eq8$mhk$1 at newton3.pacific.net.sg... > Hi Everyone, > > I am totally a new python wannabe coder. I have been switching between > python and perl last few months. In Perl i could code some small scripts > which does the work i wanted to but somehow in my mind it has been telling > me that python is my choice. > > I have some doubts here > 1. I would really want to learn this lang (What should i do?) i know instead > of asking here i should start coding but i have no idea what should i code. > Is there anyone in here willing to conduct a small class or at least giving > out exercise to newbies to code ? > > 2. Another thing when doing coding if i am facing problem i tend to stop or > rather wanted to learn everything in a day or as fast as i could which i > believe is a wrong approach. Is there anyone kind enough to give me some > direction in order i could code something useful. > > Thanks for all the advices. > > Regards, > Edy Lie. > > ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net From daniel.dittmar at sap.com Fri Nov 23 09:30:28 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Fri, 23 Nov 2001 15:30:28 +0100 Subject: Pls. help me recreate shell trick References: <3BFE4A90.1C0F1E0C@divalsim.it> Message-ID: <9tlmi5$s5d$1@news1.wdf.sap-ag.de> > This was achieved as follows: > > $ECHO rm -r / > > where ECHO was either set to "echo" or nothing according to a command import os shellExecute = os.system def echoOnly (cmd): print cmd return 0 if testForOptions (...): shellExecute = echoOnly Daniel From tjreedy at home.com Sun Nov 4 23:41:26 2001 From: tjreedy at home.com (Terry Reedy) Date: Mon, 05 Nov 2001 04:41:26 GMT Subject: How can i retrieve a key from a dictionary? References: <3BE519E0.34312B48@student.kun.nl> Message-ID: "Husam" wrote in message news:3BE519E0.34312B48 at student.kun.nl... > how can one retrieve or select a key from a dictionary? > > dict={} > dict[1]='one' > dict[2]='two' > > dict.keys() will gets all the keys. but, i need to select explicitly one > key for printing along its value. If you just want some key,value pair, and pair, check out dict.pop(). Otherwise, not clear what you are trying to do. Terry J. Reedy From pete at shinners.org Sat Nov 24 12:11:09 2001 From: pete at shinners.org (Pete Shinners) Date: Sat, 24 Nov 2001 17:11:09 GMT Subject: prep my types for 2.2? References: <3BFEF3DF.5030103@shinners.org> Message-ID: <3BFFD5C4.5080500@shinners.org> > Python will look at the type of your_type (which will be the type > type), and then look at its tp_call slot > (i.e. typeobject.c:type_call). That, in turn, will use tp_new. this is where i start to get confused? isn't the "Type type" the same for all type objects? for example.. >>> type(int) is type(float) 1 since this is both the same thing, how can i change the tp_call for only one of the types? i was guessing there was some sort of new function slot for this, but the docs on all this are a little sparse. From robin at jessikat.fsnet.co.uk Wed Nov 28 10:06:59 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 28 Nov 2001 15:06:59 +0000 Subject: lego does Python Message-ID: http://www.lego.com/studios/screening/movie.asp?opt=qtl -- Robin Becker From tim.leeuwvander at nl.unisys.com Fri Nov 2 08:16:01 2001 From: tim.leeuwvander at nl.unisys.com (Leeuw van der, Tim) Date: Fri, 2 Nov 2001 07:16:01 -0600 Subject: Python-equivalent of PHP addslashes/stripslashes functions? Message-ID: Hi, I looked at it, but it's only part of the answer. It doesn't provide for an easy unescape, as for as I can see. I found, thru reading the list, that the DBAPI provides for escaping of values sent to the database. That's great, although it doesn't help me with sending data to other programs. However, the DBAPI and re.escape together might prove to give me what I want :-) I found a question from somebody else, in a similar situation to mine, and like him, I also would like to know of any equivalent to PHP's nice functions for stripping certain HTML Entitities out of a string. I'm also looking for something similar to PHP4's session - functions, I'm writing something simple that works more or less similar with currently a mysql - backend but with other backends possible (like file, dbm, postgresql, etc). If anyone is interested I can post files when they're more complete, but if there's already something working out there, I'd be happy to use that instead of continuing my own efforts! :-) With regards, --Tim -----Original Message----- From: maxm [mailto:maxm at mxm.dk] Sent: donderdag 1 november 2001 0:06 To: Leeuw van der, Tim Subject: Re: Python-equivalent of PHP addslashes/stripslashes functions? http://www.python.org/doc/current/lib/Contents_of_Module_re.html escape(string) Return string with all non-alphanumerics backslashed; this is useful if you want to match an arbitrary literal string that may have regular expression metacharacters in it. regards Max m "Leeuw van der, Tim" wrote in message news:mailman.1004529931.3668.python-list at python.org... > Hello, > > I'd like to know if there's a Python-alternative to the very convenient PHP > functions addslashes / stripslashes which add cq remove backslashes to > things like ', " characters, so that values from HTML forms can be safely > passed around to other programs, used in SQL statements, etc. > > Any pointers? > > Thanks in advance, > > --Tim > > From fungho at sinaman.com Wed Nov 21 04:43:44 2001 From: fungho at sinaman.com (Stephen) Date: 21 Nov 2001 01:43:44 -0800 Subject: how to express the following regular expression? Message-ID: I want to search the following formats: ([1234567890]*)R or P([1234567890]*) this means there must be a 'P' before the number or a 'R' after the number. However, I think I can't use this: P?([1234567890]*)R? because the number without P and R is also matched! How can I express it? thx! Stephen From kragen at pobox.com Tue Nov 27 14:19:07 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 14:19:07 -0500 Subject: function operators References: Message-ID: <838zcsrphw.fsf@panacea.canonical.org> "James A. H. Skillen" writes: > Has anyone ever wished that Python had operators defined on functions? > For example, suppose you want the function f(x) = cos(x) + sin(x). > ... > but wouldn't: > f = cos + sin > be *much* nicer? > ... > Taking the idea of PEP 211 further, we could have the "outer product" > operator "@" work on functions too. You want something like the Functor class from functional.py in the xoltar toolkit; it overloads * to mean composition, ~, &, and | to do the appropriate shortcut logical operations, + to mean sequence, and << and >> to do currying. See http://sourceforge.net/projects/xoltar-toolkit for more. It's pretty nifty, probably the coolest code I found in the Vaults. Last year sometime, I actually wrote a bunch of code to do algebraic manipulations, and I overloaded all kinds of Python operators to create expressions. Can't remember if I ever posted it; if not, it's gone now, anyway. From max at alcyone.com Tue Nov 20 14:21:02 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 20 Nov 2001 11:21:02 -0800 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> Message-ID: <3BFAAD1E.9E9AF618@alcyone.com> Bruce Edge wrote: > OK, that works for this case, I was looking for something more > generic. There is no scanf-like parsing service in Python. Which is fine, since scanf has problems. If you want general parsing, you should use regular expressions; that's what they're there for. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From paul1brian at yahoo.com Mon Nov 26 12:47:10 2001 From: paul1brian at yahoo.com (Paul Brian) Date: Mon, 26 Nov 2001 17:47:10 -0000 Subject: smtplib help References: Message-ID: <000601c176a2$60a4d800$d9e1c3c1@pbrian> David I would suggest putting the code out to the list. That way others cleverer than me can comment.... :-) however things I might suggest: what configurations are set up in the mail server -is it trying to perform DNS lookups of every recipient to try and act as an anti-spam measure? -is it expecting some authentication from you and is having to go elsewhere to verify (LDAP etc?) - is it runing some strange virus check before accepting mail? I do not know much about ipswitch (WS-ftp / snmp people?), but perhaps their technical dept can help? I really suspect it is not a python problem. yrs Paul ----- Original Message ----- From: David A McInnis To: Paul Brian ; Python Sent: Monday, November 26, 2001 4:35 PM Subject: RE: smtplib help > Actually, I am using imail from IPSWITCH. Anyway, it was a speed issue. > When I called time.sleep(2) from the time module giving me a 2 second sleep, > I was able to process the messages. > > I don't like being able to send only one msg every 2 seconds. Any help > would be appreciated. > > Sincerely, > > David McInnis > > > -----Original Message----- > From: Paul Brian [mailto:paul1brian at yahoo.com] > Sent: Monday, November 26, 2001 8:01 AM > To: david at dataovation.com > Subject: Re: smtplib help > > > David > > I seriously doubt it - however there is no reason you cannot add in a wait > function > eg > > #assume listofmessages is list of 3 element lists; (from, to, msg) > for msg in listofmessages: > server = smtplib.SMTP('smtp.wibble.com') > server.sendmail(msg[0], msg[1], msg[2]) > server.quit() > # truly crude wait function > for x in range(1,1000000,1): > pass > > however I suspect that the thing will still crash - I doubt there is any > implementation of an SMTP server that will go wrong on a few hundred > messages a second. > > What is the smtp server you are using BTW? I assume it is on windows? > Exchange perhaps? > > Failing that perhaps you could put the code out to the group, or even try a > different smtp server and see if it still fails. > > sorry I cant be more help > > P > > ----- Original Message ----- > From: David A McInnis > To: Paul Brian ; > Sent: Monday, November 26, 2001 3:45 PM > Subject: RE: smtplib help > > > > I do call quit(). Is is possible that the script is moving too fast for > the > > smpt server to keep up? If so, how can I slow it down? > > > > David > > > > -----Original Message----- > > From: python-list-admin at python.org > > [mailto:python-list-admin at python.org]On Behalf Of Paul Brian > > Sent: Monday, November 26, 2001 6:55 AM > > To: python-list at python.org > > Subject: Re: smtplib help > > > > > > David, > > > > its hard to comment, but I suspect that the error you are getting comes > from > > the SMTP server. > > > > Basically line 222 in smtplib calls on the socket module, which has an > error > > code: > > errorTab[10048] = "The network address is in use." (line 79) > > (I am using 2.1.1 - Your version presumably has a different error msg ) > > > > So I suspect that the server is keeping alive sessions - I would check by > > quiting the session each time (xxx.quit()) you send a message. > > > > Hope that helps > > > > David A McInnis wrote in message > > news:mailman.1006768891.31431.python-list at python.org... > > Any ideas why smtplib would crash on me after about sending 150 email msgs > > (i did not count, but that is a good estimate)? > > > > This is the error that I am getting. > > > > File "C:\Python21\mm_mime.py", line 93, in Send > > server = smtplib.SMTP(host) > > File "C:\Python21\lib\smtplib.py", line 187, in __init__ > > (code, msg) = self.connect(host, port) > > File "C:\Python21\lib\smtplib.py", line 222, in connect > > self.sock.connect((host, port)) > > File "", line 1, in connect > > error: (10048, 'Address already in use') > > > > David McInnis > > > > > > -- > > http://mail.python.org/mailman/listinfo/python-list > > _________________________________________________________ Do You Yahoo!? > Get your free @yahoo.com address at http://mail.yahoo.com _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From slinkp23 at yahoo.com Thu Nov 22 00:47:31 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 22 Nov 2001 05:47:31 GMT Subject: bug in emacs python mode with long documents? References: <9thhib$3kp$1@peabody.colorado.edu> Message-ID: On Wed, 21 Nov 2001 17:37:52 +2328, Fernando P?rez wrote: >Has anyone else noticed the following problem? I have a long class (about >1000 lines). When working on code towards the bottom, opening new lines, >indenting or deindenting takes forever. Xemacs will go crazy backtracking up >the code, and my cpu usage will go to 100% for up to 10 seconds, freezing >emacs completely (800 Mhz PIII). > >I know it's a long class and in fact I need to reorganize it, but that's >besides the point. I can't see an editor which is incapable of handling >classes longer than 1000 lines! And certainly not 'the beast' Xemacs :) > >For reference, I'm using: [version 21.4; April 2001] on a Mandrake box. > >If anyone knows of a bugfix to the python mode, I'd greatly appreciate >hearing about it. > >Cheers, > >f. From mailto Wed Nov 7 20:37:19 2001 From: mailto (Robert Amesz) Date: Thu, 08 Nov 2001 01:37:19 -0000 Subject: help - Create dll References: Message-ID: Bill Bell wrote: > > "Glauco Silva" >> How can i create a dll file ( C dynamic library) from windows to >> be imported by python. > > You have a few options: > > [Snipped] You missed one: by far the simplest way is to use distutils, which then is able to call the VC++ compiler and linker to build the dll (although by default it wil get the extension .pyd, but that's irrelevant). Works like a charm. By making a small batch file with the single line "python setup.py install" I could build from within the SciTE editor, and thus catching the output of the compiler, which allowed me to simply doubleclick to jump to any syntax errors in my sources. Robert Amesz From jlh at home.com Fri Nov 30 19:21:28 2001 From: jlh at home.com (Jeff Hinrichs) Date: Fri, 30 Nov 2001 18:21:28 -0600 Subject: The Ideals of a Python Hacker (was: Poll Results) References: <3C07357A.2935.24FC2A4@localhost> Message-ID: <0bfe01c179fe$1e961190$6702a8c0@gato> > I may be a statistical anomaly but I'm almost 55. I now have two > paying Python projects on the go. True, one is funded by a > university. However, the other one is for a purely commercial play. > The president of the company, like me, is a some breed of anarchist. I wouldn't say that your an anomaly. I'm 36 with 3 kids and I've been programming in python for 3 months at my day job. We were an all MS shop but were looking for a way around the beast. It started with DNS servers on Linux and then we ripped out exchange and replaced it with Cyrus/Exim. More upheaval yet to come as we rip MS out bit by bit. Then I came across a cool python app on source forge (http://edna.sourceforge.net/) It was the app that made me take a look at python. The more I looked the more I liked. I haven't fired up VB in those 3 months either and management is pleased with the results. I've built an XML catalog generator that uploads are inventory database to Ariba. This saved a big customer from getting away and brought in a couple new ones to boot. Add to that a number of boring db reports and customer mailer programs. I am quite confident that Python is going to see at least a small boom in the next 8 - 12 months with others like me. This is a good thing. Small and mid-sized businesses represent a significant portion of the computer industry and they are definitely not happy with Microsoft. Change is coming. -Jeff From bedge at troikanetworks.com Tue Nov 20 17:16:24 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 14:16:24 -0800 Subject: Conversion from tuple to argument list? Message-ID: Forgive the stupid question, probably a C programmer mindset issue here. I have a tuple of data items say (0,1,2) I want to pass to struct.pack, which takes: pack (fmt, v1, v2, ...) How can I pass my tuple to pack as its arg2,3,4,... -TIA, Bruce. From vvainio at karhu.tp.spt.fi Sat Nov 10 15:40:39 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 10 Nov 2001 22:40:39 +0200 Subject: CORBA client & server with Python References: <01c168fd$978fe8d0$06d1178b@mvn40020> Message-ID: "Murat Demir" writes: > did someone try to write CORBA client and server applications with Python? > Can you offer me a "hello world" application about it? You should really check out OmniORB and it's docs. Corba seems to be a very simple task on Python, considering what a complicated mess it is in C++. Implementing a 100% pure python ORB and bundling it w/ Python distribution might not be a bad idea... or would it? No matter how slow, but it would always be there to fall back on. -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From d_blade8 at hotmail.com Fri Nov 16 00:54:53 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 15 Nov 2001 21:54:53 -0800 Subject: Sorry, here is the build info Message-ID: <7396d2b2.0111152154.3eac95a2@posting.google.com> C:\WINDOWS\Desktop\py2exe>python C:\Python\Freeze.py UniLocString.py File 'C:\WINDOWS\Desktop\py2exe\UniLocString.cfg' already exists. Overwrite? [yn ]y > C:\PYTHON21\PYTHON.EXE C:\Python\Builder.py C:\WINDOWS\Desktop\py2exe\UniLocS tring.cfg W: exec statment detected at line 295 of imputil W: No module named dos W: No module named mac W: No module named os2 W: No module named posix W: exec statment detected at line 282 of win32com.client.dynamic W: __import__ hack detected at line 642 of win32com.server.policy W: exec statment detected at line 65 of os W: exec statment detected at line 138 of os W: eval hack detected at line 405 of os W: No module named ce W: No module named pwd W: No module named riscos W: No module named riscosenviron W: No module named riscospath W: No module named MACFS W: No module named macfs W: No module named win32dbg W: __import__ hack detected at line 181 of win32com.client.gencache W: __import__ hack detected at line 468 of win32com.client.gencache W: __import__ hack detected at line 294 of win32com.client.makepy W: No module named SOCKS W: exec statment detected at line 153 of socket W: No module named EasyDialogs W: eval hack detected at line 187 of warnings W: __import__ hack detected at line 195 of warnings W: eval hack detected at line 47 of gopherlib W: eval hack detected at line 86 of random W: eval hack detected at line 588 of random W: No module named ic W: No module named rourl2path W: exec statment detected at line 1529 of Tkinter W: No module named MacOS From fredrik at pythonware.com Wed Nov 28 11:19:03 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Nov 2001 16:19:03 GMT Subject: Database in a simple ascii file References: <3C04F826.CB408C9D@engcorp.com> Message-ID: Peter Hansen wrote: > If you are really concerned about performance, you will > always be able to get more than a 10 times speedup by > switching to a compiled language over Python. always? From fabella at free.fr Thu Nov 29 12:15:58 2001 From: fabella at free.fr (news python) Date: Thu, 29 Nov 2001 18:15:58 +0100 Subject: Problem using exec function & classes Message-ID: <9u5qfk$rjt$1@wanadoo.fr> if you execute this exemples: #---------------------- def test1(): class c1: global n1,n2 global verify1 verify1=c1() >> test1() >>verify1 <__main__.c1 instance at 0106D2B4> ***************** * verify is now global * ***************** but doing this similar exemple -----------> #---------------------- def test2(): exec("class c2:\n global n1,n2") exec("global verify2") exec("verify2=c2()") >> test2() >>verify2 NameError: name 'verify2' is not defined is somebody have any idea why "exec" instruction don't do the same thing, and how to correct this problem, please let me know Thank's Fran?ois Abella -- Qualicontrol -- From ws-news at gmx.at Fri Nov 23 09:33:13 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 23 Nov 2001 15:33:13 +0100 Subject: What's this: run_pyc_file: nested_scopes: 0? References: <99ksvtsp9uipajsfkqehgbi9hc0f8el4mq@4ax.com> <3bfe5e53$1@brateggebdc5.br-automation.co.at> Message-ID: <3bfe5eee$1@brateggebdc5.br-automation.co.at> One more hint: The message has also been removed in Python 2.2b2 regards Werner "Werner Schiendl" wrote in message news:3bfe5e53$1 at brateggebdc5.br-automation.co.at... > Hi, > > this message is printed when you specify the flags parameter to a call to > > PyRun_SimpleFileExFlags > PyRun_AnyFileExFlags > > this functions are used, an a flags parameter is passed, in Py_Main, the > function that actually provides the entry for the python executable. > > How do you run your code? > > If the messages bothers you, you should be safe removing the line > > fprintf(stderr, "run_pyc_file: nested_scopes: %d\n", > flags->cf_nested_scopes); > > in line 1079 of the file Python/pythonrun.c. > > hth > Werner > > "Dale Strickland-Clark" wrote in message > news:99ksvtsp9uipajsfkqehgbi9hc0f8el4mq at 4ax.com... > > This message has started to appear at the end of each use of a system > > we're developing: > > > > run_pyc_file: nested_scopes: 0 > > > > It's not one of our messages and my hunch is that it coincides with > > us using compileall to ensure the main module is compiled. > > > > Any ideas what it is and how I can get rid of it? > > > > Python 2.1 > > > > Cheers. > > -- > > Dale Strickland-Clark > > Riverhall Systems Ltd > > From jared at hwai.com Thu Nov 8 14:46:51 2001 From: jared at hwai.com (Jared) Date: 8 Nov 2001 11:46:51 -0800 Subject: newbie tkinter question Message-ID: <480f610.0111081146.72a92cb0@posting.google.com> Hi, all - I am investigating using a python/Tkinter environemnt for apps development. The target hardware environment would be pretty old-fashioned - a bunch of dumb terminals (VT420's, mostly) connected to terminal servers accessing a server running Red Hat. I have read the docs, but cannot glean from them if TKinter works in such an environment. Would it? VT420's are color terminals; what happens if we write for VT420's but someone connects up a VT220 or VT100 emulator? If it's convenient, e-mail will reach me faster. TIA - Regards, jh From tfb+google at tfeb.org Thu Nov 15 06:52:42 2001 From: tfb+google at tfeb.org (Tim Bradshaw) Date: 15 Nov 2001 03:52:42 -0800 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote in message news:<7xy9l9ne1b.fsf at ruckus.brouhaha.com>... > > However, most Lisp compilers have depended on type declaration pragmas > to generate good code, AFAIK. Python would need a language extension > to support something like that. I don't think this is really true for many interesting programs. It is very definitely true for *some* kinds of programs, for instance things that do heavy numerical work, and almost all of the trivial, stupid, non-benchmarks that people use to decide that `language x is faster than language y' so they can flame on inappropriate newsgroups (cll readers will be familiar with this). However a lot of programs spend a lot of time doing stuff where the typechecking overhead seems to be in the noise. Anything that's building and manipulating large complex data structures is probably spending a lot of its time chasing pointers and worrying much more about cache misses and so on than exact details of types. As an example, I have a system (in Lisp) which parses structures from a stream, amd then does various manipulations on them. It has bnasically no declarations in it. I spent a little time profiling it, and someone else did some more work. He found a few places where type declarations help some - mostly declarations that things are better-sorts-of-arrays so array ndexing can do better (the parser reads into buffers which are arrays because a lot of what it generates is strings). We got between 1 and 5% speedup. We might not have found the big problems of course, but really, it looks like type declarations don't help here much at all. --tim From claird at starbase.neosoft.com Tue Nov 6 18:19:34 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 6 Nov 2001 17:19:34 -0600 Subject: importing a tcl/tk widget References: <3daa1aa8.0111051555.125dbd8e@posting.google.com> Message-ID: <4ABC078C86859C4F.ADA020C1CB87446E.5CBA0EE01227064A@lp.airnews.net> In article <3daa1aa8.0111051555.125dbd8e at posting.google.com>, Jeffrey wrote: >Hi All, > I wanted to know if anyone knew of a way to import a tcl/tk widget >into a Tkinter canvas widget. I know that you can write a Tkinter >wrapper function but I don't really know how to do this. If anyone >can help, and/or point me to a good website/book that would be great >thanks. . . . I find your description ambiguous. Along with Laura Creighton's follow-up, are you aware of [frame]'s container attribute? Is that what you're after? -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From boud at valdyas.org Mon Nov 5 08:54:15 2001 From: boud at valdyas.org (Boudewijn Rempt) Date: Mon, 05 Nov 2001 14:54:15 +0100 Subject: Problems compiling PyQt References: Message-ID: <3be698b3$0$203$e4fe514c@newszilla.xs4all.nl> Luca Fini wrote: > > I'm trying to compile PyQt on RedHat Linux 7.1 (gcc version 2.96 20000731) > Is this the infamous incompatible gcc? (I always forget the version numbers.) > as usually I do: > > ./configure > make > > And I always get the following errors: > > qtcmodule.cpp: In function `PyObject *registerClasses (PyObject *, > PyObject *)': qtcmodule.cpp:9159: `Rounded' is not a member of type > `QTabWidget' qtcmodule.cpp:9160: `Triangular' is not a member of type > `QTabWidget' qtcmodule.cpp:10361: `TSCII' is not a member of type `QFont' > qtcmodule.cpp:10625: `AccelOverride' is not a member of type `QEvent' > qtcmodule.cpp:11251: `WGroupLeader' is not a member of type `Qt' > > > This happens for various versions pf PyQt(2.3,2.4,2.5). Are sip and PyQt finding the same version of Qt? Aren't you trying to compile PyQt against Qt 3.0? (You need one of the recent 3.0 preleases for that.) -- Boudewijn Rempt | http://www.valdyas.org From mal at lemburg.com Fri Nov 16 17:12:18 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 16 Nov 2001 23:12:18 +0100 Subject: Recap: PEP 276 Simple Iterator for ints References: Message-ID: <3BF58F42.4D6295BB@lemburg.com> James_Althoff at i2.com wrote: > > While there is certainly merit and potential benefit in trying to invent a > new, general purpose mechanism for specifying lists of numbers, it should > be noted that for the problem that PEP 276 addresses, the various proposals > above yield things like: > > for i in [0, 1 .. table.getRowCount()-1]: > for j in [0, 1 .. table.getColumnCount()-1]: > print table.getValueAt(i,j) > > for i in int[0:table.getRowCount()]: > for j in int[0:table.getColumnCount()]: > print table.getValueAt(i,j) > > for i in integers[0:table.getRowCount()]: > for j in integers[0:table.getRowCount()]: > print table.getValueAt(i,j) > > (Acknowledging that not every proposed variation is shown here nor various > proposed shortcuts for various proposals). > > While acknowledging that several of these might read somewhat better than > xrange/range in the scenario above, it is not universally apparent that > they are a vast improvement (in this context). Well, depends on how you look at it: the third "proposal" is already available in Python 2.2: you only have to write a class exposing the iterator interface and then create a singleton named "integers". No need to change the language: iterator protocol, slices, ellipses -- it's all there. > And for each such proposal, > there is the issue as to whether the proposed new form returns an > actualized list or an iterator and how well suited the given choice might > be in various usage scenarios (given that you have to pick one or the > other: actualized list or iterator). Since for-loops always use iterators there's no problem here: even if one of the constructs does not return an iterator compatible sequence, the for-loop will wrap this object using a generic sequence iterator. In the "integer[slice]" case, an iterator should be returned which can then be turned into a list or tuple by applying tuple() or list() to it. > Nonetheless, as stated several times before, PEP 276 does not preclude the > adoption of a new mechanism for specifying lists of numbers similar to any > of the above proposals -- it doesn't have to be an "either or" choice. It > simply provides a convenient way to access indexed structures in a > for-loop. I suppose we could make iterators compatible to lists and tuples in most cases. Guido already has code for this in place in list() and tuple() (but not list assignments), so you don't lose much buy only providing an iterator. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From nhytro at t-online.de Fri Nov 2 02:53:48 2001 From: nhytro at t-online.de (Sharriff Aina) Date: Fri, 2 Nov 2001 08:53:48 +0100 Subject: test, please ignore Message-ID: <000801c16373$82277f60$6b0852d9@isis> test -------------- next part -------------- An HTML attachment was scrubbed... URL: From prabhu at aero.iitm.ernet.in Mon Nov 12 02:21:57 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 12 Nov 2001 12:51:57 +0530 Subject: Scientific Libraries in Python In-Reply-To: <9snfbh$dt3$1@peabody.colorado.edu> References: <9snfbh$dt3$1@peabody.colorado.edu> Message-ID: <15343.30869.243587.69484@monster.linux.in> >>>>> "FP" == Fernando P?rez writes: [snip] FP> 3) A true visualization *framework*, which has both high-level FP> plotting routines and access to basic FP> primitives. Mathematica's plotting system, while not the most FP> convenient to use, is a good example of this idea. You can FP> just 'plot' stuff, but you also have low-level access to the FP> graphing primitives to program more complex stuff yourself. [snip] FP> 3: there's a lot out there, but nothing convinces me FP> yet. VPython is great for 3d work but still in its infancy, FP> gnuplot and grace have python access but don't provide FP> low-level access, scigraphica doesnt' seem ready yet, ... VPython/OpenGL are great for rendering simple primitives on screen and doing animations and stuff. Yes, you can definitely build complex visualizations with them but its not so easy to do useful visualizations quickly. VPython does abstract out a lot of things very nicely but if you ask me, its still too low level. High level 3D visualization is a different ball game. If you are serious about it you *have* to look at the Visualization ToolKit (VTK). http://public.kitware.com/VTK/ VTK is an open-source, cross platform, very high level visualization library thats fairly mature but under active development. It is written in C++ and has bindings for Tcl, Python and Java. The Python bindings are really good. VTK internally uses OpenGL to do the actual rendering but presents a very high level pipeline based design to the end user. This makes it fairly easy to use. That said, VTK is *HUGE*, it has over 650 classes that enable one to do 3D graphics, data visualization, to do image processing etc. Visit the web page for more details. In short, its really amazing. Best of all its OSS. The biggest problem with VTK is its complexity. Its not something you can master in a few days even. Documentation is available in the form of a couple of books and you really have to read them. >>> s = ShamelessPlug() >>> s.start() VTK is library and some folks have trouble using it because it does take some effort to get the hang of it. There is one tool/application out there that helps such folks out by attempting to make data visualization very easy. Its written in 100% pure Python and uses VTK and Tkinter. Its available here: http://mayavi.sf.net To see specific examples in action look here: http://mayavi.sf.net/screenshots/ The latest CVS version adds the capability for one to use it from the Python interpreter and script it. A new release is due shortly so don't download the old release. I'll surely announce the next release when its done. Its certainly not perfect and the Python interface does need lots of cleaning up etc. but this feature was added recently so still needs work. I'm also investigating the possibility of adding a useful module that allows for matlab like visualizations from within SciPy using MayaVi. >>> s.stop() Cheers, prabhu From prabhu at aero.iitm.ernet.in Wed Nov 7 13:10:32 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 7 Nov 2001 23:40:32 +0530 Subject: Numerical Python Bug ? In-Reply-To: <9sbs59$96vag$1@hades.rz.uni-sb.de> References: <9sbs59$96vag$1@hades.rz.uni-sb.de> Message-ID: <15337.31000.422975.520630@monster.linux.in> >>>>> "US" == Uwe Schmitt writes: US> Hi, during a *large computation* I get problems with vectors / US> arrays: Can you reduce this to a problem that others can reproduce? If so that would most probably get you a more relavant answer. Simple tests on Numeric seem to work fine for me. US> Is there a bug in NumPy or Python respectively ??? US> Last but not least: If I use US> alpha=0.5 print alpha US> I get 0.0 as output !!! Ooh, how did that happen? this is certainly very strange unfortunately if people cant reproduce it it is really hard to see where the problem is. good luck, prabhu From db3l at fitlinxx.com Tue Nov 6 16:53:42 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Nov 2001 16:53:42 -0500 Subject: count in 'for ... in ...' References: <9s90mr$osk$00$1@news.t-online.com> <9s91c3$94mgs$1@hades.rz.uni-sb.de> <9s91je$2o0$01$1@news.t-online.com> Message-ID: "Achim Domma" writes: > "Uwe Schmitt" wrote in message > news:9s91c3$94mgs$1 at hades.rz.uni-sb.de... > > > | for i in range(len(my_list)): > > | print i,". ",my_list[i] > > > What about the following ? > > > > idx=0 > > for s in my_list: > > print idx,".",s > > idx+=1 > > two more lines ... not better, isn't it ? ;-) Well, but better need not imply shorter, unless you're in something like the obfuscated C contest :-) I'm not sure there's that much of a difference in this case, but the second form is arguably more readable since the primary function (iterating over the list) is more clearly stated, and the use of the index variable is clear. Then again, I've done the former myself at least as much as the latter, as I continue to battle my C background pulling me towards brevity :-) -- -- 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 mwh at python.net Tue Nov 27 06:25:42 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 27 Nov 2001 11:25:42 GMT Subject: Problem in a str subclass References: <3C0301D0.2D50E454@bullfrog-tech.com> Message-ID: Manus Hand writes: > Can anyone explain why I get the following result? > > Python 2.2b2 (#1, Nov 26 2001, 20:03:34) > [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> class X(str): > ... def __init__(self, xx = None): > ... if not xx: xx = 'ye olde default value' > ... str.__init__(self, xx) > ... > >>> x = X('yo yo yo') > >>> x > 'yo yo yo' > >>> x = X() > >>> x > '' > >>> > > I can't see why X() is not set to 'ye olde default value' You need to do your initialisation inside the *class method* __new__; by the time __init__ is called, the string has been constructed, and as it's immutable... You want to do this instead: >>> class X(str): ... def __new__(cls, xx="default"): ... return str.__new__(cls, xx) ... >>> X() 'default' This is getting to be a FAQ, and it's a confusing point... Cheers, M. -- 7. It is easier to write an incorrect program than understand a correct one. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From huaiyu at gauss.almadan.ibm.com Tue Nov 13 15:00:44 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Tue, 13 Nov 2001 20:00:44 +0000 (UTC) Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> Message-ID: On Tue, 13 Nov 2001 16:55:48 GMT, Terry Reedy wrote: >A recursive implementation like > >def d(m,n): return (m == 1 or n == 0) and 1 or d(m,n-1) + d(m-1,n) > >is inefficient ... [snip] > The following iterative solution computes each >function value only once. [snip] Here is a recursive solution doing the same. Note that m is reduced by 1 as per usual definition of combinatorial coefficients def dd(m, n): if m == 0: return [1]*(n+1) tmp = dd(m-1, n) for i in range(1, n+1): tmp[i] += tmp[i-1] return tmp def d3(m,n): return dd(m, n)[-1] The definition of dd could be moved inside d3 (using nested scope). But it is useful on its own. Here's a Pascal triangle >>> for i in range(10): print dd(i, 9-i) ... [1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1, 2, 3, 4, 5, 6, 7, 8, 9] [1, 3, 6, 10, 15, 21, 28, 36] [1, 4, 10, 20, 35, 56, 84] [1, 5, 15, 35, 70, 126] [1, 6, 21, 56, 126] [1, 7, 28, 84] [1, 8, 36] [1, 9] [1] Since m and n are symmetrical, one could also compare them and choose between space optimization vs recursion depth optimization. Huaiyu From prabhu at aero.iitm.ernet.in Thu Nov 15 13:33:56 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Fri, 16 Nov 2001 00:03:56 +0530 Subject: VTK-4.0 python-2.1 for Linux. Message-ID: <15348.2708.8838.517490@monster.linux.in> Hi, I decided to make an easy(?) to install VTK-Python package for Linux. I basically built the latest (20011115) VTK 4.0 CVS tree and bundled all the libraries relevant to Python into a large tarball and added a silly Makefile to make the installation easy. Installing this successfully will hopefully allow one to use VTK from Python 2.1.x (maybe even 2.0.x?). The Python version used for the build was 2.1.1. The build was made on a Debian GNU/Linux woody (testing) machine. Everything apart from the parallel/volumepro/offscreen stuff is compiled. The package is available from here: http://av.stanford.edu/~prabhu/download/vtk/ There is a README.txt that I'd recommend reading before downloading the tarball. I've only tested it on a Debian woody machine, so YMMV. Suggestions are welcome. If someone is interested in distributing their VTK 4.0 libraries built on Linux, I can give you my scripts that automate the task of creating this tarball. Cheers, prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 From joonas at olen.to Wed Nov 7 14:16:52 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Wed, 07 Nov 2001 21:16:52 +0200 Subject: Capturing screen on MS-Windows Message-ID: <3BE988A4.94B8760B@olen.to> Is it possible to somehow capture screen on Windows with Python? From osuchw at ecn.ab.ca Sun Nov 11 03:39:53 2001 From: osuchw at ecn.ab.ca (waldekO) Date: 11 Nov 2001 00:39:53 -0800 Subject: odbc: how to call a stored function in Oracle References: <25c120d1.0111071216.1947ca09@posting.google.com> Message-ID: tom.hines at usa.net (Tom Hines) wrote in message news:<25c120d1.0111071216.1947ca09 at posting.google.com>... > Hi. I'm using ActivePython 2.1.212 and MS ODBC driver for Oracle. I > am able to call a stored procedure that returns a cursor, but I > haven't been able to figure out how to call a stored function or a > procedure that has an output parameter. > > # this works > schools = "" > ret = cur.execute( > "{Call MYPKG.MYPROC (?, {resultset 50, outSchools})}", > ('myparam', schools)) > > > # this doesn't work > retparam = 0 > ret = cur.execute("{? = Call MYPKG.MYFUNC (?)}", > (retparam, 5341562)) > > I've tried a million combinations trying to get it to work, but I > either get > > dbi.internal-error: [Microsoft][ODBC driver for Oracle]Invalid > parameter type in EXEC > > or > > dbi.program-error: [Microsoft][ODBC driver for > Oracle][Oracle]ORA-06550: line 1, column 7: > PLS-00306: wrong number or types of arguments in call to 'MYFUNC' > ORA-06550: line 1, column 7: > PL/SQL: Statement ignored in EXEC > > Anybody know how to do this? I see two ways you could do that. First is to use ADO instead of ODBC. See the page below for example. The page is in Thai I belive but code is code. You will figure that out. http://www.exzilla.net/exDocs/oraado/ado_sp_singel_row.html Other is to forget about ODBC or ADO and connect to Oracle directly. You could use DCOracle module from zope.org site http://www.zope.org/Products/DCOracle or my favorite the one from Computronix http://www.computronix.com/utilities/ for example: import cx_Oracle as cx conn = cx.connect('demo/demo at oracl') cur = conn.cursor() cur.execute("begin MYPKG.MYPROC(:retparam, 5341562);end;", retparam='emptynow') resultdict = cur.fetchbinds() resultdict would be dictionary holding result of the procedure. You may have to set input size before calling execute. waldekO From phd at phd.pp.ru Fri Nov 2 09:33:52 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Nov 2001 17:33:52 +0300 Subject: Freeware Python editor In-Reply-To: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com>; from Randy.L.Kemp@motorola.com on Fri, Nov 02, 2001 at 08:25:04AM -0600 References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> Message-ID: <20011102173352.C16650@phd.pp.ru> On Fri, Nov 02, 2001 at 08:25:04AM -0600, Kemp Randy-W18971 wrote: > I think of the whole concept of free having many facets. Imagine a cake was > baked and I was free to eat it. Now the cake can be made according to the > following methods: > 1. The cook makes the cake, gives it to us to eat, and doesn't share the > recipe. > 2. The cooks makes the cake, gives it to us to eat, and hands out copies of > the recipe. > 3. Several cooks try a variation of the cake, based on the original recipe, > and give it to us to eat. > Now there are probably other variations above, but from the philosophy of > pragmatism, I can have my cake, and eat it to. Unfortunately, no. Information is completely different beast. Think about...hm...TV component (TiVo? ReplayTV?) that you got for free. But it has some unknow (to you) capabilities. It silently reports your TV habits to its producer, e.g. You'd want to stop these reports, but you need to know that these reports are taking place. And if you catch the device by sending reports - how do you stop it without having access to source code and without rights to modify it? And after you've modified it - do you have rights to distribute it to your friends? Information have to be free. Without it we are all but slaves of our governments and megacorporations. Information have to be available, modifiable and redistributable. Especially source code of programs, because programs and microchips are now everywhere. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jeff at ccvcorp.com Fri Nov 9 12:57:27 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 09 Nov 2001 09:57:27 -0800 Subject: New to pyton. Maybe a dumb question? References: <3beb180c@news.bezeqint.net> Message-ID: <3BEC1907.4675EE7A@ccvcorp.com> Eyal Lotem wrote: > > Python must be interpreted, unless a native-code compiler is used. The only > one I know of is the .NET ActiveState Python compiler (and I'm not even > sure it is one). As a minor additional point... Jython can compile Python code into java class files. This isn't quite the same thing as a native-code compiler, though given the near-ubiquity of JVMs these days, it's a pretty close approximation. Though in general, installing python on your target machines first, or packaging your application via McMillan Installer/py2exe/etc., is not a significant barrier. Have you noticed how many programs ship with Visual Basic (and/or MFC) runtimes? ;) Jeff Shannon Technician/Programmer Credit International From mikael at isy.liu.se Wed Nov 14 08:46:05 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 14 Nov 2001 14:46:05 +0100 (MET) Subject: PEP proposal: enhanced string functions In-Reply-To: <9stqn1$gqo$1@isp-m-srv06.izb.net> Message-ID: On 14-Nov-2001 Matthew Dixon Cowles wrote: > I'd prefer to be able to pass a sequence to strip() and have > any of those characters stripped. On 14-Nov-2001 Oliver Fromme wrote: > For the center() case, it might be useful to optionally > allow another argument, so you can have different padding > on the left and on the right. > > Example: > >>> string.center(" Title ", 25, ">", "<") > '>>>>>>>>> Title <<<<<<<<<' To conform with Matthew's proposal about strip(), you might want to use the same argument for left and right padding in center(), as in >>> string.center(" Title ", 25, "><") '>>>>>>>>> Title <<<<<<<<<' /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 14-Nov-2001 Time: 14:41:35 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From printers at sendme.cz Thu Nov 15 16:48:12 2001 From: printers at sendme.cz (A) Date: Thu, 15 Nov 2001 22:48:12 +0100 Subject: Is it a job for Thread or Process? Message-ID: <3BF4462D.18995.122E154@localhost> Hello, In my Python script I would like to start one function of this script in a different thread or process? That function sends an email. Can you please give me an example how I can start a new thread or process under Win32 systems? Is it better to use a new thread or a new process for this task? Thank you for help. Ladislav From qrczak at knm.org.pl Thu Nov 29 14:44:31 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Thu, 29 Nov 2001 19:44:31 +0000 (UTC) Subject: Non-Indented python References: <3C0678DF.2DFE924A@home.net> Message-ID: Thu, 29 Nov 2001 10:05:19 -0800, Chris Barker pisze: > I often start working on a file I got from elsewhere with tabs in > it, get some wierd error, eventually think to check for tabs. Then > I run a script on it, clean it up, and all is well. This problem doesn't exist if you use 8 as the tab width because then the apperance is consistent with semantics. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From matt at mondoinfo.com Fri Nov 9 22:23:48 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 10 Nov 2001 03:23:48 GMT Subject: Tkinter menu commands activate when menu is built References: <3bec7f09$1_6@goliath.newsgroups.com> Message-ID: <851H7.1703$H7.824133@ruti.visi.com> On Fri, 9 Nov 2001 20:17:43 -0500, David Mallwitz wrote: Dear Dave, >According to the documentation >menu.add_command(label='x',command=y) >should create a dropdown menu entry named 'x' that will activate >function y() when clicked. [. . .] >connectmenu.add_command(label="Example 1", command=do_stuff(1)) Compare the exmple to your code again . You're not giving it a command=y, you're giving it a command=y(). The first is a matter of passing a function around, the second is calling the function. Everyone get bitten by this early on in writing Tkinter programs. The simple thing is to use four functions but I bet that you wanted to use that argument for a reason, probably because the code would be more natural with one function rather than four. In that case, you can store the state in an object that will respond to being called. Something like this would probably work for you: class do_stuff: def __init__(self,val): self.val=val return None def __call__(self): print "My stored value is",self.val return None Then you could say command=do_stuff(1). Regards, Matt From phd at phd.pp.ru Wed Nov 14 06:50:44 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Nov 2001 14:50:44 +0300 Subject: Python .elc and /etc/magic In-Reply-To: ; from mwh@python.net on Wed, Nov 14, 2001 at 11:35:00AM +0000 References: Message-ID: <20011114145044.Q11497@phd.pp.ru> On Wed, Nov 14, 2001 at 11:35:00AM +0000, Michael Hudson wrote: > [mwh at starship mwh]$ python1.5 get_magic.py > 1.5 0xa0d4e99 > > 0 belong 0x994e0d0a python compiled > > > Where did they get that number from? Doesn't seem to match anything I > can find. This is just reverse byte order of your 0xa0d4e99 :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jaraconospam at jaraco.com Fri Nov 30 23:19:17 2001 From: jaraconospam at jaraco.com (Jason R. Coombs) Date: Sat, 01 Dec 2001 04:19:17 GMT Subject: IOError when printing in Python service after 2 days Message-ID: <9TYN7.189006$IR4.70920026@news1.denver1.co.home.com> I'm getting an exception in my code in a print statement. I'm running my program as a service using the service classes provided in ActivePython. The program doesn't crash in debug mode. In run mode, it runs fine for a couple of days, then I get this exception in one of my threads: Exception at Thu Nov 29 04:04:20 2001 Traceback (most recent call last): File "C:\bin\FileChangeNotifier.py", line 87, in run self.Handle( filepath ) File "C:\bin\watch.py", line 41, in SetLastChange print time.asctime(), 'Change detected in', filename IOError: [Errno 9] Bad file descriptor So, something strange appears to be happening to the stdout file descriptor. I'm having difficulty identifying this as anything but a bug in Python. I suspect it has to do with redirection of standard output in the service handling. It's possible that in writing services, I'm supposed to do something with the output, but I'm not. Does anyone have a suggestion on this? Thanks, Jason From chrishbarker at home.net Thu Nov 15 19:24:15 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 15 Nov 2001 16:24:15 -0800 Subject: Scientific Libraries in Python References: <9t1iqq$es0$2@peabody.colorado.edu> Message-ID: <3BF45CAF.9983E26A@home.net> Nice Summary of the state of the art: A few comments: Fernando P?rez wrote: > Libraries: > > SciPy at http://scipy.org > Comment: This seems to be by consensus the horse to bet on as a base > platform. It seems to have a great architecture and very good ideas (the > compiler is *really* cool). But its coverage is still very patchy. I am one of the folks that think this is the horse to bet on. Mostly because the project has been set up from the beginning to be a framework for a comprehensive library. > GSL -- The GNU Scientific Library at http://sources.redhat.com/gsl > There may be licensing issues that need to be addressed. It is GPL'd, which is a pity, it seems a prime candidate for the LGPL. Anyway, it would seem to me that linking it with Python would be license issue, although Python's current license is supposed to be "GPL Compatible". Does anyone know what that means? Can this be clarified by someone who knows what they are talking about? I'd love to know whether this is a project I should delve into. > Visualization: I agree that Visulisation is key. You didn't mention it here, but the problem I have with most of the available stuff is that it is all wrappers around other external packages. To really get what I want, I need to be able to access the primitives form Python. That means a lot of the code should probalby be in Python, or at least written with this kind if access in mind. I've been imagining a package built in Python that looks a lot like MATLAB's handle graphics (although with OO, you wouldn't need the handles). MATLAB's system makes it very easy to whip out a plot: plot(x,y) but you can also get access to all the properties of the plot, so that you can customise things as much as you like. I think all plots are created by a set of only three types of primitives, a line, a patch (surface), and a text object. It really works pretty well. I also believe that all plots are 3-d with 2-d plots being a special casse, where z=0 everywhere, and the view is from the top. The system is set up eith a hierarchy something like this: Figure: Any number of Axis: Properties of the Axis (limits, location, view position, etc.) Any number of lines Properties of the line (Markers, color, width, data(x,y,z), etc) Any number of patches Properties of the patch (Color, data(x,y,z), etc) Any number of text objects Properties of the text (color, font, size, etc) Anyway, it's a pretty nifty system, and I think one like ot for Python would be great. The Graphite project (http://Graphite.sourceforge.net/) was a nice start to this, and I think the native SciPy one looks pretty promising as well. My main feeling is that we really do need something native to Python. A wrapper around an external package will never be flexible enough to really compete withe MATLAB or IDL. > MayaVi at http://mayavi.sourceforge.net > ----- > Comment: this seems the most promising tool to me from what I've seen, though > it's pretty 'heavyweight'. If a good interface can be made for interactive > prompt use and python scripted control, I think it's a winner. I don't know > how it handles 2d plots (if at all). But I tend to think it's easier to add > 2d functionality to something like this rather than growing a 2d or basic 3d > tool into a full blown visualizer that handles volume rendering. I agree. framework like what I suggest above, built on top of MayaVi, or directly on VTK, or even more directly on OpenGL, would be great!! > Final comment: that's what I see as the key players at this point. > In my ideal fantasy world, a single 'import ScientificTools' (whatever you > want to call it) would give me python access to all the above functionality, > with a sane overall naming structure. Another think I'd love to see is a "Scientific Python Distribution" this would be all of Scientific Python all packaged up with Python itself, all compiled and ready to go (with optimised BLAS, etc) for your platform of choice. It would also support MacOS, along with *nix and MSW. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From skip at pobox.com Wed Nov 28 11:52:38 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 28 Nov 2001 10:52:38 -0600 Subject: doesNotUnderstand ? In-Reply-To: <3C051246.9C15125E@corest.com> References: <3C051246.9C15125E@corest.com> Message-ID: <15365.5718.503419.129716@beluga.mojam.com> Gerardo> Is there a way to intercept the activation of messages which Gerardo> are not implemented? Well, you will get an AttributeError exception when trying to access a missing method or data attribute. If you want a catch-all (say, for a proxy), add __getattr__ method to your class. Check out the "Customizing attribute access" section of the Language Reference Manual for details: http://www.python.org/doc/current/ref/attribute-access.html -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From clpy at snakefarm.org Thu Nov 8 05:53:58 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Thu, 08 Nov 2001 11:53:58 +0100 Subject: complex() bug or feature? Message-ID: <3BEA6446.8D8B4012@snakefarm.org> Hi there, is this the way complex() is supposed to work? Python 2.2b1 (#2, Oct 22 2001, 10:47:30) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> complex('1', '1') (1+0j) >>> If complex() allows stings as arguments (like float()), what's happened to the imaginary part? Regards Carsten. --- 'In iteger arithetric divsion is no the oposite of multiplication.' From jeff at ccvcorp.com Thu Nov 15 13:55:06 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 10:55:06 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <3BF40F8A.378CC6F8@ccvcorp.com> David Eppstein wrote: > You seem to be inconsistent here about whether you want these ranges to be > open or closed on the right. I think closed is the only reasonable > choice for this syntax. Which is exactly why I think that the Haskell-ish syntax is a bad idea. This syntax cries out to be a closed interval, and it would be very confusing if used as a half-open interval. But that would make it the *only* case of Python using a closed interval. I find that inconsistency to be *far* more jarring than the use of range(). Jeff Shannon Technician/Programmer Credit International From uwe at rocksport.de Wed Nov 7 12:48:25 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 7 Nov 2001 17:48:25 GMT Subject: Numerical Python Bug ? Message-ID: <9sbs59$96vag$1@hades.rz.uni-sb.de> Hi, during a *large computation* I get problems with vectors / arrays: print sp delivers [ 100, 50,] and print 0.5*sp yields [ 0, 0, ] type(sp) is "array" and type(sp[0]) is "float". What makes me wonder is the output format. "print sp" should give [ 100., 50. ] which is different from my result above... Further: if I use print 1/2.0*sp i get the correct result [50, 25,] Is there a bug in NumPy or Python respectively ??? Last but not least: If I use alpha=0.5 print alpha I get 0.0 as output !!! One remark: all the behaviour above does not happen if I enter some vectors manually... Yours, Uwe. -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From kragen at pobox.com Fri Nov 30 20:11:29 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 30 Nov 2001 20:11:29 -0500 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> <20011129.151831.971899228.1845@hp.com> Message-ID: <83vgfru4la.fsf@panacea.canonical.org> ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) writes: > I was commenting on the standard python distribution in reference to > the original comment about php forcing you to mix html and code. In > both php and python the standard distribution doesn't have > templating features, however it is fairly easy to get a module that > implements it or to create one yourself. "%s" % foo in Python is a templating feature. In PHP the whole language is a templating feature. What am I missing? From gioco at nekhem.com Tue Nov 6 04:35:17 2001 From: gioco at nekhem.com (Corrado Gioannini) Date: Tue, 6 Nov 2001 10:35:17 +0100 Subject: RE Module Question. In-Reply-To: References: Message-ID: <20011106103517.A573@zephyr> On Tue, Nov 06, 2001 at 05:49:38AM +0000, Paul Winkler wrote: [snip] > You can do it like so: > > test = "this is spam" > if test.find("spam"): print "found it" this would fail if the sub-string to be found is at the beginning of the string (find returning 0). Corrado. -- Corrado Gioannini "Thought is only a flash between two long nights, but this flash is everything." (H. Poincar?) From modman at altavista.com Wed Nov 14 22:38:59 2001 From: modman at altavista.com (modman) Date: Thu, 15 Nov 2001 03:38:59 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> Message-ID: <3BF3378B.8030205@altavista.com> >> >>Yes, there is, and it's delivered with Python! It's Tools/scripts/ >>pindent.py in the standard distribution. It only needs a block end >>delimiter (# end). You already have ":" as the opener... >> > > It messes up multiline strings, though. (or, rather -- it messes up the > indentation in multiline strings.) apparently this script relys on the programer of the other language to write good readable code so that it looks a bit like python indentation in the first place. From ws-news at gmx.at Fri Nov 16 06:45:14 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 12:45:14 +0100 Subject: What is "marshal data"? References: <859c71be.0111151028.63227109@posting.google.com> Message-ID: <3bf4fd0f$1@brateggebdc5.br-automation.co.at> Hi, just a guess, but even if the magic id in the .pyc file is the same, does this guarantee that the .pyc file is protable between different platforms? Things as the size of a data type (like int or double), endian issues and so on? just a guess Werner "Soren Ragsdale" wrote in message news:859c71be.0111151028.63227109 at posting.google.com... > I'm testing some scripts with Python 2.1.1: we're upgrading from > 1.5.2. I've been noticing this error, and the REAL problem is that > I've never heard of "marshal data" before. This error is not > reproducible: this script is part of a distributed program which runs > on about 200 machines, and four of the scripts produced this error. > The problem isn't isolated to individual machines: > > > /tip/td/python2-irix64/bin/python -u ren_blade.py 44 > Traceback (most recent call last): > File "ren_blade.py", line 4, in ? > import uh,gh > ValueError: bad marshal data > > Possible sources of the problem: "uh.py" is imported from MANY > programs on our network. It's being imported by Linux and Irix > machines running 1.5.2 and 2.1.1 versions of Python. Could this be > some sort of race condition, where one platform or version produces a > .pyc file while the other platform or version is also writing the same > .pyc file? From burt at dfki.de Tue Nov 27 05:27:37 2001 From: burt at dfki.de (Alastair Burt) Date: 27 Nov 2001 11:27:37 +0100 Subject: vCard parser anywhere ? References: <9trh93$o1e$1@norfair.nerim.net> Message-ID: "Gillou" writes: > I'm looking for a vCard parser that changes a vCard stream into a Python > object. WorldPilot has code for handling the vCard format: http://sourceforge.net/projects/worldpilot/ --- Alastair From eppstein at ics.uci.edu Wed Nov 14 19:46:37 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 14 Nov 2001 16:46:37 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <7xadxo27tr.fsf@ruckus.brouhaha.com> Message-ID: In article <7xadxo27tr.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: > > > for i in 0 .. len(sequence)-1: > > > > This is very common in C, but is it so common in Python? > > Isn't it usually more idiomatic to do > > for item in sequence > > ? > > Sometimes you want to use the index in the loop. Maybe the loop syntax > should be extended somehow to easily let you do that. Ok, suppose you are numbering output lines, or something. You may likely want to number them starting from one, anyway. index = 1 for item in sequence: print index, item index = index+1 would be my preference over for i in range(len(sequence)): print i+1, sequence[i] for three reasons: 1. it works with iterators as well as lists 2. you can skip items in the sequence and keep the numbering contiguous 3. I don't trust sequence[i] to take constant time 4. I'm not as likely to produce an off-by-one error 5. I don't like having to remember what range(n) means ...among our *many* reasons are... -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From prabhu at aero.iitm.ernet.in Mon Nov 19 19:01:05 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 20 Nov 2001 05:31:05 +0530 Subject: MayaVi-1.1 released. Message-ID: <15353.40257.400938.50656@monster.linux.in> Hi, This is to announce the availability of the MayaVi Data Visualizer version 1.1. MayaVi is a free, easy to use, scientific data visualizer. It is written in Python and uses the Visualization Toolkit (VTK) for the graphics. It provides a GUI written using Tkinter. MayaVi is free and distributed under the GNU GPL. It is also cross platform and should run on any platform where both Python and VTK are available. For more information, downloadable sources and *binaries*, screenshots, installation instructions, documentation etc. visit the MayaVi home page at: http://mayavi.sourceforge.net Also bundled with MayaVi is a VTK pipeline browser written in Python and a new utility module that makes using VTK easier from the interpreter. What's new in this release: (*) Binaries for Linux and Win32 made using Gordon McMillan's Installer. (*) MayaVi can now be used from other Python programs, can be scripted and can also be used interactively from the Python interpreter. For a specific example see: http://mayavi.sourceforge.net/docs/guide/c760.html (*) Installs as a Python package using distutils. (*) Command line arguments are now supported. (*) Added 3D Studio file import, RenderMan RIB/JPEG/PNG export. (*) Improved streamline module and better 2D streamlines. (*) More options to place the vector glyphs for vector plots. (*) Added filters: PolyDataNormals, WarpVector, WarpScalar, ExtractUnstructuredGrid. Added module: WarpVectorCutPlane. (*) New VtkData class that handles user constructed vtk data. (*) Added basic tensor support, a tensor related filter and module. Contributed by Jose Paulo -- many thanks! (*) Huge speed up (by a factor of 50 or more) in the "expand all" feature of the pipeline browser, many thanks to Dan Blezek for this! (*) New utility module, ivtk.py, that makes interactive VTK a pleasure. More information on this module is available at: http://mayavi.sourceforge.net/docs/guide/x799.html (*) Intelligently disable annoying VTK warning messages. Various bugs have been fixed and other small enhancements have been made. Have fun! prabhu From pinard at iro.umontreal.ca Wed Nov 28 13:24:03 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 28 Nov 2001 13:24:03 -0500 Subject: Editor for Python: A PLEA In-Reply-To: <01112900050307.13207@linux> References: <3bfd7f87@news.airtel.net> <01112900050307.13207@linux> Message-ID: [Jonathan Gardner] > Tim Hammerquist wrote: > > (PS: I don't have to learn Lisp to script Vim...I can use Python... > > This was originally a python thread, wasn't it? =) > What, you can't use python in Emacs? This cannot be true... can it? > *rubbing eyes* Sure, it can. Cedric Adjih and Brian McErlean worked in that direction, and I summed up their work into a small package, which may be found as: wget http://www.iro.umontreal.ca/~pinard/pymacs/pymacs.tar.gz -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From teg at redhat.com Sun Nov 4 16:25:31 2001 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 04 Nov 2001 16:25:31 -0500 Subject: Solving Partial Differential equation in Python References: Message-ID: Roman Suzi writes: > Probably, if you could find library like LAPACK for linear algebra > and use SWIG to make bindings to C for Python, you will have > PDE solving functionality in Python. LAPACK doesn't do PDEs? -- Trond Eivind Glomsr?d Red Hat, Inc. From bbollenbach at home.com Mon Nov 12 18:11:07 2001 From: bbollenbach at home.com (Brad Bollenbach) Date: Mon, 12 Nov 2001 23:11:07 GMT Subject: Obfuscator for Python? References: Message-ID: The people who are too clueless to be able to "reverse engineer" obfuscated Python code were no threat to begin with. The best way to protect your code isn't through obfuscation...it begins with good lawyers, and a suitable license. The people wh "Amitabh" wrote in message news:ac25a19e.0111121503.189ea177 at posting.google.com... > Hi, > > I wanted to know if there are any products which obfuscate the python > byte code so that it cant be reverse engineered easily? > > TIA > > Cheers > Amitabh From weismann at netvision.net.il Fri Nov 2 14:46:07 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Fri, 02 Nov 2001 21:46:07 +0200 Subject: I have a file.eml with my message . What's next ? Message-ID: <054b01c163d7$046ac870$9996003e@rashome> Hi I'm new to python but I love it :) I have a fileName.eml with my email message . How do I send it away ? Thanks in advance ---------------------------------------------------------------- Weisman Amit 11 Rupin st. Holon 58344 Israel Tel : 050397330 weismana at cs.bgu.ac.il -------------- next part -------------- An HTML attachment was scrubbed... URL: From logiplexsoftware at earthlink.net Mon Nov 12 15:56:06 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 12 Nov 2001 12:56:06 -0800 Subject: Teaching python (programming) to children In-Reply-To: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> References: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> Message-ID: <01111212560602.01611@logiplex1.logiplex.net> On Sunday 11 November 2001 03:36, Laura Creighton wrote: > In the meantime, I think that letting teachers cut and paste whatever > academic educational theories and texts they like reduces teaching > to a hobby, and diminishes it as a profession. Many people appear to > want this. They speak of the 'vocation' of teaching, and the > 'calling'. > > David Ritchie and I both teach programming, as a hobby, and we > have independently come up with the principle that it works better > if you have the students code adventure stories. So we do this. > If it turns out we are misguided idiots, are students can always > leave and do something else. It is quite possible that we have > only demonstrated that you should teach students that have joined > a club where you code adventure stories, by teaching them to > code adventure stories. This is a problem with a self selected set. > David Ritchie was teaching people to program in Perl. I don't > approve of that, and am pleased that he is now using python. But > I think that it was an _unfortunate_ choice. But if David Ritchie > was a professional middle school teacher, I would have a much > stronger choice of words to describe what I think of the acceptability > of Perl as a first programming language. So then, what if your committee, who happens to have the esteemed Larry Wall as an advisor, decides that Perl *is* the appropriate language? What will happen to *your* precious ideas about which language is more appropriate? This is the basic problem with committees making such decisions - you, whom I assume to be an excellent teacher - will be forced to abandon what is working well for you in favor of an idea foisted upon you by people who are at least one step removed from the actual teaching process. > I expect more from you and every professional teacher of programming > to high school students. (Which perhaps you aren't doing any more.) > But unless I misremember, you said that you were teaching C++ as a > first programming language. And I think that this is worse than > foolish, this is evil. You should not have been allowed to do this, > even if you wanted to, a responsible educational policy should have a > list of acceptable first programming languages, and C++ should not be > on the list. What if Python isn't on the list either? But I don't think that you actually _wanted_ to teach > C++ as a first programming language to high school students, but it > was part of the the educational policy that you were given. So it is > not a matter of a lack of policy, which would be bad enough, but a > greater evil. The _policy_ itself is evil. What other evils do you > have, and how do you get them, and why can't responsible teachers such > as yourself get rid of evil damaging policies? If that is not worth > getting angry about, I don't know what is. My point exactly. Committees and policies are dangerous things and once they are institutionalized, they tend to lose focus on what they were designed to do and instead merely more red tape for teachers to fight through. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From plakal at yumpee.org Tue Nov 6 13:55:20 2001 From: plakal at yumpee.org (Manoj Plakal) Date: Tue, 06 Nov 2001 18:55:20 GMT Subject: Yahoo Groups archive of python-list wiped - what happened? References: Message-ID: <3BE8324F.6060602@yumpee.org> Hamish Lawson wrote: > The Yahoo Groups archive of python-list seems to have started over > with message #1 dated 5 November 2001, losing all messages before > that. Does anyone know what happened? > > http://groups.yahoo.com/group/python-list/messages/1 > > Hamish Lawson Dunno what happened there, but the python-list archive is available at: http://mail.python.org/pipermail/python-list/ Manoj From tim.one at home.com Sat Nov 3 13:06:03 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 13:06:03 -0500 Subject: [ #456742 ] Failing test case for .*? In-Reply-To: <9s0rqo$rrg$1@bob.news.rcn.net> Message-ID: [A.M. Kuchling] > +? is a non-greedy +, and it's not equivalent to (...+)?. > > Here's a test program: > > import sre > s = "a\nb\na1" > > # Original, buggy pattern > p = sre.compile(r" [^\n]+? \d", sre.DEBUG | sre.VERBOSE) > m = p.search(s) > print (m and m.groups()) This is chasing an illusion: print m.group(0) instead. Since this pattern contains no explicit capturing groups, m.groups() can't produce anything other than an empty empty. Here in a simpler setting: >>> m = re.match('a', 'a') >>> m.groups() # useless for a pattern without capturing groups () >>> m.group(0) # useful 'a' >>> > # Add a group > p = sre.compile(r" ([^\n]+?) \d", sre.DEBUG | sre.VERBOSE) > m = p.search(s) > print (m and m.groups()) > > When I run with the current CVS Python, two different results are > produced, even though the only difference is adding a pair of > parentheses: Yes, and that means .groups() is working correctly in both cases. Back to the simpler example: >>> m = re.match('(a)', 'a') >>> m.groups() ('a',) >>> m.group(0) 'a' >>> The bug is that the pattern should have found just the 'a1' tail, not all of s; it's the same bug in both cases: import re s = "a\nb\na1" m = re.search(r'[^\n]+?\d', s) print m and `m.group(0)` # prints 'a\nb\na1'; should have been 'a1' m = re.search(r'([^\n]+?)\d', s) print m and `m.group(0)` # also prints 'a\nb\na1' From DeepBlue at DeepBlue.org Wed Nov 28 10:30:34 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Wed, 28 Nov 2001 09:30:34 -0600 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: "Jonathan Gardner" wrote in message news:mailman.1006958441.30706.python-list at python.org... > Ken Seehof wrote: > > > > > > more. True, I think .NET is cool - but I'll only use it if MS keeps it > > > promise and ports it too Linux and such. > > > > Odds of MS keeping any promises of this kind: 0.027% > > > > It has never been in MS's best interest to be compatible with the rest of > > the > > computing world. > > > > Look at Visual C++. Portability? Compatability? Ha. > > Look what they did to Java, HTTP, HTML, and JavaScript. > What did they do to Java, HTTP, HTML, and JavaScript? > Microsoft is in the business of making money, not software. > Is Sun and Netscape any different? DeepBlue From bill-bell at bill-bell.hamilton.on.ca Wed Nov 7 09:08:48 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 7 Nov 2001 09:08:48 -0500 Subject: Disk explorer from python with COM In-Reply-To: <1005141342.812.66177.m5@yahoogroups.com> Message-ID: <3BE8FA20.19435.7DA17E0@localhost> Benoit Lagrange wrote, in part: > I am wondering wether it is possible to browse the disk from a python > application by using COM. And if it is possible, how to use it? Certainly possible. What do you want to do? "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From phr-n2001d at nightsong.com Fri Nov 2 04:31:46 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 01:31:46 -0800 Subject: Python extension modules References: <7fd99f9.0110311606.7e0a5836@posting.google.com> Message-ID: <7xwv19r01p.fsf@ruckus.brouhaha.com> You might look at www.swig.org. It's less headache than using the native interface directly. From lac at strakt.com Fri Nov 16 12:30:27 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 16 Nov 2001 18:30:27 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Cliff Wells of "Tue, 13 Nov 2001 09:04:56 PST." <01111309045601.02982@logiplex1.logiplex.net> References: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> <01111212560602.01611@logiplex1.logiplex.net> <200111130925.fAD9PPua015737@ratthing-b246.strakt.com> <01111309045601.02982@logiplex1.logiplex.net> Message-ID: <200111161730.fAGHURua021744@ratthing-b246.strakt.com> >Cliff Wells > I'm curious why you chose to respond to that particular part of my post and > disregarded the rest, which IMHO, has more relevance to the discussion at > hand. 'You cannot force someone to think as you do or to feel as you do, but you can teach them to think a little better, to think a little more. To listen a little more critically. To listen to what they're really doing, not what they think they're doing.' Isaac Stern, teaching in 1995 Laura Creighton From eddie at holyrood.ed.ac.uk Thu Nov 1 10:19:11 2001 From: eddie at holyrood.ed.ac.uk (Eddie Corns) Date: Thu, 1 Nov 2001 15:19:11 +0000 (UTC) Subject: map, filter, reduce, zip, range, and.. slice? References: <3bdf39a6@news.bezeqint.net> Message-ID: <9rrp5f$37r$1@scotsman.ed.ac.uk> Eyal Lotem writes: >Hey. Recently, I've been heavily using functional-style programming in >Python, doing almost all of my text processing and so with complex nested >lambda clauses. I love those, as they are so short, and seem to work with >a painless "debug" cycle, usually consisting of some missing reduce initial >value or so. >To get to the point, I've almost always lacked a 'slice' function, that >slices sequences into smaller chunks. For example: >divide("Hello world!", 2) => ["He", "ll", "o ", "wo", "rl", "d!"] It's a bit clumsy but how about: [x[i:i+2] for i in range(0,len(x),2)] Where x is your string. Eddie From stuart at bmsi.com Thu Nov 15 21:06:56 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Thu, 15 Nov 2001 21:06:56 -0500 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> Message-ID: <9t1sc0$40c$1@nntp1-cm.news.eni.net> In article <9t1ml4$vhi$1 at nntp1-cm.news.eni.net>, "Stuart D. Gathman" wrote: > I have been putting my thoughts toward the elusive goal of making python > as fast as some LISP dialects. > The basic idea is to split namespace dictionaries into two parts, a > simple C array of PyObject pointers, and a SymbolTable which maps names > to indexes into the C array. A SymbolTable can grow, but never shrink. > Deleting a name from the namespace is represented by storing a 0 into > the C PyObject array. The C array is automatically enlarged as required > when adding names to the dictionary (call it a SymbolDictionary). > > In the general case, access is slightly slower due to the extra index > into the C array, and memory could be wasted due to deleted names, which > still occupy a (0 value) slot in the array and SymbolTable. However, > all python semantics are preserved. Forget all that stuff about caching optimized copies of function code. Instead, an adaptation of call site caching will work wonders. The bytecode to access a global contains a namespace id, and an index. The namespace id can be a direct pointer, or an index into a table of namespaces. E.g. LOAD nid idx When accessing a global, the desired namespace is compared against the namespace id in the bytecode. If they match, the global is fetched directly using the index (giving a Name Error if the slot is 0). If they don't match, the name is retrieved using the index and old namespace id, and the index in the new namespace is looked up/added. The new namespace id and new index are stored into the bytecode. This scheme will work even for compound globals (e.g. os.argv) - the global access for each component has its own bytecode and is cached independently. The namespace id for each global access bytecode is initialized to the namespace of the module or class the function is defined in (and the identifier preloaded in that module or classes namespace SymbolTable). If the function is assigned to multiple modules or classes, a byte code may switch namespaces frequently - and will be somewhat slower than it is currently. But in the common case where a function stays with the module or class it is defined in, there will be a significant speedup. This strategy should work with a python compiler - preserving the dynamic semantics. Each global access would look like this: def execGlobal(nid,bc): curNID = getNID(bc) if curNID == nid: return nid.getByIndex(getIDX(bc)) # name error if slot is 0 name = nid.getNameByIndex(getIDX(bc)) idx = nid.getIndexByName(name) # add name if not in new namespace setNID(bc,nid) setIDX(bc,idx) return nid.getByIndex(idx) # name error if slot is 0 The cache hit path would have only a few machine instructions (for some random load/store machine): # a2 has bytecode pointer, a0 has namespace pointer load a1,a2[bcnid] compare a1,a0 jeq hit call fixupbc hit: load d0,a2[bcidx] load a0,a0[d0] compare a0,0 jeq name_err # a0 has address of PyObject -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From fdrake at acm.org Thu Nov 29 03:48:05 2001 From: fdrake at acm.org (Fred L. Drake) Date: Thu, 29 Nov 2001 03:48:05 -0500 (EST) Subject: [development doc updates] Message-ID: <20011129084805.0885328696@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Added section of example regular expressions to the "re" module docs. Various small clarifications. From aardvark_three at yahoo.com Sun Nov 18 21:32:15 2001 From: aardvark_three at yahoo.com (aardvark) Date: 18 Nov 2001 18:32:15 -0800 Subject: List-of-lists (aka array) mystery Message-ID: <4f49f3e8.0111181832.7162be1b@posting.google.com> Hi everyone A friend of mine has discovered some interesting behavior with lists-of-lists (I suppose some call them "arrays"). When you define (or "initialize") a list-of-lists using the range() function, then set a value within one of the inner lists, the value of each inner list item in that same position becomes the new value. When you explicitly define (or "initialize") the list-of-lists the behavior is as expected, i.e. only the value in the list position you specified, within the list you specified, is changed. A better way to show this is with an example: Definition using range: >>> x=[range(-1,0)*3]*3 >>> x [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]] >>> x[1][1]=0 >>> x [[-1, 0, -1], [-1, 0, -1], [-1, 0, -1]] I did not expect x[0][1] and x[2][1] to become 0. I only expected x[1][1] to become 0. This does not happen when you explicitly define the list: >>> x=[[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]] >>> x [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]] >>> x[1][1]=0 >>> x [[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]] Why is this? It would seem that multiplying the result of the range() function twice returns pointers to a single list rather than discrete lists. Is there a better way to initialize lists-of-lists? Should I be going about this differently? I'm sure it's something obvious... I'd just appreciate being pointed in the right direction. thanks for any help you can provide! aardvark ------------------ identifying string: mjunhybgt ------------------ From kseehof at neuralintegrator.com Thu Nov 15 16:20:41 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Thu, 15 Nov 2001 13:20:41 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <049801c16e1b$fef31380$7a93b23f@kens> > Ken Seehof wrote: > >Hey, what ever happened to the int[:10] iterator idea? > > > >>>> for i in int[2:10:2]: print i, > >2 4 6 8 > > Nothing actually *happened* to it. ;-) > > It needs a PEP (or needs to be added to an existing PEP). > > Among the issues that the PEP should probably address are: > > - Does int[] return a list or an iterator? (Or an iterator that implements > some or all of the sequence protocol?) > > A list would be useful in many cases and would be a bit more consistent in > the sense that slicing applied to current builtins returns actualized > sequences not iterators. > > But iterators are more useful for for-loops (because you don't have worry > about generating large sequences unnecessarily). > > So both are useful. Do we need two mechanisms? What would be the proposal > for that? I think iterator. > - Does int[] do anything more than act as a new spelling for the "range" > function? (Or "xrange", depending on the answer to the issue above). Yeah, I suppose it is. But then 'print' is just another spelling for sys.stdout.write. Sometimes a new spelling is worthwhile if an idiom is common enough, as long as we don't get too perlish^H^H^H^H^H^H^H^H^H^H^H^H^H^H^Hoverdo it. Actually, my main motivation in bringing the slice idea up again is to replace PEP 276 which I don't like because making an integer behave like a sequence is just weird, and maybe even a bit perlish^H^H^H^H^H^H^Hobscure. So I think my current attitude is something like this: 1. Integer slicing is better than iter(n), and accomplishes the same objectives. 2. Integer slicing is just a different spelling for xrange. So don't bother. 3. Therefore, might as well just reject 276. 4. But wait, xrange and range are really ugly in for loops. 5. So let's do integer slicing after all. > - Issues from PEP 204 "Range Literals". PEP 204 proposed using slice > syntax to create lists of integers. That PEP has been rejected. It > included some issues such as: how do you handle [:] which is valid slicing > syntax but contains no end value? Because the "int[]" proposal is less > drastic than PEP 204 -- calling for the implemetation of __getslice__ as a > class method on types.IntType rather than new syntax -- most of the issues > in PEP 204 are probably not a big deal. But the PEP author should probably > give them consideration. I agree. PEP 204 would have been nifty, but I have to agree with it's rejection mostly because the benifits don't seem to be worth the problems associated with adding new core syntax. The `end' argument issue goes away if the slice returns an iterator, so int[:] returns the sequence of natural numbers [0, 1, 2, ...], which would be a useful idiom as an infinite for loop: . for i in int[:]: . print i . do_something(i) . if done(): break The syntax issues of 204 (mixing with list literals and list comprehensions) don't apply since no new syntax is added. Accepting non-integer arguments is unambiguous: return an integer sequence sliced according to normal slicing rules (e.g. after numeric unification, int[:2.0] would yield iter([0,1])). As I mentioned before, float[:3.0] == [0.0, 1.0, 2.0], where slicing is implemented separately for the float class. > Finally, it should be noted that PEP 276 -- adding an iterator to > types.IntType -- doesn't preclude implementing __getslice__ as a class > method of types.IntType as suggested above. True, but having both would seem to be redundant, since you would not need both solutions which would be redundant. Hence I am suggesting int slicing as an alternative to PEP 276 (did I say that already? :-) BTW, as a reminder, __getslice__ is depricated, so we are really talking about __getitem__(slice), which amounts to the same thing. - Ken From tim.one at home.com Mon Nov 5 18:14:45 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 5 Nov 2001 18:14:45 -0500 Subject: Program very slow to finish In-Reply-To: <3BE706ED.1264548E@chello.nl> Message-ID: [Roeland Rengelink] > Thanks for your comprehensive answer. I hope you'll bear with me, for > I'm looking for some clarification I should have said "I expect you're just measuring your platform C's free() performance", not "cache". I agree that cache effects should have little bearing on this (beyond very small dicts that actually fit in cache), and will give some evidence from my Win98SE box below. > ... > Here are my numbers again, just for comparison (and I do think you're > showing an increase in destruction time too, just not as bad) Yes, but not nearly as bad. > The algo: > > - create dictionary d with N 7-char keys [all mapping to the same value] > - execute d=None > > All times in micro-seconds per item. For the code see end of this post. > (Linux 2.2.14, 128M RAM, Cel 333 MHz) > > size: 10000, creation: 31.00, destruction: 1.49 > size: 20000, creation: 31.10, destruction: 1.57 > size: 50000, creation: 32.77, destruction: 1.76 > size: 100000, creation: 32.00, destruction: 1.92 > size: 200000, creation: 32.59, destruction: 2.38 > size: 500000, creation: 32.12, destruction: 4.35 > size: 1000000, creation: 32.25, destruction: 10.47 > > ... > ["head argument" about cache effects elided] > Now, this may be a very naive argument. But, hey, I'm an astronomer, not > a computer scientist. No, it was a good first approximation, but measurement speaks louder than argument . I fiddled Python's dict dealloc routine like so: for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { --fill; //Py_DECREF(ep->me_key); //Py_XDECREF(ep->me_value); /* New code follows. */ ep->me_key->ob_refcnt -= 1; if (ep->me_value) ep->me_value->ob_refcnt -= 1; } } This does everything the DECREF macros did *except* to call the platform free() on the now-dead string-object keys. So all that memory leaks, and creation times start to zoom as my box runs out of RAM. "destruction" times stay very steady, though (using time.clock() here, a much better timer on Windows than time.time()): size: 10000, destruction: 0.20 (usec/elem) size: 20000, destruction: 0.20 (usec/elem) size: 50000, destruction: 0.23 (usec/elem) size: 100000, destruction: 0.22 (usec/elem) size: 200000, destruction: 0.22 (usec/elem) size: 400000, destruction: 0.23 (usec/elem) size: 600000, destruction: 0.21 (usec/elem) size: 800000, destruction: 0.22 (usec/elem) I can't push it much beyond that, as "the usual" result of provking Win9X into disk thrashing is a system crash (indeed, I endured 4 reboots before giving up on letting this run thru a million). So, on this box, all the nastiness is due to MS's free() implementation. > ... > You've convinced/reassured me that it can't be Python. I'm not convinced > it's the cache. That basically leaves free(). I'm curious if anybody > else has seen this behaviour. I hope some more people try this You can be sure that everyone who suggested to exit the program via os._exit() has seen similar behavior in anger . Alas, every platform acts differently -- even different flavors of Windows have radically different malloc/free performance characteristics. Win9X is usually the worst of the lot, so I'm amazed that your flavor of Linux's performance made Win9X look stellar in comparison. I can't make time for it now, but "someone should" try this test using Vladimir Marangozov's PyMalloc package (shipped with Python 2.1 but turned off by default -- see the 2.1 NEWS file). malloc-works-best-when-it-isn't-used-ly y'rs - tim From mwh at python.net Thu Nov 22 08:51:30 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 22 Nov 2001 13:51:30 GMT Subject: Proper usage of properties in 2.2 References: Message-ID: sandskyfly at hotmail.com (Sandy Norton) writes: > Hi, > > I've been playing round with properties in 2.2b2 and I'm having a bit > of trouble understanding what I _shouldn't_ be doing when I use them. > For example this simple code doesn't work: > > Python 2.2b2 (#26, Nov 16 2001, 11:44:11) [MSC 32 bit (Intel)] on > win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> Example #1 > >>> class Room: Room needs to be a new-style class! Change that to >>> class Room(object): and it will work as you expect. (If it makes you feel better, this confused me for ten minutes and had me with my head in the source before I thought of this...). > Also another minor question: how does one get access to the doc string > of the property? r.__class__.area.__doc__, I think. Cheers, M. -- I'm okay with intellegent buildings, I'm okay with non-sentient buildings. I have serious reservations about stupid buildings. -- Dan Sheppard, ucam.chat (from Owen Dunn's summary of the year) From cfelling at iae.nl Thu Nov 29 16:58:17 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 29 Nov 2001 22:58:17 +0100 Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Message-ID: <9u6b1p$9tr$1@animus.fel.iae.nl> Dan Allen wrote: > Say I have > mylist = ['one','two','three'] > which I presume is a "tuple" as I have been scanning the manual. Now, it's a list. A tuple would use () instead of []. Both are sequnces. > is there a way to run the php-like function in_array() on this. I don't know php, but from the example code I guess you're looking for: if "four" in mylist: print "your value was found" else: print "your value was not fond" > Consider this, I want to know if one of the values in that tuple is > exactly equal to "four". The answer of course is no, but how would I > find it. Here is what I have so far, which works, but it is ugly.. > d = {} > for value in mylist > d[value] = 1 > try: > if d['four']: > print "your value was found" > except: > print "your value was not found" > Two question here, is that a bad use of try/except? Second is, is I personally would go for the simpler: if d.has_key("four"): .... > there an array_flip, or do you just have to do what I did above? I and what is array_flip supposed to be doing? -- groetjes, carel From cezary at bigfoot.com Fri Nov 16 07:05:32 2001 From: cezary at bigfoot.com (Cezary Biernacki) Date: Fri, 16 Nov 2001 13:05:32 +0100 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <3BF2C715.7050400@bigfoot.com> <97ae44ee.0111150043.4382fe2f@posting.google.com> Message-ID: <3BF5010C.9090707@bigfoot.com> Stephen wrote: > Thanks for the help, Cezary >>So, for really testing server you should launch clients from another >>machine(s). >> > > Sorry, you've lost me here. If the server can't generate > threads quick enough to deal with the incoming connections, > how will moving the clients to another machine give the > server more time (except perhaps in introducing a network > delay) ? Your client threads also use processor time. When NUMTHREADS > 5 they can be sheduled before a server starts accepting connections. It doesn't depend on speed of the machine - faster processor -> faster clients generates new connections. -- CB From the1eagle at aol.com Sun Nov 4 03:46:57 2001 From: the1eagle at aol.com (The1Eagle) Date: 04 Nov 2001 08:46:57 GMT Subject: newbie question References: <8BxE7.171920$5A3.64506718@news1.rdc2.pa.home.com> Message-ID: <20011104034657.29820.00002527@mb-ch.aol.com> Thanks Gerhard and Terry From nhodgson at bigpond.net.au Fri Nov 16 16:29:36 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Fri, 16 Nov 2001 21:29:36 GMT Subject: python vs ecmascript References: Message-ID: <4zfJ7.342473$bY5.1434742@news-server.bigpond.net.au> Peoter Veili: > Anyone familiar with ECMAscript (JavaScript)? How does it > compare to Python? I studied ECMAscript last year, people > have an aversion to it from doing web client programming, > but it is a high-powered OO scripting language in its own right. I have done quite a bit of work in both languages and while I prefer Python, do not mind ECMAScript that much. ECMAScript benefits include a real standard (ECMA) definition and multiple implementations on a wide variety of platforms. For client-side scripting of web applications it is really the only viable cross-platform solution. Python's use of indentation, which is a big benefit for stand-alone code, is more difficult when interleaved with HTML or as inline code for event handlers. ECMAScript has been an easy language for newcomers and people who only want to do a minimal amount of scripting. However, ECMAScript is moving in the direction of a 'real' language with type declarations and similar features which are good for experienced developers but an impediment to this earlier usage group. Many of the points put forward by the other posters are also good, such as the large number of useful Python libraries. Neil From BPettersen at NAREX.com Thu Nov 29 18:12:48 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 29 Nov 2001 16:12:48 -0700 Subject: A modest indentation proposal Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192158C5A@admin56.narex.com> > From: Erann Gat [mailto:gat at jpl.nasa.gov] > [snip] > > I propose to use a semicolon at the end of a line to denote > the end of a block, e.g.: > > for i in l: # Colon signals beginning of block > foo() > baz(); boff() # Semicolon separating statements works as usual > bar(); # Semicolon at end of line signals end of block > biff() > > > This convention is 100% backwards-compatible with current > practice, that is, code written using this convention runs > with no problems in Python as it currently stands. This is currently correct code: for I in l: foo(); baz(); boff(); bar(); biff() FWIW, I don't see what block terminators have to do with large scale programming... -- bjorn From ajs at ix.netcom.com Sat Nov 10 09:36:58 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 10 Nov 2001 09:36:58 -0500 Subject: Teaching python (programming) to children Message-ID: <000d01c169f5$27e4e1e0$a9e1fea9@carol> >Piaget's work is considered mainstream and valid these days. I >suppose there are people who think it's horseshit, but there are also >some who think the earth is flat. Then maybe I just need change my strategy. Everything I say is also based on Piaget - retroactively. >I don't think Papert had any particular agenda to use Logo. Logo was >just a vehicle that he had available. He could just as happily have >used something else if he had it. What might he come up with using out-of-the-box Python, maybe a 20 line underlying module, and a text editor? Probably plenty. Truely succinct and Pythonic. It always seem to me that *I* am being the Python advocate in these discussions - and fighting something uphill within the Python community in being so. Confusing. Art From oktay_safak at yahoo.com Tue Nov 13 10:18:05 2001 From: oktay_safak at yahoo.com (Oktay Safak) Date: Tue, 13 Nov 2001 17:18:05 +0200 Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> <3BF12F7A.DF1938B8@engcorp.com> Message-ID: <002001c16dae$d2d81c40$0200a8c0@b> ----- Original Message ----- From: "Peter Hansen" > > Sounded like another class assignment to me... > > (Am I becoming paranoid? :) I think that's right (I mean the class assignment issue :) _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From mickey at tm.informatik.uni-frankfurt.de Sun Nov 11 14:27:18 2001 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 11 Nov 2001 21:27:18 +0200 Subject: A Python GUI Book. Message-ID: <3beedf26@nntp.server.uni-frankfurt.de> Hi group, I'm currently writing a Python GUI book, where several toolkits (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... of course... Tkinter) are presented and explained. My idea is that besides going into some detail of every Toolkit I construct _one_ application scenario with a skeleton, which I later complete with each of the toolkits. This should give the reader the means to choose the toolkit which matches their personal taste & programming philosophy. Given this approach, the main question I'm currently trying to figure out is: What application shall I present? It must be complicated enough to show some advanced topics (not only presenting a tour of the widgets and voila...) but at the same time small enough to cover it within 50 pages or so (remember: for each toolkit!). I first thought of some contact application - in outlook style - or some kind of presentation program - powerpoint style - ... here's a plea for your input. What do you think would be a good application to show the basics and a few more sophisticated topics in programming GUI applications with Python? Apart from this concrete question do you have some topics which you think should be a _must_ in such a book? Imagine you're a not a total newbie in python GUI programming... what did you want to read in such a book? thanks for your input! Yours, Mickey. From phr-n2001d at nightsong.com Sun Nov 4 16:38:44 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 04 Nov 2001 13:38:44 -0800 Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> <7xy9lnzmo9.fsf@ruckus.brouhaha.com> <3BE5AE8C.30BDCF3D@nospamco.com> Message-ID: <7xn1229py3.fsf@ruckus.brouhaha.com> Fred writes: > It does look like a bug. os.exit(0) ends the program right after the > print statements, taking about 1/3 of the time. > > I see another respondent to this thread has done more tests and > has opened a bug report. Yes, that was interesting. I hope it gets fixed. > > Also, counting the entries with len(nacc.keys()) is pretty horrendous > > if the number of entries is very large (several million). For 120,000 > > it's probably tolerable. > > > > If you expect to get a much larger number of distinct values (like > > 10's or 100's of million distinct) in your 100 GB data set, you > > probably don't want to use Python dictionaries to remember them. The > > overhead per value is rather large, like dozens of bytes. > > > > Well, it looks like I'm going to top out at about 600K values for the > three variables; so far the times look pretty good. A first test had python > beating compiled fortran, SAS and perl. 600K values should be tolerable on a largish PC these days (e.g. 256M or more of memory). Memory is so cheap these days that it's probably easier to add a GB of ram if you need it, than to mess with fancy algorithms. From neal at metaslash.com Tue Nov 6 11:47:28 2001 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 06 Nov 2001 11:47:28 -0500 Subject: Tkinter bind single key References: Message-ID: <3BE81420.FD104F8D@metaslash.com> John Hunter wrote: Try using the "dialog". In your example, this would be root. ie: root.bind('z', press_z) I think I had to do this to get keys to work. Neal -- > I am working with the key 'z' to simplify. All I want to do is bind > an event to the 'z' keypress. I have tried (without success): > > frame.bind('', press_z) > frame.bind('', press_z) > frame.bind('', press_z) > frame.bind('KeyPress-z', press_z) > frame.bind('Key-z', press_z) > frame.bind('z', press_z) > > Ditto for 'plus' > > My keysymdef entries are: > > #define XK_z 0x07a > #define XK_plus 0x02b > > Here is the test script; the mouse binding works fine: > > #!/usr/local/bin/python > > from Tkinter import * > > def press_z(event): > print 'You pressed z' > > def press_mouse(event): > print 'You pressed mouse-1' > > root = Tk() > frame = Frame(root, width=500,height=500) > frame.bind('', press_z) > frame.bind('', press_mouse) > frame.pack() > root.mainloop() From tdickenson at devmail.geminidataloggers.co.uk Wed Nov 28 09:48:27 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Wed, 28 Nov 2001 14:48:27 +0000 Subject: windows to linux pickled objects? References: Message-ID: <87u90u0jp8ih3uh5gvh142ight387qs49t@4ax.com> >The size >shouldn't have actually changed at all AFAIK. Different versions of python can write slightly different pickles, and it is different between pickle.py and cPickle too. Despite being different, they are all compatible. Toby Dickenson tdickenson at geminidataloggers.com From mgerrans at ix.netcom.com Fri Nov 16 03:25:10 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Fri, 16 Nov 2001 00:25:10 -0800 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> <9t1uce$5d8$1@nntp1-cm.news.eni.net> Message-ID: <9t2ija$qtl$1@slb5.atl.mindspring.net> > Didn't we discuss this a month or two ago? There was... Well, one simple solution is to continue to discuss it here for another 17 months or so and we'll have doubled the performance without a single change to the interpreter, via Moore's Law (unless it is repealed by then). :-) - mfg From mwh at python.net Wed Nov 7 05:00:00 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 7 Nov 2001 10:00:00 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: "Tim Peters" writes: > No threads on c.l.py end up being about Hitler. Not even this one! Indeed, > I expect this one to veer into transfinite cardinals before I finish this > sentence. That hasn't happened for a few years has it? I wonder whether the possibilities for tweaking memory allocators are uncountably infinite or merely countable? > python-needs-a-transfinite-cardinal-type-ly y'rs - tim set-theory-brr-ly y'rs M. -- LINTILLA: You could take some evening classes. ARTHUR: What, here? LINTILLA: Yes, I've got a bottle of them. Little pink ones. -- The Hitch-Hikers Guide to the Galaxy, Episode 12 From logiplexsoftware at earthlink.net Thu Nov 1 15:15:15 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 1 Nov 2001 12:15:15 -0800 Subject: python development practices? In-Reply-To: <01110111582600.08187@logiplex1.logiplex.net> References: <01110111582600.08187@logiplex1.logiplex.net> Message-ID: <01110112151501.08187@logiplex1.logiplex.net> As an aside, it wouldn't surprise me to find that many people who "can't upgrade from 1.5.2" because some application they've written breaks under 2.x are the victims of name collisions introduced in newer versions of the standard libraries that they are deriving from. The results of such collisions would be highly unpredictable and difficult to track down. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From shalehperry at home.com Fri Nov 2 02:05:50 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Thu, 01 Nov 2001 23:05:50 -0800 (PST) Subject: Python 2.1 syntax to Python 1.5.2 In-Reply-To: Message-ID: On 02-Nov-2001 Stuart Bishop wrote: > Before I rewrite all my lovely list comprehensions and > 'print >>' statements into python 1.5 syntax, I don't suppose > anyone has code that automagically does the translation? > the list comprehension could be tricky, the print is fairly easy. From steve at clublinux.org Tue Nov 6 08:17:53 2001 From: steve at clublinux.org (steve) Date: Tue, 06 Nov 2001 07:17:53 -0600 Subject: Converting exponential numbers to strings. References: <32921e0b.0111051350.41e35f26@posting.google.com> <7xpu6w6es0.fsf@ruckus.brouhaha.com> Message-ID: <3BE7E301.3E5EDDF1@clublinux.org> Hi, > How about this: > try: > x = float(s) > result = 1 > except: > result = 0 Genious. Short and simple. I like it. Thank you. One more question about string processing. I've written a small report formating routine that prints everything as strings. The reason for this is that I want to be able to add commas, floating dollar signs, etc. to the report and printing everything as a string seemed to be the easiest way to perform such tasks. I run into the same problem when trying to process the string from printing when I use the str() function. Is there another way to convert a number to a string that will return the number in a non-exponential format? (e.g. return .000085 instead of 8.5e-5?) Thanks again for your help, Steve From fperez at pizero.colorado.edu Wed Nov 14 18:02:06 2001 From: fperez at pizero.colorado.edu (=?ISO-8859-1?Q?Fernando_P=E9rez?=) Date: Wed, 14 Nov 2001 16:02:06 -0700 Subject: Problem with .pth files under linux In-Reply-To: References: Message-ID: > I'm sure this is simple and stupid, but I still don't know what's going > on. I have some modules without a package structure (no __init__.py) but > which have a .pth file. Specifically, Numeric. It comes in its own > directory: site-packages/Numeric, and in site-packages I have a file > Numeric.pth whose contents is simply 'Numeric' (no quotes). Yet import > Numeric doesn't work! I solved it by hand-coding Numeric into sys.path, > but it annoys me and I have the same problem with other modules I'll need > to use soon. I'm replying to myself b/c some people made suggestions but none quite worked. However they got me on track and eventually I found a solution, this might help others. Basically the path search mechanism in python is a bit primitive for non-packages (modules without an __init__.py). Packages are fine. For non-packages, from: http://www.python.org/doc/current/lib/module-site.html here's the relevant part: It starts by constructing up to four directories from a head and a tail part. For the head part, it uses sys.prefix and sys.exec_prefix; empty heads are skipped. For the tail part, it uses the empty string (on Macintosh or Windows) or it uses first lib/python2.1/site-packages and then lib/site-python (on Unix). For each of the distinct head-tail combinations, it sees if it refers to an existing directory, and if so, adds to sys.path, and also inspects the path for configuration files. A path configuration file is a file whose name has the form package.pth; its contents are additional items (one per line) to be added to sys.path. Non-existing items are never added to sys.path, but no check is made that the item refers to a directory (rather than a file). No item is added to sys.path more than once. Blank lines and lines beginning with # are skipped. Lines starting with import are executed. So the point is, your .pth files have to be in your normal site-packages hierarchy. But my problem is that my python is installed in /usr, but I also have a /usr/local/lib/python2.1/site-packages directory where I put things I get off the web. I like it that way because when I upgrade linux, I can just let the installer wipe /usr and all the things I have in /usr/local remain. Since the searcher will only expand on sys.prefix and sys.exec_prefix (and it's a *bad* idea changing these to anything that's not your real python directory), things that are not under that will not be easily found (as .pth files). I found a workaround: since I don't have a /usr/lib/site-python directory (I'm guessing this is for old compatibility), I made that be a symlink to /usr/local/lib/site-packages. Now all the .pth's in /usr/local/lib/site-packages are found! However, this is a kludgy solution. I understand that modules should be moving to a proper package structure, but until everyone in the world does it, it wouldn't hurt if Python loaded .pth files found *anywhere* in sys.path, not just under sys.prefix and sys.exec_prefix + those special 'tails' which are hard-coded. Anyway. I posted this long story so at least there's a documented solution to this problem *somewhere*, since nobody seemed quite sure what the right approach was and it took me a while to piece things together. Cheers, f. From hungjunglu at yahoo.com Thu Nov 22 13:13:08 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 22 Nov 2001 10:13:08 -0800 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> <9t9h3j$7r9$1@tyfon.itea.ntnu.no> Message-ID: <8ef9bea6.0111221013.327f5292@posting.google.com> "Magnus Lie Hetland" wrote in message news:<9t9h3j$7r9$1 at tyfon.itea.ntnu.no>... > Well... If you want an evil solution: > locals()[['a','b'][idx]] = val Two more: exec '%s=val'%'ab'[idx] exec '%x=val'%(10+idx) Hung Jung :) From dalke at dalkescientific.com Thu Nov 8 15:12:15 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 8 Nov 2001 13:12:15 -0700 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> <9sebn1$28g$1@news.lth.se> Message-ID: <9sepde$gnf$1@slb4.atl.mindspring.net> Paul Winkler: >Anybody done such studies [of software development productivity] >with python in the list? I'm curious how it would fare. Quoting from the Python language comparison page at http://www.python.org/doc/Comparisons.html ] Lutz Prechelt wrote "An Empirical Comparison of C, C++, Java, ] Perl, Python, Rexx, and Tcl for a Search/String-Processing Program ] in which he compares productivity and program performance for 80 ] different implementations of the same requirements, in 7 languages. The referenced URL is http://wwwipd.ira.uka.de/~prechelt/Biblio/#jccpprtTR Andrew dalke at dalkescientific.com From mkelly2002NOSPAM at earthlink.net Sun Nov 25 21:47:44 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Mon, 26 Nov 2001 02:47:44 GMT Subject: win32process question References: Message-ID: On Mon, 26 Nov 2001 09:17:47 +1100, Tom Harris wrote: Hi Tom. You might find this article of interest: http://www.wdj.com/articles/1999/9907/9907c/9907c.htm Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From nas at python.ca Tue Nov 13 15:54:33 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 13 Nov 2001 12:54:33 -0800 Subject: Stopping exception unwinding at exit In-Reply-To: <20011113204200.50877.qmail@web21106.mail.yahoo.com>; from daves_spam_dodging_account@yahoo.com on Tue, Nov 13, 2001 at 12:42:00PM -0800 References: <20011113204200.50877.qmail@web21106.mail.yahoo.com> Message-ID: <20011113125433.B27571@glacier.arctrix.com> Try changing the last bit to: try: ... except SystemExit: raise except: Puke("An unknown exception was raised in the script.") Cheers, Neil From achim.domma at syynx.de Sun Nov 11 11:25:22 2001 From: achim.domma at syynx.de (Achim Domma) Date: Sun, 11 Nov 2001 17:25:22 +0100 Subject: Is this considered black magic? References: Message-ID: <9sm8kb$tmm$01$1@news.t-online.com> Hi, I would try to put your foreach in a class : ----------------------- class Ham: def say(self): print "I am Ham, and I don't want any arguments, thank you." def speak_up(self, arg): print 'I am Ham, and my arguments are %s' % arg class Eggs: def speak_up(self, arg='bacon'): print 'I am Eggs, and my arguments are %s' % arg class Spam: def shout(self, arg1, arg2='sausage'): print 'I AM SPAM AND MY ARGUMENTS ARE %s AND %s' % (arg1, arg2) class FktCall: def __init__(self,name,fkt): self.name = name self.fkt = fkt def __call__(self,*args): return self.fkt(self.name,*args) class ClusteredCall: def __init__(self,*items): self.items = items def do_foreach(self,name_key,*args): for o in self.items: try: getattr(o, name_key)(*args) except AttributeError: pass def __getattr__(self,attr): return FktCall(attr,self.do_foreach) ########################## if __name__ == '__main__': cluster = ClusteredCall(Ham(),Eggs(),Spam()) cluster.shout('sandwich') cluster.speak_up('test') ----------------------- I'm no Python Expert and don't know how much performance you loose due to the extra level of indirection. But in my opinion the client code (i.e. cluster.shout(...)) is much more readable this way. greetings Achim From philh at comuno.freeserve.co.uk Mon Nov 12 11:41:26 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 12 Nov 2001 16:41:26 +0000 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> Message-ID: >Michael 'Mickey' Lauer wrote: > >> Hi group, >> >> I'm currently writing a Python GUI book, where several toolkits >> (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... >> of course... Tkinter) are presented and explained. >> My idea is that besides going into some detail of every Toolkit I >> construct _one_ application scenario with a skeleton, which I >> later complete with each of the toolkits. >> This should give the reader the means to choose the toolkit >> which matches their personal taste & programming philosophy. >> >> Given this approach, the main question I'm currently trying to >> figure out is: What application shall I present? It must be complicated >> enough to show some advanced topics (not only presenting a tour of >> the widgets and voila...) but at the same time small enough to cover >> it within 50 pages or so (remember: for each toolkit!). How about a chess-playing program? It wouldn't have to make chess moves (there are engines such as gnuchess that do that), but it would have to display the board, allow people to make moves, put the moves on the board, display a clock for how much time people have used, etc. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From gmfawcett at operamail.com Wed Nov 7 13:31:07 2001 From: gmfawcett at operamail.com (Graham Fawcett) Date: Wed, 7 Nov 2001 13:31:07 -0500 Subject: Passing object as param to Python COM server Message-ID: <3BE97F14@operamail.com> Hi folks, I've got a COM server written in Python, and it's running great (thank you to EVERYONE who made this marvellous tech possible). But I've got a question about passing parameters in method calls on my server. I have a VB script in PowerPoint that creates an instance of my server. I'd like to pass a reference to the PowerPoint application to my server, for example: 'in the PowerPoint macro, sub PassExample(pptapp as Application) Set myserver = CreateObject("UWindsor.MyServer") myserver.QueryApp pttapp end sub # in the server, def QueryApp(self, app): #Name should be a valid attribute of a PowerPoint.Application print app.Name ... Running the VB macro incurs an AttributeError: Name when the QueryApp method is called. The object (app) passed to my server is a PyIDispatch object. What do I have to do to make my server recognize this as a PowerPoint.Application object so that I can access its attributes (and hopefully invoke its methods)? Apologies for my lack of what is probably basic COM knowledge. Thanks, everyone. -- Graham From eppstein at ics.uci.edu Thu Nov 15 17:04:08 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 15 Nov 2001 14:04:08 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <2YTI7.30749$vQ1.1137481@atlpnn01.usenetserver.com> Message-ID: In article <2YTI7.30749$vQ1.1137481 at atlpnn01.usenetserver.com>, "Steve Holden" wrote: > Whether or not either comma is (even optionally) necessary syntactically, > the main problem with any such representation is the impedance mismatch with > [x]range(), which are built on the half-open interval. Particularly > difficult to explain the mismatch to newbies, I think. > > If I have a vote, I'm afraid it's -1 OK, but my problem is precisely the impedance mismatch between range and newbies -- do you really think that they come pre-equipped with an understanding of range and half-open intervals? I am happy enough with [x]range when it comes to programs that I write for myself, but would like a more intuitive syntax for using in algorithms lectures where I can't expect the students to know Python syntax. It sounds like too many Pythonists see this as a non-problem, so it is unlikely to change and I will continue using non-Python for my lectures. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jslowery at hotmail.com Fri Nov 30 21:48:58 2001 From: jslowery at hotmail.com (Jeremy Lowery) Date: Fri, 30 Nov 2001 20:48:58 -0600 Subject: load a class dynamically Message-ID: I know that implementing this may be a little bit of work, but could someone point me in the right direction? Have a text file that only contains a class definition, or just a string for the sake of simplicity. str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1" #the magical code goes here. obj = myClass() # of course, it doesn't have to be called like that, but to #get the ability to instantainate that class. Jeremy From sabren at manifestation.com Thu Nov 29 09:47:08 2001 From: sabren at manifestation.com (Michal Wallace) Date: Thu, 29 Nov 2001 09:47:08 -0500 (EST) Subject: pypan In-Reply-To: <655abd4a.0111290425.5cbfa108@posting.google.com> Message-ID: On 29 Nov 2001, e toffi wrote: > i put this in a separate posting in anticipation (or > rather in case) of a long thread. > > i wish to start a pypan -- something similar to cpan, but > for python, obviously. You know, this comes up every few weeks, and we always talk about it in terms of CPAN. Why? Wey're the *python* group. Why can't we do something cooler? :) Why don't we model it after, say Napster? (What's the license like on Mojo Nation?) Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From mwh at python.net Tue Nov 27 06:01:26 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 27 Nov 2001 06:01:26 -0500 (EST) Subject: bugs in `gc.get_referents()' In-Reply-To: <200111271036.fARAa6415091@paros.informatik.hu-berlin.de> Message-ID: On Tue, 27 Nov 2001, Martin von Loewis wrote: > > > Again, this might go away with the patch. get_referents isn't supposed > > > to trigger a garbage collection. > > > > All those PyList_Appends might, though. > > How could that happen? PyList_Append calls ins1, which calls (through > NRESIZE) PyMem_RESIZE, which is realloc. Apart from that, and apart > from the error cases (which lead to immediate abortion of > get_referrers), it only does INCREFs. Oh yeah. Sorry, brain fart. Something like it could trigger a gc in other languages; not this one. Oops. M. From phr-n2001d at nightsong.com Thu Nov 15 09:29:39 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 06:29:39 -0800 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <9t0du9$f2t$1@pea.uk.research.att.com> <7xbsi4cg6m.fsf@ruckus.brouhaha.com> <9t0ijd$is9$1@pea.uk.research.att.com> Message-ID: <7xherw5cq4.fsf@ruckus.brouhaha.com> Duncan Grisby writes: > >If it's on the local machine, why mess with TCP at all, instead of using > >AF_UNIX? I'm not sure whether the OP intended to run locally tough. > > Indeed, using Unix sockets makes it 20% to 25% faster than the TCP > loopback. Somewhere along the line I got the impression we were > talking about TCP, though. Another idea, how about using preforking (like Apache) instead of threading or asyncore? From phr-n2001d at nightsong.com Tue Nov 13 01:20:49 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 12 Nov 2001 22:20:49 -0800 Subject: How much is set in stone? References: Message-ID: <7xeln319a6.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > On the bright side of darkness , not all of cPickle got > documented. We'll try to repair that for 2.2. In particular, you > can set a find_global attribute on a cPickle Unpickler to supply > your own function for resolving names, and of special interest is > that if you set it to None, the Unpickler won't import modules or > unpickle class instances at all. You could, of course, also supply > a function that accetps only a set of blessed names (etc). Great! This sounds like a pretty flexible way to fix the problem, so it's cool that the code was already there for it. From sandskyfly at hotmail.com Fri Nov 16 18:47:29 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 16 Nov 2001 15:47:29 -0800 Subject: CGIHTTPServer and Win2k References: <4q39vt4silvue8rl0qv4ff4tar6942r9g3@4ax.com> Message-ID: "Steve Holden" wrote in message news:... > I suspect this is a documentation bug, because since 2.0 (?) the code uses > fork() if it can, popen2() otherwise; if neither of these are available it > will run imported Python scripts as CGIs. Here's a quote from the docstring > at the head of the 2.0 module: > > """If the os.fork() function is not present (e.g. on Windows), os.popen2() > is used as a fallback, with slightly altered semantics; if that function is > not present either (e.g. on Macintosh), only Python scripts are supported, > and they are executed by the current process.""" Wonderful news... I was under the impression that CGIHTTPServer didn't work on windows. You just made my day. Thanks. Sandy From phr-n2001d at nightsong.com Thu Nov 1 22:05:16 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 01 Nov 2001 19:05:16 -0800 Subject: Source files? References: <3BE200BA.3F271DA0@ix.netcom.com> Message-ID: <7x668toosz.fsf@ruckus.brouhaha.com> Jive Dadson writes: > I just learned about Python a couple of days ago. A customer suggested > we use it (rather than Java) for an application interface. So, I > downloaded the latest beta version, Python-2_2b1.exe, and installed it. > I was under the impression that it came with open source. I can't find > any source files. Dot-h, yes. Dot-c or dot-cpp, no. How does one > obtain them? They're at www.python.org, you must have just not downloaded the right tarball. From matt at mondoinfo.com Sun Nov 11 22:52:10 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Mon, 12 Nov 2001 03:52:10 GMT Subject: agrep equivalent? References: <3BEEF857.D8F6438B@uniserve.com> Message-ID: On Sun, 11 Nov 2001 15:14:47 -0700, bvdpoel at uniserve.com wrote: >Is there an agrep or something similar module for python? Right now >I'm calling this though the shell, but it be cleaner to do this >natively... Agrep has been wrapped as a Python module. It's at: http://www.bio.cam.ac.uk/~mw263/pyagrep.html I've used it though not lately and it seems to work fine. You may also want to have a look at difflib which is new in Python 2.1's standard library. It takes a slightly different approach but depending on what you're doing it may also be useful. Regards, Matt From tjreedy at home.com Wed Nov 14 12:39:32 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 14 Nov 2001 17:39:32 GMT Subject: Infinite lists and generators References: Message-ID: "Steven D. Majewski" wrote in message news:mailman.1005757000.20449.python-list at python.org... > > > On Wed, 14 Nov 2001, Terry Reedy wrote: > > The problem with filtering an infinite stream is that if there are > > only N items that pass, the filter will never halt looking for the > > N+1st. > > You just do 'lazy' filtering -- in fact you try to avoid forcing > evaluation of the whole stream until the very end, and then you > stop when you get a sufficient number, or reach the end of the > stream. The topic was infinite streams that have no end! > ( And if possible, you may not have to force full evaluation > at all if you can do your output one item at a time. You should > avoid list comprehensions though, which force evaluation -- kind > of like Icon's 'every' ) > > Filter is just: > > def filter( f, stream ): > for item in stream: > if f(item): yield item This is what I had in mind when I wrote my comment. To illustrate, try def n_true(n): if n < 0: raise StopIteration while n: yield n n -= 1 while 1: yield 0 for item in filter(lambda x: x, n_true(10)): print item Terry J. Reedy From nhodgson at bigpond.net.au Mon Nov 12 18:19:25 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 12 Nov 2001 23:19:25 GMT Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: <1OYH7.330231$bY5.1354924@news-server.bigpond.net.au> Wolfgang Strobl: > Again, thanks for the nice patch, and sorry for the confusion. What > about convincing Mark Hammond about adding it to the standard > distribution? It is not really high enough quality for me to convince Mark of this. It should be its own menu item (File | E&xecute?) or be integrated into the Run Script dialog as an option. If it was in the Run Script dialog, or its own dialog, then there could also be check boxes for using the -i or for output to go to the Interactive Window. I'm too lazy to do these for now although they may get added as I need them. For this feature, it was my intention to not touch much code as there is more scope for failure in applying a multi-part patch. Using Scroll Lock as a modifier is really poor UI design ;) Neil From mathiasm at pvv.org Tue Nov 13 13:26:37 2001 From: mathiasm at pvv.org (Mathias Mølster Lidal) Date: 13 Nov 2001 19:26:37 +0100 Subject: input References: <9srncp$15ljf7$1@ID-69142.news.dfncis.de> Message-ID: "Andreas Penzel" writes: > Hello NG! > > I am new in the world of python. > First I made some Tuturials, but what I could not find: > > How to get an input from the console? > > for example: the program starts, givs some prints on the screen and now I > want an input from the user like this: print "please type your name:" > > the input should get into to a variable like user_input = ??? > > I hope I could explain the problem, that everyone can follow my minds. > You can use the built-in function raw_input(), like this: user_input = raw_input("please type your name:") this will print the string "please type your name", recieve the input and place it int user_input. raw_input is documented here: http://www.python.org/doc/current/lib/built-in-funcs.html Mathias Lidal From dswegen at allstor-sw.co.uk Mon Nov 12 07:50:34 2001 From: dswegen at allstor-sw.co.uk (Dave Swegen) Date: Mon, 12 Nov 2001 12:50:34 +0000 Subject: Running program off CD In-Reply-To: <00f501c16b77$2f7dac10$0601a8c0@mxm1200> References: <00f501c16b77$2f7dac10$0601a8c0@mxm1200> Message-ID: <20011112125034.U11733@software.plasmon> On Mon, Nov 12, 2001 at 01:40:18PM +0100, maxm wrote: > From: "Dave Swegen" > > > The platforms I potentially need to support are linux, solaris, win 9x, > > win NT and win 2k. It would be ideal if all these could be placed on one > > CD. > > I dont think that would be legal, Besides it would have to be one heck of a > CD ;-) > Oops, didn't make myself clear enough. What I want our customers to do is simply launch the appropriate version of python for their OS off the CD, not boot the OS itself... Cheers Dave From steve at ferg.org Fri Nov 2 14:22:47 2001 From: steve at ferg.org (Stephen Ferg) Date: 2 Nov 2001 11:22:47 -0800 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> <3BE20B6E.F9275CD0@cosc.canterbury.ac.nz> <9rt3co$rid$1@slb2.atl.mindspring.net> Message-ID: > Not that it's used all that often, but there is an input builtin, so in the > interest of not hiding builtin functions, it's probably best to get into the > habit of not using them as local variable names. Good point. I used "input" because that is the way that it is referred to in the REXX documentation. But that can be changed. From kentsmith at dxsys.com Sat Nov 10 20:35:26 2001 From: kentsmith at dxsys.com (kentsmith at dxsys.com) Date: Sat, 10 Nov 2001 20:35:26 -0500 Subject: Using browser as interface to python app References: Message-ID: Have you considered a GUI built with Flash 5.0? It's very nice for straightforward business apps, and is pretty much agnostic on the browser and screen-resolution front. As long as you're just using Windows-type widgets, etc., there's really no loading time. You'll probably think it's overkill, but it's really no harder than HTML (and a heck of a lot simpler than Tkinter, etc.) You're likely to spend an awful lot of time futzing with HTML and Javascript in order to serve up those web pages... From philh at comuno.freeserve.co.uk Fri Nov 30 09:25:12 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 30 Nov 2001 14:25:12 +0000 Subject: A modest indentation proposal References: Message-ID: On Thu, 29 Nov 2001 14:09:28 -0800, Erann Gat wrote: > >The subject of syntactically-significant indentation seems to dominate a >lot of discussions on Python. Personally I've found it to be less of a >problem than I thought it would be, but annoying nonetheless. It also IMO >makes the language unsuitable for mission-critical applications. It's >just too easy to screw up indentation (particularly when cutting and >pasting large blocks of code) without realizing it. I held off learning Python for a year because I disliked the indentation so much. But then when I started learning it, I found it was not a problem, in fact it makes the program look a lot nicer. If I ever design a Python-like language, there will be 2 alternate syntaxes, one with and one without semantic indentation. So people will be able to write if x > 3: a := b + c print a or: if x > 3: { a := b + c; print a; } (Though why anyone would prefer the second way is beyond me). The language would be stored internally in a form resembling the upper of the two, and there would be automatic translators so everyone could see it the way they liked, with {} or not, with whatever number of characters per indentation they liked, spaces/tabs, etc. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From kragen at canonical.org Fri Nov 23 22:53:11 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 23 Nov 2001 22:53:11 -0500 Subject: Strange thing: file.close did not show error but work wrong References: <9tho04$2or14$1@ID-11957.news.dfncis.de> Message-ID: <83r8qovn88.fsf@panacea.canonical.org> "Emile van Sebille" writes: > "wqhdebian" wrote in message > news:db288b61.0111211822.2e903177 at posting.google.com... > > fdw.close######################### When I use like this ,there is no > > warning and > > ##############any error message,but the file do not have been > > writen.After I change back to fdw.close(),Then it work well. > > Yes, this is all as it should be. It's semantically consistent with the rest of Python, but it's suboptimal from a human-factors perspective, IMHO; people who are used to Perl or Delphi or Pascal will expect it to call fdw.close. It would be nice if the interpreter were smart enough to issue a warning in this case: a method is gotten and then immediately discarded. From sholden at holdenweb.com Thu Nov 8 08:04:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Nov 2001 08:04:19 -0500 Subject: how to call a stored function in Oracle References: <25c120d1.0111071216.1947ca09@posting.google.com> Message-ID: <2mvG7.5619$%g7.266054@atlpnn01.usenetserver.com> "Tom Hines" wrote in message news:25c120d1.0111071216.1947ca09 at posting.google.com... > Hi. I'm using ActivePython 2.1.212 and MS ODBC driver for Oracle. I > am able to call a stored procedure that returns a cursor, but I > haven't been able to figure out how to call a stored function or a > procedure that has an output parameter. > > # this works > schools = "" > ret = cur.execute( > "{Call MYPKG.MYPROC (?, {resultset 50, outSchools})}", > ('myparam', schools)) > As you would expect it to, because the module can replace the parameter marker with the *value* of the provided parameter. > > # this doesn't work > retparam = 0 > ret = cur.execute("{? = Call MYPKG.MYFUNC (?)}", > (retparam, 5341562)) > This won't work because here you are trying to provide a Python *name* and somehow have the driver automagically have the output from the stored procedure pushed through into the Python namespace. I don't have examples of stored procedures to show me how to do what you want. You *might* find useful information in or near http://aspn.activestate.com/ASPN/Mail/Message/db-sig/775892 > I've tried a million combinations trying to get it to work, but I > either get > > dbi.internal-error: [Microsoft][ODBC driver for Oracle]Invalid > parameter type in EXEC > ... because your call is becoming something like 0 = Call MYPKG.MYFUNC(5341562) > or > > dbi.program-error: [Microsoft][ODBC driver for > Oracle][Oracle]ORA-06550: line 1, column 7: > PLS-00306: wrong number or types of arguments in call to 'MYFUNC' > ORA-06550: line 1, column 7: > PL/SQL: Statement ignored in EXEC > > Anybody know how to do this? > Sorry, best I could to was try to explain. You probably need the .callproc() DB API call, but not all modules implement it, and you need to remember that output parameters are intended to return values directly into variables of an embedded programming environment such as PL/SQL. I'm not sure you can do what you want vie the DB API. regards Steve -- http://www.holdenweb.com/ From googoo at melbourne.cosmos.net.au Fri Nov 16 12:20:48 2001 From: googoo at melbourne.cosmos.net.au (Mark Hatherly) Date: Sat, 17 Nov 2001 04:20:48 +1100 Subject: html rendering question Message-ID: <1005963048.324574@ferrari.mikka.net.au> Hi, in my html variable 'playerhtml' I am trying to set the width attribute of a table to width="80%". However, my call to that variable results in the interpreter not recognizing what it sees as %". Is there a way setting my table to 80% of the browsr window without taking away the double quotes? From ngreco at softhome.net Mon Nov 12 14:23:34 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Mon, 12 Nov 2001 16:23:34 -0300 Subject: IsPython really O-O? In-Reply-To: <9soaj3$mev$1@news1.wdf.sap-ag.de> References: <9soaj3$mev$1@news1.wdf.sap-ag.de> Message-ID: <20011112162334.71141286.ngreco@softhome.net> On Mon, 12 Nov 2001 12:08:17 +0100 "Daniel Dittmar" wrote: > > But, Smalltalk is not Object Oriented, is **Object Based!** sometime ago, > in a > > smalltalk workshop, a line was drawed: > > Actually, the term 'object based' was used for languages like Ada when they > had encapsulation, but not inheritance. > Ok, call it "Object Technology", instead of the "traditional" "Object Oriented Technology" - Nahuel Greco Web Development - Open Source - - http://www.codelarvs.com.ar Game Programming - Research - - Freelance coding / sysadmin Networking. The answer is 42. - From bbollenbach at home.com Sun Nov 11 10:59:05 2001 From: bbollenbach at home.com (Brad Bollenbach) Date: Sun, 11 Nov 2001 15:59:05 GMT Subject: Is this considered black magic? References: Message-ID: "Laura Creighton" wrote in message news:mailman.1005485895.7082.python-list at python.org... > I want to do something which is conceptually very simple. Given a list of > objects, call make everybody call the same method you want to run. Sort > of like apply(), but for methods. apply() is made for methods as well. All it cares about is that you pass it a callable object as its first argument. Whether said callable object is foo, or x.foo is irrelevant. Either one is callable. > This is what I came up with: > > class Ham: > def say(self): > print "I am Ham, and I don't want any arguments, thank you." > > def speak_up(self, arg): > print 'I am Ham, and my arguments are %s' % arg > > class Eggs: > def speak_up(self, arg='bacon'): > print 'I am Eggs, and my arguments are %s' % arg > > class Spam: > def shout(self, arg1, arg2='sausage'): > print 'I AM SPAM AND MY ARGUMENTS ARE %s AND %s' % (arg1, arg2) > > def foreach(name_key, object_list, *args): > print 'foreach: args are ' + `args` > for object in object_list: > try: > object.__class__.__dict__[name_key](object, *args) > except KeyError: > pass > > ########################## > if __name__ == '__main__': > > h=Ham() > e=Eggs() > s=Spam() > > foreach ('say', [h, e, s]) > > foreach('speak_up', [e]) > foreach('speak_up', [h, e, s], 'sandwich') > foreach('speak_up', [h, e, s], None) #can i pass None? > > foreach('shout', [h, e, s], 'sandwich') > foreach('shout', [h, e, s], 'sandwich', 'beer') > -------------- > > This works: Indeed, but doesn't buy you much over a simple: for x in [h, e, s]: try: x.speak_up() # or apply(x.speak_up, (args, go, here)) if you're so inclined. except AttributeError: pass etc. > foreach: args are () > I am Ham, and I don't want any arguments, thank you. > foreach: args are () > I am Eggs, and my arguments are bacon > foreach: args are ('sandwich',) > I am Ham, and my arguments are sandwich > I am Eggs, and my arguments are sandwich > foreach: args are (None,) > I am Ham, and my arguments are None > I am Eggs, and my arguments are None > foreach: args are ('sandwich',) > I AM SPAM AND MY ARGUMENTS ARE sandwich AND sausage > foreach: args are ('sandwich', 'beer') > I AM SPAM AND MY ARGUMENTS ARE sandwich AND beer > ---------------- > > But is it white, grey, or black magic? Is there a better way I should have > done? Suggestions on what to name the function gratefully welcomed. > > Laura Creighton Hope that helps, Brad From Gareth.McCaughan at pobox.com Sat Nov 17 11:38:58 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sat, 17 Nov 2001 16:38:58 +0000 Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <7xg07fwn6l.fsf@ruckus.brouhaha.com> <3BF49DE9.95DC02FA@earthlink.net> Message-ID: Marco Antoniotti wrote: [Ben Wolfson:] > > I've often thought that would be a neat project, but I don't know any > > Lisp and hardly any Scheme. [Marco Antoniotti:] > Time to learn: http://www.alu.org. Common Lisp has very good > compilers both commercial and free (CMUCL - http://www.cons.org - is > Public Domain). And CMU CL's compiler is even called "Python". What more could you want? -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From buzzard at urubu.freeserve.co.uk Sun Nov 4 14:06:20 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Sun, 4 Nov 2001 19:06:20 -0000 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> Message-ID: <9s43jo$bku$1@news8.svr.pol.co.uk> "Gary Stephenson" wrote in message news:9s2hl0$u6o$1 at bugstomper.ihug.com.au... > > Gidday all! > > > You're missing one important link that is well represented in the > > python-list archives: The Goon Show -- with Spike Milligan and > > Peter Sellars. The Goon Show was a BBC radio show that was the > > inspiration for Monty Python. > > > > Spike Milligan beat out John Cleese for 1st place in the BBC's > > millenium poll of the top 10 funniest people: > > > > The patriot (scoundrel??) in me wishes to point out that Spike was / is an > Australian - though I imagine many Brits would be somewhat upset to learn > this . Yet he was born in India and (now) holds an Irish passport (as a result of having an Irish father (English mother? not sure)). Has he ever held an Australian passport? Duncan From andy47 at halfcooked.com Fri Nov 30 00:12:03 2001 From: andy47 at halfcooked.com (Andy Todd) Date: 30 Nov 2001 05:12:03 GMT Subject: Design tips requested for OOP forum system (using pickle) References: <56zN7.139$Jm.5630@stones> Message-ID: "Graham Ashton" wrote in <56zN7.139$Jm.5630 at stones>: >In article , "Simon >Willison" wrote: > >> I'm something of a Python newbie but I'm keen to learn so I've decided >> to throw myself in at the deep end. > >Good plan. The fastest way to learn, I reckon. > >> Anyway - I've decided to code a flat threaded web forum system ... using >> pickled objects in flat files to store the data (rather than using a >> database or a delimited flat file format of some sort). > >Here's an idea to think about; see if you can work out how to design a >fairly generic interface to your storage. Implement it first with pickle >(cPickle is much faster by the way) and then see if you can fiddle around >with it a bit so that it supports different storage systems (e.g. anydbm), >selectable at run time. Design patterns will be your friend here, and are >very interesting ways of taking your OOD knowledge beyond the standard >inheritance and delegation techniques. If your interface is generic enough it is but a small step from pickle to database type storage (either an object database like ZODB or a relational database). > >Top pickle tip (cPickle isn't available everywhere): > > try: > import cPickle > pickle = cPickle > except ImportError: > import pickle Let me save you a whole line of code here; try: import cPickle as pickle except ImportError: import pickle > [snip some great tips and hints] > For what it is worth, you will probably end up needing a fast efficient database server to store your data in. I know you are building this project as a learning exercise but consider porting the data storage of your (nearly) finished version to something like MySQL or PostgreSQL as an exercise in OO <-> RDBMS mapping. That one can twist even the finest minds into knots ;-) Regards, Andy -- Content free posts a speciality From skip at pobox.com Fri Nov 16 06:31:14 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 12:31:14 +0100 Subject: Sign Problem in Python In-Reply-To: References: Message-ID: <15348.63746.497258.456346@beluga.mojam.com> guy> query = eq('?mission') --> problem is the "?" Try using Unicode strings: query = eq(u'?mission') -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From phr-n2001d at nightsong.com Mon Nov 5 05:21:13 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 02:21:13 -0800 Subject: Teaching python (programming) to children References: Message-ID: <7xvggph61y.fsf@ruckus.brouhaha.com> Brian Elmegaard writes: > So, any comments are appreciated, especially on: Are there good reasons > for advocating python being a language one could teach children > programming with and are there perspectives in translating python to many > different languages in order to facilitate this, or will children not be > ready for learning programming before they have learnt English after all? The best-known attempts to teach children programming have been with the Logo language. See the book Mindstorms, by Seymour Papert. He has another book out called "The Children's Machine: Rethinking School in the Age of the Computer", but I haven't seen it yet. From aaldv97 at student.remove-this-part.vxu.se Wed Nov 7 04:51:54 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Wed, 7 Nov 2001 10:51:54 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> Message-ID: <9sb0a1$61i$1@news.lth.se> > > Having a non-declarative language as a first choice is bad, teaches them to > > write sloppy code. > > have you teached python to the kind of people you label as > "them"? Yes. > or are you just yet another 3l33t language snob? Isn't this nice, semi-ad hominem attack by a person with strong economical/commertial interests in Python; you don't think you might just be a little too biased to take part in this kind of discussion? > > Ada is fantastic, with it I write inline Assembly > > well, duh. nevermind. If you don't have anything worthwhile to say, don't say it. From nospam at bigfoot.com Sun Nov 25 14:43:41 2001 From: nospam at bigfoot.com (Gillou) Date: Sun, 25 Nov 2001 20:43:41 +0100 Subject: vCard parser anywhere ? Message-ID: <9trh93$o1e$1@norfair.nerim.net> Hi, I'm looking for a vCard parser that changes a vCard stream into a Python object. Did not find this treasure in Vault of Parnassus ! Thanks in advance for any clue. --Gillou From dale at riverhall.NOTHANKS.co.uk Mon Nov 19 07:45:19 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Mon, 19 Nov 2001 12:45:19 +0000 Subject: Does smtplib lookup MX records? References: Message-ID: Thanks to all the replies and emails. It never occured to me that smtplib was intended to work with a mail host and, for various reasons - including failure detection, that wasn't really what we wanted. However, after a bit of fiddling around we made it work with one of our mail servers and got the job done. My particular thanks to Steve Holden for his DNS lookup code which I shall study shortly. -- Dale Strickland-Clark Riverhall Systems Ltd From root at rainerdeyke.com Tue Nov 6 17:54:50 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 06 Nov 2001 22:54:50 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: <_SZF7.57706$IR4.31105048@news1.denver1.co.home.com> "John Roth" wrote in message news:tugphsjop81s04 at news.supernews.com... > Integer division is not an inverse of integer multiplication, therefore > the proposed counterexample fails. What do you mean? '(a * b) / b' equals 'a' for all integers 'a' and 'b' (assuming 'a * b' evaluates without overflow), except when 'b' equals 0. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From bernie at pacific.net.hk Mon Nov 19 05:42:29 2001 From: bernie at pacific.net.hk (Bernie) Date: Mon, 19 Nov 2001 10:42:29 GMT Subject: Question on default value of __init__ References: <3BF8D3BC.105F0536@pacific.net.hk> <3bf8dc9a$1@brateggebdc5.br-automation.co.at> Message-ID: <3BF8E23E.DD73FEC2@pacific.net.hk> Thanks for the confirmation, Werner. I am intented to use the null object pattern, that is the reason why I use foo() as default. Bernie Werner Schiendl wrote: > > Hi, > > yes, this is the default behaviour of Python. > The default value you provide is stored and passed to every invokation of > the function/method. > This means, the _same_ instance of foo will be passed for every call to > bar.__init__() > > To get what you probably want, use None as the default and handle that > special case by creating a new instance explicitely. > This also prevents an instance of foo being created, before you create bar. > > hth > Werner > > "Bernie" wrote in message > news:3BF8D3BC.105F0536 at pacific.net.hk... > > Hello all, > > > > When I run test.py, an instance of foo is created. Is this the default > behavior > > in Python for default value? i.e. The value must be exist as an object. > Are > > there any way to delay the creation of foo() until bar() is created. > > > > Bernie > > > > test.py: > > > > class foo: > > def __init__( self, param=None): > > print 'executed!' > > self.__param = param > > > > def __nonzero( self): > > if self.__param: > > return 1 > > else: > > return 0 > > > > class bar: > > def __init__( self, param=foo()): > > assert isinstance( param, foo), '"in" must be an instance of > foo' > > pass From junkster at rochester.rr.com Thu Nov 1 18:36:34 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Thu, 01 Nov 2001 23:36:34 GMT Subject: .exe References: <9rkcbb$ucb5d$1@ID-69142.news.dfncis.de> Message-ID: In article <9rkcbb$ucb5d$1 at ID-69142.news.dfncis.de>, "Andreas Penzel" wrote: > Hello NG! > > Is it possible to make an .exe file from the .py soure running under > DOS/Windows? > > Thanks! > - Andreas Yes, use Gordon Mcmillian's "Installer".... (And it's easier than py2exe)... - Benjamin From johnmc at velseis.com.au Thu Nov 15 21:07:05 2001 From: johnmc at velseis.com.au (John McMonagle) Date: Fri, 16 Nov 2001 12:07:05 +1000 Subject: Returning values from a lambda References: Message-ID: <3BF474C9.2080607@velseis.com.au> William Tanksley wrote: > On Fri, 16 Nov 2001 10:36:06 +1000 (EST), John McMonagle wrote: > >>I wish to return values from a lambda function which is bound to the >>Tkinter button command option. For example, >> > > Wait a second. You don't want to return values; you want to modify > variables. There's a HUGE difference; lambdas can do the first, but they > don't support any of the syntax to do the second. > > The solution is to not use a lambda. Just define a function which > modifies the variables you need, and pass that function's name in place of > the lambda. But I need to use a lambda in order to pass arguments to the function. > > >>def operations(a,b): >> return a+b, a*b >> > > def operations(a,b): > x = a+b > y = a*b > Indeed I could do it like that, but I would need to define globals for x and y. Can this be done without using globals ? >>from Tkinter import * > >>root = Tk() >>btn = Button(root, text='Press Me', command=lambda a=2, b=5: operations(a,b)) >>btn.pack() >> > > With the function I've defined, things should work. > > >>John >> > From rogerha at ifi.uio.no Mon Nov 5 12:04:56 2001 From: rogerha at ifi.uio.no (Roger Hansen) Date: 05 Nov 2001 18:04:56 +0100 Subject: Solving Partial Differential equation in Python References: <3BE51085.90702@stu.ust.hk> Message-ID: * ee_fhw at stu.ust.hk > > Did anyone have the experience in solving a PDE numerically in > Python. The PDE is a Euler-Lagrange equation. In fact it is a > simulation of LCD modeling. I search the web and find many libraries > like Numeric Python. But I cannot find any library aim at solving > PDE. So I think I have to design my own Algorithm. Could anyone help > me. I have solved some PDEs in Python, both hyperbolic (wave equations) and elliptic. The packages I've used is Numeric and/or wrapped C,C++ or Fortran libraries. The last time I checked (a year or two ago) I didn't find any Python modules or packages directly aimed for solving PDEs. What you could do is to check http://gams.nist.gov/ or http://www.netlib.org/ for your specific equation. The code will probably be Fortran or C, but you can wrap or translate the code to Python. Wrapping Fortran code can be done with f2py and Pyfort, and for C code SWIG is a nice tool. HTH -- Roger From phd at phd.pp.ru Mon Nov 12 10:32:04 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 12 Nov 2001 18:32:04 +0300 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) In-Reply-To: <20011112102612.A1723@gerg.ca>; from gward@python.net on Mon, Nov 12, 2001 at 10:26:12AM -0500 References: <20011112175357.F26476@phd.pp.ru> <20011112102612.A1723@gerg.ca> Message-ID: <20011112183204.H26476@phd.pp.ru> Thank you! Looks nice! On Mon, Nov 12, 2001 at 10:26:12AM -0500, Greg Ward wrote: > > --file outfile1 -f outfile2 > > Yes, but just what happens in this case depends on the action you use. > I'm assuming --file and -f are synonomous, ie. > > parser.add_option("-f", "--file", ...) > > is how you defined them. If you did > > parser.add_option("-f", "--file", > action="store", type="string", dest="file") > > then the most recent option seen takes effect, and > options.file == "outfile2" > > But if you did > > parser.add_option("-f", "--file", > action="append", type="string", dest="file") > > (note the different action), then all occurences of -f or --file build > up, and > options.file == ["outfile1", "outfile2"] > > In other words, you're free to define the Right Thing for your > application, and Optik will Do The Right Thing. That's why I used > "flexible" in the description. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From huaiyu at gauss.almadan.ibm.com Fri Nov 9 20:30:38 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Sat, 10 Nov 2001 01:30:38 +0000 (UTC) Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Message-ID: On Fri, 09 Nov 2001 23:30:25 GMT, William Tanksley wrote: >What if slicing/indexing the "int" builtin resulted in a generator with >the desired behavior? > >for x in int[10]: >for x in int[1:11]: >for x in int[1:11:2]: Best proposal so far. ># now some hard ones >for x in int[0:]: # all the natural numbers >for x in int[0::2]: # all the even naturals >for x in int[:0]: # illegal >for x in int[:0:-1]: legal, all negative numbers The negative steps are tricky. The last one should be int[0::-1]. But what would x[a:b:-1] do if x is an iterator? Maybe that's useful for a "bidirectional iterator"? A unidirectional iterator would raise exception and say "no attribute 'prev'" and the like. Actually, this makes sense: An interator is equivalent to the set of natural numbers, and a bidirectional iterator is equivalent to set of integers. One candidate would be a linked list. It might be useful to abstract out the slicing objects itself, which is used in NumPy arrays. So 1:10:2 would be the syntax for creating a slicing object. To enable steps of other integers, you'd need an optional argument in next class someiterator: def next(self, step=1): ... So x[a:b:c] would get its elements by something like i = s = a while iWait -- a question. Do slices act on generators? That is, can I slice >out every other item of a generator (as I just did above)? If not, could >that be added? Once that's added, what's to stop me from annoyingly >demanding to be able to slice out every 'n'th item (keeping the rest as >part of the generated sequence)? Such a thing would feed my hunger for an >interesting prime # sieve... What would be the semantics? Is it iterate and discard, or simply jump? >Wait, I'm hearing a voice. It tells me, "WRITE A PEP." Well, go for it. :-) Huaiyu From emile at fenx.com Tue Nov 6 23:04:37 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Nov 2001 20:04:37 -0800 Subject: Yahoo Groups archive of python-list wiped - what happened? References: <3BE878FA.103DA334@letterror.com> <9sa4hk$11vhaf$1@ID-11957.news.dfncis.de> Message-ID: <9sac5j$124ic6$1@ID-11957.news.dfncis.de> "Kalle Svensson" wrote in message news:mailman.1005102189.3205.python-list at python.org... > [Emile van Sebille] > > "Fredrik Lundh" wrote in message > > news:nJ%F7.4684$R43.746961 at newsb.telia.net... > > > Just van Rossum wrote: > > > > I hope it's a temporary glitch, and not that they've simply > > > > wiped their archives... > > > > > > note that the first post in their new archive is timestamped > > > "Nov 5, 2001 7:29 pm". > > > > > > before and after Orlijn? > > > > > > > OK... what's that? The closest hit I get is spoorlijn. Has somebody pulled > > a fast one? > > http://www.python.org/~guido/orlijn/ > > Peace, > Kalle > -- Cool! Guido, harte gefeliciteerd met de geboorte van je zoon. -- Emile van Sebille emile at fenx.com --------- From phillip at transwitch.co.za Thu Nov 1 03:12:49 2001 From: phillip at transwitch.co.za (phillip) Date: 1 Nov 2001 00:12:49 -0800 Subject: Using Python Scripts in Zope Message-ID: <74cc9702.0111010012.2edb7dca@posting.google.com> Hi, I am a little lost as to how I can send http requests to python scripts from a form element with Zope as the webserver. I know how to do this with jsp's under a tomcat webserver. But it looks like you have to add the python scripts in the management front end - which I did, yet I still get an error when performing a simple query from a form. I used : action="/cgi-bin/crawl.py", action="/pcgi/crawl.py", action="crawl.py" still the error - can't locate the resource any ideas? Phill From none at nowhere.invalid Tue Nov 6 05:59:54 2001 From: none at nowhere.invalid (Alexei Zverovitch) Date: Tue, 06 Nov 2001 10:59:54 -0000 Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> Message-ID: Fred wrote in news:3BE41CBE.94AED22 at nospamco.com: > Python 2.1.1 (#3, Oct 25 2001, 12:54:40) [C] on osf1V4 Since you're running Digital Unix, you might want to try tweaking the __fast_free_max et al variables used by the system malloc(). 'man malloc' is your friend (I believe you'll need to re-link the python executable if you want to change those variables). We've had a similar problem recently when a (C++) program was taking ages to free() .5 million small structures. It turned out that most of the time was spent by free() coalescing memory blocks as they were being deallocated. Increasing __fast_free_max solved the problem (IIRC the execution time was reduced by several orders of magnitude). You may be seeing the same (or similar) behaviour. Cheers Alexei -- alexei (at) barclays (dot) net From tim at vegeta.ath.cx Mon Nov 12 23:01:04 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 13 Nov 2001 04:01:04 GMT Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> Message-ID: Adam Spitz graced us by uttering: > Tim Hammerquist wrote: >> Besides, no matter how brilliant the programmer, in my experience, ^^^^^^^^^^^^^^^^ >> a Smalltalker will never acknowledge anything except Smalltalk as >> an OOP. Don't waste your breath. =) > For what it's worth, I consider myself a Smalltalker, and I like > Python very much. I don't give a hoot about OO purity - I like > Smalltalk because I'm really productive in it, and I like Python for > the same reason. (Ruby, too. ;) This is the exact reason I included that phrase. =) Also, it might have been an unconscious attempt to bring some of the less argumentative Smalltalkers out of hiding. Your opinion may be quieter, but it's not any less important. > But then, maybe I'm in the minority... Before your post, every Smalltalker I'd talked to said something very similar to "That's alright, but if you want a _real_ OO language, look at Smalltalk." > Adam Spitz Cheers! Tim Hammerquist -- Emacs is a nice OS - but it lacks a good text editor. That's why I am using Vim. -- Anonymous From wurmy at earthlink.net Fri Nov 9 18:45:35 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Fri, 09 Nov 2001 23:45:35 GMT Subject: String Search. References: Message-ID: <3BEC6AAA.ABFBC462@earthlink.net> Adonis Vargas wrote: > i posted a thread before asking help on how to find a specific string within > a line of string, i unfortunately did not get too specific on what i was > asking for. how can i do a search within a string using wildcards? > i.e.: > (pseudocode) > if "*something*is*" in "something is written here": return true > > ive looked into the re module and have been to the how-to pages, but i cant > seem to understand it. I suppose that, for a simple case like this, you can (ab)use the fnmatch module: >>> import fnmatch >>> fnmatch.fnmatch('something is written here', '*something*is*') 1 >>> fnmatch.fnmatch('something was written here', '*something*is*') 0 >>> For more sophisticated stuff, you'll really need the re module, though (or something with similar power). HTH, --Hans Nowak From brian at rk-speed-rugby.dk Mon Nov 5 04:55:17 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 05 Nov 2001 10:55:17 +0100 Subject: Teaching python (programming) to children Message-ID: Hi, in the special Python issue of Linux Journal last year Guido explained one of the perspectives of the future was children sitting in class writing python code for a lot of different applications. I think that Python may be very well suited for this because it is easy to get going with the language compared to other languages (AFAICS). However, in order to program you need to be able to write. And out of the English-speaking world, learning English will be one obstacle delaying the learning of programming. So, any comments are appreciated, especially on: Are there good reasons for advocating python being a language one could teach children programming with and are there perspectives in translating python to many different languages in order to facilitate this, or will children not be ready for learning programming before they have learnt English after all? -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From lac at strakt.com Fri Nov 16 12:20:09 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 16 Nov 2001 18:20:09 +0100 Subject: PEP 276 Simple Iterator for ints (fwd) In-Reply-To: Message from David Eppstein of "Wed, 14 Nov 2001 16:46:37 PST." References: <7xadxo27tr.fsf@ruckus.brouhaha.com> Message-ID: <200111161720.fAGHK9ua021722@ratthing-b246.strakt.com> If you are going to be needing an index sequence a lot, what is so wrong with this? import sys # a reusable index sequence, use with zip only, NOT with map _indices=xrange(sys.maxint) for i, old, new in zip(_indices, oldwidths, newwidths): #or whatever you want To the extent that this PEP is motivated by a desire to kill xrange, isn't this as good or better? The PEP has other aims, I am well aware. Laura Creighton From mwh at python.net Wed Nov 28 12:25:51 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 28 Nov 2001 17:25:51 GMT Subject: Nested scope suggestion References: Message-ID: John Thingstad writes: > I am somwhat upset that is seems impossible to to set variales in > higher levels of the scope. [...] > Any chance of this functionality being added to nested scopes? I doubt it. See PEP 227: http://python.sourceforge.net/peps/pep-0227.html Especially the "Rebinding names in enclosing scopes" section near the end. Cheers, M. -- Imagine if every Thursday your shoes exploded if you tied them the usual way. This happens to us all the time with computers, and nobody thinks of complaining. -- Jeff Raskin From mlh at idi.ntnu.no Sun Nov 18 18:43:47 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 19 Nov 2001 00:43:47 +0100 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> Message-ID: <9t9h3j$7r9$1@tyfon.itea.ntnu.no> "Uwe Schmitt" wrote in message news:9t95gu$ab7l1$1 at hades.rz.uni-sb.de... > Hi, > > i there a nice python shortcut for: > > if idx=0: > a=val > elif idx=1: > b=val This isn't really an answer to your question, perhaps, but have you considered keeping the if-sentence? It's a very Pythonic and readable thing to do, IMO. Trying to find fancy shortcuts will often make your code less readable, although possibly more fancy ;) > ??? > I tried > (a,b)[idx] = val > > but this does not work, i get an error message. Well... If you want an evil solution: locals()[['a','b'][idx]] = val :) > Greetings, Uwe. > > > -- > Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From jdadson at ix.netcom.com Wed Nov 14 22:37:14 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 15 Nov 2001 03:37:14 GMT Subject: access greed? References: <20db6273.38778ed9@nntp.salon.com> Message-ID: <3BF33828.F833733C@ix.netcom.com> Please check the "Reply-to" line in the header of newsgroup messages before replying. Also the "To" line in your browser's message composition window. The message you replied to had the reply-to set to news.admin.net-abuse.email. Why? That is the latest tactic of an internet vandal who calls himself Hip Crime. For a long time he has been waging a denial of service attack against that newsgroup. Lately, he posts thousands of inflammatory messages all over the newsgroups, with the reply-to set to his despised newsgroup. All the irate responses go there. Jive From skip at pobox.com Wed Nov 14 03:42:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 09:42:40 +0100 Subject: Are there any list comparison optimizations in Python? In-Reply-To: References: <3BF0883B.62473129@engcorp.com> Message-ID: <15346.11904.274187.204371@beluga.mojam.com> Huaiyu> class A: Huaiyu> def __cmp__(a,b): return -1 Huaiyu> a = [A()]*3 Huaiyu> a == a # returns 0 Huaiyu> a is a # returns 1 Huaiyu> Is this intended? Yup, that's what you told the system. You can override "==" by writing your own cmp method, but there is no option to override the behvaior of the "is" operator. The bytecode generated for "x is y" does nothing more than compare the two object pointers. You chose to define __cmp__ such that nothing is ever equal with anything else, so you have to live with it. ;-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From lac at strakt.com Wed Nov 14 12:28:04 2001 From: lac at strakt.com (Laura Creighton) Date: Wed, 14 Nov 2001 18:28:04 +0100 Subject: How to know when a variable is set In-Reply-To: Your message of "Wed, 14 Nov 2001 15:49:23 GMT." References: Message-ID: <200111141728.fAEHS4ua018174@ratthing-b246.strakt.com> >Two decades later, well-known hacker Henry Spencer described the > Perl scripting language as a "Swiss-Army chainsaw", intending to > convey his evaluation of the language as exceedingly powerful but > ugly and noisy and prone to belch noxious fumes. -- the jargon file 1. It didn't take us 2 decades to start saying that about perl. 2. You need one other definition here: Swiss-Army knife: precisely the wrong tool for every job. The so-called Toronto Unix Mafia were describing things as swiss-army knives from before there _was_ a perl. It's a _strong_ pejorative. And I can't remember which of us coined it -- probably Geoff Collyer, since Henry and Ian Darwin and I all believed in carrying Swiss Army knives, and owned them. From philh at comuno.freeserve.co.uk Sun Nov 25 13:25:57 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 25 Nov 2001 18:25:57 +0000 Subject: python compiler compiler google results References: <3c009440$1@207.229.64.20> <3C00B956.8489AC7F@earthlink.net> Message-ID: On Sun, 25 Nov 2001 09:26:40 GMT, Hans Nowak wrote: >Peter Bismuti wrote: >> >> Ok, I know, Google 1. Post 2. >> >> I found PLY (Python Lex-Yacc). >> I also found PyLR -- Fast LR parsing in python. >> Any Others? > >There's something called SPARK, and kjParsing... not sure where >to find them, but I'm sure Google can tell you more. I can recommend SPARK. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From fperez528 at yahoo.com Mon Nov 26 15:45:52 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 20:13:52 +2328 Subject: Copy operator (was list.remove for Noivces) References: Message-ID: <9u1kqt$rlh$1@peabody.colorado.edu> Arthur Siegel wrote: > > What if we could help matters marginally, at no real cost? Remember, nothing is free. If nothing else, every bit of syntactic sugar you add means extra complexity in the interpreter/byte compiler code. More codepaths, more possible bugs, more work to maintain it, possibly a performance hit from the added syntax analysis. This doesn't mean that syntactic sugar should be banned, only that it should be *very* well justified. There's a reason why getting a PEP through is hard: because the ones who finally ok it are the ones who will have to actually live with maintaning the animal, not those who propose it. Life under the hood (in C) is a lot uglier than in the air-conditioned leather cabin of the interpreter (Python). And every pretty knob that lights up and makes music needs 55 more cables inside, so you see why the guys who do the cabling are reluctant to put 'another knob, in a different color and with a different song' :-) Just some thoughts, f. PS: don't take this personally. My irony is not directed at you: we all have our list of 'things Python needs *today*'. I wrote mine when I started with the language, but after a while I've realized there are very good reasons why things are the way they are, and why they change at the rate they change. From erno-news at erno.iki.fi Mon Nov 19 05:31:08 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 19 Nov 2001 12:31:08 +0200 Subject: Pulling out References: Message-ID: In article , "David A McInnis" writes: | I am writing a script to catalog about 30,000 html pages on my site and need | to pull out the value of . http://www.oreilly.com/catalog/pythonsl/chapter/ch05.html#t4 -- erno From shiver at yubc.net Tue Nov 13 22:28:54 2001 From: shiver at yubc.net (I.J.) Date: Wed, 14 Nov 2001 04:28:54 +0100 Subject: input References: <9srncp$15ljf7$1@ID-69142.news.dfncis.de> Message-ID: <9ssodn$tko$1@cer.yubc.net> user_input = input("Message that comes before input, like c:\>") From paul at boddie.net Mon Nov 26 09:55:16 2001 From: paul at boddie.net (Paul Boddie) Date: 26 Nov 2001 06:55:16 -0800 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> <9tsfls$7q2$1@news8.svr.pol.co.uk> Message-ID: <23891c90.0111260655.3f32fb44@posting.google.com> Martin von Loewis wrote in message news:... > "Duncan Smith" writes: > > > Thanks for the reply. Basically I have an XML file containing data > > that I need as various Python objects (strings, lists, arrays etc.). > > I don't need to make changes to XML files, although I might want to > > write data to new XML files of the same type (same DTD). > > I see. In that case, I recommend to use plain print statements to > generate the XML (or other means of string processing, like collecting > pieces of the document in a list). This is easier than generating a > DOM or SAX in-memory representation, and then serializing it. Typically, I would agree that this is the case, although it can limit your flexibility later on in cases where you might, for example, want to generate documents in a "random access" fashion. Another danger is that non-well-formed documents can be produced, whereas the xml.dom package takes care of most of this for you. > > (I don't really want to have to learn about XSL, XSLT, X-path, SAX, > > DOM, Pyxie etc. unless I know it's going to be useful.) > > Depending on the exact processing job, XSLT may be indeed useful. If > you know that the output only depends on the input, then writing a > style sheet that does the transformation, without writing a line of > Python, might be possible. But for anything more than really simple transformations, I'd think that the terminology of the DOM, if nothing else, would be unavoidable in XSLT (and with the terminology arguably comes most of the complexity). XSLT is nice for certain situations, but it's not something I would instinctively reach for, but then I've possibly done some fairly bizarre things with it. For beginners, xml.dom.minidom seems to be a good place to start, at least from PyXML 0.6.6 onwards - there just aren't as many obscurities in knowing how to parse documents as there are for 4DOM (or something like the javax.xml package). It's also much faster than 4DOM as far as I can tell. [...] > > Martin, you were bang on with the 'invalid XML' thing. Cheers. > > That's a phrase (to be bang on) that is beyond my English > understanding. I take it to mean something good, in absence of a clear > understanding :-) If someone was "bang on" about something then it usually means that they were accurate; another similar term is "spot on". Like a lot of English slang, the meaning of a phrase can change dramatically (and amusingly) if one makes it a verb ("to bang on" could mean "to endlessly repeat the same thing"), omits or changes the preposition ("to bang"), or introduces things that the verb refers to... :-) Paul From dag.wahlberg at se.unisys.com Wed Nov 7 11:12:39 2001 From: dag.wahlberg at se.unisys.com (Dag Wahlberg) Date: Wed, 7 Nov 2001 17:12:39 +0100 Subject: Unix message queues? Message-ID: <9sbm2a$f2r$1@trsvr.tr.unisys.com> Hi, I would like to use Unix message queues from Python, in order to talk to legacy apps using this IPC. What is needed is an interface to msgget(), msgrcv(), msgsnd(), ... So the Queue module in the standard distribution is not really usable for this. The socket interface in Python works great, so I thought queues would be available as well? Any known implementations? Thanks, /Dag From phr-n2001d at nightsong.com Sat Nov 3 14:25:18 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 03 Nov 2001 11:25:18 -0800 Subject: MMap "access" keyword, choice of exception class References: Message-ID: <7xu1wbzmg1.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > SystemError is used for things that "can't happen" -- a SystemError is > Python telling you that something is insane in Python's own implementation. > For example, if the Python Virtual Machine sees an undefined bytecode; it's > akin to an assert. Note that user code can create undefined bytecode, e.g. by demarshalling something that looks like a valid code object but isn't. So I hope SystemError isn't like an assert in the sense that bytecode validity checking is disabled when the debugging flags are turned off. From cjw at sympatico.ca Wed Nov 28 13:06:36 2001 From: cjw at sympatico.ca (Colin J. Williams) Date: Wed, 28 Nov 2001 13:06:36 -0500 Subject: PEP 276 Simple Iterator for ints - text repeat Message-ID: <3C0527AC.5BEED99F@sympatico.ca> An HTML attachment was scrubbed... URL: From bernhard at intevation.de Mon Nov 19 09:57:18 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 19 Nov 2001 14:57:18 GMT Subject: GUI toolkit References: <9t13p3$1v9$1@news1.xs4all.nl> Message-ID: <9tb6ke$1evoq$3@ID-89274.news.dfncis.de> In article <9t13p3$1v9$1 at news1.xs4all.nl>, boud at rempt.xs4all.nl (Boudewijn Rempt) writes: > Cary Coulter wrote: >> Platforms would be Linux (primary), Windows, and AIX (didn't see any >> prebuilt code for wxPython). > You should be able to use PyQt on all these platforms - but you will > have to build Qt and PyQt yourself of AIX. It is less know that Qt is only Free Software (as in freedom) for X11, not for Windows or MacOSX. (For me that's a big argument. Everybody should be aware of it, I've seen this stated wrong many times.) Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From buzzard at urubu.freeserve.co.uk Sun Nov 25 23:15:23 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Mon, 26 Nov 2001 04:15:23 -0000 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> Message-ID: <9tsfls$7q2$1@news8.svr.pol.co.uk> "Martin von Loewis" wrote in message news:j4bshrnh29.fsf at informatik.hu-berlin.de... > "Duncan Smith" writes: > > > I have a lot of code written for a particular application I'm > > working on and I've got to the point where I need to access data > > from XML files. I will also need to save to XML files. There's > > almost too much information available and I'd appreciate any advice. > > SAX? DOM? > > You don't specify what you mean by "accessing", most likely, you will > need a tree representation of the document, i.e. the DOM. The only > reason *not* to use the DOM would be if the document is too large to > fit into memory. > Thanks for the reply. Basically I have an XML file containing data that I need as various Python objects (strings, lists, arrays etc.). I don't need to make changes to XML files, although I might want to write data to new XML files of the same type (same DTD). What I can't really figure out is my best strategy. (I don't really want to have to learn about XSL, XSLT, X-path, SAX, DOM, Pyxie etc. unless I know it's going to be useful.) Learning all that lot would be a lot of effort to achieve what I need. So if you (or anyone) could give me advice along the lines of "DOM would be appropriate but you'll have to know... as well", then I'd be grateful. And if anyone could point me to a decent (simple) example involving Python objects rather than HTML, that would help me a lot. Martin, you were bang on with the 'invalid XML' thing. Cheers. Duncan From rdsteph at earthlink.net Sun Nov 11 17:59:21 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 11 Nov 2001 22:59:21 GMT Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <3BEF0436.33D7F2A5@earthlink.net> As someone else said, pleas einlcude anygui. Also, it woudl be nice if you could include PythonCard, as an application frmaework on top of wxPython. Michael 'Mickey' Lauer wrote: > Hi group, > > I'm currently writing a Python GUI book, where several toolkits > (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... > of course... Tkinter) are presented and explained. > My idea is that besides going into some detail of every Toolkit I > construct _one_ application scenario with a skeleton, which I > later complete with each of the toolkits. > This should give the reader the means to choose the toolkit > which matches their personal taste & programming philosophy. > > Given this approach, the main question I'm currently trying to > figure out is: What application shall I present? It must be complicated > enough to show some advanced topics (not only presenting a tour of > the widgets and voila...) but at the same time small enough to cover > it within 50 pages or so (remember: for each toolkit!). > > I first thought of some contact application - in outlook style - or > some kind of presentation program - powerpoint style - ... here's a plea > for your input. > > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? > > Apart from this concrete question do you have some topics which you > think should be a _must_ in such a book? Imagine you're a not a total newbie > in python GUI programming... what did you want to read in such a book? > > thanks for your input! > > Yours, > > Mickey. From cuiod-tec at web.de Mon Nov 26 06:23:17 2001 From: cuiod-tec at web.de (Jens Gelhaar) Date: 26 Nov 2001 13:23:17 +0200 Subject: question: metaclass and C - a new general style Message-ID: <3c02343d@netnews.web.de> Hi, I am working serveral years with Python, but I am new to the C stuff. I need an hint, to change the source code to get the following behaviour: When I compile a module with an class in it, I would like to call a special function: __metainit__ after the class has been compiled. The calling parameters should the be the class itself and the enviroment one step up. class a: def __metainit__(, ) ... In the case of two classes class a: def __metainit__(...): pass class b: def __metainit__(...): pass there should be a call to b with __metainit__(b,a) The reason for this feature is something in between to metaclass concept and macros. You can go one step further an implement an eiffel style like "deffered" and check after creating an new class, that this class must define an special method or attribute. For me, I would be more helpfull metaclass concept in python and I can implement every style I like. For the sake of simplicity lets assume class meta_a: _collect: [] def __metainit__(,): "store all classes with meta_a as predessor in collect" for name, object in .__dict__.items(): if issubclass(meta_b,): ._collect.append(object) class meta_b: pass implementation class a(meta_a): class b_1(meta_b): pass class b_2(meta_b): pass class b_3(meta_c): pass result class a: _collect: [b_1,b_2,b_3] and would be the same as class a(meta_a): class b_1(meta_b): pass class b_2(meta_b): pass class b_3(meta_c): pass _collect: [b_1,b_2,b_3] but much more readable and efficient, because I do not have to type it manually and forget it once. The I need in the case there are more levels then two. Thanks Jens -- __________________________________________________________ News suchen, lesen, schreiben mit http://newsgroups.web.de From mwh at python.net Fri Nov 9 05:42:26 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 9 Nov 2001 10:42:26 GMT Subject: iters on ints? (reducing the need for range/xrange) References: <3BEB4F6E.A173C05D@cosc.canterbury.ac.nz> Message-ID: Greg Ewing writes: > Rainer Deyke wrote: > > > > Seriously, I don't see how this is worse or less Pythonic than, say, 'for > > line in file'. > > It makes sense to think of files as containing lines, > but it's stretching things to think of the integer 10 > somehow "containing" the integers 0 to 9. Doesn't this depend on your set theory? (Thinking back to the first line of Jim's post...). Horrific idea, BTW. Cheers, M. -- > So what does "abc" / "ab" equal? cheese -- Steve Holden defends obscure semantics on comp.lang.python From philh at comuno.freeserve.co.uk Sat Nov 24 21:58:17 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 25 Nov 2001 02:58:17 +0000 Subject: A permutation on permutations References: Message-ID: On Sat, 24 Nov 2001 19:22:05 -0500, Arthur Siegel wrote: >Was able to find nice stuff on the python-list archives >as to list permutations, list reversal, and removing >duplicates from lists. > >My problem is to combine them. > >I am feeding control points to a curve function, and >want all permutations that result in unique curves. >For this purpose a sequence is duplicative >of its reverse, i.e. [1,2,3,4] == [4,3,2,1], etc. Can you have the same number appearing twice, e.g. [1,2,3,3] ? >So am a looking for a function to return all >permutations, excluding duplicates as defined above. Consider the following source: def perm(source, done=0, current=[]): if done == len(source): if current[0] < current[-1]: #removes reversals print current else: for i in source: if i not in current: perm(source, done+1, current+[i]) d = [1,2,3,4] perm(d) When run produces: [1, 2, 3, 4] [1, 2, 4, 3] [1, 3, 2, 4] [1, 3, 4, 2] [1, 4, 2, 3] [1, 4, 3, 2] [2, 1, 3, 4] [2, 1, 4, 3] [2, 3, 1, 4] [2, 4, 1, 3] [3, 1, 2, 4] [3, 2, 1, 4] -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From nas at python.ca Tue Nov 27 10:41:48 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 27 Nov 2001 07:41:48 -0800 Subject: pyrepl-0.6 In-Reply-To: ; from mwh@python.net on Tue, Nov 27, 2001 at 01:01:28PM +0000 References: Message-ID: <20011127074148.A27892@glacier.arctrix.com> Michael Hudson wrote: > This is pyrepl 0.6, a readline-a-like for Python, which seems to be > being released on 2001-11-27. ... > * sane multi-line editing This is cool. We have a little script that we use to interact with our object database (ZODB). It's used to do ad hoc queries or maintenance on the database. Usually we run it with "python -i". I installed the files in the pyrepl distribution in site-packages and added a __init__.py in order to make it a package. Next, I added the following lines to the end of the script: from pyrepl.python_reader import ReaderConsole ReaderConsole(globals(), 0, None).interact() It works great. Thanks Michael. Neil From ajs at ix.netcom.com Sun Nov 25 15:09:38 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 25 Nov 2001 15:09:38 -0500 Subject: A permutation on permutations Message-ID: <000701c175ed$1cbc83a0$a9e1fea9@carol> Phil writes - >Can you have the same number appearing twice, e.g. [1,2,3,3] ? Actually I hadn't considered double points for what I'm doing. But I believe that the universe of unique curves would include curves with double point args. I'll play with it and see if I can get a better criteria for unique curves. >>So am a looking for a function to return all >>permutations, excluding duplicates as defined above. >Consider the following source: >def perm(source, done=0, current=[]): > if done == len(source): > if current[0] < current[-1]: #removes reversals > print current > else: > for i in source: > if i not in current: > perm(source, done+1, current+[i]) Works nice, but I haven't found a great way to get a return value. Using a global L=[] in the calling code and an L.append(current) at "print current" in the perm func. Thanks. Art From weismann at netvision.net.il Sat Nov 10 15:55:05 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Sat, 10 Nov 2001 22:55:05 +0200 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> Message-ID: <002a01c16a29$fa31dde0$a890003e@rashome> I'm trying . :) I have a parser for HTML pages . My program scans them automaticaly . After 500 pages that the parser worked OK (no errors) it failed with the error message : Traceback (most recent call last): File "", line 1, in ? a.feed(b) File "C:\Python21\lib\sgmllib.py", line 91, in feed self.goahead(0) File "C:\Python21\lib\sgmllib.py", line 158, in goahead k = self.parse_declaration(i) File "C:\Python21\lib\sgmllib.py", line 238, in parse_declaration raise SGMLParseError( SGMLParseError: unexpected char in declaration: '<' I attached to this message a sample of a parser that should print the comments to the screen - when "feeding" this parser with "correct" string as >>> b = """ bla bla bla """ >>> a = sample() >>> a.feed(b) Regular comment It's OK But with a string that contains "< bla bla bla>" or " " I get an error message -> >>> b = """ < eee > bla bla bla """ >>> a = sample() >>> a.feed(b) Traceback (most recent call last): File "", line 1, in ? a.feed(b) File "C:\Python21\lib\sgmllib.py", line 91, in feed self.goahead(0) File "C:\Python21\lib\sgmllib.py", line 158, in goahead k = self.parse_declaration(i) File "C:\Python21\lib\sgmllib.py", line 238, in parse_declaration raise SGMLParseError( SGMLParseError: unexpected char in declaration: '<' I hope I was more understandable this time . I'm new to Python and this news group . Sorry . Thanks Amit ----- Original Message ----- From: "Hernan M. Foffani" Newsgroups: comp.lang.python To: Sent: Saturday, November 10, 2001 8:00 PM Subject: Re: " "Amit Weisman" escribi? en el mensaje > news:mailman.1005403215.5502.python-list at python.org... > > I don't know what comes after the "<" . It's not " processed > > by handke_comment . > > How can I parse (or even better - ignore) the "<" ?? > > Amit, > I think it would be best if you tell us exactly what do you want to do > giving us a sample input too. > I'll promise you'll have a better answer from us. > > Regards, > -Hernan > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: sample.py URL: From emile at fenx.com Thu Nov 1 11:52:57 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Nov 2001 08:52:57 -0800 Subject: in string References: <3BE17AFD.1655EEF8@juno.com> Message-ID: <9rruun$uuu4u$1@ID-11957.news.dfncis.de> "Jeff Sandys" wrote in message news:3BE17AFD.1655EEF8 at juno.com... > I kind of understand why this (below) doesn't work. > What would you have to do to make it work? > (to make 'eggs' in 'spam and eggs' return 1) > Or what does: string member test needs char left operand > mean? > > Python 1.5.2 (#2, Apr 4 2000, 13:12:48) [C] on aix4 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> a = 'spam and eggs' > >>> 'e' in a > 1 > >>> 'eggs' in a > Traceback (innermost last): > File "", line 1, in ? > TypeError: string member test needs char left operand > >>> > import string string.find(a, 'eggs') Note: this can return 0 (as in 'eggs and eggs'); -1 is the not found return value -- Emile van Sebille emile at fenx.com --------- From aaldv97 at student.remove-this-part.vxu.se Wed Nov 7 16:46:29 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Wed, 7 Nov 2001 22:46:29 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> <9sbpr1$c4f$1@news.lth.se> <6BeG7.2$%g7.20675@atlpnn01.usenetserver.com> Message-ID: <9sca61$gol$1@news.lth.se> > Given what you've said, I guess I'll accept that Ada had a lot of upfront > design - I'm not here simply to disagree! I presume you mean strawman, > stoneman, ironman? OK, but in that case how come there had to be a "next > version"? Clearly all that up-front design didn't produce a perfect > language. How is this different (except perhaps in terms of gestation time) > from other standardised languages? Naturally, there is no such thing as a perfect language, because the perception of people are different, and changing with time. The design changed when OO became the thing on everyone's lips, just like components are today, but adding components to a language is simple, OO is not. (Though it is quite simple to write OO code in a non-OO language.) There is some strong doubt about the need of OO in Ada, but now it's part of the standard so there no point in complaining about it. > Well you surely don't believe that *buildings* are built exactly as they are > conceived? Why else do the construction teams have to supply "as built" > drawings - because they have to modify the building design as construction > progresses, to take into account the practical considerations of the site, > materials, etc. No, of course not. But I recommend that you read books on architectures by members of the Go4 or the simpler ISBN 0-201-69967-2 to understand what I'm trying to say. > Software is difficult precisely because it is so malleable, and so a design > can evolve. This is both a good and a bad thing. But none of this really has > to do with suitability as a teaching language, and I still don't see Ada as > any better for teaching purposes than Python. You could read my reply to Laura for more information. From sholden at holdenweb.com Tue Nov 13 07:46:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 07:46:23 -0500 Subject: Signed (and now seen) References: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> Message-ID: "Martin Armstrong" wrote in message news:PhgUoNIqkE87Ew2Z at tactilis.demon.co.uk... > In article , J?rgen A. > Erhard writes > > > It doesn't matter what you wrote. > > What matters is: > > Content-Type: multipart/signed; > boundary="pgp-sign-Multipart_Sat_Nov_10_23:43:08_2001-1"; micalg=pgp-sha1; > protocol="application/pgp-signature" > ^ ^ > ^ ^ > Colons are no longer broken :) -----------^--^ Sadly, my wonderful Microsoft mail reader still insists on showing the message as empty, with a 448-byte text attachment and a 286-byte .dat attachment. Of course, it must a be problem with the posting, because there's no chance Microsoft could wrong-headedly ignore well-established Internet standards this way ;-) But I'm glad the mail gateway is fixed. sorry-wrong-thread-ly y'rs - steve -- http://www.holdenweb.com/ From sholden at holdenweb.com Fri Nov 2 07:19:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 07:19:00 -0500 Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> <9rrtud$ff8$1@nntp6.u.washington.edu> <9rsn9s$cvu$3@newshost.accu.uu.nl> <7xy9lquj5a.fsf@ruckus.brouhaha.com> Message-ID: "Paul Rubin" wrote in message news:7xy9lquj5a.fsf at ruckus.brouhaha.com... > m.faassen at vet.uu.nl (Martijn Faassen) writes: > > > Personally, I prefer the effect of double underscore for this case, as > > > well. I can easily get to the variables by applying the name mangling > > > myself, yet cannot accidentally stomp on the variables in a subclass. > > > > > To each his/her own. > > > > That's a good point. I haven't done this because I've never remembered > > the name mangling rule. I'm not even sure if it's really part of the > > Python standard, but I'd guess it should be. > > Depending on the name mangling scheme staying the same between python > version updates sounds like asking for trouble. I don't see why. It's a documented part of the language, so a change would create backward incompatibility known to be anathema to the development team. regards Steve -- http://www.holdenweb.com/ From boud at rempt.xs4all.nl Sun Nov 18 05:59:31 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 18 Nov 2001 10:59:31 GMT Subject: Python IDE Opinion Request References: Message-ID: <9t84aj$ha7$1@news1.xs4all.nl> A. Keyton Weissinger wrote: > Hello All, > I am a recent inductee into the Pythonista Cult. I use MicroEdge's Visual > SlickEdit (mostly so I can go back and forth with Python and Java, and Perl > and Java, and HTML and Java, etc). > However, I've played with a few of the Python IDEs out there. Some are nice, > some are cute. None soom the "obvious" choice. > Questions: > 0) This question must have been asked before. Can someone point me in the > direction of the last set of answers? I've discussed IDE's twice on www.informit.com - you should search for my name (rempt), because direct links to the articles have long since disappeared. > [If not:] > 1) Do you use a code editor (SlickEdit, emacs, etc) or an IDE (IDLE, etc)? > Why? I use XEmacs, mainly because I was writing a book on Python programming, and wanted to switch back and forth between Python and sgml mode quickly. Before that I used nedit. IDLE has always been too slow, but I really like Wing IDE, and BlackAdder. > 2) Are there any IDEs out there that allow me to do UIs easily (ala VB)? I > don't want a big code generator, but being able to drag and drop some simple > forms would be nice... BlackAdder includes Qt Designer, which is very good for UI design - if you use PyQt on its own, you can use the native Qt Designer. Take a look at http://stage.linuxports.com/projects/pyqt/c3112.htm (but all screenshots are still missing from the online copy.) The book should go to the printer this week, and you pre-order it at: https://secure.linuxports.com/cart/. > 3) Does anyone out there use SlickEdit for Python? Any tips and tricks for > that combo? I've tried it, that's all. It didn't have a compelling advantage over XEmacs. > Thank you all. I know I'm telling you nothing you don't already know, but > Python rocks! > Why is it not out there more???? > Regards, > Keyton -- Boudewijn Rempt | http://www.valdyas.org From brian at sweetapp.com Fri Nov 16 18:32:50 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Fri, 16 Nov 2001 15:32:50 -0800 Subject: python vs ecmascript In-Reply-To: Message-ID: > I'm using Python 2.0 at the moment (it is necessary as it is integrated > into another product), perhaps this limitation was removed in later > versions. If I try to do this: > > print "integer i = " + i > > it will barf on this and tell me that i is not a string, I must do this: > > print "integer i = " + str(i) This not a limitation of print, it is a consequence of Python's strong typing (I'm sure others will jump in to tell you why that is a good thing). The syntax that you are looking for is: print "integer i =", i From peter at engcorp.com Wed Nov 28 01:26:24 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 01:26:24 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <3C048390.A1BDFFC0@engcorp.com> Paul Rubin wrote: > > Peter Hansen writes: > > > Depends. If only one person is working on the project, CVS is overkill. > > > > > > If lots of people are working on it, it's a good idea. > > > > My opinion: a good idea if only one person is working on it. > > > > Mandatory if more than one work on it. > > CVS is a layer over RCS that lets multiple people work on the same > files at the same time, and automatically merges their changes at > check-in. I don't see any point to it for a one person project. RCS > is a lot simpler. I use RCS for one-person projects and couldn't live > without it. But I haven't found a reason to deal with the increased > complexity of CVS. Is there one? I don't know much (anything) about how scalable RCS might be, but I tried it briefly years ago and never found it of much use at the time. That may have been before I was really ready for decent revision control. I suspect that CVS does have some clear advantages, however, and those might be in the following areas: - compatibility with most open-source projects, at least in terms of the reusability of knowledge - multiple directory handling - support for decent client-server interaction via pserver among other things - GUI support via WinCVS and others (e.g. on Mac) - actively maintained (maybe RCS is too?) Those suggestions aside, I certainly didn't mean to suggest that CVS is the only viable option for single-developer use! I really only meant to suggest that revision control itself is of significant value even for one-person "teams", and you obviously agree. :) I wouldn't try to push somebody from RCS to CVS (or vice versa) without knowing more. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sholden at holdenweb.com Mon Nov 19 09:29:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Nov 2001 09:29:09 -0500 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> <9t9h3j$7r9$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote in message news:9t9h3j$7r9$1 at tyfon.itea.ntnu.no... > "Uwe Schmitt" wrote in message > news:9t95gu$ab7l1$1 at hades.rz.uni-sb.de... > > Hi, > > > > i there a nice python shortcut for: > > > > if idx=0: > > a=val > > elif idx=1: > > b=val > > This isn't really an answer to your question, perhaps, but have > you considered keeping the if-sentence? It's a very Pythonic and > readable thing to do, IMO. Trying to find fancy shortcuts will > often make your code less readable, although possibly more > fancy ;) > > > ??? > > I tried > > (a,b)[idx] = val > > > > but this does not work, i get an error message. > > Well... If you want an evil solution: > > locals()[['a','b'][idx]] = val > This is absolutely verboten. I quote from Section 2.3 of the 2.0 manual, but I don't think anything has changed since: """locals () Return a dictionary representing the current local symbol table. Warning: The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter. """ regards Steve -- http://www.holdenweb.com/ From chris.gonnerman at newcenturycomputers.net Thu Nov 22 09:50:47 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 22 Nov 2001 08:50:47 -0600 Subject: Colored console on Windows References: <1712.011122@storm.ru> Message-ID: <004401c17365$3424c280$0101010a@local> I wrote a module, WConio, which does exactly what you are wanting. If you plan to be working at the Windows console very much, you may also want my Alternative Readline module. You can get both at: http://newcenturycomputers.net/projects /F has a Console module over at effbot.org but I was never able to get it working properly on my Win98 system. ----- Original Message ----- From: "Kerim Borchaev" To: Sent: Thursday, November 22, 2001 8:05 AM Subject: Colored console on Windows > Hello! > > They say python can't output colored text to Windows console? > Are they right? > > Best regards, > Kerim mailto:warkid at storm.ru > > > > -- > http://mail.python.org/mailman/listinfo/python-list > > From use-net at schabi.de Tue Nov 20 15:52:32 2001 From: use-net at schabi.de (Markus Schaber) Date: Tue, 20 Nov 2001 21:52:32 +0100 Subject: Try block problem References: <9tcnls$42k$1@news1.ucsd.edu> <3bf9eacb$0$79564$6e49188b@news.goldengate.net> <9td60p$g15$1@news1.ucsd.edu> <6qoflxem42.fsf@abnoba.intevation.de> Message-ID: <20011120215232.3fd2d648.use-net@schabi.de> Hi, Am 20 Nov 2001 12:07:57 +0100 schrieb Bernhard Herzog: > > python choose to make the language that way. > > IIRC, the reason is that the precise sematics are not clear in every > situation. For instance, what happens if an exception is raised in an > except clause? Should the finally clause be executed in that case or > not? The semantics would have to be defined clear. Java says: Whenever an exception appears in the try block, execute the catch (except) block. Finally is executed always. Gru?, Markus -- You don't have to be Microsoft to suck... but it helps. (Tim Hammerquist in comp.lang.python) From barry at zope.com Tue Nov 6 01:18:02 2001 From: barry at zope.com (Barry A. Warsaw) Date: 06 Nov 2001 01:18:02 -0500 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: Others have posted their wrapper solutions, so I'll just quickly mention mine. Mailman has a C wrapper for both CGI and mail programs. It's about 3 C files and a single header file that are used to compile a dozen binary executables using C preprocessor tricks. Works like a charm and should be very portable. Mailman works via setgid scripts, and the allowable group-ownership of the process is compiled in. But it is very careful about the environment variables it allows in, and will only exec a compiled in Python executable (i.e. not one found on $PATH). It also tries to produce useful error messages in the case of failures. If your program is compatible with the GPL, you're welcome to use it and adapt it to your needs. -Barry From peter at engcorp.com Tue Nov 20 23:46:01 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 20 Nov 2001 23:46:01 -0500 Subject: Default DNS References: Message-ID: <3BFB3189.A8B32528@engcorp.com> A wrote: > > Is there any possibility in Python to find out my primary or > secondary DNS when using Dial Up connection from Windows? Something like the following might be the quickest approach: >>> import os,re >>> text = os.popen('ipconfig /all').read() >>> dns = re.search(r'DNS Servers[ .]*:\s+(\S+)\s*(\S+)?', text).groups() >>> dns ('206.221.248.4', '206.221.248.5') I tried using a pattern like this at first, but it only returned a result of (' :',) and I'm not sure why: >>> dns = re.search(r'DNS Servers[ .]*:((?:\s+)\S+)+', text).groups() >>> dns (' :',) I suppose the non-grouping group (?:...) cannot be nested inside another group? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nhodgson at bigpond.net.au Tue Nov 27 16:06:33 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Tue, 27 Nov 2001 21:06:33 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> Message-ID: Bill Melcher: >"Neil Hodgson" ... > > One of the more recent features of my SciTE editor > > (http://www.scintilla.org/SciTE.html) is to allow typing command lines > into > > the output pane making it easy to retrieve the combined text from the > output > > and error streams. It can't handle running interactive scripts, though. > Yet. > > I'm waiting! :-) -- In the mean time I have downloaded the three windows > packages and will play a bit with them. It is not certain yet whether this can be done as I'm having trouble with bugs. Will probably turn up but may only work with some programs. Neil From max at alcyone.com Thu Nov 1 16:35:46 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 01 Nov 2001 13:35:46 -0800 Subject: open vs. open References: Message-ID: <3BE1C032.6926D1D9@alcyone.com> Armin Steinhoff wrote: > I'm surely not the first one who was trapping into the > '__builtin__.open vs. os.open' problem. That what module names are for. > Question: is it possible to rename the __builtin__.open call to > __builtin__.fopen because it does really a fopen library call?? > > Or does it break something ?? It would break all existing code which uses it. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From clpy at snakefarm.org Fri Nov 30 03:49:56 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 30 Nov 2001 09:49:56 +0100 Subject: Why Python? References: <0nDN7.14999$WC1.1783701@newsread2.prod.itd.earthlink.net> Message-ID: <3C074834.FE00593D@snakefarm.org> "Patrick K. O'Brien" wrote: > > I've added a Python advocacy page to our company website and I'm looking for > suggestions for improvements or additional material. Take a look at > http://www.orbtech.com/why_python.htm and let me know what you think. It's pretty cool! Aside from all the apostrophes showing up as question marks ... %-) Please add 1&1 Internet to the list of Python users. cg. -- For dealing with Matrix you need something more powerful than Python. Otherwise ... Matrix has you! -- scenes from comp.lang.python From weismann at netvision.net.il Sun Nov 11 15:38:19 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Sun, 11 Nov 2001 22:38:19 +0200 Subject: HTTP proxy variable References: <20011111134501.318$SA@news.newsreader.com> Message-ID: <005c01c16af0$cd0114e0$1b95003e@rashome> ----- Original Message ----- From: "Hernan M. Foffani" Newsgroups: comp.lang.python To: Sent: Sunday, November 11, 2001 8:44 PM Subject: Re: HTTP proxy variable > "amit weisman" escribi? en el mensaje > news:mailman.1005491354.22778.python-list at python.org... > >Hi > >How does one change the http proxy and ftp proxy of a user ? > > Amit! > It's really hard for us to guess your needs. > Please don't be so shy when asking for help! > :-) I'll try . :-) > Are you talking about setting http proxy with > urllib ? > If so, read the doc Python Library Reference > chapter 11.3 urrlib. > At the bottom of urlopen() description it > explains how to set the proxy data. > On Unix system , I run a CGI that activates a Python program . When activating the CGI script from my shell it is working OK . BUT , when activating the CGI by an HTML form , it seems as if the Python program can't connect the net . As I learned that the CGI run as HTTPUSER and not as my user , I want to assign the http proxy value "by hand" because it is the only reason I can think of that makes this error . I tried the % http_proxy="http://www.someproxy.com:3128" as mentioned in the "Python Library Reference" but all I get is "Command not found" . Is there a way of setting the http proxy within Python ? I saw "class ProxyHandler" in urllib2 and the proxyHandler object , but couldn't understand all of it (My only attempt made no difference ) . Any ideas ? Thanks Amit From ws-news at gmx.at Fri Nov 16 12:46:13 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 18:46:13 +0100 Subject: Sizing Up Graphics Automatically References: Message-ID: <3bf551a8$1@brateggebdc5.br-automation.co.at> Hi, If you just want to know the size of the Image, this information is already available in Zope. (otherwise it could not produce a proper IMG tag with sizes set, as it actually does) See the documentation of the Image object for details. For more advanced graphics manipulations, I think PIL (Python Imaging Library) is the tool of choice. see http://www.pythonware.com/products/pil/index.htm Resizing and querying size is probably at the simple end of the possibilities this library provides. You'll need External Methods or a product to use it, IIRC. hth Werner "Ben Ocean" wrote in message news:mailman.1005924983.29807.python-list at python.org... > Hi; > Is it possible to automatically size up a graphic upon upload and > programmatic insertion into a script? I use Zope and want to build a > through-the-Web interface to enable my client to automatically change/add > photos, but I want to set the site up such that all the dimensions of > graphics, font sizes, etc., are resized depending on the visitor's browser > resolution. In order to do that, I *must* somehow capture the dimensions of > the uploaded graphic programmatically? Any ideas how to do this? Anybody > have some code they'd like to share? > TIA, > BenO > > > From daves_spam_dodging_account at yahoo.com Tue Nov 27 15:33:01 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Tue, 27 Nov 2001 12:33:01 -0800 (PST) Subject: Evaluate a python expression from C? Message-ID: <20011127203301.71719.qmail@web21108.mail.yahoo.com> Hi all, I would like to embed Python in my application, and one of the methods of access I'd like to have is the ability to send an expression to Python as a string, and get back a string containing the result. For example, to be able to say "(2+5)*3" and get "21" as the result. I have tried using PyRun_String() but I get an access violation. My code looks like this: void PyEval(char *data) { // data is a shared char[900] buffer; // size checking is left out for clarity here Py_Initialize(); // The following line access violates. PyObject *pObj = PyRun_String(data,0,NULL,NULL); char *buf; PyArg_ParseTuple( pObj, "s", &buf); strcpy( data, buf); } Could the problem be the NULL args I pass in? For simple evaluation, what should I populate them with instead? Thanks for any ideas or help. -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From dhaaron at hotpop.com Thu Nov 29 01:32:27 2001 From: dhaaron at hotpop.com (Aaron Sterling) Date: Thu, 29 Nov 2001 06:32:27 GMT Subject: message returned by poplib to email.Messge instance Message-ID: <1103_1007015547@news.mindspring.com> Hi, The poplib.POP3.retr() method returns a tuple (size_string, content_list, size_int). The email package provides a function message_from_string(string) that returns an object tree describing the string as an rfc2822 message. My problem is in how to convert content_list into a string that message_from_string will recognize as a multipart message. What I have so far is msg = email.message_from_string('\n'.join(content_list)) this executes without error. It is a message object but: >>> msg.is_multipart() 0 I know it is a properly formatted message, because I made it myself, using email package, and check its validity by: >>> message.is_multipart() 1 as well as succesfully extracting all of the information I need to from it. I send it over the internet with smtplib. I send it directly to my isp's smtp server, as i believe smtplib is supposed to be used. to do this I use smtplib.SMTP.sendmail(fromaddr, toaddr, str(message)) I am fairly sure that stringing the message is not causing the problem, as smtplib requires a string and: >>> message = email.message_from_string(str(message)) >>> message.is_multipart() 1 any light that could be shed on the issue would be greatly appreciated. Thanks, --------------------------------------------------------------------------- Aaron, dhaaron at hotpop.com "In this time of war against Osama Bin Laden and the oppressive Taliban regime, we are thankful that *our* leader isn't the spoiled son of a powerful politician from a wealthy oil family who is supported by religous fundamentalists, operates through clandestine organizations, has no respect for the democratic electoral process, bombs innocents, and uses war to deny people their civil liberties" -unknown From phr-n2001d at nightsong.com Thu Nov 15 03:50:43 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 00:50:43 -0800 Subject: who called a function? References: Message-ID: <7xpu6k5sf0.fsf@ruckus.brouhaha.com> writes: > > Raise and catch an exception and examine the stack trace object. > > -- > How do I step back through the trace stack object? Basically a few points > would be nice or better yet a web page that shows some examples. Hmm, I don't know of a web page but you can check the docs for traceback objects. You could look at the python debugger (pdb) code for an example but it's pretty straightforward how the frames are chained together. Hold on a sec... ok, here's something from one of my programs. Maybe it will help. def dump_trace(): ecl,e,trace=sys.exc_info() # print exception info print '@@ exception e=%s:%s' % \ (e, [(a,getattr(e,a)) for a in dir(e)]) while trace: co=trace.tb_frame.f_code print "@@trace: func=%s file=%s line=%d" \ % (co.co_name, co.co_filename, trace.tb_lineno) trace = trace.tb_next From loewis at informatik.hu-berlin.de Tue Nov 20 06:57:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Nov 2001 12:57:57 +0100 Subject: Python execution speed References: Message-ID: "Morten W. Petersen" writes: > 1. What is the plan for psyco (inclusion in the standard > distribution, etc) ? Here is what I think should/will happen: * Psyco needs more help. Poor Armin is trying to get people interested, but nothing happens. I guess this is *also* an aspect of free software: Even if you follow the rules (publish early, publish often), success is not guaranteed. However, it may be that he'll give up one day if there isn't more interest in his work beyond people posting "looks cool" in a newsgroup... * Psyco, as is, is unstable and incomplete. So the natural next step would be completion of the work done. * Psyco currently supports x86 only, so volunteers might be interested in adding support for other hardware. * I don't think Psyco will be integrated into the standard distribution in any foreseeable feature, especially if nobody is using it. Putting something into the standard distribution is no guarantee that it will be stable, supported etc. Instead, being stable and supported is a prerequisite for being included in the standard distribution. > 2. Will there be a JIT compiler for Python ? Well, Psyco is one. I doubt anybody would start another one. > 3. Are there any similar efforts for Jython [5] ? Sun is making big efforts in producing code just in time for Java on different machines, and Jython uses the Java JIT compiler today. > 4. Are efforts made to optimize Python's execution speed in > general ? Yes, constantly. Most Python contributors believe that this is where the realistic improvements "for the masses" can be made in the near future, and concentrate on improving the performance of the interpreter. Regards, Martin From eppstein at ics.uci.edu Mon Nov 12 17:14:05 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Mon, 12 Nov 2001 14:14:05 -0800 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> Message-ID: In article , David Bolen wrote: > However, if you mean that today's browsers are often capable of parsing > malformed HTML and thus people get away with invalid HTML in web pages, > I'd agree. Yes, that's what I mean. > But that's not the same as saying that HTML implies errors in the > documents from an SGML perspective. Such errors should imply that it > wasn't valid HTML either. Sure. But if you want to parse HTML that you don't control, you are going to have to be ready to handle invalid input and do something reasonable with it. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From DTSRV10-SA at dutchtone.nl Tue Nov 13 22:25:07 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Wed, 14 Nov 2001 04:25:07 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C715B7@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = hahaha at sexyfun.net Recipient(s) = python-list at python.org Subject = Enanito si, pero con que pedazo! Scanning Time = 11/14/2001 04:25:05 Action on virus found: The attachment enano porno.exe matched file blocking settings. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From eppstein at ics.uci.edu Fri Nov 16 11:50:13 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Fri, 16 Nov 2001 08:50:13 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <2YTI7.30749$vQ1.1137481@atlpnn01.usenetserver.com> Message-ID: In article , "Steve Holden" wrote: > Well in the interests of getting Python into your teaching, might I suggest > that you simply describe [x]range(n) as producing the range of subscripts > required to index the elements of a sequence of length n? But, when I need to index a sequence, I use "for item in sequence", it's only for the non-sequence-indexing uses of for loops that I use ranges. > Since it's presumably computer science you are teaching, your students > should be familiar enough with the (mathematically justifiable, but equally > pragmatically justifiable) advantages of numbering from zero. If not, then > arguably they won't be learning much computer science anyway, though I have > no objection to their tinkering with programming ;-) The reason they're familiar with numbering from zero is that we switched from Pascal to C/C++/Java in our introductory courses several years ago. It has very little to do with mathematical or pragmatic justification. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From boud at rempt.xs4all.nl Tue Nov 20 12:40:25 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 20 Nov 2001 17:40:25 GMT Subject: Still on python GUI toolkit References: Message-ID: <9te4i9$crl$2@news1.xs4all.nl> Luca Fini wrote: > The application I tested is a pixel-intensive type of application because > it is the most challenging of the tools I will need: it displays > continuously an 80x80 syntetic image randomly generated with 256 > graytones, by using small filled squares for each pixel. I coded the three > versions in python to my best knowledge (which is almost zero) of each > toolkit. If you could share the source (and a testcase to generate the continuous data), we might be able to tell whether there are better ways of handling the problem. I'm quite interested. -- Boudewijn Rempt | http://www.valdyas.org From t_sjodin at spray.se Tue Nov 13 16:05:42 2001 From: t_sjodin at spray.se (Dumbledore) Date: 13 Nov 2001 13:05:42 -0800 Subject: Filecount Message-ID: <43246c37.0111131305.105e9fe3@posting.google.com> Hi, Is it possible to use a Jpython script to count files in a certain directory? If yes, how is the script look like? Thanks in advanced. From sholden at holdenweb.com Thu Nov 29 14:59:40 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 14:59:40 -0500 Subject: using access databases from python References: <3C0672A8.86BD7D43@ecn.purdue.edu> Message-ID: [posted & mailed] "Christopher N. Deckard" wrote ... > Do to M$ Access's inability to correctly export data from its > database, I am searching for other ways to dump an access database > to tab delimited files. I was wondering if there is an access > database python module. Even if it only works on Windows, that's > fine. I just need to get data out of Access to put it into a > Postgres database. > You should be able to do considerably better than transfer via tab-delimited files. You can access both PostgreSQL and Access through the Python DB API. I haven't actually used PostgreSQL in anger yet, but there are at least three modules for it. I usually use mxODBC to access Jet databases. It's freeware for personal use, though you have to buy a license for commercial applications. > If something like that doesn't exist, how else can I do it? > You'll need to take a look at the DB API documentation, which you'll find under the DB SIG's area of www.python .org. It's not that hard to use. To give you some idea of exactly how simple database transfer is, here's a program I used to copy a small Access database into Gadfly so I could test an application on that platform. Only one table is involved, but the principles would be the same for any number. In this particular program I used the odbc module which comes with the Win32 extensions. I was lucky: often program will fail if you don't import the dbi module before importing odbc. # # Create the gadfly database from the "Webdata" ODBC source # import gadfly import odbc ocn = odbc.odbc("Webdata") ocu = ocn.cursor() gcn = gadfly.gadfly() gcn.startup("webdata", "gadfly") gcu = gcn.cursor() gcu.execute("create table PgData (PgName varchar, PgNum integer, PgText varchar)") ocu.execute("select PgName, PgNum, PgText from PgData") gcu.execute("insert into PgData (PgName, PgNum, PgText) values (?, ?, ?)", ocu.fetchall()) gcn.commit() for obj in (gcu, ocu, gcn, ocn): obj.close() print "gadfly database created" regards Steve -- http://www.holdenweb.com/ From mikael at isy.liu.se Thu Nov 1 09:59:56 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 01 Nov 2001 15:59:56 +0100 (MET) Subject: Monty Python (was: Freeware Python editor) In-Reply-To: Message-ID: On 01-Nov-2001 Me, myself, and I hastily wrote: > You should really watch them in their original language. And I admit, > some of them are not that great (those where legs and arms are cut off > and blod everywhere). But then there are the others (for instance the ^^^^ > dead parrot sketch), where the humour is in the language. And they are > fantastic. Make that "blood". /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 01-Nov-2001 Time: 15:58:27 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From wolfson at uchicago.edu Wed Nov 14 18:12:00 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Wed, 14 Nov 2001 17:12:00 -0600 Subject: How to marshal a function? References: <01111412544105.04702@logiplex1.logiplex.net> Message-ID: In article , "Cliff Wells" wrote: > On Wednesday 14 November 2001 12:54, Cliff Wells wrote: > > >> > Earlier today, I wondered how to marshal a function, in view of >> > transmitting it to a remote machine and executing it there. The idea >> > was to not transmit Python source, when the byte-compilation has >> > already been done on this side. > > Another reason to use pickle rather than marshal: Pickle won't necessarily work, though. If I have: #file test.py def make_adder(a): def adder(b): return a + b return adder #file test2.py import test, cPickle print cPickle.dumps(make_adder) The result relies on importing a module called "test" and accessing an attribute called "make_adder". If that file isn't present on the other machine, there's trouble. A solution using marshal that doesn't suffer from that problem is: def load_function(s): dummy = lambda: None dummy.func_code = marshal.loads(s) return dummy But that dumps core with nested scopes: Python 2.2b1 (#1, Oct 19 2001, 15:58:12) [GCC 2.96 20000731 (Red Hat Linux 7.1 2.96-81)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import marshal >>> import test >>> def load_function(s): ... dummy = lambda: None ... dummy.func_code = marshal.loads(s) ... return dummy ... >>> g = load_function(marshal.dumps(test.add4.func_code)) >>> g(1) Segmentation fault (core dumped) -- BTR Why does this Wolfson person see fit to clutter up Usenet with such absurd nonsense? -- Bob Cunningham in From wurmy at earthlink.net Sat Nov 24 13:38:04 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sat, 24 Nov 2001 18:38:04 GMT Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> <3BFF94BE.512ABA80@verizon.net> Message-ID: <3BFFE8F0.78190842@earthlink.net> Power-Tech wrote: > > Hey guys, > Thank you very much for the answers....I loved this group and I'll > definitely stick around to share your expertise! > I used the solution mentioned by Jeff: > At the very end of your script, add this line: raw_input("Press Enter > to Finish") This is a solution that usually works well, but keep in mind that if your script raises an exception, that last line may never be reached. (Unless you wrap everything in a try-finally or so.) So if the window disappears anyway, you know something went wrong. :-) --Hans From DeepBlue at DeepBlue.org Mon Nov 5 12:01:03 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Mon, 5 Nov 2001 11:01:03 -0600 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: "Hung Jung Lu" wrote in message news:8ef9bea6.0111050832.4474d66a at posting.google.com... > Python seems very friendly, at first sight. But unless you really > understand the dictionary and namespace (and name binding) mechanisms > behind it, you'll run into surprises in no time. And at that moment, > there is simply no way that it could be explained in easy terms to > beginners, when they don't understand things like pointers, > references, memory stack and heap, hash tables. > You run into surprises in every field. What you are running into is not the inherent difficulty in grasping such concepts, but the teaching methodology. Also you are underestimating students. Teaching methodology is what counts. I have seen some smart people with grasp of certain 'difficult' concepts but are such failed instructors who made a mess in the way they explain things. What you need is the equivalent of John Archibald Wheeler and Richard Feynman in Physics. Believe me: if someone can explain Space Time Physics (Wheeler) and Quantum Electrodynamics (Feynman) in an everyday language that everyone can actually follow and understand; you are going to find talented people who can explain name spaces to beginners. After all, on a 'diffiiculty' ladder, what is a name space concept to the concept of a Riemann non-Euclidean Geometry or a 4D Minkowskian Space Time vector! DeepBlue From barry at zope.com Fri Nov 16 14:45:33 2001 From: barry at zope.com (Barry A. Warsaw) Date: 16 Nov 2001 14:45:33 -0500 Subject: How much is set in stone? References: <9sraco$35f$1@nntp9.atl.mindspring.net> Message-ID: [Andrew posts a cute way to trick cPickle into deleting a file...] Note that pickle isn't so easily tricked, but only because of an implementation accident in TemporaryFileWrapper. This was a fun one that had Tim and me stumped for a bit while we tried to figure out exactly what was going on. Turns out that if you use pickle for this example, you'll get an exception during loads() because TemporaryFileWrapper implements a __getattr__() that fails when the Unpickler tries to see if the object has a __setstate__ attribute. This is because the instance's __dict__ doesn't yet have a 'file' key, so you get a KeyError at that point. cPickle is vulnerable because it masks all exceptions during the search for inst.__setstate__; if that fails it just interprets that to mean that it had no __setstate__ attribute and continues onward. pickle OTOH only catches AttributeErrors so the KeyError shorts out pickle.loads() and thus your TemporaryFileWrapper instance never gets a chance to run its __del__(). AD> Sure, and it was doable in pickle.py as well by making a AD> subclass and overriding the find_class method (example shown AD> elsewhere). But I didn't know I needed to do that, and it's AD> hard to figure out which classes are okay to pickle safely. AD> Some of my own classes have these sorts of filesystem cleanup AD> code in __del__. So pickles are hard to use safely for AD> insecure-but-non-trivial data. Indeed. I'm curious on how we can systematically make it better, but that's for another day, hopefully to be captured in a pickle PEP for 2.3. sniffing-pickles-is-bad-for-your-health-ly y'rs, -Barry From tjreedy at home.com Wed Nov 28 01:05:12 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 28 Nov 2001 06:05:12 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrna07n5a.t7e.qrczak at qrnik.zagroda... > Tue, 27 Nov 2001 14:30:18 GMT, Terry Reedy pisze: > > As I explained in my last post in this thread, > > := > > is not 'right' but merely an ill-chosen convention of a minority of > > computer users, > > It's not a minority. Almost everybody uses this convention. It's > better to use the most common convention consistently than to invent > new conventions (like "tab = one indent level"). There are far more people doing word processing, spreadsheet work, and database reports than people doing programming and Unix/Linux systems work. I believe that almost all of the former would find your dictum on tabstops to be weird and useless. Terry J. Reedy From tdelaney at avaya.com Mon Nov 19 00:28:28 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 19 Nov 2001 16:28:28 +1100 Subject: List-of-lists (aka array) mystery Message-ID: > From: Matthew Morency [mailto:mmorency at wpi.edu] > > What version of python did you find this in? > > aardvark wrote: [snip list of lists created via *] It should be in every version of Python. Tim Delaney From deliberatus at my995internet.com Thu Nov 8 13:50:58 2001 From: deliberatus at my995internet.com (Kirk Bailey) Date: Thu, 08 Nov 2001 13:50:58 -0500 Subject: I just got in! Message-ID: <3BEAD412.C65C45E3@my995internet.com> in the list that is. I want to learn about python, write some things in it, and show that smug bunch ovver in the perl tree that snakes are way cooler than camels. Although these days, EVERYONE wants to smoke a camel... -- Respectfully, -Kirk D Bailey (C)2001 Addme! icq #27840081 end My Sites: http://www.howlermonkey.net/ - free REAL email! list service soon! http://www.sacredelectron.org/ - Rants! Spleenvents! http://www.minorfish.org/ - The list server for some of us! From billw at witherspoon-design.com Mon Nov 19 14:57:02 2001 From: billw at witherspoon-design.com (Bill Witherspoon) Date: Mon, 19 Nov 2001 14:57:02 -0500 Subject: General infrastructure/design question - long Message-ID: <20011119145702.3d23ad04.billw@witherspoon-design.com> (First - this is a great list, I learn alot everyday just reading the posts. You should all be congratulated for this!) (Second - I'm not a professional so this question may seem, well, a bit off...) I'm writing an app for small businesses which have to 'track' clients and schedule visits, (dentist, barber,etc.) I'm using mySQL right now but hope to keep my programming abstract enough to use Postgres, or another db. I've written a wrapper over the MySQLdb module (thanks Andy) which allows me to open a database, and execute queries in a very simple fashion. Another module has all of the classes which I want to load with data (like client info). I can load a 'client' object with info from the database with a line like: client1 = appclasses.Client(queryresults[0]), where queryresults was a SQL query on the db. This loads the data into the appropriate object 'properties' using the client class's __init__ method. whew... almost there Is there a better way to do this? My fear is that everytime I change the db schema, I have to run around and update all of the classes to insure that the data maps correctly. Is there any way to easily have a class that 'knows' how to create its own __init__ so that the db fields always become appropriate properties? ie. (passing the db schema, and values for a particular client) class Client: def __init__(self, attributevalues, schema): Loop through schema list and create properties so that I end up with: client1.Name = 'Bill' client1.Address = yadayada... and if I add a field to the db (like phnumber), the next time I instantiate a client object it will have a phnumber property. (Without changing the __init__ code). Is this ridiculous? I assume everyone faces this problem so I'm hoping someone can give me a little guidence. TIA, Bill. From max at alcyone.com Thu Nov 22 23:20:14 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 22 Nov 2001 20:20:14 -0800 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> Message-ID: <3BFDCE7E.DD6E6245@alcyone.com> Peter Caven wrote: > I think that the previous concerns expressed about syntax etc. have > been > mostly solved in the work done by: > > http://www.grammatical-evolution.org/ You can _do_ it, but it's much harder to automatically generate programs for languages that are not well-suited to it. Since when you're putting together a genetic programming system you get to choose which language is used to generate programs (which is potentially totally separate from the language used to create the system), it only makes good sense to choose a well-suited language; choosing something else is just a waste of time. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From phr-n2001d at nightsong.com Sun Nov 4 03:27:53 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 04 Nov 2001 00:27:53 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: <7xk7x7ey9i.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > Across decades of integer numeric programming, I can't recall any *use* for > that identity; but that i%j >= 0 whenever j>0 is endlessly useful, as is > your identity relating int-div and int-mod. I did notice that Algorithm X from Knuth vol. 2 for extended GCD gives negative answers in Python if you code it straight from the book. It was easy to correct so I didn't analyze it carefully but I think floor-mod may have had something to do with it. From phd at phd.pp.ru Fri Nov 9 06:05:12 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 9 Nov 2001 14:05:12 +0300 Subject: Matrix in Python . In-Reply-To: <018001c1690c$5b3af8c0$9792003e@rashome>; from weismann@netvision.net.il on Fri, Nov 09, 2001 at 12:50:32PM +0200 References: <018001c1690c$5b3af8c0$9792003e@rashome> Message-ID: <20011109140512.J20597@phd.pp.ru> On Fri, Nov 09, 2001 at 12:50:32PM +0200, Amit Weisman wrote: > Is there a module for dealing with Matrix ? Not a module, but big good package of modules and tools - Numerical Python: http://www.numpy.org/ Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tdelaney at avaya.com Mon Nov 26 20:52:33 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 27 Nov 2001 12:52:33 +1100 Subject: function operators Message-ID: > From: James A. H. Skillen [mailto:jahs at jahs.org] > > Has anyone ever wished that Python had operators defined on functions? > For example, suppose you want the function f(x) = cos(x) + sin(x). > You could do: > > def f(x): > return cos(x) + sin(x) > > or > > f = lambda x: cos(x) + sin(x) > > but wouldn't: > > f = cos + sin > > be *much* nicer? You could do all of this using callable classes. Wouldn't even be particularly difficult. For a few pointers in the right direction, look at the currying classes at http://aspn.activestate.com/ASPN/Python/Cookbook/. Tim Delaney From radue at thuntek.net Sat Nov 3 14:13:09 2001 From: radue at thuntek.net (Roger Due) Date: Sat, 03 Nov 2001 12:13:09 -0700 Subject: Tiny Personal Firewall vs ZoneAlarm Message-ID: I recently implemented Tiny Personal Firewall 2.0.15 (12 Oct 01) on our Win2K server that also servers as an application development workstation, email, & internet access. TPF is easy to setup and operate and seems to work well. You can get a copy from www.tinysoftware.com. It understood that I was on a local network and configured itself properly and set itself up to run as a service. By default it configures itself for medium security, which means that you are prompted when one of your applications initiates outside communication and you can either accept or deny this access and have the option to tell it to create the appropriate rule for the next time. Before I installed TPF, I had downloaded their 37-page pdf manual and read it. For someone who is not an expert on firewalls, I found it easy to understand and much prefer this over help built into the program. By using IE & Eudora & Agent to access the internet, I quickly configured TPF to allow their traffic. I also used www.grc.com to refine access further. Then used all the tests found on http://scan.sygatetech.com to further validate the effectiveness of TPF. So far it has passed every test. Now why did I switch to Tiny Personal Firewall when I had already purchased ZoneAlarm Pro 2.6 back in June and ZoneAlarm seems to get all the publicity? The primary reason is that the people at ZoneAlarm don't have a clue about customer service!!! I tried 5 different times via email, each time rewording the request, to get an answer as to how I could get the latest version of ZoneAlarm Pro 2.6 to use with my license code to install at this time instead of having to install the older 2.6 version first and then upgrade. Never once did they answer the question satisfactorily. Of course they don't provide phone support, but when I managed to get hold of a sales person he was annoyed and hung up on me without helping. So I started doing some additional checking. Some of you have mentioned WinRoute Pro and I have seen reasonably good reviews of Tiny Personal Firewall. I placed a call to Tiny and got hold of one of their sales people. What a switch!!! He was very helpful. I didn't mention anything about ZoneAlarm at first, but had a lot of questions about what would be best for our configuration. We decided that TPF was the way to go. I then called another person who writes reporting utilities for different firewalls, and he confirmed what I had already figured out. He also uses TPF and is satisfied. Today I called back the salesman at Tiny and thanked him and then logged onto their web site and paid my $39, since this is being used in a business environment. For personal use, it is free. Hope this helps someone else who might be thinking about firewalls. -- Roger From ahamm at programmer.net Thu Nov 29 22:57:40 2001 From: ahamm at programmer.net (Andrew Hamm) Date: Fri, 30 Nov 2001 14:57:40 +1100 Subject: New updates needed for an old computer language humor piece References: Message-ID: <3c0703b3$1_2@news.iprimus.com.au> Ric Werme wrote in message ... >The following wandered into my mail box for the first time in a year >or two. Since I've been learning a bit of Python this year, it seems >to me an update is needed. > >For Logo, perhaps: Draw a foot, draw a gun, but the bullet comes out >the handle and misses the foot altogether. > ksh: export CALIBRE=45 set -a COLT $CALIBRE $CALIBRE $CALIBRE $CALIBRE $CALIBRE $CALIBRE foreach bullet in ${COLT[*]}; do shoot -c $bullet >> foot & echo scream done wait && sleep $RANDOM -- Space Corps Directive #997 Work done by an officer's doppleganger in a parallel universe cannot be claimed as overtime. -- Red Dwarf From tdelaney at avaya.com Tue Nov 27 21:37:51 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 28 Nov 2001 13:37:51 +1100 Subject: Copy operator (was list.remove for Noivces) Message-ID: > From: Arthur Siegel [mailto:ajs at ix.netcom.com] > Jeff Shannon wrote: > > But if I could find some way to demonstrate (not saying that I > necessarily could find a way to do so convincingly) that it would > indeed make Python better equipped for beginners/learners - > is there a shot it would find acceptance by the community? Probably not, since the only thing it would be doing would be introducing syntactic sugar for something which Python already has. Most importantly however, beginners rarely have any idea of the difference between a deep and a shallow copy. It is important to keep these two concepts separate (though closely related). Python already has the difference well disambiguated (copy.copy vs copy.deepcopy). Adding line noise is more likely to confuse beginners than having the copy operations in a separate module. In addition, there is already standard syntactic sugar for performing a shallow copy of a sequence (slicing notation) - this can be abused, but it is usually safe to rely on it (and if not, it should be in the docs). I've noticed most of your recent posts concern things which are either possible flaws in the documentation, or are in the FAQ list, or should be in the FAQ list. I think a well-maintained FAQ list is much more important than making changes to Python to make it "more friendly" to beginners. In addition, the FAQ list must be very readily available i.e. it should be part of the standard docs, with (of course) links to the online FAQ list (and preferably, the option to update the local copy from the online copy) and IMO should be part of the tutorial. That is, the tutorial should have a link to the FAQ list prominently on its contents page, and each section should contain links to the relevant sections in the FAQ. This would of course be a very large job. Tim Delaney From tim at vegeta.ath.cx Sun Nov 11 23:28:05 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 12 Nov 2001 04:28:05 GMT Subject: IsPython really O-O? - Think different ! References: <9smovs$cbu$02$1@news.t-online.com> Message-ID: Guido Stepken graced us by uttering: [ snip ] > 13. Python has future - see Microsoft Visual Studio implementation of > Python ..... - Even Microsoft likes Python !!!!!!!!!!!!!!!!!!!!!!!! Visual Python is distributed by ActiveState. Visual Perl is also distributed by ActiveState. Microsoft certainly doesn't "like" Perl (as inferred from it's attempted license agreement. Tim Hammerquist -- The mind of a bigot is like the pupil of the eye. The more light you shine on it, the more it will contract. -- Oliver Wendell, Jr. Holmes From chrishbarker at home.net Wed Nov 28 17:28:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 28 Nov 2001 14:28:57 -0800 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: <3C056529.46E0508@home.net> Ken Seehof wrote: > Also, the Open Source community generally likes to maximize > interoperability, because the utility of the software and size of the user > base tend to be the most important design objectives, whereas creating > leverage for operating system market dominance is not an issue. Interestingly, creating leverage for software license dominance IS an issue. See: http://www.gnu.org/licenses/why-not-lgpl.html I would argue that there is an altruisic motivation, rather than a selfish one behind this, however. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From brian at rk-speed-rugby.dk Thu Nov 1 02:23:47 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 01 Nov 2001 08:23:47 +0100 Subject: Documentation for tkFileDialog [WAS: [comp.lang.python] Re: tkinter - tkFileDialog - how to get dir instead of file] References: <9rou3f$p0b$1@news.sinet.slb.com> Message-ID: Martin Franklin writes: > In short YES;-) Thanks, then I know and where to look. Seems very useful. > > I 'found' this and other modules in the standard library > (/usr/local/lib/python2.1/lib-tk) -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From paul at boddie.net Fri Nov 23 10:20:25 2001 From: paul at boddie.net (Paul Boddie) Date: 23 Nov 2001 07:20:25 -0800 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: <23891c90.0111230720.13243591@posting.google.com> tboyle at NoSMAProsehill.net (Todd Boyle) wrote in message news:<3bfe9816.152519843 at news.cortland.com>... > > But, what is the best way to build web-based database applications > like accounting systems, on Python? i.e. what is the equivalent > of ASP pages or PHP pages or JSP pages, for Python?? Shouldn't > we be learning THAT instead of PHP??? For an overview of "templating systems" for Web applications, take a look at... http://webware.sourceforge.net/Papers/Templates/ For an overview of frameworks, have a look at the comparison table at... http://www.paul.boddie.net/Python/web_modules.html I'll attempt to do a more serious update of that document soon, so that the most relevant, updated and capable frameworks feature more prominently, and the "stale", less relevant and more limited frameworks are mentioned primarily for historical reasons. Paul From DTSRV10-SA at dutchtone.nl Wed Nov 28 04:35:35 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Wed, 28 Nov 2001 10:35:35 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C717EC@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = _Krzysztof.Czarnowski at dgt-lab.com.pl Recipient(s) = python-list at python.org Subject = Scanning Time = 11/28/2001 10:35:34 Action on virus found: The attachment SETUP.DOC.scr exists WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From uwe at rocksport.de Wed Nov 28 05:37:47 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 28 Nov 2001 10:37:47 GMT Subject: wxPython: problems with doubleclick References: <9u0um2$b9p93$1@hades.rz.uni-sb.de> <83d7236eor.fsf@panacea.canonical.org> Message-ID: <9u2epr$b8vrs$1@hades.rz.uni-sb.de> In comp.lang.python Kragen Sitaker wrote: | Perhaps saving a file could reset the painting tool to a no-op tool? I had that idea too, but what happens if I select a file with two single clicks: the file is loaded/saved and the first click in my canvas does not work... Yours, Uwe. -- Dr. rer. nat. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From dalke at dalkescientific.com Tue Nov 6 12:25:12 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 6 Nov 2001 10:25:12 -0700 Subject: Converting exponential numbers to strings. References: <32921e0b.0111051350.41e35f26@posting.google.com> <7xpu6w6es0.fsf@ruckus.brouhaha.com> Message-ID: <9s96cn$cnj$1@slb6.atl.mindspring.net> Paul Rubin wrote: >How about this: > try: > x = float(s) > result = 1 > except: > result = 0 It's better to catch ValueError and not all exceptions. Else what would happen if you get a MemoryError or a KeyboardInterrupt? try: float(s) result = 1 except ValueError: result = 0 In general, I consider 'except:' to be too blunt. You should catch only those exceptions you know about. If you have to catch everything, do except KeyboardInterrupt: raise except: .. (If there's a callback, I often allow it to exit, so I often do except (KeyboardInterrupt, SystemExit): raise except: .. ) Andrew dalke at dalkescientific.com From logiplexsoftware at earthlink.net Tue Nov 20 13:44:35 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 20 Nov 2001 10:44:35 -0800 Subject: How to marshal a function? In-Reply-To: <83adxhu0sk.fsf@panacea.canonical.org> References: <83adxhu0sk.fsf@panacea.canonical.org> Message-ID: <01112010443500.01362@logiplex1.logiplex.net> On Tuesday 20 November 2001 03:41, Kragen Sitaker wrote: > Cliff Wells writes: > > On Wednesday 14 November 2001 15:10, Fran?ois Pinard wrote: > > > Besides, I feel a bit safe as I channel these Python services > > > through `ssh', which provides enough user authentication for us, so > > > I presume. > > > > Well, that's a different story altogether =) If you weren't using > > ssh, it would be a huge security hole. > > Not necessarily. You need to know more about his setup than whether > or not he is using ssh to know whether some process trusting data it > receives over a network is "a huge security hole". For example, if > his intended security policy is that anyone on the network should be > able to run arbitrary Python code on the server, it is not a security > hole, ssh or no ssh. This is a reasonable security policy for many > networks, like the one in my bedroom. (In today's virus-prone world, > perhaps it isn't the best security policy, but it's a reasonable one.) > > On the other hand, if the machine he's sending the arbitrary code from > is poorly secured (relative to whatever his threat model is), allowing > a program on that machine to run arbitrary code on the other machine > is a security hole, ssh or no ssh. (Although if ssh is permitting him > to run arbitrary code anyway, it's not his program's fault if it's > insecure.) > > It irks me when people have such a glib attitude about security; it > reminds me of newspaper agony aunts who are happy to recommend that a > woman leave her husband on the basis of two ambiguous sentences of > complaints. To know whether something is "a security hole" requires, > at least, that you know what threats you want to defend against and > what threats might actually exist. Actually, I read his post _very_ carefully and decided that what he was saying is that he is routing the port that his server is listening on over ssh. This is probably reasonably secure for most circumstances. Additionally, since his attitude was similar to yours (annoying), I decided to end it by agreeing with him, which I find to be the quickest way to avoid wasting my time with people who flame rather than discuss. You are absolutely right: no one can decide except him whether his security is sufficient, hence everyone should avoid offering advice on the subject in case someone may disagree with you. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From jeff at ccvcorp.com Fri Nov 9 13:38:38 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 09 Nov 2001 10:38:38 -0800 Subject: Matrix in Python . References: <9sglpt$a3r$1@news.tpi.pl> Message-ID: <3BEC22AE.AAA58F3@ccvcorp.com> Nomad wrote: > You mean Python is going to take over the world and keep living people > in vats of goo? What do you think the PSU has been doin From pieroul at attglobal.net Sun Nov 4 20:10:26 2001 From: pieroul at attglobal.net (Pierre Rouleau) Date: Sun, 04 Nov 2001 20:10:26 -0500 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> <3BE5A1A7.75C7EC9C@attglobal.net> <9s4f79$8b3$1@nntp2-cm.news.eni.net> <87ady25fdf.fsf@lisboa.ifm.uni-kiel.de> <3BE5D350.6BD162FB@attglobal.net> <87y9lmnl4o.fsf@lisboa.ifm.uni-kiel.de> Message-ID: <3BE5E702.B19ECFBD@attglobal.net> > But as noted in this thread, > popen also starts a shell for each command, so it doesn't really solve > your problem, if this is actually a problem :-). It's not that it is a problem. But I was trying to create an Python object that I would be able to use where I would change directories, change environment variables values (or add/delete environment variables). Using os.system(), os.popenXX() and the like the environment of these sub-processes are lost after every invocation. I guess my other bet would be to re-direct stdin/stdout/stderr to a shell process, but then I would not have access to the returned shelled program value. When i first tried os.system() i tried it within the IDLE system in NT. Under IDLE in NT, every time your call os.system(), a shell window pops up briefly while the command runs. I was trying to avoid that. Later, i noticed that if i run python from a shell directly, os.system() does not behave like that (no other window pops up). Thanks for the help! Pierre From osuchw at ecn.ab.ca Sat Nov 10 04:59:22 2001 From: osuchw at ecn.ab.ca (waldekO) Date: 10 Nov 2001 01:59:22 -0800 Subject: Open a windows database file with a path name? References: Message-ID: Nomad wrote in message news:... > Hi, > > Is there anyway that I can open a database (MSAccess in this case) > using the path and file name rather than a DSN? I can't seem to get > it to work. > > TIA try this: >>> from win32com.client import Dispatch, constants >>> eng = Dispatch('DAO.DBEngine.36') >>> db = eng.OpenDatabase('c:/db1.mdb') >>> rs = db.OpenRecordset('select * from tblHolidays') >>> rs.Fields('ID').Value 1 >>> rs.MoveNext() >>> rs.Fields('ID').Value 2 From skip at pobox.com Wed Nov 14 04:15:27 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 10:15:27 +0100 Subject: Sockets and messaging services In-Reply-To: <97ae44ee.0111131614.57ff3098@posting.google.com> References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> Message-ID: <15346.13871.89267.849569@beluga.mojam.com> >> IMHO the SMTP and POP protocols provide the same benefit (and there >> are Python modules for those protocols). shriek> Using a mailserver as a messaging platform for middleware ? It's not all that far-fetched. I know some people have experimented with XML-RPC over SMTP (which is no longer XML-RPC, but that's a nit). -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From cpr at emsoftware.com Wed Nov 14 00:37:37 2001 From: cpr at emsoftware.com (Chris Ryland) Date: 13 Nov 2001 21:37:37 -0800 Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: <8827e15d.0111132137.5beb1809@posting.google.com> "Morten W. Petersen" wrote in message news:... > Hello, > > I'm currently doing some research, to see if it could be an advantage to > use Common Lisp instead of Python (currently Python and Zope [1] are used > to build web applications). You have to see , particularly the "Beating the Averages" and "The Other Road Ahead". I went back and forth with Paul a few times re: Lisp vs. Python, and in the end the only really serious differences we could come up with were (a) Lisp's universal (i.e., non-) syntax makes it easy to write little languages and to use macros, and (b) Lisp compilers exist today which produce quite a bit more efficient code than Python's interpreter can do. [Forgive me, Paul, if I'm mis-remembering.] (a) could be tackled, if someone were seriously inclined, by getting the Python folks to agree on an intermediate Lisp-like syntax (lists), and letting people use either the normal Python syntax or the lower-level syntax, which would then admit of macros and "easy little languages". (b) is only a matter of time & will. Of course, nothing is that simple, and there are huge reservoirs of expertise in the Lisp community that the Python folks haven't tapped into, and vice versa (though clearly less versa, since Python has only been around for 10-ish years, and hasn't had the academic/research following that Lisp has). Just some random thoughts. --Chris Ryland, Em Software From jae at jerhard.org Thu Nov 29 17:19:44 2001 From: jae at jerhard.org (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Thu, 29 Nov 2001 23:19:44 +0100 Subject: python editor poll In-Reply-To: (message from Tim Hammerquist on Wed, 28 Nov 2001 06:03:57 GMT) References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> Message-ID: >>>>> "Tim" == Tim Hammerquist writes: >>>>> "Jonathan" == Jonathan Gardner wrote: Tim> You wanna start a flame war? Say you're a Vimmer _and_ a Tim> Perler! I learned my lesson! So why do you say it again? ;-) BTW, do you know how "vimmer" sounds to a German? :-) Jonathan> * In case you're wondering what editor I use, let me Jonathan> just say that it works really well with the email client Jonathan> that sucks less than all the others. Tim> Yes, I use the mutt+vim combo, myself. You couldn't _pay_ me Tim> to change. And in my case... Emacs, since I happened to run across uEmacs in my Amiga days (first editor that felt *good*). (As if anyone wanted to know that ;-) Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sf.net) My WebHome: http://jerhard.org The GNU Project (http://www.gnu.org) "MCSE: Minesweeper Champion and Solitare Expert" -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From phr-n2001d at nightsong.com Thu Nov 15 20:58:56 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 17:58:56 -0800 Subject: Python & cgi on win98--tinyweb problems, etc References: <7x8zd7zfh8.fsf@ruckus.brouhaha.com> Message-ID: <7xbsi3328v.fsf@ruckus.brouhaha.com> Chris Stromberger writes: > Hadn't thought of that. Do you mean CGIHTTPServer? The docs say > "Note: This module is Unix dependent since it creates the CGI process > using os.fork() and os.exec()." so that won't work for win98, unless > I'm missing something. I don't see how to run cgi's without forking. That's more or less the definition of a cgi. So I was thinking more in terms of extending BaseHTTPServer to run your Python code directly on parsing the request. From dalke at dalkescientific.com Thu Nov 15 07:45:52 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 15 Nov 2001 05:45:52 -0700 Subject: shutil.rmtree bug ? References: <85e27928.0111150239.464505e@posting.google.com> Message-ID: <9t0dbq$6qj$1@slb6.atl.mindspring.net> copter24: >With win nt4 and Python 2.1, why shutil.rmtree(path, 0) does not raise >an exception when there is effectivly one ? > >Any idea ? I just looked at the implementation. It should raise an error for your case. There's no way I see that it could do otherwise. Can you give an example of something you expect to fail but doesn't? Why do you think it isn't doing the right thing? Andrew dalke at dalkescientific.com From BgPorter at NOartlogicSPAM.com Fri Nov 30 10:03:13 2001 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Fri, 30 Nov 2001 15:03:13 GMT Subject: The Ideals of a Python Hacker (was: Poll Results) References: <3bfd7f87@news.airtel.net> <3C06FE0D.BD7E55A0@engcorp.com> Message-ID: "Peter Hansen" wrote in message news:3C06FE0D.BD7E55A0 at engcorp.com... > Jonathan Gardner wrote: > > > Rather than wait for such a group to find/hire you, however, > you would be well advised to find ways of integrating > Python into the work environment you are already at. I > have yet to see a development environment in which it was > not often necessary to write little utilities to assist > in development, file massagers, and so on. Python is > easily one of the most effective at this, and unlike > otherwise suitable languages it will be hard for anyone > to complain the result is not maintainable. And no > one can stop you from using it on your own machine. > (Well, I've heard of such companies too, but I can't > imagine working for one.) Exactly -- in the two years that I've been goofing with Python, just an occasional mention of how cool Python is (and why that's the case) have started getting others at work to check it out. Of course, being able to deliver an inhouse tool written during a single lunchbreak that someone else had estimated as taking a few days doesn't hurt, either. Python is now in my cow orkers' minds when suggesting solutions to clients. -- // Brett g Porter * Lead Engineer, Development Practices // BgPorter @ artlogic . com * http://www.artlogic.com // Art & Logic * Custom software solutions for hardware products // Windows * MacOS * Embedded Systems From mlh at idi.ntnu.no Tue Nov 20 05:01:35 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Tue, 20 Nov 2001 11:01:35 +0100 Subject: GUI toolkit References: <9t13p3$1v9$1@news1.xs4all.nl> <9tb6ke$1evoq$3@ID-89274.news.dfncis.de> Message-ID: <9td9lv$c8p$1@tyfon.itea.ntnu.no> "Bernhard Reiter" wrote in message news:9tb6ke$1evoq$3 at ID- > It is less know that Qt is only Free Software (as in freedom) for X11, > not for Windows or MacOSX. > > (For me that's a big argument. > Everybody should be aware of it, I've seen this stated wrong many times.) At least the Professional edition costs money... But does it prevent you from building Free software? The FAQ only says that it allows you (as opposed to the free/Free version) to make non-Free software... And the Free version is very Free (in a very negative sense, IMO) in that it contaminates software that has been *developed* with the Free version, even if you ship it with the Professional software... Scary... I'm glad Emacs doesn't come with a license like that. > Bernhard -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From mwh at python.net Thu Nov 8 08:12:55 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 8 Nov 2001 13:12:55 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> "Frederic Giacometti" writes: [schnipp] > Does this make sense? But isn't the point of many multithreaded apps allowing code to run during blocking IO operations? Your approach would knock that on the head. Cheers, M. -- languages shape the way we think, or don't. -- Erik Naggum, comp.lang.lisp From logiplexsoftware at earthlink.net Fri Nov 9 17:59:56 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 14:59:56 -0800 Subject: count in 'for ... in ...' In-Reply-To: References: Message-ID: <01110914595606.01414@logiplex1.logiplex.net> On Friday 09 November 2001 14:37, DeVerter at robinsonmechanical.com wrote: > Try this. > > for s in my_list: > print my_list.index(s), ".", s > > This way you don't need a counter variable. > I'm guessing that list.index() does a linear search through the list, so this would degrade performance pretty badly. Additionally, if there are duplicate items in the list, you'll get the first one every time. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From frederic.giacometti at arakne.com Wed Nov 7 11:47:48 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Wed, 07 Nov 2001 16:47:48 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: "Gordon McMillan" wrote in message news:Xns91518EE46939Bgmcmhypernetcom at 199.171.54.215... > Frederic Giacometti wrote: > > In Stackless, the Python stack and the C stack are completely separate. > In the case where C code needs to call Python and then do something with > the result (that is, where tail recursion doesn't apply), Christian used > the trick of manufacturing a Python-style frame object that represents the C > code. As far as (Stackless) Python is concerned, it gets dispatched like > any other frame (Stackless' Python "stack" is really a tree). That sounds to me that the current Python thread model could also be reengineered with stackless, profitably. Here is a possible direction: *** Replacement of the Python lock with a Python dedicated thread *** Instead of having the Python VM running in multiple threads sequentially, by means of the Pythonsynchronization lock, the Python VM would run in one dedicated thread (on single thread build, this would just be the main thread) - this is just a reversal of paradigm -.. Then: - stackless would manage the micro-threads within the (unique) python thread - there is no more need for a global python lock (and performance would boost); stackless managing on its own its continuation list, and the event queues from other threads and C functions. - C code can run independently in other threads, using standard inter-thread communication mechanisms to communicate with the Python VM (just like the lock; but then only the 'C client functions' have to hang on the interrupt; while Python stackless would run uninterrupted, unlike in the current system). On other terms: - the Python VM would run in one single thread (presently, the Python VM, by means of the Python lock, already runs in a single-threaded fashion) - the Python thread would act as server thread to the other threads requesting calls to Python. - this would get rid to the Python lock synchronization overhead, and somehow simplify the current multithreaded approach - the concept of stackless microthread would be conciliated with the current Python thread objects, that reflect the OS native threads. This would impact the current threading/thread modules: then a Python thread object would be a handle to the OS thread were the C code would be run; while all Python bytecode and reference operations would be performed by stackless in THE Python VM thread. Does this make sense? Thanks, FG From dswegen at allstor-sw.co.uk Mon Nov 12 06:00:40 2001 From: dswegen at allstor-sw.co.uk (Dave Swegen) Date: Mon, 12 Nov 2001 11:00:40 +0000 Subject: Running program off CD Message-ID: <20011112110040.T11733@software.plasmon> I'm currently working on a project where I'd like to be able to put python for various platforms on a CD and run it directly off that, without actually installing anything on the host computer. As far as I can tell py2exe is what I want for win, but is there anyhting similiar for un*x/linux? Is it enough to use distutils and setting python path to point to the CD? The platforms I potentially need to support are linux, solaris, win 9x, win NT and win 2k. It would be ideal if all these could be placed on one CD. Any pointers would be much appreciated. Cheers Dave From phr-n2001d at nightsong.com Sat Nov 3 14:02:15 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 03 Nov 2001 11:02:15 -0800 Subject: Python/QT Book no in final edit References: <7xady4cxng.fsf@ruckus.brouhaha.com> <9s1bo2$goc$1@news1.xs4all.nl> Message-ID: <7x3d3v1xvs.fsf@ruckus.brouhaha.com> boud at rempt.xs4all.nl (Boudewijn Rempt) writes: > >>Looks nice. It would be nice to have a link to render it all on one web > > page. > > > why not just wgetting it! (wget exists also for ms-dos and it's a really > > cute software) > > > wget -m -c -np http://stage.linuxports.com/projects/pyqt I just want to read it on the screen without having to click links all the time. > Or you could pre-order it, and have it delivered at your doorstep > in a convenient format that would be an adornment to the shelves > of even the most refined library! I have too many dead tree books already and want to avoid weighing myself down with more. > Please note that the version on the website is not the definitive > version - the editor and I are taking the text through the final edit > just now... Bringing the text up to date for Qt 3.0, for instance, > and getting the last pesky little bugs out of the example code. > > When the book has gone to the printers, we'll be setting up a webforum > at linuxports, with all the sourcecode, and a q&a forum. Cool! From sandskyfly at hotmail.com Wed Nov 21 04:31:22 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 21 Nov 2001 01:31:22 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> <3BF3378B.8030205@altavista.com> Message-ID: Michael Kelly wrote > Is there a utility to "clean" foreign scripts so that tabs/spaces > issues and other stuff invisible to the programmer can be > weeded out? I mean, it would save a lot of time if I could > stick some Begin .. Ends or {} delimiters in the script and > move on to what I'm trying to do or at lease mark a block > and "clean" it so I'd know there'd be and end point to > messing with lines that have no apparent syntactic > errors(and are aligned, at least to the naked eye.) Here are some doc comments from pindent.py (located in Python\Tools\Scripts): # This file contains a class and a main program that perform three # related (though complimentary) formatting operations on Python # programs. When called as "pindent -c", it takes a valid Python # program as input and outputs a version augmented with block-closing # comments. When called as "pindent -d", it assumes its input is a # Python program with block-closing comments and outputs a commentless # version. When called as "pindent -r" it assumes its input is a # Python program with block-closing comments but with its indentation # messed up, and outputs a properly indented version. I also use reindent.py (same location as above)... here's what the doc says: "Change Python (.py) files to use 4-space indents and no hard tab characters. Also trim excess whitespace from ends of lines, and empty lines at the ends of files. Ensure the last line ends with a newline." Happy Pythoning, Sandy From s713221 at student.gu.edu.au Fri Nov 9 04:29:56 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Fri, 09 Nov 2001 19:29:56 +1000 Subject: I just got in! References: <9sep77$eg6$1@slb4.atl.mindspring.net> <9sf2n1$c4u$3@newshost.accu.uu.nl> Message-ID: <3BEBA214.4A206D96@student.gu.edu.au> Martijn Faassen wrote: > > Andrew Dalke wrote: > > One thing about Python people is we are less (outwardly ;) smug > > then your phrase seems to suggest. Perhaps that derives from the > > influence of Dutch tolerance in the early days. > > That's a nice compliment, though my limited experience on Dutch forums > makes it seem implausible. :) > > I am not sure where the generally nice atmosphere comes from. > I think the audience is just fairly mature. It may have settled the > atmosphere early on. Small languages generally attract a more mature > audience, where the average newcomer has a fair number of languages > under their belt already, with more knowledge of language theory but > also language pragmatism. Python is clean and pragmatic enough at > the same time to be useful for such people. It's where > theory and pragmatism meets peacefully. Perhaps that's why the > newsgroup is relatively peaceful as well. *chuckles* Or maybe it's just that behaviour is contagious. Shout at others, eventually they'll leave or shout back. Be polite and kind, and point out that kindness is expected ... *grins* Of course I HAVE to believe this explanation. Despite being "officially grown up" at 24, I really can't think of myself as "mature" by any stretch of the imagination!!! -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From km-list-dated-1006154946.7252a0 at miazine.net Wed Nov 14 02:29:06 2001 From: km-list-dated-1006154946.7252a0 at miazine.net (Kirill Miazine) Date: Wed, 14 Nov 2001 08:29:06 +0100 Subject: test_signal never ends Message-ID: <20011114082906.A9033@poff.miazine.net> Hello, I'm trying to install Python on a machine running OpenBSD 3.0-current. It compiles OK, but make test hangs on test_signal. Here's a timed output of running Lib/test/test_signal.py: kirillm at poff:~/tmp/Python-2.1.1$ time ./python ./Lib/test/test_signal.py starting pause() loop... + sleep 2 call pause()... + kill -5 24575 pause() returned call pause()... + sleep 2 + kill -2 24575 pause() returned + sleep 2 call pause()... + kill -3 24575 pause() returned call pause()... Terminated real 1m29.035s user 0m0.020s sys 0m0.028s kirillm at poff:~/tmp/Python-2.1.1$ (I had to kill the test script because it never finished) It may be something wrong with OpenBSD 3.0-current, because when I tried to install Python-2.2b1 and Python-2.1 I got the same problem. Currently I have Python-2.1 compiled under OpenBSD 2.9-stable and it compiled OK and passed all tests. Any suggestions are greatly appreciated. P.S. Please Cc me when replaying beause I'm not on the list. Thanks. -- Kirill From guignot at wanadoo.fr Tue Nov 13 20:59:06 2001 From: guignot at wanadoo.fr (guignot) Date: Tue, 13 Nov 2001 20:59:06 -0500 Subject: registering a python prog. as a windos service Message-ID: <9sru7r$qkg$1@wanadoo.fr> I have to run some python scripts in background on dual boot Windows/Linux machines. For Unix, no pb. The scripts are launched from rc.local, et hop! For Windows, I tried to register them as a service to be launched at boot time, but they always suck... I beleive that not any prog can be registered??? What did I miss? Tks in advance. J. From peter at engcorp.com Thu Nov 15 22:44:36 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 15 Nov 2001 22:44:36 -0500 Subject: anonymous functions? class? References: <9t1ii2$es0$1@peabody.colorado.edu> Message-ID: <3BF48BA4.D03A627C@engcorp.com> Fernando P?rez wrote: > > Peoter Veliki wrote: > > > I'd like to be able to use a function as an argument without declaring it > > externally. This is what I don't want to do: > > [snip] > > Listen, this is the third time you post this question and people actually > *have* answered it already. Could you be bothered to check for replies first > before you repost or is that too much to ask? Do you require hand-delivery in > special stationery or something else we should be aware of? Funny thing is, he changed names between the second and third posting... used to be named Peter Bismuti. I guess while he was out getting the name-change papers signed he missed our replies. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tim.one at home.com Sun Nov 4 02:14:45 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 02:14:45 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: <3BE4E4FF.BD553892@ix.netcom.com> Message-ID: [Jive Dadson] > ... > Back when dinasaurs walked the earth, I had a long argument with the > Pascal standards committe about the correct definition of the modulus > operator. Believe it or not, they had it so that (-3)%2 was a negative > number! Most languages do, alas. > After much going back and forth, I convinced them otherwise. To > my astonishment, they then proceded to get integer division wrong -- > incompatible with the definition of mod that they finally agreed to! C > and C++ have it wrong also. C89 actually allowed 1 or -1 in this case -- it left floor vs truncation implementation-defined for negative int division results. C99 goes out of its way to insist on truncation, though; the Rationale only mentions "compatibility with Fortran", like masses of C programmers give a rip about that . > The following relation should hold for any integer x and any positive > integer M: > > (x/M)*M + (x%M) == x While C left floor-vs-trunc undefined, it did insist on this (so int / and % are both right or both wrong in a given C89 implementation). > That makes "slicing and dicing" work easy to do. Change it, and you > start needing tests for negative in your code. Yup! Long before Python 1.0 was released, I badgered <0.6 wink> Guido into changing Python to do the floor-div + usable-mod business. We both missed that i/j shouldn't do integer division at all, though (and // is being introduced for flooring division in 2.2, and int/int will eventually be changed to return a float or a rational). An odd thing is that, when this comes up, people complain that under Python's current rules it's not necessarily the case that (-i)/j == -(i/j) Across decades of integer numeric programming, I can't recall any *use* for that identity; but that i%j >= 0 whenever j>0 is endlessly useful, as is your identity relating int-div and int-mod. doing-a-right-thing-is-a-trial-ly y'rs - tim From andreas at mtg.co.at Fri Nov 30 06:21:54 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Fri, 30 Nov 2001 12:21:54 +0100 Subject: CryptKit 0.9: cryptsock In-Reply-To: References: Message-ID: <200111301121.fAUBLwY28204@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! Stupid newbie question: How does cryptsock guard against a man-in-the-middle attack? Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8B2vVHJdudm4KnO0RAoksAKDUghus22aLXUDuywYF0z7FoJJnMQCgrrO1 DeFdHF438MZbEgrqr8Bvydg= =XXR1 -----END PGP SIGNATURE----- From kestrel at ernie.icslab.agh.edu.pl Mon Nov 12 05:46:25 2001 From: kestrel at ernie.icslab.agh.edu.pl (Michal Tondyra) Date: Mon, 12 Nov 2001 11:46:25 +0100 Subject: converting C library to python In-Reply-To: References: Message-ID: On Mon, 12 Nov 2001, Michal Tondyra wrote: > So what I have is an array of int's e.g. int my_array[100] > and what I want to have is PyObject structure representing tuple of > integers from my_array. You have to build a tuple first with PyTuple_New(int size), than for every int in my_array convert it to PyObject with PyInt_FromLong, and add to tuple using PyTuple_SET_ITEM. :) not schizophrenic - just found answer a minute ago Michal Tondyra From Armin_member at newsguy.com Tue Nov 20 11:43:51 2001 From: Armin_member at newsguy.com (Armin Steinhoff) Date: 20 Nov 2001 08:43:51 -0800 Subject: Python to compile to Java-bytecode References: <61f6bfa8.0111200558.2f52ad44@posting.google.com> Message-ID: <9te18701qf8@drn.newsguy.com> In article , Martin says... > >gaya at infomail.lacaixa.es (Toni Gaya) writes: > >> There is any project that allows compile a Python program to Java >> bytecode, as py2exe does compiling a python program to a .exe? > >Jython does that. Stupid question ... and why is for C-Python not possible to compile it to C++ ?? Armin > >Regards, >Martin From mberiatlinkgroupdotit at takebeforeatandtranslate.it Fri Nov 30 17:33:45 2001 From: mberiatlinkgroupdotit at takebeforeatandtranslate.it (Marco Beri) Date: Fri, 30 Nov 2001 22:33:45 GMT Subject: 2.1 loop with try & continue -> bug? Message-ID: Hi, look at this simple program: print "Running..." cont=0 while -1 : print cont cont = cont + 1 try: if cont == 2: continue if cont == 3: break except: pass If I run it with python 2.1, this is the output: Running... 0 1 2 Running... 0 1 2 . . . And so on, so it's clear that the "break" statement is never reached. It seems that the "continue" included into the "try" statemente break to an understood "while". Why? Thanks for your time. Ciao. Marco. P.S. If I run it with python 1.5.2 at least I got an error. From odeckmyn at teaser.fr Sat Nov 3 17:54:39 2001 From: odeckmyn at teaser.fr (Olivier Deckmyn) Date: Sat, 3 Nov 2001 23:54:39 +0100 Subject: Exception holes, again. References: Message-ID: <9s1sen$1sdd$1@feed.teaser.net> Did you look in the C sources ? "Dale Strickland-Clark" a ?crit dans le message news: k808uto6v8g6f2ilnfvdv1ondah38lslif at 4ax.com... > On a related subject to the earlier exceptions wart thread. > > I want to trap the specific 'api_error' exception raised by win32api. > > I can't find where that exception is defined so how do I catch it? > > I have searched the whole Python installation for the string > 'api_error' but it isn't there. > -- > Dale Strickland-Clark > Riverhall Systems Ltd From db3l at fitlinxx.com Thu Nov 29 01:23:32 2001 From: db3l at fitlinxx.com (David Bolen) Date: 29 Nov 2001 01:23:32 -0500 Subject: IIS with Python References: <89302408.0111261804.62ec6f@posting.google.com> Message-ID: Jim Abrams writes: > > In low (IIS process), the scripting interpreter is loaded as an inproc > > server (via the pythoncom##.dll file), and while I'm not sure if a > > separate interpreter is created internally for each user, you won't > > have individual processes running on your IIS box - just the one DLL > > loaded straight into your IIS process. > > This means that your python code runs inproc with the IIS proc. Don't do > anything too drastic or you can crash the IIS proc too. Yep, and that's true for any other in-proc ASP code (no matter the language) as well - you're just loading a DLL into the IIS process. But it's definitely higher performance and lower resource utilization. Of course, you'd have to crash the Python interpreter which isn't all that easy. > > In High, a completely separate COM object is instantiated (via > > execution of a separate pythonw.exe process running a localserver > > script) and you will have a completely separate process for each > > connection to the server. > > I don't think this is how it works. IIRC, the isolation means that the > application is running in its own process, meaning that IIS must use IPC to > talk to the intepreter and when the interpreter proc crashes or does > something extermely bad, IIS doesn't go with it. This also makes it nice > for debugging and reloading your Python ASP pages, Python COM servers and > elsestuff. You do lose a little performance this way. Um, that's what I think I said said (or meant to - note separate pythonw.exe process). In "high" the COM object invocation is via external server (or I believe LocalServer32 in COM parlance), which is a separate process to which COM requests are marshalled and responses demarshalled - this is the same approach used by DCOM for remote invocation although I believe the IPC in the former case is a low overhead RPC which in the latter its DCE RPC. Any ASP language is accessed as a COM object for its interpreter, and the IIS settings are really just the standard possibilities for COM object invocation (well, the medium involves MTS which is more an add-on). > Here's a simple example, I have it set to High (Isolated) Hmm, that's interesting - I would have expected high to re-invoke an interpreter per session. I'm pretty sure it's invoking separate COM object instances, but perhaps there's something in the Pythonwin ASP support that covers that under a single interpreter? Could you need to restart IIS to change security models or was this a fresh page? The definition for the Python interpreter class for LocalServer32 (the out of process server) explicitly runs a copy of pythonw and executes localserver.py to process the object requests, so I'm not quite sure how you'd get away without separate pythonw processes for each requester. Or, I wonder if IIS (or Windows itself) is trying to be efficient and re-use the interpreter if the pages are not accessed simultaneously (much as a remote COM server for objects over DCOM can stay instantiated for a period of time to avoid the overhead of reactivating if they get reused quickly)? I wonder if the page accesses were simultaneous would they share the same interpreter or not? Or if you waited long enough before re-accessing the page would it have retired the previous interpreter? In that case you probably couldn't depend on sharing the global namespace since it wouldn't be deterministic. I'll have to experiment when I have some time - most of our intranet stuff right now is just run in-proc. -- -- 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 aaldv97 at student.remove-this-part.vxu.se Wed Nov 7 16:56:37 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Wed, 7 Nov 2001 22:56:37 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: <9scaos$gtc$1@news.lth.se> > oh, give him a little slack. it might be true that the computer science > department at his university isn't exactly the best one in Sweden (hardly > his fault), but he has a point there: Ada wasn't just designed once, but > twice. True, MSI is not prominent, on the other hand, there is no CS apartment in Sweden that is worth jack. In fact, I'd say it's hard to find any university that does anything special these days, though I'd cut my arm off to be teached by Aho, Ullman, McIlroy, Rabin etc. Though in MSI's defence, Ritzau's Java technology is considered state of the art, 1.4 is largly based on his work I have heard. > unlike e.g. Scheme, which we all know was discovered, not designed. Though LISP is neat, since it's so darn easy to implement, I wouldn't stretch it as far as call it well designed syntax-wise. Scheme is no different, parathesis mania is hardly good design, ask anyone what they think of writing 30kLoC+ programs in LISP. On the other hand, wouldn't call anyone that has not written 30kLoC+ programs a real programmer. > (and we all know that the van Rossum's don't know anything about > design ;-) Non-declarative languages are not following good design patterns, though in all fairness I love the Python implementation and its fast prototyping abilities. Now repeat after me: "Non-declarative is bad!" From hughett at mercur.uphs.upenn.edu Fri Nov 16 10:55:15 2001 From: hughett at mercur.uphs.upenn.edu (Paul Hughett) Date: 16 Nov 2001 15:55:15 GMT Subject: Scientific Libraries in Python References: Message-ID: <9t3ct3$grq$1@netnews.upenn.edu> Another entrant in this race is the BBLimage/Pyvox package, which is definitely focused on volume image processing but also contains a moderate amount of general-purpose scientific functionality. See the website http://www.uphs.upenn.edu/bbl/bblimage for more information. The license is BSDish, so there are no problems there. Paul Hughett From vincent_a_primavera at netzero.net Tue Nov 27 05:56:48 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: 27 Nov 2001 10:56:48 +0000 Subject: Pine and MIME... Message-ID: <1006858608.3010.23.camel@del-vap-bos.ralphpill.com> Hello, Using mimetools and MimeWriter I am trying to write a program to send an E-Mail with a .xls attachment. I have gotten to the point where the MIME encoded message will appear correctly with it's attachments with KMail, Evolution, and Outlook Express. But, when the message is viewed with Pine it is not broken down into it's parts/attachments. Any suggestions? I notice that any existing messages with attachments in Pine display correctly broken down. Thank you, Vincent A. Primavera. P.S. I have added the Content-Disposition header... From James_Althoff at i2.com Wed Nov 28 14:35:45 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 11:35:45 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: *** modified resend *** Fernando Perez wrote: >well, while on the topic why not go for full math notation? >for i in [0,1,..,5), (0,1,..,5], etc. > >That would satisfy all math options for semi-open, semi-closed >intervals, and send every brace-matching text editor on the face of >this planet into a fit :-) > >I get a feeling this PEP isn't going to get too far... Just another reminder for those who haven't followed the entire thread (or perhaps didn't read the PEP ;-) ... Although PEP 276 has stimulated much interesting discussion about new syntax for specifying integer intervals, PEP 276 itself does not call for any such syntactic changes to Python. It (merely) suggests adding an *iterator* to types.IntType (using stuff that is already fully supported in Python 2.1) to make more convenient the common case of using an index to access items in a sequence (in a for-loop) when direct access to said items is not practical (as in the case of a multi-dimensional table, for example). With such an iterator one could write (with *no* syntax changes to Python): for i in table.rowcount: for j in table.colcount: print table.value(i,j) Doesn't help David Eppstein write better pseudo-code for his algorithms class, doesn't add Haskell-like-lazy-lists-created-from-closed-intervals functionality, doesn't generalize slicing notation for half-open intervals, etc. It just eliminates the need to use or think about range and xrange in common cases like the example above. Jim -- http://mail.python.org/mailman/listinfo/python-list From zope at thewebsons.com Sat Nov 17 09:43:19 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sat, 17 Nov 2001 06:43:19 -0800 Subject: Sizing Up Graphics Automatically Message-ID: <5.1.0.14.0.20011117064257.00a5c4e0@thewebsons.com> Hi; Is it possible to automatically size up a graphic upon upload and programmatic insertion into a script? I use Zope and want to build a through-the-Web interface to enable my client to automatically change/add photos, but I want to set the site up such that all the dimensions of graphics, font sizes, etc., are resized depending on the visitor's browser resolution. In order to do that, I *must* somehow capture the dimensions of the uploaded graphic programmatically? Any ideas how to do this? Anybody have some code they'd like to share? TIA, BenO From sholden at holdenweb.com Wed Nov 7 12:59:52 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Nov 2001 12:59:52 -0500 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> <9sbpr1$c4f$1@news.lth.se> Message-ID: <6BeG7.2$%g7.20675@atlpnn01.usenetserver.com> "David Andreas Alderud" wrote ... > Java, C and C++ got there after a while, but they where not to begin with. > Ada was well documented and with lots of RFC before the actually > implementation of Ada83. Considering that it took 7 years of design before > the next version of Ada to be finnished, it started in '88. > I might be wrong, but I'm not aware of a language that was publicly designed > for years before its first implementation, if you know something I don't, > please enlighten me. Given what you've said, I guess I'll accept that Ada had a lot of upfront design - I'm not here simply to disagree! I presume you mean strawman, stoneman, ironman? OK, but in that case how come there had to be a "next version"? Clearly all that up-front design didn't produce a perfect language. How is this different (except perhaps in terms of gestation time) from other standardised languages? > Yes, most languages are designed, but not from start to finnish, more like > version 1.0 and forward, that is not _what I call design_, maybe because I'm > schooled in software architectures, I don't know. > > Maybe we have different opinions of design, I think of design as in > architectural design. > Well you surely don't believe that *buildings* are built exactly as they are conceived? Why else do the construction teams have to supply "as built" drawings - because they have to modify the building design as construction progresses, to take into account the practical considerations of the site, materials, etc. Software is difficult precisely because it is so malleable, and so a design can evolve. This is both a good and a bad thing. But none of this really has to do with suitability as a teaching language, and I still don't see Ada as any better for teaching purposes than Python. regards Steve -- http://www.holdenweb.com/ From stephen at stephencox.org Mon Nov 26 01:18:08 2001 From: stephen at stephencox.org (stephen cox) Date: Mon, 26 Nov 2001 06:18:08 GMT Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> <3c015433.778200@news> Message-ID: I also just installed Active Python. Also green too - coming from the xBase (Fox) world. Figured it was time to move up. I picked up the O'Reilly book too. I like their books.... have their HTML, VBScript, and ASP books.. Anyway, down to business - Have you gotten to the Lists section yet (it's located in the beginning of the book)? If so, I have a simple question: isn't a list just an array? -- Stephen Cox web.net geek for non-profits, political campaigns, and a few socially conscious businesses. stephen at stephencox.org. From elmar.hoefner at uibk.ac.at Wed Nov 28 06:05:21 2001 From: elmar.hoefner at uibk.ac.at (Elmar =?ISO-8859-1?Q?H=F6fner?=) Date: Wed, 28 Nov 2001 12:05:21 +0100 Subject: Installing Python > 2.1: make fails in posixmodule.c Message-ID: <9u2g7u$5i5al$1@ID-113469.news.dfncis.de> Hi all, When I try to compile Python, version 2.1.1 and up, 'make' stops in posixmodule.c with following message: gcc -g -O3 -Wall -Wstrict-prototypes -I. -I./Include -DHAVE_CONFIG_H -c ./Modules/posixmodule.c -o Modules/posixmodule.o ./Modules/posixmodule.c: In function `posix_nice': ./Modules/posixmodule.c:1145: warning: implicit declaration of function `getpriority' ./Modules/posixmodule.c:1145: `PRIO_PROCESS' undeclared (first use in this function) ./Modules/posixmodule.c:1145: (Each undeclared identifier is reported only once ./Modules/posixmodule.c:1145: for each function it appears in.) make: *** [Modules/posixmodule.o] Fehler 1 I use gcc 2.95.3 on Linux glibc2, kernel 2.4.15-pre2 and I use configure with no special options, just --prefix=/usr Rerunning make after 'make clean' didn't help. I also couldn't find a bug report on sourceforge concerning this. Has anybody any hint or tip on how to get around this? Thanks, Elmar -- | Elmar W. Hoefner | See http://home.pages.at/oeller/pubkey.txt | for my PGP public key. From d_blade8 at hotmail.com Mon Nov 12 00:39:59 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 11 Nov 2001 21:39:59 -0800 Subject: Splitting on a regex w/o consuming delimiter References: Message-ID: <7396d2b2.0111112139.7890b06f@posting.google.com> Nadav Horesh wrote in message news:... > Whats about: > >>> st = 'This @is a @modul@ ar trr' > >>> re.split(".(?=@)", st) > > ['This', '@is a', '@modu', '@ ar trr'] > > Nadav. Actually, I like this one, and you can do it an infinite number of ways (take a look at Mastering Regular Expressions by O'Reilly for a better idea of why using regular expressions can be tricky (like trying to split something and losing what you split). Personally, I would go like the above, but let's try something else, like maybe (and you can hide this in a function, I just do it here interactively): st = 'This @is a @modul@ ar trr' xl = [] while st.find('@') != -1: xl.append(st[st.rfind('@'):]) st = st[:st.rfind('@')] xl.append(st) xl.reverse() print xl gives ['This ', '@is a ', '@modul', '@ ar trr'] Put something like it into a function/class (depending on what you need to do with the results, I guess). Maybe pass in two parameters, a string and a seperator. Then you just call the fucntion to get your result. Maybe something like: def StringSep(YourString, sep): newlist = [] while YourString.find(sep) != -1: newlist.append(YourString[YourString.rfind(sep):]) YourString = YourString[:YourString.rfind(sep)] xl.append(YourString) xl.reverse() return xl Keep in mind, I've kept it simple but you can feed in seps that are bigger than one digit, you would just have to do some initial coding, then you would be home free. Later From wurmy at earthlink.net Sun Nov 25 04:26:40 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sun, 25 Nov 2001 09:26:40 GMT Subject: python compiler compiler google results References: <3c009440$1@207.229.64.20> Message-ID: <3C00B956.8489AC7F@earthlink.net> Peter Bismuti wrote: > > Ok, I know, Google 1. Post 2. > > I found PLY (Python Lex-Yacc). > I also found PyLR -- Fast LR parsing in python. > Any Others? There's something called SPARK, and kjParsing... not sure where to find them, but I'm sure Google can tell you more. --Hans From gh_pythonlist at gmx.de Tue Nov 13 14:23:51 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Tue, 13 Nov 2001 20:23:51 +0100 Subject: IsPython really O-O? In-Reply-To: <9srqem$vt2$1@slb0.atl.mindspring.net> References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> Message-ID: <20011113202351.B3819@lilith.hqd-internal> On Tue, Nov 13, 2001 at 11:59:00AM -0700, Andrew Dalke wrote: > [...] > When I first started Python, I wrote a class like: > > class Spam: > def __init__(self, x): > self.x = x > def show(self): > print self.x > > After I figured out it worked, I wanted to add a new method, so > I did > > class Spam: > def double(self): > self.x = self.x * 2 > > then was annoyed that it didn't work the way I expected. So I > don't think you are alone in this view. I bring it up here because > I suspect for many people this is forgotten amoung all the other > confusions in the early stages of learning Python. Hey, you could have written: class Spam(Spam): ... It doesn't really add a method to the class, but at least it looks nicer. What I miss(ed) was overloadable function and method signatures. Gerhard -- The information transmitted in this message (if any) is intended only for the person or entity to which it is addressed. The message may contain confidential and/or privileged material. It doesn't really matter, we will append this lengthy legalese mumbo-jumbo anyway. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. The same goes for the intended recipient herself. If you have received this in error, please contact your lawyer and delete this e-mail and everything else from any computer in your vicinity. The intended recipient of this e-mail may only use, reproduce, disclose or distribute the information contained in this e-mail and any attached files, with the permission of BigBrother Inc. This message has been scanned for anti-Microsoft propaganda and cleared by MailMarshal. From ursus_horibilis at hotmail.com Tue Nov 27 13:50:21 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Tue, 27 Nov 2001 13:50:21 -0500 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> <9u0m3l$447$2@peabody.colorado.edu> Message-ID: "Fernando P?rez" wrote in message news:9u0m3l$447$2 at peabody.colorado.edu... > Ursus Horibilis wrote: > > >> > >> Use longs: > >> > > > > Okay. My next project was to do the same thing with 64-bit > > numbers. So how do I disable trapping for integer overflow? > > > > (And don't tell me to use very longs ;-) > > No. Python longs are not C longs, they are arbitrary length integers (think > Mathematica/Maple/etc). They're therefore dog slow, but never overflow. Very > handy when you really need them. > Thanks very much. I did not realize that a Python long was not simply a 64-bit number. Just pure ignorance on my part. Is it legal to mask a long and assign it to an int? For example: (a) is an (int), (b) is a (long) b = 6*sys.maxint a = b & (0xFFFFFFFF) From paustin at eos.ubc.ca Fri Nov 9 12:26:43 2001 From: paustin at eos.ubc.ca (Phil Austin) Date: 09 Nov 2001 09:26:43 -0800 Subject: HOWTO change user on UNIX for os.system References: <2rBG7.27968$LD.1025113@e3500-atl2.usenetserver.com> Message-ID: "Tom Higgins" writes: > Is there any way to su or login as a different user > within a python script? I mainly need to discover a > method which accepts a password from with the script. > > Regards, > Tom > > http://www.multimania.com/fredp/python/pyscp.html might be good for an example of this. Regards, Phil From slinkp23 at yahoo.com Tue Nov 20 11:14:38 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 20 Nov 2001 16:14:38 GMT Subject: Free Python Server References: <283adf56.0111200521.66b2e538@posting.google.com> Message-ID: On 20 Nov 2001 05:21:11 -0800, Kevin Dahlhausen wrote: >question: "What is your favorite low-cost, low-frills web hosting that >provides access to Python for CGI scripting? Bonus points for >long-running Python processes." Depends what "low cost" means. I've used: jumpline.net - the "Standard" plan gets you 50 MB for $15 / month. Python not officially supported but you can install it yourself. Long-running processes not allowed IIRC. hurrah.com - "Standard" account is 100 MB for $25 / month comes with Zope, perl, PHP, Python, Java Servlets, SSI, and you can add domains for $5 / month / each, so if you host multiple domains it often ends up being cheaper than 3 or 4 no-frills accounts somewhere else. At one point I had 3 domains with unique content for $35. I've been very happy with it. --PW From dkuhlman at rexx.com Tue Nov 27 16:10:10 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: 27 Nov 2001 15:10:10 -0600 Subject: postgresql triggers to update GUI? References: <20011126.145234.816620091.2222@localhost.localdomain> <3c02b086.304990102@wa.news.verio.net> Message-ID: <1006896132.298644@rexx.com> Python supports SOAP and XML-RPC, both server-side and client-side. Perhaps, have your Python trigger make a SOAP or XML-RPC request to a SOAP or XML-RPC server implemented in your (gui) application. - Dave Bengt Richter wrote: > > On Mon, 26 Nov 2001 15:28:26 -0500, "Steve Holden" wrote > : > >>"Robert Nikander" wrote ... >>> Hi, >>> >>> I am writing a python program that uses a postgresql db backend. I would >>> like to update the gui whenever a change in certain tables occurs, so it >>> would be nice to use triggers rather than generating the 'events' when I >>> update the db. That way I get cascading changes. Does anyone know of a >>> python module that supports postresql triggers? ie: you can create a >>> trigger that calls a python function? Is there another solution here >>> that I am missing? >>> -- Dave Kuhlman dkuhlman at rexx.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From fperez528 at yahoo.com Wed Nov 28 15:55:55 2001 From: fperez528 at yahoo.com (=?ISO-8859-1?Q?Fernando_P=E9rez?=) Date: 28 Nov 2001 12:55:55 -0800 Subject: windows to linux pickled objects? References: Message-ID: <86f75fa2.0111281255.713bdbb5@posting.google.com> Stephen Boulet wrote in message news:... > I tried it on linux and the program did run, but the size of the pickled > file only went down from 8183905 bytes to 8180057 bytes, and the file > wasn't binary at all. Maybe the size difference can be explained by the > lack of carriage returns. ;) > > It would be nice if the binary option worked on linux... > Just to clarify, what I meant was binary *pickle*, not binary file write. Pickling in binary should decrease file size by quite a bit (think of it: a float is 8 bytes long, but can take about 16-18 characters to print as text). Cheers, f From gbreed at cix.compulink.co.uk Tue Nov 20 11:41:49 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: Tue, 20 Nov 2001 16:41:49 +0000 (UTC) Subject: problem with a python script References: <9tdvv4$1ugdj$1@ID-79019.news.dfncis.de> Message-ID: <9te14d$gm8$1@thorium.cix.co.uk> Felix Seeger wrote: > Here is the part of the code: > > > class Mail: > def __init__(self,outserver="localhost"): > import smtplib > self.outserver=outserver > > def sendmail(self,from,to,msg,mopts="",rcptopts=""): > s=smtplib.SMTP(outserver) > s.sendmail(from,to,msg,mopts,recptopts) > s.quit() It must have been written for an old interpreter where "from" wasn't a keyword. Try changing the sendmail method to def sendmail(self,fromadddr,to,msg,mopts="",rcptopts=""): s=smtplib.SMTP(outserver) s.sendmail(fromaddr,to,msg,mopts,recptopts) s.quit() From huaiyu at gauss.almadan.ibm.com Wed Nov 14 16:59:44 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 14 Nov 2001 21:59:44 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> <9su33o$14kfp9$1@ID-11957.news.dfncis.de> Message-ID: On Wed, 14 Nov 2001 07:32:07 -0800, Emile van Sebille wrote: > >"Huaiyu Zhu" wrote in message >news:slrn9v2qc7.1ss.huaiyu at gauss.almadan.ibm.com... >> >> class A: >> def __cmp__(a,b): return -1 >> >> a = [A()]*3 >> a == a # returns 0 >> a is a # returns 1 >> >> >> Is this intended? > >Yes, as decreed by the author of class A. > > > I would think that mandating >> a is b implies a == b >> would make programs easier to read. >> > >Because it's in the class that way, you'd have to assume the author knew >what was intended. I made up the example just to show the issue. Can someone think of a real world example where this is useful? If it's not like this until recently, was it a feature missed by users in the past? Is the special case introduced by NaN worth changing the behvior in all the other cases? Huaiyu From zope at thewebsons.com Sat Nov 24 23:35:11 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sat, 24 Nov 2001 20:35:11 -0800 Subject: Does Anybody Know How To Get Tkinter Working?? Message-ID: <5.1.0.14.0.20011124203401.00a90010@thewebsons.com> Hi; This is my third request for help and I'm hoping someone will respond this time :) I just configured Tcl--itworks--and I went to configure tk (both latest stable distros) on my RH71 box and ran into all sorts of errors on *make*. Both installations are in /usr/lib and I'm in as root. It exits with Error 1. Here's how the errors start: [root at hermes unix]# make gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED /usr/lib/tk8.4a3/unix/../generic/tk3d.c In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or directory In file included from /usr/lib/tk8.4a3/unix/../generic/tkPort.h:32, from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:27, from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: /usr/lib/tk8.4a3/unix/../generic/../unix/tkUnixPort.h:77: X11/Xlib.h: No such file or directory etc. etc. etc. etc. etc. etc. etc. etc. etc. Any ideas? TIA, BenO From mal at lemburg.com Mon Nov 26 09:14:11 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 26 Nov 2001 15:14:11 +0100 Subject: ANN: Python Benchmark Suite -- pybench 1.0 Message-ID: <3C024E33.B7F7A962@lemburg.com> ________________________________________________________________________ ANNOUNCING: pybench -- The Python Benchmark Suite Version 1.0.0 Extendable suite of of low-level benchmarks for measuring the performance of the Python implementation (interpreter, compiler or VM). ________________________________________________________________________ WHAT IS IT ?: pybench is a collection of tests that provides a standardized way to measure the performance of Python implementations. It takes a very close look at different aspects of Python programs and let's you decide which factors are more important to you than others, rather than wrapping everything up in one number, like the other performance tests do (e.g. pystone which is included in the Python Standard Library). pybench has been used in the past by several Python developers to track down performance bottlenecks or to demonstrate the impact of optimizations and new features in Python. There's currently no documentation and no distutils support in pybench; that'll go into one of the next releases. For now, please read the source code. The command line interface for pybench is the file pybench.py. Run this script with option '--help' to get a listing of the possible options. Without options, pybench will simply execute the benchmark and then print out a report to stdout. Here's some sample output: """ Tests: per run per oper. overhead ---------------------------------------------------------------------- BuiltinFunctionCalls: 131.50 ms 1.03 us 0.50 ms BuiltinMethodLookup: 195.85 ms 0.37 us 1.00 ms CompareFloats: 126.00 ms 0.28 us 1.00 ms CompareFloatsIntegers: 201.05 ms 0.45 us 0.50 ms CompareIntegers: 192.05 ms 0.21 us 2.00 ms CompareInternedStrings: 117.65 ms 0.24 us 3.50 ms ... TryExcept: 289.75 ms 0.19 us 3.00 ms TryRaiseExcept: 179.05 ms 11.94 us 1.00 ms TupleSlicing: 159.75 ms 1.52 us 0.50 ms UnicodeMappings: 171.85 ms 9.55 us 1.00 ms UnicodePredicates: 152.05 ms 0.68 us 4.00 ms UnicodeProperties: 203.00 ms 1.01 us 4.00 ms UnicodeSlicing: 190.10 ms 1.09 us 2.00 ms ---------------------------------------------------------------------- Average round time: 10965.00 ms """ ________________________________________________________________________ WHAT'S NEW ? This release includes a few more tests and extends the range of supported Python versions to 1.5.x - 2.2. It is also the first publically announced new version of pybench in years. ________________________________________________________________________ WHERE CAN I GET IT ? The download archive of the package can be found at: http://www.lemburg.com/files/python/ ________________________________________________________________________ WHAT DOES IT COST ? pybench comes with a Python style license, which means that you can use them in both commercial and non-commercial settings without fee or charge. It comes with full source code. ________________________________________________________________________ WHERE CAN I GET SUPPORT ? Commercial quality support for this package is available from eGenix.com Software GmbH in form of support tickets. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Support for details about the eGenix support offerings. ________________________________________________________________________ REFERENCE:

pybench 1.0 - Python Benchmark Suite. (26-Nov-2001) ________________________________________________________________________ Enjoy, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From qrczak at knm.org.pl Fri Nov 16 14:35:12 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 16 Nov 2001 19:35:12 +0000 (UTC) Subject: Fw: Re: IsPython really O-O? References: Message-ID: Sun, 11 Nov 2001 13:00:37 -0300, Nahuel Greco pisze: > All the objects created (in your "box", the ST) are "persistent" > by default, when you close the ambient/box, the next time that you > open it, are there. There isnt a distinction between "Create the > program" and "Use it", you always play with live objects. I've seen VisualWorks and Dolphin Smalltalk crashing and damaging the world images. And I subjectively can't stand this style of development at all. I prefer arranging code in files such that it's easy to find related parts. Opening a window to see another method is not an option. Packages are not a good substitute for a module system. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From sandskyfly at hotmail.com Mon Nov 12 19:46:01 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 12 Nov 2001 16:46:01 -0800 Subject: Using browser as interface to python app References: Message-ID: "Sandy Norton" > > I'm simply trying to use the browser as an interface to a small python > > program that retrieves and parses webpages and then publishes the > > results in an html page. I would like for example for the user to be > > able to configure the app via the browser (by selecting checkboxes and > > whatnot) without having to use a command-line menu or a full blown GUI > > such as wxPython or Tkinter. "Bill Bell" > Have you considered using Webware (webware.sourceforge.net)? I > can't tell you anything about it since I've just started learning about > it myself. 400K download. Looks really cool. Thanks. Webware looks very good. Now to test... Sandy From jahs at jahs.org Mon Nov 26 20:43:34 2001 From: jahs at jahs.org (James A. H. Skillen) Date: Tue, 27 Nov 2001 01:43:34 +0000 Subject: function operators Message-ID: Has anyone ever wished that Python had operators defined on functions? For example, suppose you want the function f(x) = cos(x) + sin(x). You could do: def f(x): return cos(x) + sin(x) or f = lambda x: cos(x) + sin(x) but wouldn't: f = cos + sin be *much* nicer? Similarly for *, -, /, etc. Taking the idea of PEP 211 further, we could have the "outer product" operator "@" work on functions too. So f = cos @ sin would be equivalent to f = lambda x,y: (cos(x), sin(y)) There is also another tremendously useful operator on functions: composition. For want of a better symbol, how about a new keyword "on" to be composition. So to get the function f(x) = cos(sin(x)) I could do f = cos on sin Why? Well this is useful if you use map, filter etc. If I wanted to apply f as above to {0, ..., 9} then at the moment I could do map(cos, map(sin, range(10))) or map(lambda x: cos(sin(x)), range(10)) but with the new syntax I could write map(cos on sin, range(10)) which is much clearer. These are just trivial examples, but in conjunction with the car and cdr functions it becomes powerful. For example, cadr = car on cdr. Does this make sense, or have I been doing too much mathematics? ;-) -- James A. H. Skillen - jahs at jahs.org 4th year MMath Mathematics undergraduate, University of Warwick, UK. From chrishbarker at home.net Tue Nov 6 19:11:23 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 06 Nov 2001 16:11:23 -0800 Subject: help - Create dll References: Message-ID: <3BE87C2B.B733ACC1@home.net> > Glauco Silva wrote: > Hi , > How can i create a dll file ( C dynamic library) from windows to be > imported by python . http://www.python.org/doc/current/ext/building-on-windows.html -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From store_li at sina.com Wed Nov 21 09:18:56 2001 From: store_li at sina.com (Kick) Date: Wed, 21 Nov 2001 22:18:56 +0800 Subject: How can I distribute a python program Message-ID: <9tgd5i$2fjm5$1@ID-12869.news.dfncis.de> I write a python that import TK and some other packages. What shall I do if I want to distribute this program to my friends who hasn't python environment? Thanks for any help! Kick From phd at phd.pp.ru Tue Nov 6 09:15:18 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 6 Nov 2001 17:15:18 +0300 Subject: Freeware Python editor In-Reply-To: ; from DeepBlue@DeepBlue.org on Tue, Nov 06, 2001 at 07:48:16AM -0600 References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> Message-ID: <20011106171518.A20452@phd.pp.ru> On Tue, Nov 06, 2001 at 07:48:16AM -0600, DeepBlue wrote: > Let me add to this that in such a boring predictable world, I have always > appreciated Oleg's Pushkin-Lermentov-like sensibility and idealism :) Always? Did I really show it *so* many times? :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From andreas at mtg.co.at Wed Nov 7 11:46:06 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Wed, 7 Nov 2001 17:46:06 +0100 Subject: How much is set in stone? In-Reply-To: <3BE8724E.7482C881@ix.netcom.com> References: <3BE8724E.7482C881@ix.netcom.com> Message-ID: <200111071647.fA7GlGG04554@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Mittwoch, 7. November 2001 00:29 schrieben Sie: > I expected better from this group. Well, normally, when I'm a newbie, and this happens everytime I try a new language community, I not only try to learn the rules, but also the useful idioms. Basically while it's usually quite easy to learn a language, it's more complicated to get a feeling for the language. I've also got the impression that you ignore the fact that Python is quite a mature language (I personally have been maintaining a commercial solution written in Python since 1996 ;) ), and that is not a wise thing to do. And lastly your proposition is quite popular only with newbies that don't know Python. Actually it is already implementable with Python now: UnknownName="UnknownName" class ProtectedValues: def __init__(self): self.a=1 self.b=2 self.classsetup=1 def __setattr__(self,k,v): if self.__dict__.has_key("classsetup"): if not self.__dict__.has_key(k): raise UnknownName self.__dict__ [k]=v x=ProtectedValues() x.c=100 # -> UnknownName # Warning: I've typed this in my Mailer, and didn't test it. So the # indentation is propably wrong ;) But then, You said You were a newbie. ;) You just didn't behave like a newbie, by proposing obviously a very non-Pythonish change. But then, perhaps I should tell the guys at Audi, that my A6 should have 6 tires instead of the 4. As a newbie in car design I know it better than them. Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE76WVSHJdudm4KnO0RAgM/AKCOMyzQmXApy8rNUlNvkA5BUdaPuwCfa/Kh AZehM280nUQ9hmNu6xB9Xoc= =iMk5 -----END PGP SIGNATURE----- From fperez528 at yahoo.com Fri Nov 9 17:11:24 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 10 Nov 2001 21:39:24 +2328 Subject: doc generator References: <9sku4g$egh$1@peabody.colorado.edu> Message-ID: <9skvfn$fg9$1@peabody.colorado.edu> > You'll have to pardon _my_ ignorance, because the only thing that I know > about Teud is "It looks better than HappyDoc". :) I'm generally not > interested in documentation generators, and haven't touched PyDoc -- I > just know the authors, and throught it'd be nice of me to plug their project Well, I'll fill you in a bit (if you're running Python 2.1 you already have it). Pydoc is a full blown help/documentation system that now comes with python. As a doc system: in a command line window, type 'pydoc -g'. This will open up a little tk window with a search field, and an 'open browser' button. Push this button and you'll get a nice webpage in your browser with an index of all the modules you have in your sys.path. The docs are updated in real time, so if you're working on a module and you modify it, hitting 'reload' in your browser will reflect those changes immediately. It's quite nifty. As help: at the interactive prompt, do 'from pydoc import help'. Then just type help. A help system, with access to all your python documentation, will pop up (you might have to first set a PYTHONDOCS env variable). Furthermore, pydoc is based on a module called inspect, which is an impressive set of utilities for doing object introspection. So if you ever need to do fancy run-time analysis of your own code and objects, the functionality (at least all the basic tools) is already there. Anyway, this is probably worth mentioning b/c I wouldn't be surprised if many people didn't even know they already have this in their system. It's a *huge* time saver (at least I think so). Cheers, f From drs at alex2.labs.agilent.com Fri Nov 30 14:01:39 2001 From: drs at alex2.labs.agilent.com (David R. Smith) Date: Fri, 30 Nov 2001 11:01:39 -0800 Subject: Converting an integer to base 2 References: <3C07CFED.C7F7CA38@motorola.com> Message-ID: <3C07D793.4CCE9954@alex2.labs.agilent.com> int(string, 2) converts the string to the internal representation. You told it that the string was base-2, e.g., '101'. '5' is not a valid digit in binary. Stephen Boulet wrote: > > I'm trying to convert integers to base 2. Can someone tell me why this > doesn't work? > > >>> int('5', 2) > Traceback (most recent call last): > File "", line 1, in ? > int('5', 2) > ValueError: invalid literal for int(): 5 > > Thanks. > > -- Stephen From ptsczz at netsystemsusa.cjb.net Wed Nov 14 16:25:54 2001 From: ptsczz at netsystemsusa.cjb.net (ptsczz at netsystemsusa.cjb.net) Date: Wed, 14 Nov 2001 21:25:54 GMT Subject: E-Mail order processors needed now! Message-ID: Net Systems USA is currently seeking people to run a home based business for work at home. Good income and flexible hours. Great for stay-at-home moms, students, and those who need the extra money. No experience necessary, we will train. Start next day! Computer and internet required. Visit us online: www.netsystemsusa.cjb.net for more info. From support at internetdiscovery.com Tue Nov 6 18:00:46 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Tue, 06 Nov 2001 23:00:46 GMT Subject: [Q] Python and expert system shell References: Message-ID: <3be86b98.325429@nntp.ix.netcom.com> On Sat, 3 Nov 2001 16:02:59 -0600, "Young-Jin Lee" wrote: >Hi, all. >I'm a python newbie and I want to get some advice. >I have developed a Java application and I want to convert it to Python >application. >I think I can easily do most of the part except one module. In my Java >application, I used a JESS (Java Expert System Shell). JESS is a CLIPS >interpreter written in Java. Is there any CLIPS interpreter written in >Python? Or any expert system shell in Python? > SWIG interface file (clips.i) so that I could try wrapping it? There is a SWIG wrapped version of CLIPS by Vladimir I. Ulogov (gandalf @ python.eu.org), and the set of the interface files are downloadable from his site: http://www.python.eu.org/software I works fine under 1.5.2 and should easily recompile under 2.x (in fact I may have used his binary under 2.1). Let him know if you are using it. Mike. From drs at alex2.labs.agilent.com Mon Nov 19 19:48:06 2001 From: drs at alex2.labs.agilent.com (David R. Smith) Date: Mon, 19 Nov 2001 16:48:06 -0800 Subject: Tkinter: cleaning up when a toplevel is destroyed References: <3BF448DD.90195EA2@labs.agilent.com> Message-ID: <3BF9A846.F7A373A@alex2.labs.agilent.com> Matthew Dixon Cowles wrote: > I think you want something like: > > root.protocol("WM_DELETE_WINDOW", destroyCB) > > The call is documented in Fredrik Lundh's excellent An Introduction > to Tkinter at (wrapped for line length): > > http://www.pythonware.com/library/tkinter/ > introduction/events-and-bindings.htm That's the ticket. Thank you. David From scholey at totalise.co.uk Fri Nov 30 13:22:06 2001 From: scholey at totalise.co.uk (Sam Scholey) Date: Fri, 30 Nov 2001 18:22:06 -0000 Subject: Using Python with a webserver Message-ID: Hey Folks I was interested in the prospect of using python with my webserver but a search on the python site and on deja produced virtually zero results. Can it be done? is it as easy as editing a few lines of code in the apache httpd.conf file? I am using Windows xp pro, apache 1.3.22 (for windows) Thanks Very Much From tdelaney at avaya.com Thu Nov 29 18:02:24 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 30 Nov 2001 10:02:24 +1100 Subject: Python evangelists unite! Message-ID: > From: brucehapman at hotmail.com [mailto:brucehapman at hotmail.com] > > So, I need some help. I've checked out c.l.p and some on-line > articles, and I just can't find good practicle examples of a program > that adds members to instances (or classes) at runtime. Anybody got > any? I don't want to have to start avoiding my friend.... Suggest he look at unit tests. With unit testing, you are supposed to write the tests first, then the code. Unfortunately, in most languages, this is simply not possible. For example, you can't compile the unit tests for a java package if you don't have at least a bare skeleton of each class existing (all methods present, etc). OTOH, this is incredibly simple in Python. The method doesn't exist yet? Throw an exception! The class doesn't exist? Throw an exception! Which is exactly what you want in a unit test - you can code one bit at a time, and gradually your tests start succeeding. Tim Delaney From logiplexsoftware at earthlink.net Mon Nov 5 15:34:42 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 5 Nov 2001 12:34:42 -0800 Subject: identify x,y coordinates in an image In-Reply-To: References: Message-ID: <01110512344206.18247@logiplex1.logiplex.net> On Monday 05 November 2001 12:10, John Hunter wrote: > I need to get the x,y coordinates of a bunch of points in a 2d image. > > I would like to mouse click on a point in the image and get the > coordinates of that point with reference to some origin (also > identified with mouse click) and some x,y scale which could be > customized. > > I will need to be able to zoom in at some points of the image, and > perhaps scroll because the image will be large. > > I suspect some combination of PIL and Tk is what I an looking for, but > am soliciting advice and/or prototype code before I begin. PIL is an excellent choice and will allow you to zoom to particular point in an image. wxPython is an alternative to Tkinter (there isn't any native support for wxPython from PIL, but a couple of simple routines will convert between PIL images and wxImages - I can provide them if you like). Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From Gareth.McCaughan at pobox.com Wed Nov 7 19:39:34 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Thu, 8 Nov 2001 00:39:34 +0000 Subject: Q: Feature Wish: "%" Extension References: Message-ID: Tim Peters wrote: > No threads on c.l.py end up being about Hitler. Not even this one! Indeed, > I expect this one to veer into transfinite cardinals before I finish this > sentence. > > python-needs-a-transfinite-cardinal-type-ly y'rs - tim Mmm, that would be nice. >>> import cardinals >>> a = cardinals.aleph(1) >>> print a >>> b = 2 ** cardinals.aleph(0) >>> print b >>> a == b Undecidable Just as well Python doesn't have a conventional boolean type. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From kestrel at ernie.icslab.agh.edu.pl Mon Nov 12 04:25:00 2001 From: kestrel at ernie.icslab.agh.edu.pl (Michal Tondyra) Date: Mon, 12 Nov 2001 10:25:00 +0100 Subject: converting C library to python Message-ID: Hi, While I was converting C library to python I came across a little problem - how to convert an array of int's into tuple. I found it impossible to do with Py_BuildValue function, which needs every element of tuple to be mentioned in format string. So what I have is an array of int's e.g. int my_array[100] and what I want to have is PyObject structure representing tuple of integers from my_array. How to do it? Can anyone help me? thanks in advance Michal Tondyra From gbreed at cix.compulink.co.uk Thu Nov 29 12:31:02 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: Thu, 29 Nov 2001 17:31:02 +0000 (UTC) Subject: __setattr__ recursion problem References: <3C066BF8.8D911FCB@olen.to> Message-ID: <9u5rcm$beg$1@thorium.cix.co.uk> In article <3C066BF8.8D911FCB at olen.to>, joonas at olen.to (Joonas Paalasmaa) wrote: > The code above causes an infinite loop. How can I set an attribute of > Class > without overloading the __setattr__ function? Or does someone have some > other > solution to make that script work? > > > > class Class2: > eggs = 1 > spam = 2 > > class Class: > base = Class2() > def __setattr__(s,attr, value): > if hasattr(s.base, attr): > setattr(s.base, attr, value) > else: > setattr(s, attr, value) > > Class().foo = "eggs" Um, well, how about class Class(Class2): pass ? or change setattr(s, attr, value) to s.__dict__[attr]=value Graham From bokr at accessone.com Tue Nov 6 17:43:41 2001 From: bokr at accessone.com (Bengt Richter) Date: Tue, 06 Nov 2001 22:43:41 GMT Subject: PDF->Text converter/extractor References: Message-ID: <3be8616f.404079655@wa.news.verio.net> On Tue, 6 Nov 2001 11:31:28 -0300, "Alves, Carlos Alberto - Coelce" wrote: >This message is in MIME format. Since your mail reader does not understand >this format, some or all of this message may not be legible. > Some was also in HTML. Would you and others similarly set up please switch to plain text, and maybe do a little editing? E.g., the following 7 lines would have been more than sufficient to convey your message: +------------------------------------------------- On Mon, 5 Nov 2001 22:52:57 +0100, "Bruno Li?nard" wrote: >I had written a script some time ago to extract directly from PDF file, it's >quite easy . As I had a very large volume of text to extract (some giga of >text), I now use PDFTOTEXT which comes with XPDF. I slighly modify for my >needs. If you are interested, I will look for the script in my archives Please do, and post a link. Thanks. +------------------------------------------------- And you could have left out: >------_=_NextPart_001_01C166CF.B8C164F0 >Content-Type: text/plain; [ ... about 62 lines ] >------_=_NextPart_001_01C166CF.B8C164F0 >Content-Type: text/html; [ ... about 95 lines ] >------_=_NextPart_001_01C166CF.B8C164F0-- > BTW, I find HTML particularly annoying in newsgroup posts, in case you can't tell ;-) From christophertavares at earthlink.net Fri Nov 23 04:41:00 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Fri, 23 Nov 2001 09:41:00 GMT Subject: Error on Socket Server ? References: Message-ID: "GT" wrote in message news:e253b770.0111230130.40d3fcac at posting.google.com... > Hi, > > May be someone who can tell me what is wrong with this code. > Not until you tell us what it's actually doing, and what you expected it to do. Platform and Python version would help too. Help us help you. [ ... code snipped ... ] From rand0m at nelvento.it Mon Nov 5 05:52:55 2001 From: rand0m at nelvento.it (rand0m) Date: Mon, 05 Nov 2001 10:52:55 GMT Subject: Python GUI for a C program Message-ID: Hi all, could someone point me to some good resources -beside official ones- (code snippets, tutorials, etc...) that could show me the way to build a Python GUI (i'm interested in wxPython) for C applications? Thank You, Lorenzo From loredo at astro.cornell.edu Tue Nov 20 23:09:28 2001 From: loredo at astro.cornell.edu (Tom Loredo) Date: Tue, 20 Nov 2001 23:09:28 -0500 Subject: sscanf ? References: Message-ID: <3BFB28F8.663AF1A8@astro.cornell.edu> It's not sscanf, but ScientificPython has a module that can do Fortran-style formatted reading/writing: http://starship.python.net/crew/hinsen/scientific.html -Tom Loredo From nhodgson at bigpond.net.au Thu Nov 8 03:49:55 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 08 Nov 2001 08:49:55 GMT Subject: Australian Disco (was: And Now for Something Completely Diff References: Message-ID: Mikael Olofsson: > Talking about the BeeGee's, weren't the HeeBeeGeeBee's from Australia? No, they were English too although I saw them perform in a Sydney pub. That's normally enough to claim them. "Meaningless songs in very high voices" Neil From zhangsc at neusoft.com Fri Nov 2 05:30:38 2001 From: zhangsc at neusoft.com (=?gb2312?B?1cXJ2bPb?=) Date: Fri, 02 Nov 2001 18:30:38 +0800 Subject: question Message-ID: <015c01c16389$6e2cbe60$4301010a@sky> First I'm sorry for sending this letter to your box without obtaining your permission,I beg your pardon. I have a question about Python.Now I am worrying about it very very much!!! I can't sleep well,time is passing fast,but I can't solve this problem on time! So I hope you could help me. I have asked so many people,even help at python.org and python-help at python.org ,but they all can't solve my question.I think you are the only expert which can help me.I beg you help me! My system is Red Hat Linux 7.0 .My python's version is 1.5.2.The question is that How to collect information about DNS using Python language? How to listen data packages about DNS on network and from the data packages,How can seperate IP address and relevant region name? My computer works in a LAN which contains many computers,LAN's struct is HUB.My computer isn't the default DNS.My computer's IP is 10.1.1.67, the DNS is 202.118.x.x. I have compiled a program,it follows: import socket, struct import os # IP header byte format (equiv of a C struct) # get from /usr/include/netinet/ip.h: # vers/hdrlen # TOS byte (not used often) # total_len # ident (internal use) # offset (internal use for partial packets) # ttl # proto (ICMP, ARP, TCP, UDP, etc.) # chk_sum # src_addr # dst_addr IPheader = '!bbhhhbbhll' IPheader_len = struct.calcsize(IPheader) # UDP header byte format (equiv of a C struct) # get from /usr/include/netinet/udp.h: # src_port # dst_port # data_len # chk_sum UDPheader = '!HHHH' UDPheader_len = struct.calcsize(UDPheader) os.system("ifconfig eth0 promisc") # we open a RAW socket instead of STREAM or DGRAM # when they say "raw," they mean raw - you need to read an exact # ammount of data, packets are not formed until later ipsock = socket.socket(socket.AF_INET, socket.SOCK_RAW,socket.getprotobyname("udp")) while 1: # I get both headers here, but this is buggy: # better to get each header # at a time recvpack = ipsock.recv(IPheader_len + UDPheader_len) ipdata = struct.unpack(IPheader, recvpack[:IPheader_len]) # we should now have a tuple of values # we should perform a checksum, but that's left for later if ipdata[6] == socket.IPPROTO_UDP: # is the protocol UDP? # get the UDP header decoded (it starts after the IP header) udpdata = struct.unpack(UDPheader, recvpack[IPheader_len:]) # src or dst port is DNS? if udpdata[0] == 53 or udpdata[1] == 53: #I think DNS uses 53th port # now we get the real (DNS) data, the length is in the # UDP header ulen = udpdata[2] data = ipsock.recv(ulen-24) # now we process the data, the IP addresses are in 'ipdata' # the ports are in 'upddata', and the DNS request/responce # is in 'data' itself ##process_packet(ipdata, udpdata, data) # instead, for now, just print it srcaddr = "%i.%i.%i.%i" %(ipdata[8]>>24 & 255,ipdata[8]>>16 & 255, ipdata[8]>>8 &255,ipdata[8] & 255) destaddr = "%i.%i.%i.%i" %(ipdata[9]>>24 & 255,ipdata[9]>>16 & 255, ipdata[9]>>8 &255,ipdata[9] & 255) print 'packet from %s:%d to %s:%d' % ( srcaddr,udpdata[0], # source addr & port dstaddr,udpdata[1] # destination addr & port ) I run this program,but udpdata[0] or udpdata[1] is never equal to 53,I can't receive DNS packages.Why? How to do to solve it? Which functions of Python do I need to use and how do I use them? Where can I get relevant information about DNS with Python? What are Internet address? Where can I get free source code? Could you help me to correct my program and make it to work? I'm looking forward to receiving your help letter! Thank you !!!!!! -------------- next part -------------- An HTML attachment was scrubbed... URL: From kuran42 at yahoo.com Tue Nov 6 23:59:52 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Tue, 06 Nov 2001 23:59:52 -0500 Subject: wxWindows link error References: <3BE8AA75.1090101@yahoo.com> Message-ID: <3BE8BFC8.3000803@yahoo.com> Well after a few hours of looking around and rebuilding a few times, this bug appears to have been due to wxPython's setup.py script (directly? indirectly? I have *no* clue how python's distutil system works) using gcc instead of g++. I fixed by symlinking /usr/bin/g++ to ./gcc in the base directory and including . in my path before anything else. Clearly this is not the right way to fix this. Can anyone tell me what is (or point me to some docs on distutils)? Jp Calderone wrote: > Just finished building wxPython 2.3.1 using GCC 3.0 and wxGTK 2.3.1. > But to my dismay, I get the following: > > ~$ python > Python 2.1 (#6, Sep 25 2001, 04:43:19) > [GCC 3.0] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> import wxWindows > Traceback (most recent call last): > File "", line 1, in ? > ImportError: No module named wxWindows > >>> import wxPython > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/local/lib/python2.1/site-packages/wxPython/__init__.py", > line 20, in ? > import wxc > ImportError: /usr/local/lib/libwx_gtk.so: undefined symbol: > __gxx_personality_v0 > >>> > > > Googling yields many results, none seem python related, most point to > gcc 3.0 as the cause. Do I need a different version of GCC to use > wxPython (in other words, do I need to get a different windowing > library) or can someone show me how to fix this? > > Thanks in advance, > Jp Calderone > From core.lists.python at core-sdi.com Wed Nov 28 11:35:18 2001 From: core.lists.python at core-sdi.com (Gerardo Richarte) Date: Wed, 28 Nov 2001 13:35:18 -0300 Subject: doesNotUnderstand ? Message-ID: <3C051246.9C15125E@corest.com> Is there a way to intercept the activation of messages which are not implemented? For those of you Smalltalkers, I'm talking about #doesNotUnderstand: In smalltalk, if you send a message to an object, but the object has no implementation for it, it'll receive a doesNotUnderstand messasge, with the failed message as argument. You can use this mechanism to implement proxies or auto accessors, or a lot of other interesting things... Hooking Bye! richie PS: I know it's impossible to understand my explanation of doesNotUnderstand... sorry --- for a personal reply use: Gerardo Richarte From brueckd at tbye.com Fri Nov 30 16:24:21 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Fri, 30 Nov 2001 13:24:21 -0800 (PST) Subject: A modest indentation proposal In-Reply-To: Message-ID: On Fri, 30 Nov 2001, Erann Gat wrote: > > Yes, in theory, their > > objection can cause problems. In practice, however, it rarely does. > > Rarely isn't good enough. Sure it is, otherwise you've also just disqualified every other language in existence. You said they also like C++. Well, the missing brackets in C++ rarely causes bugs, but it happens, and in my experience the indentation "problem" in Python happens even less often. By that standard, C++ is less suitable for your mission-critical application. For C++ users that are prone to that problem, the standard solution is to create a coding standard that always requires braces. If you find yourself prone to indentation problems in Python then create a coding standard that always uses an end-block comment. In neither case does the compiler care. In neither case is it required because the vast majority of the time it doesn't cause problems. > The annals of catastrophic failures are > chock-full of multi-million-dollar failures that were the result of things > that "rarely" caused problems. Perhaps, but you cannot now and will never find a total solution to that problem in a computer language. The language can but help, and that's what Python (and many other languages) do. > > Right now you're essentially in the tough position of showing that Python > > is perfect, which it's not, so you're bound to lose the argument. > > You misjudge the situation. I like Python a lot, but I don't really have > what you would call a passion for it. (My passions run in other > directions.) What's happening here is that I see an opportunity for > Python potentially expanding into a cool new market, but meeting > resistance. I see a way to overcome that resistance while at the same > time IMO improving the language with minimal impact on existing > infrastructure. But as you agreed earlier, their objection is a nit-pick and their reasoning (based on the fact that it's an "underdog") is irrational. Those are two very bad reasons to change a language. ;-) > But I am not engaged in any argument with anyone, so I'm > not "bound to lose." Ok, not arguing, but "selling" as you put it, and you're obviously interested in convincing them to buy into the idea of Python. My point was that it's a pretty tough thing to do if you have to respond to such nit-pick issues that they are dreaming up but don't have any real experience with. You can just as easily come up with a nit-pick list for any other choice of language, often a much longer list and with much more meaningful concerns. You're trying to convince someone of this indentation thing while they're partial to a language (C++) where you have to do your own memory management?!? > All I'm doing is bringing a problem and a suggestion > for a solution to your attention for your consideration. Not that I even have any say in whether or not the suggestion would ever be considered, but we're talking about a problem that is so obscure in practice as to make it essentially non-existent. In other words, the payoff would, at best, be about zero because in practice the presence of this characteristic of Python incurs about zero cost. By their reasoning we should not use computers at all since it is possible for them to lose power. We should not go to the store because it is possible to get into an accident on the way. We should not breathe because it is possible that the air is contaminated. These are all possible but improbable events. In this specific case there is a nearly infinite list of more probable sources of problems; your friends are concerned with the wrong end of the list. :) -Dave From rxg218 at psu.edu Wed Nov 21 18:02:56 2001 From: rxg218 at psu.edu (Rajarshi Guha) Date: Wed, 21 Nov 2001 18:02:56 -0500 Subject: which one to choose - NumPy or Scientific Python Message-ID: <9thboj$ud4@r02n01.cac.psu.edu> Hi, I've been doing most of my science related work using C - but for some new work I'm starting (neural nets, QSAR etc) I'm thinking of using python. I know there are 2 sets of libs - NumPy and Scientific Python. Are there any suggestion as to which one is better or more suitable - I won't need heavy duty number crunching. I do need arrays, basic statistical functions (I could code these myself - but their presence would be nice) -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 152 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- "I'd love to go out with you, but there are important world issues that need worrying about." From walter at livinglogic.de Thu Nov 22 12:16:41 2001 From: walter at livinglogic.de (Walter =?ISO-8859-1?Q?D=F6rwald?=) Date: Thu, 22 Nov 2001 18:16:41 +0100 Subject: extracting html table rows into a list References: <9aadf0f.0111220750.719466de@posting.google.com> Message-ID: <3BFD32F9.8030100@livinglogic.de> damien Wetzel wrote: > hi , > does any body has a script which parse a big table from an html file > and create a list of rows ? You could give XIST a try (http://www.livinglogic.de/Python/xist/) Code might look like this: from xist import parsers from xist.ns import html doc = parsers.parseTidyURL("http://www.freshmeat.net/", defaultEncoding="latin-1") firsttable = doc.find(type=html.table, searchchildren=1)[0] rows = firsttable.find(type=html.tr) for row in rows: print row.asPlainString() HTH, Walter D?rwald From syver-en at online.no Thu Nov 29 13:29:01 2001 From: syver-en at online.no (Syver Enstad) Date: 29 Nov 2001 19:29:01 +0100 Subject: debugging under NTEmacs? References: <9u5q1g$so7$1@bob.news.rcn.net> Message-ID: "David Abrahams" writes: > Does anyone know how to get pdb debugging in gud mode under emacs > for NT? No and yes (I'll explain), I've tried to get the gud mode working serveral times but not had much luck (on the other hand, I've never used GUD so I don't know how it's suppose to work). But the new pdbtrack feature in python-mode works great. One way to use it is as follows: Flip up the python interpreter buffer. put a pdb.set_trace call in the source file you wish to debug. Call into the code you wish to debug from the python interpreter window. Bamm, when the set_trace displays the (Pdb) prompt in the python interpreter window, pdbtrack hits in and displays the source file an the overlay arrow, so you can step through it. > > Any help appreciated, especially if you send answers to me directly! ;-) > > Thanks > Dave > -- > =================================================== > David Abrahams, C++ library designer for hire > resume: http://users.rcn.com/abrahams/resume.html > > C++ Booster (http://www.boost.org) > email: david.abrahams at rcn.com > =================================================== > > > -- Vennlig hilsen Syver Enstad From tim.one at home.com Fri Nov 30 14:57:20 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 30 Nov 2001 14:57:20 -0500 Subject: Non-Indented python In-Reply-To: Message-ID: [Michael Abbott] > Please, please, it would be helpful if Python had a (configuration > settable) option to reject tabs in all source. Write a PEP -- in a later msg you expanded the scope of what you want, and other people will want yet other gimmicks. I've got no interest in it myself (use -tt; use reindent.py; use tabnanny.py; don't let babies edit your source code ). > ... [later] ... > Is there a global option (I'm on WinNT) to make -tt the default? No, but you can use an obvious one-liner .bat file to supply -tt instead of running python.exe directly. > P.S. Where is this documented? I can't see any documentation of command > line parameters in any of the standard documentation (ref.ps, lib.ps, > etc) I have, so I presume that > Python -h > is all I've got to go on. I think "that's it" on Windows. Unix users have a wordier man page (Misc/python.man). > There doesn't seem to be an environment variable which can pre-set > command line options, so I'll have to do something more tricksy to get > -tt set by default. A .bat file is easiest on Windows. > Finally, when -t refers to "inconsistent tab usage", what exactly does > this mean? That there exists an adjacent pair of statements (not counting comments or blank lines) such that the relative indentation of their initial lines ("more", "less", "same") differs if hard tabs are considered to be 4-space gimmicks instead of 8-space gimmicks. So, e.g., and where T is a hard tab and S a space, this is inconsistent according to -t: SSSSSSSSx Ty (they're both indented 8 if T is an 8-space gimmick, but the second is indented less if T is 4). This is not inconsistent according to -t: SSTx Ty because -t only looks at tab widths of 4 and 8, and both those lines are indented the same (as each other) either way. The last example is inconsistent according to tabnanny.py, which looks at all tab widths greater than 0 (and those two lines are not indented the same (as each other) if, e.g., a hard tab is a 2-space gimmick). > I would really like something like to treat tabs (and indeed all > non-printing characters except for space and newline) as syntax errors > wherever they appear in the source. PEP, but it's so easy to write a little program to ensure this (on Unix it's a grep one-liner) I doubt anyone will bother. Note that Emacs users often use form feed characters to mark the start of a function, so "all non-printing characters" is too broad. From fperez528 at yahoo.com Sat Nov 10 19:44:27 2001 From: fperez528 at yahoo.com (=?ISO-8859-1?Q?Fernando_P=E9rez?=) Date: 10 Nov 2001 16:44:27 -0800 Subject: Bug in list comprehensions in Pyhton 2.1.1? Message-ID: <86f75fa2.0111101644.6f9de070@posting.google.com> The code below can be copied and run as is. Hopefully it documents clearly enough what to me seems to be a bug in list comprehensions: the global namespace is polluted with a local variable which was only used as the dummy running index of the list comprehension. If there is a good reason why this behavior is expected, I'd love to know about it. Cheers, f. # ------------- example code follows def flatten_bug(seq): # a *global* variable x is left over after calling this function, # with the value of the last element in the return list return [x for subseq in seq for x in subseq] def flatten_nobug(seq): x = 0 # forces x to be explicitly local. Ugly kludge. return [x for subseq in seq for x in subseq] # test code. Notice a variable x isn't defined anywhere. lst = [[1,2],[3,4]] print '\nlist',lst, 'flat_nobug',flatten_nobug(lst) try: print 'x:',x, print ' BAD! There should be no global x!' except: print 'x not found. Good, this is as it should be.' pass print '\nlist',lst, 'flat_bug',flatten_bug(lst) try: print 'x:',x, print ' BAD! There should be no global x!' except: print 'x not found. Good, this is as it should be.' From James_Althoff at i2.com Tue Nov 13 15:13:56 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 13 Nov 2001 12:13:56 -0800 Subject: IsPython really O-O? Message-ID: Prabhu Ramachandran wrote: >Andrew Dalke wrote: >> but I've never really needed it. Better I think would be if >> Python's IDE's offered a reload() which was closer to >> Smalltalks's, where a modified class definition propagates >> even to existing instances of that class. So someone could >> edit a module and manipulate things interactively without >> having to reload and rerun everything. > >That would be incredibly cool but is most probably very hard to do? I wrote such a tool for Jython. It is used quite extensively at our company and is well-liked. :-) Jim From anthony at interlink.com.au Thu Nov 1 02:55:15 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 01 Nov 2001 18:55:15 +1100 Subject: Underscore data hiding (was python development practices?) In-Reply-To: Message from Skip Montanaro of "Thu, 01 Nov 2001 00:09:53 MDT." <15328.59185.615816.939496@beluga.mojam.com> Message-ID: <200111010755.fA17tF718017@mbuna.arbhome.com.au> >>> Skip Montanaro wrote > scripting language for the Amoeba distributed operating system. The fact > that Python is "fast enough" for many things you might apply C++ to is in > large part because: Not forgetting the other point - it's usually very easy to optimise your application by recoding the performance critical fragment in C. Python's just so damn easy to extend... Anthony From pjotr at poland.com Mon Nov 26 16:03:33 2001 From: pjotr at poland.com (Pjotr) Date: Mon, 26 Nov 2001 22:03:33 +0100 Subject: problem with "elif" References: Message-ID: <1ba50u4ce8f390vur7nucf15e92l7s4pfn@4ax.com> On Sat, 24 Nov 2001 20:35:18 GMT, matt at mondoinfo.com (Matthew Dixon Cowles) wrote: >elifs need to line up with the corresponding if so if you move your >elif left by three spaces, you should be fine. That's a convenient way >of doing things because it means that long sequences of elifs don't >end up marching right across the screen until even short lines wrap. > >Regards, >Matt Thanks a lot! Best regards Pjotr _____________________ &&& pjotr at poland.com &&& From shalehperry at home.com Thu Nov 29 16:01:24 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Thu, 29 Nov 2001 13:01:24 -0800 (PST) Subject: finding a value in a tuple In-Reply-To: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Message-ID: On 29-Nov-2001 Dan Allen wrote: > Say I have > > mylist = ['one','two','three'] > > which I presume is a "tuple" as I have been scanning the manual. Now, > is there a way to run the php-like function in_array() on this. > Consider this, I want to know if one of the values in that tuple is > exactly equal to "four". The answer of course is no, but how would I > find it. Here is what I have so far, which works, but it is ugly.. > [] => list, () => tuple if 'one' in mylist: print "found it" if 'bob' in mylist: print "hi bob!" only the first on succeeds. From mwh at python.net Mon Nov 12 06:55:21 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 12 Nov 2001 11:55:21 GMT Subject: Tim Peters on speed! References: Message-ID: David Goodger writes: > > not-responsible-for-insane-user-methods-ly y'rs - tim > > Insane user or insane methods? Well, the insane user produces the insane method. And one can conclude from the production of the insane method that the user is insane (unless the method is for the Python test suite, I hope...) so there's no real ambiguity here. Cheers, M. -- Q: Isn't it okay to just read Slashdot for the links? A: No. Reading Slashdot for the links is like having "just one hit" off the crack pipe. -- http://www.cs.washington.edu/homes/klee/misc/slashdot.html#faq From phr-n2001d at nightsong.com Mon Nov 5 12:48:51 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 09:48:51 -0800 Subject: Teaching python (programming) to children References: <7xvggph61y.fsf@ruckus.brouhaha.com> <9s67gd$874$00$2@news.t-online.com> Message-ID: <7x4ro9un0c.fsf@ruckus.brouhaha.com> Guido Stepken writes: > > The best-known attempts to teach children programming have been with > > the Logo language. See the book Mindstorms, by Seymour Papert. He > > has another book out called "The Children's Machine: Rethinking School > > in the Age of the Computer", but I haven't seen it yet. > > I have had great success in making children (12-15) having fun programming > python .... before the were only interested in playing gameboy...with > pygame, SLT they are now trying to programm a simple game for windows .... > For Mindstroms there is a python module in work..... Yes, Python is probably a good choice at ages 12-15. By "children" I thought of the kids aged maybe 6-8. Python wouldn't make any sense at that age, but Logo apparently worked ok. From chris.gonnerman at newcenturycomputers.net Sun Nov 4 09:54:12 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sun, 4 Nov 2001 08:54:12 -0600 Subject: Python packages - problems, pitfalls. References: <15332.57918.232705.721124@monster.linux.in> Message-ID: <004d01c16540$a6690fa0$0101010a@local> ----- Original Message ----- From: "Prabhu Ramachandran" > Lets say I have a directory 'pkg' that is the root of a package. > Inside this directory I have a sub-package, called sub. So its > something like: > > pkg/ > __init__.py > a.py > sub/ > __init__.py > b.py > > Now, from b I'd expect to be able to import 'a' straight away. > > Say in b.py I do > > import a > > This will not work! I know why it happens but shouldn't Python be > smart enough to avoid such problems? Why I consider this a major > problem is that the importing of a sub-package depends on where its > parent package is!! So if pkg is no longer the root of the package > and say its put inside another BigPkg then to make pkg's sub packages > work you'd have to edit *all* the sub packages and change every > reference to pkg.a to BigPkg.pkg.a. This is a huge pain. Hmm. I personally can't say that I've ever renested a package to a deeper level. Has anyone else had a problem with this? The closest I can think of is converting a group of related modules into a package, and that wasn't all that much work. From trytop at 21cn.com Wed Nov 7 00:26:58 2001 From: trytop at 21cn.com (luckey) Date: Wed, 7 Nov 2001 13:26:58 +0800 Subject: may be a dumb question,but I can't understand why? Message-ID: <9sagj3$a0f$1@mail.cn99.com> the following function is in bpnn.py def makeMatrix(I, J, fill=0.0): m = [] for i in xrange(I): m.append([fill]*J) return m I rewrite it to : def makeMatrix(I, J, fill=0.0): m=[[fill]*J]*I return m the result is defference Can someone tell me the defference between the two function? From chrishbarker at home.net Fri Nov 30 15:25:36 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 30 Nov 2001 12:25:36 -0800 Subject: summing NumPy byte arrays References: <3C07DA0A.2DB4F78C@alex2.labs.agilent.com> Message-ID: <3C07EB40.1EFC594B@home.net> "David R. Smith" wrote: > > I have a big NumPy byte array, and want to sum it. Unfortunately, the > add.reduce (alias: sum) method does the sum in the same size receptacle, > e.g., > > >>> from Numeric import * > >>> X = arange(255, typecode='b') > >>> sum(X) > 129 > How can I get it to sum the array in a full-width accumulator, without > making an up-sized copy of the array? I'm pretty sure you can't. That would take some preety fancy footwork in the typecasting code. > ps. The array I am working with is a 2-d noncontinguous slice. Your options are to either upcast the whole thing (you can make a copy of that slice, and only upcast the copy), >>> from Numeric import * >>> X = arange(216, typecode='b') >>> X.shape = (6,6,6) >>> s = sum(X[3,:,:].copy().astype(Int)) >>> s array([738, 744, 750, 756, 762, 768]) Or to write a little C routine, which would be pretty straightforward if you only need it to work for one type, and one rank. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From mwh at python.net Wed Nov 14 10:49:23 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 15:49:23 GMT Subject: How to know when a variable is set References: Message-ID: madsurfer2000 at hotmail.com (-) writes: > How can I test if a variable has been given a value, or if it's undefined? Why would you want to do that? Specificaly, in what context do you want to know? Cheers, M. -- Two decades later, well-known hacker Henry Spencer described the Perl scripting language as a "Swiss-Army chainsaw", intending to convey his evaluation of the language as exceedingly powerful but ugly and noisy and prone to belch noxious fumes. -- the jargon file From kseehof at neuralintegrator.com Tue Nov 27 19:23:55 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Tue, 27 Nov 2001 16:23:55 -0800 Subject: module.__path__ References: <9u16r4$h2f$1@peabody.colorado.edu> Message-ID: <003701c177a3$68ac9540$4fc5fc9e@kens> Fernando P?rez wrote: > Ken Seehof wrote: > > > Why is the __file__ attribute (of a module) a relative filename rather than > > a fully qualified filename? One would think that the __file__ attribute > > might be used for the purpose of locating and opening a source file, right? > > If somebody wants a relative filename couldn't they split it themselves? > > By making module.__file__ relative, information is lost. What was Guido > > thinking??? Perhaps a __fullpath__ should be added. > > > > Don't tell me about the fact that .pyc files might be moved along with .py > > file from a different computer, thereby rendering the full pathnames > > incorrect. That's a silly argument not worth addressing. :-) > > > > Is there a good general way to determine the full pathname of a module file, > > or is the best approach to search sys.path for module.__file__? > > I don't know what Guido was thinking, my telepathy cap broke yesterday. But > as far as finding full, correct pathnames, use the inspect module (standard > with python >=2.1). It can get you filenames, code, function headers, just > about anything you want about an object. > > An example: > > In [21]: ranlib ? > Details for: ranlib > Type: module > String Form: '/usr/lib/python2.1/site-packages/Numeric/ranlib.so'> > Namespace: Local - IPython Session > File: /usr/lib/python2.1/site-packages/Numeric/ranlib.so Cool, that is a big help. Thanks. Ka-Ping Yee comes up with some neat ideas. > > If the module is an extension module, how do I find the full pathname of the > > source code file (preferably platform independent)? > > > > You can't. It may have been compiled to binary and the source may not even be > on your computer at all. So it's inherently impossible to get it. In my case, the application is an IDE, and it is a reasonable assumption that the source code exists locally (and that the extension module was built from the source in it's current location). Anyway, since I control the source code, I'll just add a bit of code to do the trick. I was just hoping something like this happened to be standard already that I didn't know about.... Perhaps something like this in the init function: PyObject *module, *dict, *sourcefile; module = Py_InitModule("engine", engine_methods); dict = PyModule_GetDict(module); sourcefile = PyStringFromString(__FILE__); PyDict_SetItemString(dict, "__sourcefile__", sourcefile); From boud at rempt.xs4all.nl Mon Nov 19 01:33:46 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 19 Nov 2001 06:33:46 GMT Subject: Anyone Using BlackAdder? References: Message-ID: <9ta94a$kt0$2@news1.xs4all.nl> A. Keyton Weissinger wrote: > I asked about Python IDEs yesterday (or so) and many of you responded (thank > you). One particularly interesting suggestion was BlackAdder. I'm playing > with the Demo copy and am about to drop my real money on it, but wanted to > ask the group. > Anyone using this? Considerations? > I'm not a huge user of debuggers and it seems that BlackAdder == Qt Designer > + PyUIC + Debugger. Plus a version of the Scintilla editor. > Don't get me wrong. It's very nice and well put together. I just don't want > to slap down the coin if I can help it. That depends on how comfortable you are without integration - eric, the debugger included in PyQt isn't as good as the debugger in BlackAdder, but does work. Another consideration is distribution: if you want to sell apps commercially on Windows, then you might prefer BlackAdder pro above buying a commercial Qt license. As for myself, I've used BlackAdder while writing the book on PyQt, but I mostly use XEmacs nowadays. There's something to be said for using one editor to write fiction, articles, sgml, Java and Python and anything else... -- Boudewijn Rempt | http://www.valdyas.org From sholden at holdenweb.com Wed Nov 14 07:50:58 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 07:50:58 -0500 Subject: A file object is an iterator, not a container References: Message-ID: "Oren Tirosh" wrote in message news:mailman.1005719178.24676.python-list at python.org... > I am currently working on a framework for dataflow-oriented programming. > This framework makes it easy to create dataflows by connecting together > sources, transformations and destinations. It makes extensive use of the > new iterators and generator functions defined in Python 2.2. A first public > release is expected soon. > Sounds interesting. [ ... controversy ...] > > Is there any chance this could still make it to the final 2.2 release or > would a thorough discussion of this proposal on the list take too long? > No chance at all. 2.2 is in feature freeze since it went into beta, and this is definitely too risky to drop in at that stage. Even if you had a patch implementing it! The development team isn't exactly risk-averse in the early stages of a new release, but I'd be very surprised to see anything radically new appear at this stage. [ ... ] regards Steve -- http://www.holdenweb.com/ From marcoxa at cs.nyu.edu Tue Nov 13 17:04:38 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 13 Nov 2001 17:04:38 -0500 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> <9srbs8$pur$1@slb2.atl.mindspring.net> <9srr3l$3v7$1@slb6.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > Marco Antoniotti: > >Historical cruft? The evolution of the languages have been different. > >The presence of strong vendors in the CL camp does (IMHO) work as a > >disincentive to community wide standardization. > > Interesting. So by *not* having a strong advocacy for Python, > there isn't the urge to have multiple competing implementations, > so Python can keep developing new 'standard' libraries? > > I like that approach -- less arguments and more code :) I guess :} > > [Seeing that you didn't cross-post to c.l.lisp ..] > I try never to cross post. I believe it makes it difficult to follow a discussion and it augments the noise. > I always seemed to me too easy to make new Lisps, and many of the > people doing Lisp argue for esthetic purity, which leads to the > large number of variations in the language. THis argument was true until the early nineties. Now people make (because it is relatively easy) new Scheme's, all slightly incompatible. Common Lisp is remarkably stable and with a large set of primitives. > Python has always felt more pragmatic, and pragmatically speaking > it's easier to have one standard, reference platform from which > other implementations derive, rather than through a language spec. This is true of Python and Perl and other languages (INTERCAL included :) ). Common Lisp did simply not evolve like this. In the early eighties there was a lot of money being poured into "Lisp", and vendors appeared very early in the process. Once you have people with a lot at the stake and you get committed to a stadardization process you slow down. The ANSI CL standard (not very usable as a tutorial, but very good indeed) provides a sound and very flexible foundation upon which to build various systems. Unfortunately, whatever is not in the standard, makes it relatively difficult to write "very" (note the quotes) portable code. Take the case of C/C++ interfaces. Every CL implementation allows you to interface to - at least - C. This means that you could always link in C code into your application. However, in CMUCL you do it in one way, while in ACL you do it differently. And, up to this point there has not been any incentive or energy to come up with either a "reference implementation" for a C interface (a Foreign Function Interface), or a specification document accepted by all the people with a stake in CL. > >As for "widely used though non-standard libraries for CL for "doing > >stuff like internet programming", you can check the CLOCC > >(http://sourceforge.net/projects/clocc). Not much, but it is there. > > I know little about CL systems, which is why I quoted the original > statement from someone else. Maybe it's time to have a better look at CL?!? :) Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From philh at comuno.freeserve.co.uk Sun Nov 25 17:37:02 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Sun, 25 Nov 2001 22:37:02 +0000 Subject: A permutation on permutations References: Message-ID: On Sun, 25 Nov 2001 01:18:28 -0500, Arthur Siegel wrote: >What I've come up with is: > >L is my list of arbitrary length. >M= [i for i in range (len(L))] > >#thanks to Rainer Deyke's post >def perms(L): > if list == [] : > return [[]] > return [[list[i] + p for i in range(len(list))\ > for p in perms(list[:i] + list[i+1:])] > >def removedups(t): > for p in t: > m=copy.copy(p) > m.reverse() > if m in t: > t.remove(m) > >def drawcurve(t): > #t is M or a slice of M > perm=perms(t) > removedups(perm) > for i in range(len(perm)): > cp=[L[j] for j in perm[i]] > BezierCurve(cp) > >It seems to work. > >But I wonder if there is a significantly more >efficient solution Assuming that the list of of numbers, and every element in the list is different, a quick way to test for reversals is to disallow all lists where the first element is greater than the last one; this means that you get exactly one of each pair. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From tim.one at home.com Sun Nov 18 18:39:52 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 18 Nov 2001 18:39:52 -0500 Subject: something Evil happens when large hashes destroyed In-Reply-To: <9t8m1c019qd@enews1.newsguy.com> Message-ID: [guuge] > I was trying to sort about 100,000 items by splitting them into > groups (using a python dictionary type) and then successively splitting > these groups until they were small enough to use a brute force method. Try list.sort(). > My test program, which used only two or three keys to create the first > split, worked fine. When I tried the real thing, using 256 keys, the > program slowed to a crawl. The python interpreter took forever to > destroy the dictionaries. > > Here's a little program ... I tried that w/ 2.2b2 under Win98SE, 866MHz, 256MB RAM, also with 100,000 elements, and the number of bins didn't matter: for assorted values from 1 through 100,000, creation time was 2 seconds and destruction time 0 (time.time() only has 1-second resolution on Windows). So best guess is that you're fighting your platform C library's malloc()/free(). Which OS? Which C compiler and library? If you build Python yourself, try rebuilding 2.2b2 --with-pymalloc, and see whether that helps. It would be interesting to know one way or the other. From qrczak at knm.org.pl Sun Nov 4 05:50:17 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Sun, 4 Nov 2001 10:50:17 +0000 (UTC) Subject: Q: Feature Wish: "%" Extension References: Message-ID: Sun, 4 Nov 2001 02:14:45 -0500, Tim Peters pisze: >> Back when dinasaurs walked the earth, I had a long argument with the >> Pascal standards committe about the correct definition of the modulus >> operator. Believe it or not, they had it so that (-3)%2 was a negative >> number! > > Most languages do, alas. Among these types in OCaml: 1. int: builtin, machine word size, 2. big_int: unbounded, 3. num: union of int, big_int and ratio, all have different meanings of division and modulus! I wasn't aware that there are more than two variants in use. In each case separately division is consistent with modulus. The following conditions hold in the respective cases: 1. (-x) div y = -(x div y) 2. 0 <= x mod y < |y| 3. x div y = floor (x/y) Intel processors and C99 do the first variant. Python does the third variant. Knuth says the third variant is the true one. In SML and Haskell the first variant is called quot/rem and the third is called div/mod. I recently needed to express quot/rem and div/mod in terms of the first and the second variant. I think I haven't seen the second variant before. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From prabhu at aero.iitm.ernet.in Wed Nov 7 08:55:34 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 7 Nov 2001 19:25:34 +0530 Subject: A smarter(?) package importer. In-Reply-To: References: Message-ID: <15337.15702.858450.515714@monster.linux.in> >>>>> "GMcM" == Gordon McMillan writes: GMcM> But sys.modules is a dictionary. It's hashed, not scanned. Indeed but doesn't the length of the table matter for performance? I am no expert here so I'm just asking. GMcM> If you *don't* cache failure, you get 3 (4 on Windows) GMcM> attempted opens per directory that you could have avoided. Yes, thats a problem, didn't look hard enough. Thanks for pointing it out. Okay I'm convinced of caching now. Will try to cache it and post an updated version. thanks, prabhu From era_akost at yahoo.de Thu Nov 15 12:29:02 2001 From: era_akost at yahoo.de (Era Akost) Date: 15 Nov 2001 09:29:02 -0800 Subject: Pmw.ScrolledListbox References: <6749bb94.0111140719.15db2737@posting.google.com> <9t04c2$53ra$1@mail1.wg.waii.com> Message-ID: <6749bb94.0111150929.73df59df@posting.google.com> Martin Franklin wrote in message news:<9t04c2$53ra$1 at mail1.wg.waii.com>... > Era, > > Could you post some code I can't see this with the following code.... > > >>> from Tkinter import * > >>> import Pmw > >>> root=Tk() > >>> lb=Pmw.ScrolledListBox(root) > >>> lb.pack() > >>> lb.insert(0, 'one') > >>> lb.insert(0, 'two') > >>> lb.insert(0, 'three') > > Oh and what platform/version etc.... > > Martin Hi Martin, you're wright. This code doesn't show what I was talking about. I tried myself several from these simple examples and no one show an underlined item selection. In fact, my code is a little more complicated. I will paste it at the end of the message. I create a class SelectionWindow - which has a Pmw.SelectionDialog (one of which components is Scrolledlist). I need this class because in my application I'll be calling several times the SelectionDialog, with different items. To show how it is called in my application, I wrote a simple class Demo. Making some tests now, it seems that the problem is connected to the functions withdraw(), activate(). I have no idea why. I'm using Python 2.0 on Windows NT. Here is the code. It runs. ###################################### from Tkinter import * import Pmw class SelectionWindow: def __init__(self, parent, data = ()): self.data = data self.dialog = Pmw.SelectionDialog(parent, title = 'Selection Window', buttons = ('Accept Selection', \ 'Undo Selection'), defaultbutton = 'Accept Selection', scrolledlist_labelpos = 'nw', label_text = "Make your selection", scrolledlist_items = self.data, command = self.selected) self.dialog.withdraw() def activate(self, data = ()): if data: self.data = data self.dialog.setlist(self.data) self.dialog.activate() return self.dialog.getcurselection() def selected(self, result): if result == 'Accept Selection': self.dialog.deactivate() else: self.dialog.selection_clear() data = ('January', 'February', 'Mars', 'April', 'May', 'June') class Demo: def __init__(self, parent): self.var = StringVar() Button(parent, text = 'Select Fields', command = self.call_sw).pack(padx = 10, pady = 10, side = LEFT) Label(parent, textvariable = self.var, width = 10).pack(padx = 10, pady = 10, side = RIGHT) self.sw = SelectionWindow(parent) #uncomment last line, #while commenting self.dialog.withdraw() above #self.sw = SelectionWindow(parent, data) def call_sw(self): selection = self.sw.activate(data)[0] #result is a tuple self.var.set(selection) #set the value to the lable text if __name__ == '__main__': root = Tk() root.title('Demo Test') d = Demo(root) root.mainloop() From deoradh at yahoo.com Thu Nov 8 13:58:09 2001 From: deoradh at yahoo.com (Keith Farmer) Date: 8 Nov 2001 10:58:09 -0800 Subject: C-extension in Python -- returning results References: <3BE9F266.A2794615@ix.netcom.com> Message-ID: A word on the original function. One of the reasons this function is able to be approximated by the polynomial is that given a reasonably short period of time (a year for the outer planets, weeks for the inner), the path described is very roughly a straight line (<70deg arc), which with only a few minute's calculation (a thousand or two samples) I can get accuracies to within 0.001%. The choice of polynomial was based on the prior existance of these datasets. It provides a convenient way to check the method, if nothing else. From wzdd at lardcave.net Fri Nov 30 09:31:23 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Sat, 1 Dec 2001 01:31:23 +1100 (EST) Subject: Non-Indented python In-Reply-To: Message-ID: On 30 Nov, Marcin 'Qrczak' Kowalczyk wrote: > There is no need to ban tabs, or to ban spaces, or to ban mixing > indents (whether it's mixing tabs with spaces on the same line or > mixing indentation methods on differnent lines belonging to the same > block). Just ban non-standard tab sizes and the problem is solved. This isn't directed at Marcin, but I don't understand why people keep going on about this, because it's not accomplishing anything. * Most tab-indent users won't become space users * Most space-indent users won't magically change into tab users * The above quoted para won't convince anyone who uses 4-char tabs to switch over, especially since 8-char tabs is only demonstrably the "standard" when you're dealing with the Python interpreter. Nobody has presented a convincing argument for tabs-only, spaces-only, or 8-char tabs only, because there isn't one. Everyone's smart enough to recognise a vi/Emacs holy war when they see one; why is the tab/space war any different? Based on my experience, the solution is to have a programming standard within your project. Mixed tabs and spaces makes me feel icky inside regardless, Nicholas FitzRoy-Dale From ra9483 at email.sps.mot.com Thu Nov 29 11:33:14 2001 From: ra9483 at email.sps.mot.com (Dean Hall) Date: Thu, 29 Nov 2001 10:33:14 -0600 Subject: decoding floats References: <9u2buq$jo9$1@news.sns-felb.debis.de> <9u4lqh$gc7$1@news.sns-felb.debis.de> Message-ID: <3C06634A.B802A165@email.sps.mot.com> Nico Hartmann wrote: > > > > Hi there, > > > > > > I look for a way to decode and encode float values into byte arrays. > > > > >>> import array > > >>> a = array.array('f') > > >>> a.append(42.42) > > >>> a.tostring() > > '\x14\xae)B' > > > > Something like this? > > Yes, that would do. I figured out using the stuct.pack from struct package > also works fine: > > import struct > bytes = struct.pack("d", 34.34) > > Regards, > nico The marshal module uses the same codec method as .pyc files. Marshal might be easier and the output more readable: >>> import marshal >>> s = marshal.dumps(3.14) >>> s 'f\x043.14' >>> marshal.loads(s) 3.1400000000000001 And marshal is tolerant of trailing bytes: >>> marshal.loads(s + "bob") 3.1400000000000001 The string s is: s[0] = 'f' indicates a float type follows. s[1] = 4 the next 4 bytes contain a string describing the float. s[2:]= '3.14' the ftoa() representation of the float. !!Dean From eric at enthought.com Tue Nov 13 11:39:12 2001 From: eric at enthought.com (eric jones) Date: Tue, 13 Nov 2001 16:39:12 GMT Subject: Python Job Posting: Austin, Tx Message-ID: Company: Enthought, Inc. Location: Austin, Tx Position: Software Developer Openings: 1 Basis: Full Time Interested parties should submit their resume to jobs at enthought.com. Description: Enthought is looking for a motivated individual to join our business computing group. Responsibilities include developing and deploying Web-centric, business automation software for our clients. It is desirable for the candidate to have system administration skills for both Unix (Linux and Sun) and Windows, as the job will also involve management of our office network. At Enthought you would: Work with a team of top-notch programmers to develop business automation tools for our clients Manage our corporate computer network of Linux and Windows machines Receive a competitive salary, benefits, and stock options Ideal candidates have the following qualifications: BS or MS in Computer Science or Engineering 2-5 years experience in the software industry Experience deploying solutions at client sites Candidates should be skilled in the following areas: Python and C/C++ Programming Web and database development (HTML, ZOPE, SQL, ASP) Understanding of client business processes Linux Administration (Mail, DNS, Firewall, VPN, CVS, Beowulf Clustering) Candidates with substantial experience in Web and database development using a different language or toolset should also apply. Assistance for relocation is not available for this position. Enthought is a scientific and business computing company based in Austin, Tx. For more information see: www.enthought.com www.enthought.com/jobs_html www.scipy.org From rdsteph at earthlink.net Sun Nov 11 19:04:27 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 12 Nov 2001 00:04:27 GMT Subject: Easy(?) newbie question References: <3BEEF8A9.DBF96E74@earthlink.net> Message-ID: <3BEF136E.48601B63@earthlink.net> In other words, exec is a statement, but eval and execfile are functions. Since eval is a function, it doesn't make sense to give it a for loop. Try using exec instead, I think it will work like you expect. Hye, I'm a newbie too, and this eval and exec stuff has always confused me. I hope my adive above is correctly stated. ;-)))) Gerhard H?ring wrote: > On Sun, Nov 11, 2001 at 10:16:38PM +0000, Erik Johnson wrote: > > > > Hi, > > > > I am just getting savvy to Python - rather excited about the > > possibilities, but I have come across something that seems rather simple > > but I'm stumped... > > > > The following loop does what I would expect: > > > > >>> for x in range(10): print x, > > ... > > 0 1 2 3 4 5 6 7 8 9 > > > > but when I try to put this code into a string and evaluate it, I get a > > syntax error: > > > > >>> s = "for x in range(10): print x," > > >>> s > > 'for x in range(10): print x,' > > >>> eval(s) > > eval() evaluates expressions, exec() executes statements. More about what is an > expression/a statement can be found in the Python documentation. > > Also, the Python interactive prompt does both execute and evaluate, depending > on what you feed it. > > Gerhard > -- > mail: gerhard bigfoot de registered Linux user #64239 > web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 > public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 > reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From era_akost at yahoo.de Wed Nov 28 10:25:31 2001 From: era_akost at yahoo.de (=?iso-8859-1?q?Era=20Akost?=) Date: Wed, 28 Nov 2001 16:25:31 +0100 (CET) Subject: Should I use threads here? Message-ID: <20011128152531.62559.qmail@web21105.mail.yahoo.com> Hi all, My problem is the following. I have a program (no source code) that takes some data from a file and calculates some models. While executing, the program outputs continually on the console. Now, I want to call this program within a Tkinter GUI. I call the program (thanks to Steve Holden for the answer) through popen2() i, o = os.popen2('myProgram files') for line in o.readlines(): text.insert(END, line) #text is a widget defined somewhere before. But since I want to write the output on a GUI widget, I saw that this happens only after my program is executed (I've should have known that). But sometimes the programs runs for minutes, so in the meantime I want some results beeing displayed in my GUI. Is that something can be done with threads? If yes, how? I've never used them before. Could someone give me an example? (Python 2.01, Win NT) thank you, Era __________________________________________________________________ Gesendet von Yahoo! Mail - http://mail.yahoo.de Ihre E-Mail noch individueller? - http://domains.yahoo.de From stephen at stephencox.org Fri Nov 23 00:08:06 2001 From: stephen at stephencox.org (stephen cox) Date: Fri, 23 Nov 2001 05:08:06 GMT Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: > 2. I also need something practical to get away from the borg; I made > a big mistake during the 1990s and moved from Clipper to Visual Basic, MS's new .NET Framework is impressive. And believe it or not it works. And you can use Python as you lang of choice if you prefer. Also supported are J#, C#, C, Cobol, and of course VB (ASP w/VB. No more VBA). Another shocker is that the Framework is available for free. And MS is porting it to Linux and FreeBSD. Also you do not need Visual Studio (which is crap. Even the new one). I use Dreamweaver for design work, and do my scripting in ASP, or PHP depending on the job. I'm also learning Python.. and plan to use Python to replace PHP and ASP. Oh, I too made the same mistake moving from xBase (Fox, dBase, Clipper) to VB and regret it. Although FoxPro was acquired by MS a few years ago, they still treat it like a step child. It's the best damn desktop DBMS in the world. And the play it down all the time. -- Stephen Cox web.net geek for non-profits, political campaigns, and a few socially conscious businesses. stephen at stephencox.org "Todd Boyle" wrote in message news:3bfe9816.152519843 at news.cortland.com... > I am an amateur at programming and I have almost the same questions. > > My questions are: > > 1. PHP is attractive to me because after playing aroudn with it a > short while I was able to implement my own simple stuff, and some > other PHP applications from open source. Also--the leading > independent webledger in my industry is Intacct (not connection to > me) and it's written in PHP, which proves this is a very capable > system. > > 2. I also need something practical to get away from the borg; I made > a big mistake during the 1990s and moved from Clipper to Visual Basic, > which is a great platform but they churn the hell out of it, and > nothing you can write will ever be an asset to the programmer for > longer than 1-2 years. So I am using Python for day-2-day little > programming tasks... > > But, what is the best way to build web-based database applications > like accounting systems, on Python? i.e. what is the equivalent > of ASP pages or PHP pages or JSP pages, for Python?? Shouldn't > we be learning THAT instead of PHP??? > > Todd Boyle www.gldialtone.com > > > > On Thu, 22 Nov 2001 06:17:46 -0000, "the Spinning Spider" > wrote: > > >I'm finding learning Java is quite a tough challenge, like wading through a > >swamp. So I'm exploring PHP and Python as possible alternatives. > > > >I notice there doesn't seem to be much mention about PHP by Python people > >whenever they mention other languages, > >e.g.,see http://www.python.org/doc/Comparisons.html. > > > >Or is it because PHP is incomparable against Python? > > > >Could it be the news servers I have access to, or is there no comp.lang.php > >newsgroup? Is PHP too insignificant? > > > >Will Python be too intellectually challenging, like Java? > > > From fperez528 at yahoo.com Sat Nov 10 15:53:51 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 11 Nov 2001 20:21:51 +2328 Subject: Scientific Libraries in Python References: Message-ID: <9snfbh$dt3$1@peabody.colorado.edu> > > Would it be possible for one to absorb the other so we have a single > standard scientific library for Python? Indeed. SciPy seems to have a very good framework, into which probably others could be plugged in. Currently there's a ton of half-baked systems, none of which is fully satisfactory. I truly think that with a good, comprehensive system of packages for numeric/scientific work, which includes a *real* visualization framework, Python can beat as a tool MatLab and IDL by far. Mathematica/Maple are a tougher question, because symbolic computing is still a bit of a black art. But there's Ginac which has (had?) Python bindings, and in the meantime one could call Mathematica via the Mathlink protocol. The way I see it, we need a solid, integrated set of libaries with: 1) python-level access to all routines 2) c/c++ implementations of the low-level stuff for speed. 3) A true visualization *framework*, which has both high-level plotting routines and access to basic primitives. Mathematica's plotting system, while not the most convenient to use, is a good example of this idea. You can just 'plot' stuff, but you also have low-level access to the graphing primitives to program more complex stuff yourself. 4) A convenient environment for interactive work. 1/2 are being addressed by SciPy/Scientific, so some integration would be nice. 3: there's a lot out there, but nothing convinces me yet. VPython is great for 3d work but still in its infancy, gnuplot and grace have python access but don't provide low-level access, scigraphica doesnt' seem ready yet, ... 4: we have the prompt, and improvements exist. This is the easiest of the 4. F. From agavrilov at home.com Fri Nov 9 20:07:08 2001 From: agavrilov at home.com (Alexander Gavrilov) Date: Sat, 10 Nov 2001 01:07:08 GMT Subject: Defining inheritance in C extensions References: Message-ID: <05%G7.13297$Vf4.7262298@news1.rdc1.sfba.home.com> Probably it's not what you're looking for, but you can take a look on ASPN recipe called "Defining Python class methods in C". Here is the link: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/54352 -- Alexander Gavrilov Brainbench MVP for C++ http://www.brainbench.com "Timo Savola" wrote in message news:mailman.1005261310.27106.python-list at python.org... > Hello. I'm new to this list, and relatively new to Python (played around > with it every now and then, and used it as a calculator :). > > Now I'm doing an extension module, or rather a system that I want to > control via Python. I have a C++ class hierarchy that I want to be > accessible from Python. I can't figure out how to make a type object a > subclass of another type object, so that I can do type checking in the > Python wrappers of my methods. > > I've been browsing the Extending and Embedding section of the Python > documentation (version 2.2). Is it just me, or has the Defining New > Types section fallen short? It doesn't say anything about /* Attribute > descriptor and subclassing stuff */... > > Is there a more extensive reference to extending Python, or maybe some > comprehensive example code on the subject? > > Thanks in advance. :) > > Timo > > From sholden at holdenweb.com Fri Nov 16 10:22:03 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 10:22:03 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <2YTI7.30749$vQ1.1137481@atlpnn01.usenetserver.com> Message-ID: "David Eppstein" wrote in message news:eppstein-54CAED.14040815112001 at news.service.uci.edu... > In article <2YTI7.30749$vQ1.1137481 at atlpnn01.usenetserver.com>, > "Steve Holden" wrote: > > > Whether or not either comma is (even optionally) necessary syntactically, > > the main problem with any such representation is the impedance mismatch with > > [x]range(), which are built on the half-open interval. Particularly > > difficult to explain the mismatch to newbies, I think. > > > > If I have a vote, I'm afraid it's -1 > > OK, but my problem is precisely the impedance mismatch between range and > newbies -- do you really think that they come pre-equipped with an > understanding of range and half-open intervals? I am happy enough with > [x]range when it comes to programs that I write for myself, but would like > a more intuitive syntax for using in algorithms lectures where I can't > expect the students to know Python syntax. > > It sounds like too many Pythonists see this as a non-problem, so it is > unlikely to change and I will continue using non-Python for my lectures. Well in the interests of getting Python into your teaching, might I suggest that you simply describe [x]range(n) as producing the range of subscripts required to index the elements of a sequence of length n? Since it's presumably computer science you are teaching, your students should be familiar enough with the (mathematically justifiable, but equally pragmatically justifiable) advantages of numbering from zero. If not, then arguably they won't be learning much computer science anyway, though I have no objection to their tinkering with programming ;-) This thread has mixed discussions on the utility of half-open intervals with the possibility of the notational extensions proposed in the PEP. Ultimately, do we want a notation for producing *other* types of interval, or are we satisfied with having to produce them all using the current half-open style? regards Steve -- http://www.holdenweb.com/ From just at letterror.com Sat Nov 10 07:41:40 2001 From: just at letterror.com (Just van Rossum) Date: Sat, 10 Nov 2001 13:41:40 +0100 Subject: Using browser as interface to python app References: Message-ID: <3BED2723.B42B68EE@letterror.com> Sandy Norton wrote: > I've just been prototyping a simple multi-threaded internet news > monitor and have gotten to the point where I need to make a decision > about the direction(s) the user interface might take: I've ruled using > wxPython and Tkinter as I think a GUI is overkill, however I'm > intrigued by the possibility of running a simple local webserver which > would serve a set of webpages (with checkboxes, text fields, etc..) > directly to a browser which would then allow the user to interact with > the running python app. > > I thought about using CGIHTTPServer in the Standard Lib but its use of > forking doesn't make sense for Windows. OTOH, I'm also sure that > there's a COM way to do this somehow, but I'd really like to try to > make the end app as portable as possible. Another consideration is > distribution footprint...(we wouldn't want the user to have to > download and set up apache :-) > > Any tips, pointers, advice whatsoever on this topic would be greatly > appreciated. > > Thanks in advance, > > Sandy Norton > > FYI: I'm using Internet Explorer 5.0 and python 2.1.1 on win2K Does pydoc -p work under Windows? If yes, it might be a good http server demo. Just From gh_pythonlist at gmx.de Mon Nov 19 06:24:58 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Mon, 19 Nov 2001 12:24:58 +0100 Subject: Xlib bindings for Python? In-Reply-To: <23891c90.0111190210.2986aa4e@posting.google.com> References: <23891c90.0111190210.2986aa4e@posting.google.com> Message-ID: <20011119122457.A11094@lilith.hqd-internal> On Mon, Nov 19, 2001 at 02:10:09AM -0800, Paul Boddie wrote: > Mike Meyer wrote in message news:... > > Yes, I'm really looking for a set of bindings for Xlib, not a Xt or Xm > > or some other GUI toolkit. It's probably best not to ask why. > > > > I found the X-extensions package, but that apparently stopped being > > updated about python 1.4. > > > > Anyone got pointers to something more recent than that? > > Try Greg Ewing's work, which apparently includes a wrapper around Xlib: > > http://www.cosc.canterbury.ac.nz/~greg/python_gui/ There's also this one: http://sourceforge.net/projects/python-xlib/ it's the basis for http://sourceforge.net/projects/plwm/ a Window Manager written in Python. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From nika at kassube.de Sun Nov 4 07:14:10 2001 From: nika at kassube.de (Nils Kassube) Date: 04 Nov 2001 13:14:10 +0100 Subject: How can i retrieve a key from a dictionary? References: <3BE519E0.34312B48@student.kun.nl> Message-ID: <87668qivhp.fsf@kursk.kassube.de> Husam writes: > dict.keys() will gets all the keys. but, i need to select explicitly one > key for printing along its value. >>> dict={} >>> dict[1]="Foo" >>> print dict[1] Foo This dictionary method is also useful: >>> print {}.get.__doc__ D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None. i.e. to have a default value of 42 for the key 2 which is used when an entry for 2 is missing: >>> print dict.get(2, 42) 42 Please read the tutorial before asking any other question. Danke. From graz at mindless.com Thu Nov 29 18:02:14 2001 From: graz at mindless.com (Graham Ashton) Date: Thu, 29 Nov 2001 23:02:14 +0000 Subject: Design tips requested for OOP forum system (using pickle) References: Message-ID: <56zN7.139$Jm.5630@stones> In article , "Simon Willison" wrote: > I'm something of a Python newbie but I'm keen to learn so I've decided > to throw myself in at the deep end. Good plan. The fastest way to learn, I reckon. > Anyway - I've decided to code a flat threaded web forum system ... using > pickled objects in flat files to store the data (rather than using a > database or a delimited flat file format of some sort). Here's an idea to think about; see if you can work out how to design a fairly generic interface to your storage. Implement it first with pickle (cPickle is much faster by the way) and then see if you can fiddle around with it a bit so that it supports different storage systems (e.g. anydbm), selectable at run time. Design patterns will be your friend here, and are very interesting ways of taking your OOD knowledge beyond the standard inheritance and delegation techniques. Top pickle tip (cPickle isn't available everywhere): try: import cPickle pickle = cPickle except ImportError: import pickle > User - an object representing a single forum user account Forum - an > object representing a forum (e.g "General Chat" or "Site Suggestions") > Thread - an object representing a thread Post - an object representing > an actual post Do you need a thread? I don't know. Would it be better to have threads specified through relationships between posts, so each post would have an attribute that would somehow point to children? I'm not sure, I'm just thinking (briefly) aloud. How will your interface be driven and generated? Let that guide you to begin with. > In addition I'm keen on having Moderator and Admin classes which extend > User and are used for forum accounts with extra ablities. Fine, but that kind of simple inheritance isn't the most interesting kind of problem for you to solve here. The structural aspects are more complicated, and consequently interesting. By "structural" I mean how you will need to organise the various elements of your software. How will the user interface communicate with your storage system? Will you have a layer of indirection on top of the storage? I'm not suggesting you should (I've not thought it through), I'm just trying to illustrate what I'd be thinking about if I was you. > Post objects will be held in an array within a Thread object > (representing the thread the posts were posted on). Thread objects will > be held in an array within a Forum object. Sounds reasonable, but.... How will you select the next 100 posts that come after a certain date? Wouldn't you like to be able to say "I want a sub set of this list that contains only these posts"? Looping over an enormous array won't scale very well there. Is an array the best data structure? As you're doing it as a learning exercise, try playing around with different implementations of your Forum class - don't fix it's internal design this early. Decide on your initial interface for your Forum class and then build things that talk to it. Then play around with the inner workings of the Forum class to see how best to implement it. > One thing I haven't quite figured out yet is how to relate posts to the > user object for the user that posted that post. Should I look at storing > some kind of user ID and then searching through my user objects for an > object with that ID stored within it every time I display a post? If you do go that way you will want a fast database engine. I wouldn't though (go that way, I mean). I'd start by storing all data about a post in the Post object and throw the User object concept in the bin for a bit. Adding it later would be a useful exercise in refactoring if you decide you really want it. > I'm also not entirely sure how to do things like ordering posts witin > threads by date - should I ensure they are in order within the array or > sort the objects by their date property (which I assume will require me > to write my own ordering algorithm, presumably not hard but something > I've never had to do before). Assume you'll want to order them in different ways in the future and pick a data structure/storage system that lets you sort them efficiently. You can sort objects based on the values of their attributes quite easily. > My final problem (I think) is how to split pickled data up. Should I > have an OverallForum object which contains ALL the objects (and data) > within it and pickle/unpickle the whole thing for every page view > (sounds inefficient) or pickle individual forums in their own files. I've barely used pickle so can't help you much with the one big file/little file speed trade off. I imagine little files would be a good place to start though (less RAM required to load them, less time to seek right through them). > Any tips / pointers / warnings that I'm going about this project > completely the wrong way would be more than welcome :) I'm afraid I've not really thought about how I'd design it if I was you, just done a quick brain dump. Have a look here though: http://ootips.org/ -- Graham From quinn at retch.ugcs.caltech.edu Thu Nov 1 22:27:26 2001 From: quinn at retch.ugcs.caltech.edu (Quinn Dunkan) Date: 2 Nov 2001 03:27:26 GMT Subject: Monty Python (was: Freeware Python editor) References: <9rrpl6$nhi$1@news.wrc.xerox.com> Message-ID: On 1 Nov 2001 15:27:34 GMT, Mark Jackson wrote: >Evidently Monty Python is funny in French. We once went to see Holy >Grail in Paris and it's a good thing we knew the dialog by heart; since >the audience could read French subtitles faster than the actors spoke >in English there wasn't a single punchline that wasn't drowned out by >audience laughter. I'm just curious. How did the "you can tell I'm French because I have this outrrrrrageous accent" part get translated? I'd also like to see what they do to the opening credits in the Swedish translation. From wpmelcher at snet.net Mon Nov 26 09:50:02 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Mon, 26 Nov 2001 14:50:02 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> Message-ID: "Kragen Sitaker" wrote in message news:83r8qmtgu9.fsf at panacea.canonical.org... > "Bill Melcher" writes: > > I think you should use the console window instead of the Run window. > You can get a console window by typing 'cmd' or 'command' in the Run > window, depending on your version of Windows. Yes, this is a good idea -- actually I have a Windows 'shortcut' that will crank up a MS DOS window. I used this technique to capture the Python usage: C:\>python -h>python.txt usage: O:PYTHON21\PYTHON.EXE [option] ... [-c cmd | file | -] [arg] ... options and arguments (and coresponding environment variables): -d : debug output from parcer (also PYTHONDEBUG=x) -i : inspect interactively after running script, (also PYTHONINSPECT=x) and force prompts, even if stdin does not appear to be a terminal -O : optomize generated bytecode (a tad; also PYTHONOPTOMIZE=x) -OO : remove doc-strings in addition to the -O optomizations -S : don't imply 'import site' on initialization -t : issue warnings about inconsistent tab usage (-tt: issue errors) -u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x) -U : unicode litterals: treats '...' literals like u'...' -v : verbose (trace import statements) (also PYTHONVERBOSE=x) -x : skip first line of source, allowing use of non-Unix forms of #! cmd -h : print this help message and exit -V : print the Python version number and exit -W arg : warning control (arg is action:message:category:module:lineno) -c cmd : program passed in as string (terminates option list) file : program read from script file - : program read from stdin (default; interactive mode if a tty) arg... : arguments passed to program in sys.argv[1:] Other environment variables: PYTHONSTARTUP: file executed on interactive startup (no default) PYTHONPATH : ';'-separated list of directories prefixed to the default module search path. The result is sys.path. PYTHONHOME : alternate directory (or ;. PYTHONCASEOK : ignore case in 'import' statements (Windows). This stuff looks better in a mono-type font. Unfortunately, Python seems to mess up the DOS redirection so that in the command line above, the '>python.txt' fragment creates the .txt file in C:\ but the output is not redirected to that file. The ability to specify "| more" is also crippled by python. I caught the console output by using the Pause key and typing what I saw into an editor. This 'failure' to allow redirection is the reason why I have problems capturing the stdout and errout using redirection. If I use the Pause key often enough, maybe I can see at least some of the error messages. :-) > > Well, running it in a console window will save the last > scroll-buffer-full. You can set your scrollback buffer size (on > better versions of Windows) with some Properties dialog --- I can't > remember where. I'll see if I can track this down. > > There's little bits of python you could do to save the messages to a > file. I think you can say: > import sys > sys.stdout = file.open("output", w) > sys.stderr = sys.stdout > execfile "Q:\\pysol-4.2\\src\\pysol.py" I would presume that I should run this in pythonwin or ppm or idle. I will give it a shot. > > python foo.py will run foo.py by compiling it into bytecode (P-code) > and then running the bytecode; if possible, Python will also save the > bytecode in foo.pyc. In the future, python will check to see if > foo.pyc is newer than foo.py, and if so, it will run the bytecode from > the file instead of recompiling foo.py. I had come to that exact conclusion and had planned to do an experiment, i.e., re-install the original source files or delete the .pyc files and run the sucker again. > > I use Unix, and I type 'man python', which won't work on Win98. > Section 2 of the Python Tutorial has some of what you want; more of it > is in section 6.1. The Windows version of Python contains help files that contain the documentation and I have picked up a few other goodies in various formats. I just did a quick look at these sections of the tutorial - I think I'll print out the sections and study them. > > > Another topic is a file called ".gdbinit" which contains: > > > > file python > > set args -u -t pysol.py > > > > What the heck is this? > > Sounds like an initialization file for the GNU debugger, to set it up > to run your Python command under the debugger. Dunno why Python > recorded this. Mine sure doesn't. Sorry, I confused you. This is a file in the PySol source. As you can easily see, I am still having problems separating out the Python issues from the PySol issues and the MS DOS/Win issues! The whole situation is made more confusing because I have very little Unix understanding while you guys tend to be weak on Win98. In essense, I need to figure out who's doing what to whom, then burrow down into which ever product is giving me grief -- > > Glad you're not giving up! Not yet! -- Cheers, Bill TANSTAAFL! From peter at engcorp.com Tue Nov 13 20:58:55 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 13 Nov 2001 20:58:55 -0500 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> <9sp073$k6d$1@news.lth.se> <3BF06DA8.19F3E284@engcorp.com> <9sr72d$6p9$1@news.lth.se> Message-ID: <3BF1CFDF.528BB171@engcorp.com> David Andreas Alderud wrote: > > > I think we were talking about *children*, who are definitely not interested > > in writing efficient programs... Don't mix first-year students who might > > want to learn about the guts of a PC with the audience which was targetted > > by this discussion. > > You're underestimating children, don't do that, please. I've been teaching > everything from 7 year olds to university students, the 7 to 9 year olds are > by far the most powerful students, they are like vacuum cleaners, absorbing > every piece of knowledge presented to them. Oh puhleeezzz... Good luck finding one seven year old who is more interested in *efficiency* than learning about computers. Yes, kids absorb everything. No, they do not understand or care about "efficiency", and I don't think I'm underestimating "children". Maybe one or two in the world, but not this part of the planet (and note I'm not equating efficiency with optimization... kids might want to learn to make something go faster, but that's not what "efficiency" means to me.) > > So what do *you* mean by "hardware programming"? > > Writing devicedrivers and accompanying APIs, for example. As expected, this explains our differing view of Python's suitability. I agree (obviously) that Python is not suitable for device drivers, although "accompanying APIs" expands that just enough for me to point out that one can keep a driver "thin" and put the next-higher level in a more flexible language, provided adequate performance is still available. I do that with Python, which keeps me out of the really low-level stuff more often than not. > Ada is great for hardware programming, one major reason is because PGAs and > FPGAs are, normally, coded in VHDL, which is a subset of Ada. So with Ada Cool. I did not know that about VHDL. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From skip at pobox.com Wed Nov 14 03:20:06 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 09:20:06 +0100 Subject: Python Job Posting: Austin, Tx In-Reply-To: References: Message-ID: <15346.10550.987230.409563@beluga.mojam.com> eric> Company: Enthought, Inc. eric> Location: Austin, Tx eric> Position: Software Developer eric> Openings: 1 eric> Basis: Full Time Eric, Posting to c.l.py is fine, but if you want your job posting to last longer than the mean news server expire time (probably only a few days), I suggest you also place an announcement on the Python Job Board: http://www.python.org/Jobs.html -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From MarkH at ActiveState.com Tue Nov 27 22:30:09 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Wed, 28 Nov 2001 03:30:09 GMT Subject: sys.prefix in COM References: Message-ID: <3C045ABB.6030400@ActiveState.com> Sue Giller wrote: ... > I have finally looked into this, and I wonder if there might be a > problem in sys.prefix in COM. I am a python wannabe, so I am not > sure if the following is expected or what. ... There is! This has been fixed in Python 2.2 - sys.prefix will (almost) always be set correctly, even in embedded situations. From the CVS log for PC/getpathp.c: Revision : 1.25 Date : 2001/9/7 14:8:1 Author : 'mhammond' State : 'Exp' Lines : +35 -1 Description : Fix bug #410274 - sys.prefix isn't always set. If after calculating sys.path we do not have sys.prefix set, we loop over all path entries checking if one can point to our home directory. Mark. From Krzysztof.Czarnowski at dgt-lab.com.pl Fri Nov 9 08:46:56 2001 From: Krzysztof.Czarnowski at dgt-lab.com.pl (Krzysztof Czarnowski) Date: Fri, 9 Nov 2001 14:46:56 +0100 Subject: Synchronizing calls to COM event handlers in the free threaded appartment Message-ID: <002401c16924$ff8bdda0$2706a8c0@krzysiek> I have a COM event handler object implemented in Python and instantiated in a threading.Thread which is CoInitializedEx as COINIT_MULTITHREADED. There is a threading.Lock object which is acquired by each event handler method as soon the handler method is started and released just befor it returns. The Lock is meant to provide synchronization among event handlers and synchronization with another threading.Thread. It looks fine at first but when I think second time... Is it OK? Is threading.Lock sufficient means to ensure serialization of event handler calls? Can it lead to deadlocks? Is RLock sufficient then? Or is it better to make it COINIT_APPARTMENTTHREADED and make COM do the synchronization job? Thanks in advance for any comments Krzysztof From lars at larsshack.org Sun Nov 11 02:30:43 2001 From: lars at larsshack.org (Lars Kellogg-Stedman) Date: Sun, 11 Nov 2001 07:30:43 GMT Subject: Splitting on a regex w/o consuming delimiter References: Message-ID: >> Given a string such as: >> >> sample = 'one two @three @four five @six' >> >> I want to split it on the '@' character, but I want the '@' >character to be >> retained in each sequence. That is, I'd like the above string split >into: >> >> one two >> @three >> @four five >> @six > >You could do '@'.split(sample)' (which deletes at) and then add back >to all but first. I knew I should have said it the first time: this is a contrived example; what if the delimiter regex was something like '\s(!|@)\s'? Given: foo ! bar @ baz @ xyzzy ! mumble You'd end up with: [ 'foo', 'bar', 'baz', 'xyzzy', 'mumble' ] With no way of recovering the delimeter. Really, I just want to be able to split on (?=pattern), or some other method of splitting a string without consuming the delimiter. -- Lars -- Lars Kellogg-Stedman --> http://www.larsshack.org/ From phr-n2001d at nightsong.com Fri Nov 9 00:21:18 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 08 Nov 2001 21:21:18 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> <3BEB602C.EFEA8D82@engcorp.com> Message-ID: <7xofmcy0xd.fsf@ruckus.brouhaha.com> Peter Hansen writes: > A necessary step to get the robustness you claim you need is to do > extensive testing. If one writes an application with Python and it > breaks a million dollars of merchandise it will not be Python's > fault, but the programmer's fault for inadequate testing. > > The only thing those other languages give you which Python doesn't > is compiler warnings which lull you into a false sense that your program > is clean when in fact you were lazy and didn't do proper testing. > If you do the same amount of testing with Python that you would need > to do with other languages to be very safe, you would have just as > robust an end result. That makes it sound as if any non-robustness in the application is the fault of how the application is written. However, the Python interpreter itself can also have bugs. That affects application robustness. Bugs in the Python interpreter can make the application crash even if the application code is itself bug-free. Part of the question "can I write robust applications in Python" is "how reliable is the interpreter, really?". I've seen Python 2.1.1 inexplicably crash several times. One thing that another language might give you besides compiler warnings and false senses of security is implementations that don't crash. Overall Python seems pretty reliable but I think its implementation is not yet as well shaken out as some other languages' implementations. I'm happy writing web applications in Python. I could not in good conscience recommend writing life critical apps (medical implant firmware, avionics, etc.) in Python in its present form. From slinkp23 at yahoo.com Wed Nov 7 10:48:20 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Wed, 07 Nov 2001 15:48:20 GMT Subject: Games Programmed in Python References: <9sahq0$qi1$1@slb6.atl.mindspring.net> <9sbjg5$121foi$1@ID-22517.news.dfncis.de> Message-ID: On Wed, 7 Nov 2001 16:20:34 +0100, Daniel T. Bender wrote: >actually, there is a pretty cool game called 'Severance: Blade Of Darkness' >that makes heavy use of Python. > >http://www.codemastersusa.com/blade/Index3.html url = url[:-1] From owen at astrono.junkwashington.emu Mon Nov 26 12:20:35 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Mon, 26 Nov 2001 09:20:35 -0800 Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: <9tttl6$2uj0$1@nntp6.u.washington.edu> In article <3BFD49D8.F7A4C6CC at earthlink.net>, Erik Johnson wrote: >... I have a list of single character strings. A couple of people were >kind enough to clue me in to the best way to turn this back to a string: > >s = "".join(l) > > This works fine, but it seems syntactically backwards to me: > ># s = l.join("") > >makes much more sense to me. The thingy I want to do something to is my >list. I am just trying to learn Python, so no doubt there will be some >Python things I will just have to get used to, but is there a logical >reason why it was implemented as a string method rather than a list >method? Does it seem backwards to you or does it make intuitive sense to >you? Comments? (other than of the "it's moot" flavor) I would also prefer having join be a list method, but there are good reasons for the current design. One way to look at it is that the various collection classes do NOT inherit from a single base class (which would be a logical place to define a join method). Hence to have all kinds of collections learn to "join" requires a lot of repeat coding. Making join a string method solves this problem. -- Russell From sabren at manifestation.com Sun Nov 25 05:15:12 2001 From: sabren at manifestation.com (Michal Wallace) Date: Sun, 25 Nov 2001 05:15:12 -0500 (EST) Subject: any utilities to parse code?? In-Reply-To: <3c007810$1@207.229.64.20> Message-ID: On Sun, 25 Nov 2001, Peter Bismuti wrote: > I am looking for something similar but in Python. Of all > the languages to parse by hand, I'd say that Python is > probably the easiest, but I'm not sure if embarking on > a mission to parse languages like Java is practical. I'd > rather look for something that already exists. You might try ANTLR... It's a Java/C++/Sather tool, but it comes with a grammar for Java source. (And you could always have python open a pipe to your ANTLR-generated tool) Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From niemeyer at conectiva.com Fri Nov 2 23:01:36 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Sat, 3 Nov 2001 02:01:36 -0200 Subject: I found it. [Re: Getting started] In-Reply-To: <3BE36536.182EA315@ix.netcom.com>; from jdadson@ix.netcom.com on Sat, Nov 03, 2001 at 03:32:40AM +0000 References: <3BE34358.8819E585@ix.netcom.com> <9rvhf4$vjrgr$1@ID-11957.news.dfncis.de> <3BE361DE.89B01B1C@ix.netcom.com> <3BE36536.182EA315@ix.netcom.com> Message-ID: <20011103020136.A1623@ibook.distro.conectiva> > I found it. os.chdir() > > BTW, the system lets me change the variable os.curdir, but that seems to > have no effect. If I next do an os.chdir to some other directory, the > variable os.curdir does not change. I guess you're looking for os.getcwd(). pydoc will give you a hand at these tasks: >>> import os, pydoc >>> pydoc.help(os) Or from the command line: pydoc os Best regards! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From clpy at snakefarm.org Fri Nov 9 07:39:11 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 09 Nov 2001 13:39:11 +0100 Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Message-ID: <3BEBCE6F.3AAA5358@snakefarm.org> Paul Rubin wrote: > Really the ellipsis should make an iterator: for i in 0...10. Sounds pretty cool. However, the ellipsis seems to be poorly documented. cg. -- 'In iteger arithetric divsion is no the oposite of multiplication.' From uwe at rocksport.de Mon Nov 19 10:31:13 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 19 Nov 2001 15:31:13 GMT Subject: MatPy question Message-ID: <9tb8k1$ah779$1@hades.rz.uni-sb.de> Hi, I uses MatPy today and think it' quite useful. But there is one incompatibility to matlab: in MatPy indices start at zero, in Matlab they start at one. Is there a solution to adapt MatPy to the Matlab style ? Yours, Uwe -- Dr. rer. nat. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From sthiyaga at operamail.com Wed Nov 21 00:56:26 2001 From: sthiyaga at operamail.com (Senthilkumar Thiyagarajan) Date: Wed, 21 Nov 2001 05:56:26 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> <3BF3378B.8030205@altavista.com> <3BFB34A9.565BBF2E@engcorp.com> Message-ID: <20011121000734.48b85dde.sthiyaga@operamail.com> On Tue, 20 Nov 2001 23:59:21 -0500 Peter Hansen wrote: > > > > Is there a utility to "clean" foreign scripts so that tabs/spaces > > issues and other stuff invisible to the programmer can be > > weeded out? > > There's any detabbing utility on the planet, or the Tools/Scripts/ > On UNIX, col -x < infile > outfile will replace all tabs with spaces. using -b will do the reverse. GNU/Linux also provides the utility "expand" to do the same, with a little more flexibility. HTH, Senthil From fperez528 at yahoo.com Mon Nov 12 13:35:20 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 13 Nov 2001 18:03:20 +2328 Subject: Scientific Libraries in Python References: Message-ID: <9ssfui$e5g$1@peabody.colorado.edu> > > It's a pity the issue isn't just aesthetics (which I could cheerfully > ignore), but useability. The merge is worth doing because having a single > Scientific Python library will give more and richer functionality, with > less hassle, to scientists and engineers using Python. With the current > state of affairs, I can't really make the case to my colleagues here (or > anywhere) to use Python instead of Matlab or Mathematica. > > Such a merge would imply some serious manual labour on someone's part. > While I'm willing, I'm not able for a few months, but I thought I'd get > the idea up in front of the relevant community now. > Wholeheartedly agreed. Let's try to keep this alive and going, and hopefully we can get things moving to integrate SciPy/Scientific. I recently mentioned the GSL (and Prabhu correctly pointed at license issues). If the license issues can be addressed, the GSL sounds like a great base layer on which to put these two. Prabhu has the very impressive MayaVi project going for visualization, and Janko Hauser and I will soon announce (it's still rough code, it'll take a few days) an enhanced interactive environment (similar in many aspects to Mathematica's, but for Python). I can't contribute to the core libraries at this point, too busy with my thesis and on the side getting the project with Janko going. But I'm sure *there is* a lot of interest for this, especially if we can tap on the massive amount of work already done by the GSL people. I am also a believer in having an easy 'import scientific' command to get access to a full set of libraries and utilities with a consistent interface without spending a month hunting things down from 25 different websites. It seems most basic blocks are there, it's a matter of coordination and putting them together. Cheers, f. From lienard.bruno at free.fr Mon Nov 5 16:52:57 2001 From: lienard.bruno at free.fr (Bruno Liénard) Date: Mon, 5 Nov 2001 22:52:57 +0100 Subject: PDF->Text converter/extractor References: <3be6fa21$1@sol.wohnheim.uni-ulm.de> Message-ID: <3be70a38$0$15115$626a54ce@news.free.fr> I had written a script some time ago to extract directly from PDF file, it's quite easy . As I had a very large volume of text to extract (some giga of text), I now use PDFTOTEXT which comes with XPDF. I slighly modify for my needs. If you are interested, I will look for the script in my archives Bruno Lienard "Igor Stroh" a ?crit dans le message news: 3be6fa21$1 at sol.wohnheim.uni-ulm.de... > Hi there, > > has someone ever tried to extract text from a PDF with python? > So far, there are 2 alternatives, but none of them satisfies my needs > (GPL license (or the like), speed and reliability): > 1) Using pdftotext (Xpdf) with usual files > 2) Using commerical PageCatcher from reportlab.com (1000 bucks per > license lol) directly in a python script (no files opened) > > though I didnt find anything yet, perhaps there is someone who already > had the same problem and solved it by writing an own PDF parser? :) I'm > too lazy to start reading the specs of PDF and try to write the thingy by > myself :) > > TIA, > Igor From emile at fenx.com Tue Nov 6 08:52:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Nov 2001 05:52:24 -0800 Subject: Converting exponential numbers to strings. References: <32921e0b.0111051350.41e35f26@posting.google.com> <7xpu6w6es0.fsf@ruckus.brouhaha.com> <3BE7E301.3E5EDDF1@clublinux.org> Message-ID: <9s8q97$11mcd0$1@ID-11957.news.dfncis.de> "steve" wrote in message news:3BE7E301.3E5EDDF1 at clublinux.org... > > One more question about string processing. I've written a small report > formating routine that prints everything as strings. The reason for > this is that I want to be able to add commas, floating dollar signs, > etc. to the report and printing everything as a string seemed to be the > easiest way to perform such tasks. > > I run into the same problem when trying to process the string from > printing when I use the str() function. Is there another way to convert > a number to a string that will return the number in a non-exponential > format? > > (e.g. return .000085 instead of 8.5e-5?) > > Thanks again for your help, > Steve The % operator works well for this kind of output. >>> print '%7.4f' % (.0085,) 0.0085 >>> print '%9.6f' % (.0085,) 0.008500 >>> -- Emile van Sebille emile at fenx.com --------- From mwh at python.net Tue Nov 13 05:59:10 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 13 Nov 2001 10:59:10 GMT Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: David Bolen writes: > Peter Hansen writes: > > > I just created two million-integer lists with "[0] * 1000000" and > > compared them, then reassigned the second name to reference the > > first list and compared again. There was a noticeable pause during > > both compares (with "=="). > > > > Comparing two lists with different lengths *does* return > > "immediately". > > > > -empirically-yr's > > On the non-empirical front, I peeked at the listobject.c source for > its list_richcompare function and no, there doesn't appear to be any > shortcut check for having both lists refer to the same object (at > least in the latest CVS source). It does do the length check (for == > and !=), but otherwise it's the full recursion with the generic > comparison applied to each element. > > It would be an easy optimization to add, although I'm wondering how > much benefit typical real-life code would see. I'm pretty sure that in Python <2.1 this "optimization" was enabled for all comparisons (i.e. if "x is y", then "x == y" returns 1 without calling any comparison methods). It disappeared when rich comparisons turned up; for one thing NaNs sohuld not compare equal to themselves according to ieee754 (tho' they still seem to in 2.2). Cheers, M. -- It's a measure of how much I love Python that I moved to VA, where if things don't work out Guido will buy a plantation and put us to work harvesting peanuts instead. -- Tim Peters, comp.lang.python From jdadson at ix.netcom.com Mon Nov 5 17:45:45 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 22:45:45 GMT Subject: Idle bug Message-ID: <3BE71674.8B9C4A5A@ix.netcom.com> To the keepers of the bug list, whoever they may be. Start Idle under Windows NT 4.x (idle.pyw). Import the following module that's included at the bottom of this message. (It's from the book _Core Python Programming_ by Wesley J. Chun.) Idle will lock up. You have to kill it from the Task Manager. Jive import threading from time import sleep, time, ctime loops = [4,2] def loop(nloop, nsec): print 'start ', nloop, ' at: ', ctime(time()) sleep(nsec) print 'loop ', nloop, ' done at ', ctime(time()) def main(): print 'starting threads' threads = [] nloops = range(len(loops)) for i in nloops: t = threading.Thread(target=loop,args=(i,loops[i])) threads.append(t) for i in nloops: threads[i].start() for i in nloops: threads[i].join() print 'all done at ', ctime(time()) if __name__ == '__main__': main() From brian at rk-speed-rugby.dk Wed Nov 7 03:38:26 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 07 Nov 2001 09:38:26 +0100 Subject: Teaching python (programming) to children References: <3BE82570.D76DCAE9@juno.com> Message-ID: Jeff Sandys writes: > Yes, if you are interested in this you should join the > python edu-sig: > http://www.python.org/sigs/edu-sig/ Done. > I strongly believe in Computer Programming for Everyone (CP4E). 'everybody' it says, even though there probably is no distinction. > Every high school graduate should be able to express themselves > with any form of popular expression. They should be able to Exactly. > create a computer algorithm. They don't need to be a star or ! > of abstraction. For adults and students Python is that language. > Personally though I use Logo for grammar and middle school > students. Once I develop an adequate curriculum and syllabus I I have to check out logo. > Thanks, and to you, -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From gh_pythonlist at gmx.de Mon Nov 12 22:50:23 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Tue, 13 Nov 2001 04:50:23 +0100 Subject: ZODBCDA Error...python15.dll not found!! In-Reply-To: <11e94203.0111121610.63995fae@posting.google.com> References: <11e94203.0111121610.63995fae@posting.google.com> Message-ID: <20011113045021.A962@lilith.hqd-internal> On Mon, Nov 12, 2001 at 04:10:24PM -0800, Jose Rivera wrote: > Hi... > > I just installed ZOPE 2.4.2 on NT, and works great, I downloaded > ZODBCDA unzipped on "c:\program files\ZopeTest\" and when I start Zope > reports an error: > > Unable to Locate Python15.dll !!! > > I think that this DLL it's old... because Python 2.1 it's the newer > version... What database adapter is ZODBCDA using? mxODBC? What you need is a version of the database adapter that's built for Python 2.1. No problem for mxODBC (please note that the license changed! You might have to buy a license.), just download a newer version from the web page. You might have to do tricks if it's a binary installer. It won't let you install ZOPE, the trick is to install a regular Python 2.1, install the package with the binary installer, then copy the files in the proper directories of your ZOPE installation. On my homepage (see sig) you can find an installer that installs the mx-Extensions (mxDateTime et al., you will need mxDateTime for almost every database module) onto ZOPE. And the same thing for MySQLdb/ZMySQLDA. HTH, Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From tdickenson at devmail.geminidataloggers.co.uk Tue Nov 13 08:06:09 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Tue, 13 Nov 2001 13:06:09 +0000 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> Message-ID: Jeremy Hylton wrote: >I'd rather see the imports be explicit "import root.a.b.c" than >"import b.c". Then re-nesting requires all the import statements to >be edited. It's more typing and might even require a simple script to >do search-and-replace, but it doesn't sound like a prohibitive >burden. A complementary problem that I havent seen mentioned in this thread (my appologies if I have missed it) relates to sibling modules in a package. Currently python will search for sibling modules ahead of the standard library; one of my projects broke the unicode support in python 2.0 because it had a codecs.py. today a module a.b.c can import a sibling module a.b.c2. using a simple "import c2". I would be happy to allow an explicit "import local.d" in this case. Toby Dickenson tdickenson at geminidataloggers.com From fperez528 at yahoo.com Mon Nov 26 07:43:30 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 12:11:30 +2328 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: <9u0oih$64q$2@peabody.colorado.edu> Skip Montanaro wrote: > In the current 2.2 beta, int operations that would overflow silently return > longs: > > >>> 3**100 > 515377520732011331036461129765621272702107522001L Just curious: how bad is the performance impact from this (if any)? cheers, f From Steven.Scott at Synchrologic.com Fri Nov 9 15:14:48 2001 From: Steven.Scott at Synchrologic.com (Steven Scott) Date: Fri, 9 Nov 2001 15:14:48 -0500 Subject: python1.5.2 + nt services + COM Message-ID: > At 12:44 PM 11/9/01 -0500, Steven Scott wrote: > ... > >I'm not specifically using threads, although I am subclassing > >win32serviceutil.ServiceFramework as per the ntservice > example that comes > >with win32all...I don't know if it does something with > threads, but I'm led > >to believe that it's so. > ... > > That's probably the reason it doesn't work. See Appendix D of Python > Programming on Win32 for a good explanation of threading issues with > COM. Or if you don't have the book, the short version is, > try calling: > > pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) > > at the beginning of the DoRun method (or if you'd prefer > apartment-threading instead of free-threading, call > pythoncom.CoInitialize() instead). Also, you should call > > pythoncom.CoUninitialize() > > at the end of the DoRun method. > aha that seems to work many thanks From grante at visi.com Thu Nov 8 16:13:25 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 08 Nov 2001 21:13:25 GMT Subject: newbie tkinter question References: <480f610.0111081146.72a92cb0@posting.google.com> Message-ID: In article <480f610.0111081146.72a92cb0 at posting.google.com>, Jared wrote: > I am investigating using a python/Tkinter environemnt for apps > development. The target hardware environment would be pretty > old-fashioned - a bunch of dumb terminals (VT420's, mostly) Sheesh. Calling a VT420 a "dumb" terminal. Of all the nerve. Dumb terminals are ones that lack any sort of control mechanism (escape sequences and the like). None of the VTxx and VTxxx were dumb terminals. -- Grant Edwards grante Yow! Hello, GORRY-O!! I'm at a GENIUS from HARVARD!! visi.com From loewis at informatik.hu-berlin.de Wed Nov 21 09:43:01 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Nov 2001 15:43:01 +0100 Subject: Getting the class of a method in Python 2.2 (semantic change from 2.1) References: Message-ID: "Kali Kim" writes: > Can anyone help me? I think this is not possible in 2.2. Why do you need that? Regards, Martin From kragen at canonical.org Sat Nov 24 01:28:57 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 24 Nov 2001 01:28:57 -0500 Subject: Problems with Getting Tkinter to Work References: Message-ID: <83oflsvg0m.fsf@panacea.canonical.org> Ben Ocean writes: > I just configured Tcl--itworks--and I went to configure tk (both latest > stable distros) on my RH71 box and ran into all sorts of errors on *make*. > Both installations are in /usr/lib and I'm in as root. It exits with Error > 1. Here's how the errors start: > > gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall > -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix > -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps > -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 > -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 > -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED > /usr/lib/tk8.4a3/unix/../generic/tk3d.c > In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or directory Dude, you probably need -I/usr/X11/include or -I/usr/X11R6/include --- but do you even have X11/Xlib.h there? You might need to install some more packages and possibly rerun configure. From cliechti at gmx.net Mon Nov 26 15:49:55 2001 From: cliechti at gmx.net (Chris Liechti) Date: 26 Nov 2001 21:49:55 +0100 Subject: newbie question - object from a string? References: Message-ID: [posted and mailed] Gordon Scott wrote in news:mailman.1006800222.5110.python-list at python.org: [...] > Is there a way to dynamically import the class? Or is there entirely > different approach I should be > using to accomplish this? try the builtin function "__import__" (not the keyword) chris -- Chris From dalke at dalkescientific.com Mon Nov 12 12:57:55 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Mon, 12 Nov 2001 10:57:55 -0700 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> Message-ID: <9sp2in$o4e$1@slb3.atl.mindspring.net> Tim Bradshaw: > Languages such as Perl and (I think) Python are *single instance* > classes - there is only one implementation, and the language > is defined implicitly by that implementation. As a minor clarification, there are several distinct implementations of Python (or a Python-like language). The ones I know of are: Python in C -- "the" Python, www.python.org Python in Java -- www.jython.org Python in C# -- http://www.activestate.com/Initiatives/NET/Research.html Python in OCaml -- http://vyper.sourceforge.net/ Python bytecode compiler, in C -- http://homepages.ulb.ac.be/~arigo/psyco/ Andrew dalke at dalkescientific.com From root at rainerdeyke.com Wed Nov 7 01:46:52 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 07 Nov 2001 06:46:52 GMT Subject: A smarter(?) package importer. References: Message-ID: "Prabhu Ramachandran" wrote in message news:mailman.1005111070.26322.python-list at python.org... > Anyway, I managed to get knee.py to do what I wanted i.e.: > > (1) Check if module is available in the same directory, if available > - use it. > > (2) If not found walk up to parent dir. Check there, if not there > go up until out of package. > > (3) If not found in (2) look at sys.path for module. Be careful you don't import the same module isn't loaded twice, or bad performance and unreliable behavior will occur. The correct behavior of 'import D' in module 'A.B.C' looks something like this: 1. Check 'sys.modules["A.B.D"]'. If it does not exist, go to step 2. If it is 'None', go to step 3. If it is not 'None', return it. 2. Try to load 'A.B.D' from file. On success, set 'sys.modules["A.B.D"]' to the module and return it. On failure, set 'sys.modules["A.B.D"]' to 'None' and go to step 3. 3. Check 'sys.modules["A.D"]'. If it does not exist, go to step 4. If it is 'None', go to step 5. If it is not 'None', return it. 4. Try to load 'A.D' from file. On success, set 'sys.modules["A.D"]' to the module and return it. On failure, set 'sys.modules["A.D"]' to 'None' and go to step 5. 5. Check 'sys.modules["D"]'. If it does not exist, go to step 6. If it is 'None', raise an 'ImportError'. If it is not 'None', return it. 2. Try to load 'D' from file. On success, set 'sys.modules["D"]' to the module and return it. On failure, set 'sys.modules["A.B.D"]' to 'None' and raise an 'ImportError'. Notes: - 'sys.modules' is checked at each step before trying to load the module from a file. This is absolutely essential to prevent multiple copies of a module being loaded. - Each module is stored in 'sys.modules' by its true name. Again, this is essential. - A value of 'None' in 'sys.modules' is used to cache failure. This is not essential, but it matches the current behavior of Python and it can give a significant speed boost. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From weismann at netvision.net.il Tue Nov 6 04:04:03 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Tue, 06 Nov 2001 11:04:03 +0200 Subject: Reading PDF files . Message-ID: <008601c166a1$fbedfb90$2e97003e@rashome> Is there a module for reading PDF files ? I just need to check the appearance of some words in a PDF file . Is it possible ? Thanks ---------------------------------------------------------------- Weisman Amit 11 Rupin st. Holon 58344 Israel Tel : 050397330 weismana at cs.bgu.ac.il -------------- next part -------------- An HTML attachment was scrubbed... URL: From chr_werner at gmx.de Wed Nov 7 16:25:06 2001 From: chr_werner at gmx.de (christian werner) Date: Wed, 7 Nov 2001 22:25:06 +0100 (MET) Subject: HELP! What's wrong here ??? I don't get it! Message-ID: <12837.1005168306@www32.gmx.net> Hello python coders :) I'm in desperade need for a hint from you guys concerning this junk of code I produced. I JUST DON'T GET IT !!! I'm sorry about the length of this thread, but I figured that the more detailed I am about my problem, the sooner you might be able to find my stupid error !!! Maybe it's easier if I first explain what I intent to do ;): 1.) I try to read a file line by line & transform it into an array (1d) 1.) the IF statement determins, what type od data is given (done by the type variable) t = temperature, p = precipitation, r = radiation 2.) I got this one to run for the t and r case, so that's fine (code works as expected) basically line 2 - 7 do a read and transform to the data, a3 will be returned by my function - that's cool... 3.) for the precipitation I have to substract the previous timestep from the actual one (t = t(0) - t(-1)) - I named the previous array pa ;), since I can't use the data as is example: a array equals at t(0) [10, 12, 15, 5, 10, 2, 23, ...] at t(-1) [5, 7, 10, 4, 10, 1, 21, ...] than the value for t(0) corrected should look like t(0) - t(-1): [5, 6, 5, 11, 1, 0, 1, 2, ...] 4.) the main look iterates 24times (1 to 24) representing 24h of a day. Since hour = 1 has no previous value t(-1) 0 0 t(-1), I assign pa = [0, 0, 0, 0, 0, ...] before the loop starts (line 0) then: -> read line into 1d array -> reshape to 2d array -> subtract array of last timestep -> write corrected array to day-array (a3 called) If I call the function with type = t or type = r I get the right results... If I call the function with type = p I get this wired result below: hour 1: takes first line, substracts 0s' = OK! a = 1.31 / pa = 0 / a2 = 1.31 / new pa = 1.31 hour 2: a has the same value as in previous timestep, since the function assigns pa = a in the loop I get '0' for the a2 array a = 1.31 (again!!! - why?) / pa = 0 / a2 = 1.31 / new pa = 1.31 hour 3: like hour 2 hour 3: like hour 2 etc. ------my code subset ----- 0 day = 7 # just any day 0 ln=(day*24)-23 # locate position of 1st line for hour1 of day # file contains continous data: # hour 1: line1 # hour 2: line2 (...) # hour 24: line24 (...) # hour 1: line 25 [day2 starting] 0 pa = zeros((x,y), Float) 1 if (type == 't' or type == 'r'): 2 for hour in range(1,25,1): 3 print hour, 4 line = linecache.getline(file, ln) # read line 5 a = array(map(float, string.split(line))) # map line to 1d array 6 a = reshape(a, (x,y)) # reshape to 2d array 7 a3[(hour-1)] = a[:,::-1] # reverse fortran order of array and 8 # put into 3d array (day) 9 ln +=1 10 linecache.clearcache() 11 12 elif (type == 'p'): 13 for hour in range(1,25,1): 14 line = linecache.getline(file, ln) # read line 15 a = array(map(float, string.split(line))) # map line to 1d array 16 a = reshape(a, (x,y)) # reshape to 2d array 17 a2 = a - pa # a2 = corrected array 18 pa = a # this input array a will be 19 # used in the next iteration as pa 20 21 a3[(hour-1)] = a[:,::-1] # reverse fortran order off array and 22 # put into 3d array (day) 23 ln += 1 24 linecache.clearcache() I'm trying to solve this crap for days now and am getting really pissed off with it... I just don't get it. So please, please,please - where is my error ??? I thinks it either always reads the same line ('p' case) - but why? Is there a clearcache missing ? Thanks a lot folks, I really appreciate the help I get from this great list !!! cheers, christian -- -------------------------- christian werner Loisachstra?e 69 82491 Grainau +49 (0)8821 727799 Heimatanschrift: Gartenstra?e 15 97737 Gem?nden +49 (0)9351 8435 mobile: 0179 4559242 email: chr_werner at gmx.de http:\\www.christianw.de GMX - Die Kommunikationsplattform im Internet. http://www.gmx.net From weismann at netvision.net.il Wed Nov 7 02:58:36 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Wed, 07 Nov 2001 09:58:36 +0200 Subject: " Message-ID: <024801c16762$024a1530$1395003e@rashome> I wasn't clear enougth . I know one should declare functions as def do_TAGNAME def start_TAGNAME def end_TAGNAME How do I declare function for the " Newsgroups: comp.lang.python To: Sent: Tuesday, November 06, 2001 10:49 PM Subject: Re: " Amit Weisman wrote: > > When parsing an HTML page with SGMLParser ' I get an > > error when then parser meets a ! tag (' > something like this? > > SomeError: here's an error > > or did Python perhaps give you a more specific error > message? > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From cezary at bigfoot.com Wed Nov 14 14:33:41 2001 From: cezary at bigfoot.com (Cezary Biernacki) Date: Wed, 14 Nov 2001 20:33:41 +0100 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: Message-ID: <3BF2C715.7050400@bigfoot.com> Scherer, Bill wrote: > You've got a multithreaded client hitting a single threaded, > synchronous server. You can do significantly better if you > thread your server, or use asyncore (or a combination of the > two). The server is threaded to: >>class RequestServer(SocketServer.ThreadingTCPServer): >> allow_reuse_address = 1 >>But when NUMTHREADS = 20, half the threads die with this error : >>Unhandled exception in thread: >>Traceback (most recent call last): >> File "", line 6, in send_request >> File "", line 1, in connect >>socket.error: (10061, 'Connection refused') If you are has clients and a server on the same machine, it is possible, that server it does not have enough time to accept connections on a listen socket. By default only 5 connections can wait to be accepted - if more appears, they are refused by your operating system. You can raise this number, but there are limits on some OS-es. So, for really testing server you should launch clients from another machine(s). For building high-performance server check: http://www.nightmare.com/medusa/ Medusa combines asyncore with threads for optimal performance. - CB From olli at secnetix.de Tue Nov 6 09:14:13 2001 From: olli at secnetix.de (Oliver Fromme) Date: Tue, 6 Nov 2001 14:14:13 +0000 (UTC) Subject: Finding name for a signal number References: <9s8oqk$a38$1@isp-m-srv06.izb.net> Message-ID: <9s8r7l$dbt$1@isp-m-srv06.izb.net> Michael Hudson wrote: > Oliver Fromme writes: > [...] > > This works. However, the above code seems awkward and > > inefficient, in particular the eval() part. Is there a > > better way? Did I miss something? > > Yes: getattr. Ah! Stupid me. I've read about getattr before, I should have remembered it. Thanks for pointing me in the right direction (thanks to Skip, too). > Also your logic seems a touch backwards - why search through the > module every time? Well, I'd need it only once, cause I handle it as a fatal error when a os.system() command is aborted by a signal. You're right, of course -- if I needed to do the look-up multiple times, the best thing is to build a dictionary. Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From christophertavares at earthlink.net Sun Nov 11 23:39:58 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Mon, 12 Nov 2001 04:39:58 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> Message-ID: "Stephen" wrote in message news:97ae44ee.0111111912.14006c7f at posting.google.com... > I'm developing a program which sends messages back and forth > between two servers using sockets. The message format I've > been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" > > Where ~ > Y is the message type, which in turn affects the message length. > T represents a text message. (eg. "Hello World"). Note that > it could also contain newlines (eg. "Hello World\nGood bye") > > > > This was easy to build ontop of SocketServer ~ > > import SocketServer > > class RequestServer(SocketServer.ThreadingTCPServer): > allow_reuse_address = 1 > > class RequestHandler(SocketServer.StreamRequestHandler): > def handle(self): > request = self.rfile.readline() > print "Received message, %s" % request > self.wfile.write("Received OK") > print "Ending request" > > host = "127.0.0.1" > port = 1111 > server = RequestServer((host, port), RequestHandler) > print "SERVER : listening to socket [%s:%s]" % (host, port) > server.serve_forever() > > However, the readline() makes it necessary to send a "\n" at > the end of the message. So, the message format becomes > "YYYYTTTTTTTTTTTTTTTTTTTTTTT\n" > > This introduces the problem that if any of the text > characters (T) are a "\n", the message will be terminated > too soon. > > > A previous post to CLP provided the following solution > which looks out for a "\r\n" message termination string ~ > > import SocketServer > > class RequestServer(SocketServer.ThreadingTCPServer): > allow_reuse_address = 1 > > class RequestHandler(SocketServer.StreamRequestHandler): > def handle(self): > request = '' > while 1: > line = self.rfile.readline() > if line in (None, "\n", "\r\n", ""): > break > request = request + line > self.server.request = request > request = string.rstrip(request) > print "Received message, %s" % request > self.wfile.write("Received OK") > > host = "127.0.0.1" > port = 1111 > server = RequestServer((host, port), RequestHandler) > print "SERVER : listening to socket [%s:%s]" % (host, port) > server.serve_forever() > > > So, should the message format change to ~ > > YYYY\n > TTTTTTTTTTTTTTTTTTTTTTT\n > \r\n > > Other than facilitating use of SocketServer.ThreadingTCPServer, > it seems that asyncore also looks out for termination strings, > and the "Python Sockets HowTo" infers that using fixed-length > for message termination is a bad idea. So everything seems to > be pointing this way. > > Am I correct in my understanding ? > > Stephen > Welcome to the wonderful world of ambiguous message formats! The typical solution is to prefix your message with a length packet, and forget about terminating characters. So, your packet would look something like this: LLLLYYYYTTTTTTTTTTTTTTTT Where: LLLL = total length of this message in bytes You would read in your message length, then read that many more bytes off the socket. -Chris From fperez528 at yahoo.com Wed Nov 14 11:49:47 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 15 Nov 2001 16:17:47 +2328 Subject: anonymous functions? class? References: Message-ID: <9t1ii2$es0$1@peabody.colorado.edu> Peoter Veliki wrote: > > I'd like to be able to use a function as an argument without declaring it > externally. This is what I don't want to do: [snip] Listen, this is the third time you post this question and people actually *have* answered it already. Could you be bothered to check for replies first before you repost or is that too much to ask? Do you require hand-delivery in special stationery or something else we should be aware of? This newsgroup is high-volume enough as it is without people multi-posting the same question. F. From phr-n2001d at nightsong.com Tue Nov 6 23:11:18 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 06 Nov 2001 20:11:18 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: <7x7kt3nrtl.fsf@ruckus.brouhaha.com> grante at visi.com (Grant Edwards) writes: > Don't all c.o.l.p threads eventually end up being about integer > division? ;) > > It could be worse, in most other newsgroups all threads end up > being about Hitler... Godwins law, thread over! You have compared integer division to Hitler. ;-) From hfoffani at yahoo.com Fri Nov 30 12:28:35 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Fri, 30 Nov 2001 18:28:35 +0100 Subject: Newbie question --> Internet-Connection References: <9u83ng$i4v$05$1@news.t-online.com> Message-ID: <20011130122916.419$Hm@news.newsreader.com> > how can I check the state of an internet-connection (connected/disconnected) > with python? That's an OS issue, and I doubt it can be done in a portable and realibly way. On a more general advise, the way to do things in Python is: don't ask for permission, you'll have plenty of time to be sorry later. (or something like that :-)) Seriously. Just program for the "normal" case, and trap errors as you find them. For newbies, it's the most productive way to do things in Python. (or... give us more hints on what you want to achive and where :-) ) Regards, -Hern?n. From tjreedy at home.com Sun Nov 11 02:24:51 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 11 Nov 2001 07:24:51 GMT Subject: prims algorithm References: Message-ID: <7JpH7.202266$5A3.75555014@news1.rdc2.pa.home.com> wrote in message news:mailman.1005458834.15555.python-list at python.org... > Can anyone show me how to do Prims algorithm in python? I'm supposed > to find a minimum spanning tree of a weighted undirected graph using > Prims algorithm. You're 'supposed to'? As in class assignment? > I can do it in C++, but Python is giving me major problems. > I'm just learning this language and its pretty nuts, compared to C/C++. To me, Python seemed (and seems now) pretty same compared to C++ 8-). What C++ construct are you having problem with translating or re-expressing in Python? A specific problem may get a specific hint. Terry J. Reedy From mikael at isy.liu.se Mon Nov 5 05:06:12 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 05 Nov 2001 11:06:12 +0100 (MET) Subject: Process intercommunication Message-ID: Hi all! Here is what I want to do, in short: I want two processes to be able communicate with each other. Naturally, these processes are supposed to be executed Python code. And we are on Solaris. More precisely: Process A is supposed to be running all the time, while process B will only live for a short period of time. Both processes are supposed to live on the same machine. After collecting some data, B needs to communicate that data to A and A is supposed to acknowledge to B that the received data is OK. B is therefore supposed to identify A, and set up a two-way communication link to A (with A's help, I suppose). After the necessary comunication has taken place, the communication link is supposed to be shut down, and B will soon die. B is only supposed to know under what name A is running. Later, A is supposed to be able to repeat the whole thing with a new B. There may be more than one process (but probably not more than ten) knocking on A's door, and A is supposed to deal with them one by one. I feel that I am in quick sand here. I haven't got the slightest idea how to do this. Any help is welcome. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 05-Nov-2001 Time: 10:11:48 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From martin.franklin at westgeo.com Thu Nov 29 05:01:30 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Thu, 29 Nov 2001 10:01:30 +0000 Subject: Should I use threads here? References: <83bshmv8yf.fsf@panacea.canonical.org> <6749bb94.0111290155.5deb0e2c@posting.google.com> Message-ID: <9u510r$3t8q$1@mail1.wg.waii.com> Era Akost wrote: >> This may be true. But the readline() solution *can't* be any worse, and >> might be better. Readlines() will definitely not return until the called >> program closes its standard output. Of course, if Era has no access to >> the program's source he has no possibility of adjusting its output >> behavior. >> >> regards >> Steve > > Hi all, > > Steve, I tried your suggestion, but that didn't change the situation. > Let me explain it again. I have a simple GUI with a button > and a text widget. When I click the button, the following fuction is > called: > > def execute(self, command): > #command is a string containing the .exe program and its file arguments > i, o = os.popen2(command) > while 1: > line = o.readline() > if not line: > break > self.text.insert(END, line) > i.close(), o.close() > > Now, the button on the GUI remaines clicked for a while (it seems to me > all the time that the .exe program is running). And only after that, its > output is displayed in the text widget. > > But this is not the way the .exe program behaves when it runs on > its own. During the execution it keeps displaying the results on the > console. And this is exactly the behaviour that I'd like for my GUI. > Thus, I asked if threads can do something in this case. Only that I > don't yet understand how threads work, and so on - therefore I need some > help. > > Again, many thanks > Era > Era, Try calling self.text.update() in the loop. Martin. From bedge at troikanetworks.com Thu Nov 15 11:29:39 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Thu, 15 Nov 2001 08:29:39 -0800 Subject: convert a string to a method call ? Message-ID: <25SI7.32$Qh1.10549@newsfeed.slurp.net> I have an object, say xObj, which has a bunch of methods. I have the method I want to call in a string, say str. How do I call method str on xObj? Use eval? If so, the syntax eludes me. TIA, Bruce. From johnny at debris.2y.net Thu Nov 1 07:34:16 2001 From: johnny at debris.2y.net (Johnny deBris) Date: 1 Nov 2001 04:34:16 -0800 Subject: Selecting text in a Text-widget Message-ID: Hi there... I'm still working on this text-widget, but there's another thing I could not figure out: how do I set a selection? I would like to be able to, after a search-job, select the found substring and set the cursor at the start of the substring, but so far I haven't figured out how to use either of them... Can anybody help me out? Thanx again :) Guido Wesdorp From mj_dup at yahoo.com Wed Nov 7 15:25:17 2001 From: mj_dup at yahoo.com (Suresh) Date: 7 Nov 2001 12:25:17 -0800 Subject: configure using makesetup and Makefile.pre.in Message-ID: Hi All, I have been trying to build LLNL distribution (Numerical) on my SGIOctane with IRIX6.5.4. LLNL distribution uses "cc" to compile all *.c files whereas I want to use "gcc-2.95.2" compiler. I investigated a bit and found that LLNL comes with a "Setup" file and python has some scripts "makesetup", "Setup", "Makefile.pre.in" in /usr/local/lib/python1.5/config which builds "Makefile" for LLNL distribution. All these uses sedscript. I want to find out if anyone has customized for their application by chaning anything in /usr/local/lib/python1.5/config and if you could assist me as to how to include "gcc" instead of "cc -n32" ? Please let me know which file am I suppose to make changes ? thanks a bunch, ./Suresh From tim.one at home.com Tue Nov 6 23:58:30 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 6 Nov 2001 23:58:30 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message-ID: [Grant Edwards] > Don't all c.o.l.p threads eventually end up being about integer > division? ;) That's a provocative observation! I'm not sure it's a true observation, but at my age it's reward enough just to be provoked -- thank you. > It could be worse, in most other newsgroups all threads end up > being about Hitler... No threads on c.l.py end up being about Hitler. Not even this one! Indeed, I expect this one to veer into transfinite cardinals before I finish this sentence. python-needs-a-transfinite-cardinal-type-ly y'rs - tim From brueckd at tbye.com Fri Nov 30 12:30:30 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Fri, 30 Nov 2001 09:30:30 -0800 (PST) Subject: A modest indentation proposal In-Reply-To: Message-ID: On Fri, 30 Nov 2001, Erann Gat wrote: > Yes, of course we test our mission critical applications. Please extend > me the courtesy of not immediately assuming I'm an idiot just because I > make a proposal that you don't like. But testing is actually a very > ineffective way of insuring that software works, particularly > mission-critical software. For one thing, it's not possible to test > spacecraft software under field conditions until the spacecraft is > launched, and by then it may be too late. For another, many bugs, > particularly in real-time multithreaded systems, are probabilistic, and so > even if your tests work perfectly that alone does not provide a lot of > confidence that your software is in fact correct. Do you think this indentation stuff will have any bearing at all on any of this? Erann, there are much bigger fish to fry. I apologize, but this is really a nit-pick issue. Surely the people you're trying to sell this to can come up with better reasons as to why Python is not suitable. I mean, if they are complaining about this then I am *really* curious about what languages they *do* find acceptable. I guarantee that, given any language (including Python!), we can come up with more serious and reasonable objections than this one. > all screwed up and should be discarded. The reason is that I want to sell > people at JPL on the idea of using Python to write mission-critical > software, and the people I'm trying to sell are raising this objection. Congratulations on getting them this far (I'm serious). You've obviously done a lot of selling to them to get them to the point that these are the types of objections they're raising. The thing to do now is to convince them to let you use Python on a minor project or two so that they can *objectively* judge the merits of Python. You need to help them get out of the respond-to-whatever-problems-we-can-dream-up mode and into the see-what-problems-really-occur-and-how-often mode, and then you can accurately judge the suitability of Python. Yes, in theory, their objection can cause problems. In practice, however, it rarely does. YMMV, but the indentation issue you're worried about has bitten me far less than if (a < b); b++; or if (a < b) a++; b++; *ever* did in my time with C/C++/Java, and even there it wasn't that big of a deal. By using Python on one of your smaller projects they'll have more tangible experience with Python's positives (faster development, fewer bugs, lower maintenance costs, happier developers, world peace, etc.), and then they can accurately decide if it's right for your development organization. Right now you're essentially in the tough position of showing that Python is perfect, which it's not, so you're bound to lose the argument. None of us choose Python because it's perfect, but because for many programs it's the tool whose postives best outweigh its negatives, and that's the angle you need to be selling from. Best of luck, -Dave From paul at boddie.net Tue Nov 27 10:23:00 2001 From: paul at boddie.net (Paul Boddie) Date: 27 Nov 2001 07:23:00 -0800 Subject: vCard parser anywhere ? References: <9trh93$o1e$1@norfair.nerim.net> Message-ID: <23891c90.0111270723.18037907@posting.google.com> "Gillou" wrote in message news:<9trh93$o1e$1 at norfair.nerim.net>... > > I'm looking for a vCard parser that changes a vCard stream into a Python > object. This may be of interest: http://www.logilab.org/vcalsax/ It doesn't produce Python objects of the form you might be looking for, as far as I can tell, but I can imagine that it's something one could work with. Paul From rand0m at nelvento.it Mon Nov 5 05:15:56 2001 From: rand0m at nelvento.it (rand0m) Date: Mon, 05 Nov 2001 10:15:56 GMT Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> <7xitcp8wb1.fsf@ruckus.brouhaha.com> Message-ID: Make a simple application that store's and retrieves your friend's phone numbers. That could be your goal and while reading (studying Python) you could focus on what u need to do that ;-) Ciao, Lo "Paul Rubin" ha scritto nel messaggio news:7xitcp8wb1.fsf at ruckus.brouhaha.com... > "Edy Lie" writes: > > I have some doubts here > > > 1. I would really want to learn this lang (What should i do?) > > Read the tutorial in the documentation directory at www.python.org > if you want an intro to the language. > > > i know instead of asking here i should start coding but i have no > > idea what should i code. > > Is there anyone in here willing to conduct a small class or at least giving > > out exercise to newbies to code ? > > If there are some things you'd code in perl, write them in python > instead. If you want to learn programming in general, the best book > is Structure and Interpretation of Computer Programs, by Abelson and > Sussman: > > http://mitpress.mit.edu/sicp/sicp.html > > however, it's kind of idiosyncratic, and its examples and exercises > are in a Lisp dialect called Scheme. Nonetheless you'll learn a lot > from it, and Python's approach will seem natural to you. You should > be able to do a lot of its exercises in Python instead of Scheme. > > There are some Python books too, but I haven't looked at them yet. > > > 2. Another thing when doing coding if i am facing problem i tend to stop or > > rather wanted to learn everything in a day or as fast as i could which i > > believe is a wrong approach. Is there anyone kind enough to give me some > > direction in order i could code something useful. > > There's nothing wrong with wanting to learn fast. From Administrator Wed Nov 28 13:37:06 2001 From: Administrator (Administrator) Date: Wed, 28 Nov 2001 11:37:06 -0700 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <037201c1783b$ae66c9a0$0e0fbb82@corp.es.com> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = Gioachino Giussani Recipient(s) = python-list at python.org Subject = Re: Scanning Time = 11/28/2001 11:37:06 Engine/Pattern = 5.600-1011/173 Action on virus found: The attachment YOU_are_FAT!.MP3.scr contains WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to administrator. ScanMail has detected a virus. 11/28/2001 11:37 AM TORINO YOU_are_FAT!.MP3.scr/Deleted python-list at python.org Gioachino Giussani Re: From peter at engcorp.com Tue Nov 13 09:34:34 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 13 Nov 2001 09:34:34 -0500 Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> Message-ID: <3BF12F7A.DF1938B8@engcorp.com> Terry Reedy wrote: > > wrote: > > I gave a colleague of mine a Python function to optimise: > > Responding would have been easier if you had given a succinct > description of what your function computes: the number of ways of > distributing n indistinguishable items among m labelled bins, with > bins possibly left empty, and where 'labelled' means that each > permutation among bins is counted separately. Sounded like another class assignment to me... (Am I becoming paranoid? :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From kwg at renre-europe.com Fri Nov 23 09:43:04 2001 From: kwg at renre-europe.com (Ken Guest) Date: 23 Nov 2001 14:43:04 +0000 Subject: DateTime strangeness when returning MySQLdb results thru xmlrpcserver Message-ID: <1006526589.28013.5.camel@lewis> OK, I've been writing an XML-RPC server in python to serve as an intermediate between a client app and a mysql database - this works fine for the most part in that I can open a database, execute sql and close the database at will. I'm using MySQLdb, xmlrpclib and xmlrpcserver to make all this work, the version of python that I'm using is 2.0.1 and my xmlrpclib is at version 0.9.9 with the last comment by Fredrik Lundh dated 2001-02-26. And it works just fine until the resultset being returned references a datetime column - and keep getting an Internal Error (ie status code = 500). I tweaked xmlrpcserver.py to return the error type and value [1] and found that the reason is that xmlrpclib "cannot marshal objects". To be honest I'm not sure how the timestamps get converted to this type as MySQLdb returns them as strings and examining xmlrpclib.py hasn't shed as much light on the problem as I'd like. Anybody know what's going wrong here? k. [1] code block now looks like: except: # internal error, report as HTTP server error self.send_response(500) self.send_header("Content-type", "text/xml") self.send_header("X-Error-type", "%s" % (sys.exc_type)) self.send_header("X-Error-value", "%s" % (sys.exc_value)) self.end_headers() [2]: this is the code for the pertinent method of the XMLRPCHandler class that I'm using: def execute_sql(self, sql, database_id): """execute_sql(sql,database_id)""" global datadict return_this = [] conn = datadict[database_id] curs = conn.cursor(MySQLdb.cursors.DictCursor) curs.execute(sql) print curs #prints # return_this = curs.fetchall() curs.close() print return_this #prints: #({'s_datetimemapsynched': , 's_synched': 1L},) #this is odd as executing the same sql manually (well via MySQLdb) has type reporting the timestamp as a string! #may need to iterate thruough results and cast them to #datatypes that the XML-RPC protocol understands..? return return_this From wpmelcher at snet.net Wed Nov 28 09:18:51 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Wed, 28 Nov 2001 14:18:51 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> <83u1vhs2j2.fsf@panacea.canonical.org> Message-ID: I got the thing to work by building a directory structure that is a combination of the game distribution files (pysol-4.72.tar.bz2) and the sources (pysol-4.72-rc.tar.bz2) The structure I used is: drive | - pysol-4.72 | - data (from the first archive) | - src (from the second archive) Python 2.1 is installed elsewhere so then I used SciTE to load pysol.py from drive:\pysol-4.72\src and had the editor Run it. The great thing about SciTE is that when you click Tools/Run, a new pane opens that shows the entire session with all the stdout and stderr messages. You could start an MS-DOS session and type at the C> prompt: python drive:\pysol-4.72\src\pysol.py You could also double click on pysol.py in the src directory. If you do not like the pop-up DOS window, rename pysol.py to pysol.pyw then click that one. Once everything is cool, simply double click on pysol.pyw (or a shortcut to it) to start a game session. I would like to find out how to create a version of pysol_21.pyc 'bundle' that Marcus supplied in the original distribution but have not yet succeeded and I don't really know whether it is worth the effort. PySol lives on my system! I think your problem arises from the fact that the src and data directories are not part of the same directory structure so that the running PySol can't find all the stuff it needs. -- Cheers, Bill TANSTAAFL! "Andrew Brown" wrote in message news:Xns916759CC47C4Dandrewdarwinwarscom at 62.253.162.104... > "Bill Melcher" wrote in > : > > > > >"Bill Melcher" wrote in message > >news:uaCM7.538$yq7.150911048 at newssvr10.news.prodigy.com... > >> [...] > > > >I have discovered that pysol.py in .../src is supposed to create the > >'bundle' so all I have to do is discover where the output module > >(pysol.pyc) has gone or why it did not get created. > > > I have been following this thread, having come across the same problem when > I downloaded pysol 4.72 for Windows. It wouldn't run becasue of the > "dither" error. This was on Windows 2k > > I left that installation where it was -- when I ran the windows installer, I > got all the card sets and everything; and simply unpacked the source into a > fresh subdirectory under that tree (C:\program files\games\pysol-4.72\src) > and comented out the "dither" lines as suggested in this thread. > > I then run "python src\pysol.py" from the directory above, and it finds the > cards and runs perfectly -- until I move the mouse when clicking on a card. > this makes the game crash with an error about an unrecognised cursor, which > I must find and fix. From richard at bizarsoftware.com.au Mon Nov 19 17:20:59 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Tue, 20 Nov 2001 09:20:59 +1100 Subject: printing without spaces In-Reply-To: <20011119220852.89545.qmail@web21101.mail.yahoo.com> References: <20011119220852.89545.qmail@web21101.mail.yahoo.com> Message-ID: <200111192221.fAJMLM316540@bigboy.bizarsoftware.com.au> On Tuesday 20 November 2001 09:08, David Brady wrote: > Hello, > > I'm trying to print a list of information > programmatically. Using 'print i,' doesn't quite > work the way I'd like because the , seems to inject a > space between arguments. > > Is there a way to do this with print? > > Thanks > > Here's a sample of what I'm talking about: > >>> for i in range(3): > > for j in range(10): > print "%d%d" % (i,j), > print > > > 00 01 02 03 04 05 06 07 08 09 > 10 11 12 13 14 15 16 17 18 19 > 20 21 22 23 24 25 26 27 28 29 > > I'd like the output to be > > 00010203040506070809 > 10111213141516171819 > 20212223242526272829 print is a convenience statement. You need to use the sys.stdout file directly to control writing in this way. >>> import sys >>> for i in range(3): ... for j in range(10): ... sys.stdout.write("%d%d"%(i, j)) ... print ... 00010203040506070809 10111213141516171819 20212223242526272829 Richard From skip at pobox.com Fri Nov 16 03:50:11 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 09:50:11 +0100 Subject: A modest proposal (continued) In-Reply-To: References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> <9t1uce$5d8$1@nntp1-cm.news.eni.net> Message-ID: <15348.54083.295573.868772@beluga.mojam.com> John> Didn't we discuss this a month or two ago? There was quite a bit John> of talk about speeding up access to module level names and so John> forth, even going into the changes needed in the bytecode set, and John> possibly even an implementation. Go to http://python.sourceforge.net/peps/ and check out PEPs 266 and 267. There will possibly be a Developer's Day session on optimization. Skip From skip at pobox.com Thu Nov 29 16:16:37 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 29 Nov 2001 15:16:37 -0600 Subject: finding a value in a tuple In-Reply-To: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Message-ID: <15366.42421.783685.887937@beluga.mojam.com> Dan> Say I have Dan> mylist = ['one','two','three'] Dan> which I presume is a "tuple" as I have been scanning the manual. Actually, it's a list. You can think of a list as a mutable tuple for most uses (or a tuple as an immutable list). Dan> I want to know if one of the values in that tuple is exactly equal Dan> to "four". The answer of course is no, but how would I find it. >>> mylist = ['one','two','three'] >>> "four" in mylist 0 >>> "one" in mylist 1 -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From gat at jpl.nasa.gov Fri Nov 30 17:35:41 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Fri, 30 Nov 2001 14:35:41 -0800 Subject: A modest indentation proposal References: Message-ID: In article , wrote: > On Fri, 30 Nov 2001, Erann Gat wrote: > > > > Yes, in theory, their > > > objection can cause problems. In practice, however, it rarely does. > > > > Rarely isn't good enough. > > Sure it is, otherwise you've also just disqualified every other language > in existence. You said they also like C++. Yes, but it's important to understand *why* they like C++. They like C++ because "everyone uses it." That fact alone can overcome nearly any technical objection. In the case of Python it is not the case that "everyone uses it." I haven't actually tried (because I could not live with myself if I succeeded) but I strongly suspect that I'd have a much easier time convincing people to fly Perl than I would to fly Python. > By that standard, > C++ is less suitable for your mission-critical application. That's right. I actually believe that C++ is even less suitable for mission critical applications than Python. But my opinion is irrelevant because I'm not the one making these decisions. > If you find yourself prone > to indentation problems in Python then create a coding standard that > always uses an end-block comment. In neither case does the compiler care. > In neither case is it required because the vast majority of the time it > doesn't cause problems. That is in fact precisely what I am trying to do, except that I find end-block comments too verbose and I want to use something shorter. (Also, I want an editor mode to support this convention, and I'm not much of an elisp hacker.) > > The annals of catastrophic failures are > > chock-full of multi-million-dollar failures that were the result of things > > that "rarely" caused problems. > > Perhaps, but you cannot now and will never find a total solution to that > problem in a computer language. The language can but help, and that's what > Python (and many other languages) do. I never said any different. > But as you agreed earlier, their objection is a nit-pick and their > reasoning (based on the fact that it's an "underdog") is irrational. > Those are two very bad reasons to change a language. ;-) That depends on one's goal. My goal is to convince the Powers that Be here to let me write flight software in Python instead of C++. If a tiny, inconsequential change to the language lets me accomplish that then I think it's an excellent reason to change the language. BTW, I'm not really asking for a change in the language, just a semi-official adoption of a convention. Remember, there's a lot of herd-mentality reasoning going on here. I could pitch my solution purely internally, but then it would be "Erann's hack", which makes it bad. (Look at the reaction I'm getting here.) If I can convince the Python community to adopt this first then I can pitch it here as the *community's* solution to the problem, which makes the herd mentality work in my favor. > Ok, not arguing, but "selling" as you put it, and you're obviously > interested in convincing them to buy into the idea of Python. My point was > that it's a pretty tough thing to do if you have to respond to such > nit-pick issues that they are dreaming up but don't have any real > experience with. You can just as easily come up with a nit-pick list for > any other choice of language, often a much longer list and with much more > meaningful concerns. You're trying to convince someone of this indentation > thing while they're partial to a language (C++) where you have to do your > own memory management?!? Yes, I see you are beginning to understand. Fortunately, in this case the list of nit-pick issues seems to be rather short. There's not a whole laundry list of issues, just this one. Unfortunately, it seems to be a potential show stopper. > Not that I even have any say in whether or not the suggestion would ever > be considered, Oh, but you *do* have a say because the people who make the decisions here listen to you. Not directly, of course, they listen to the "buzz", and you (and everyone reading this group) are part of the buzz. And the people who read this group are influenced by what you say. > By their reasoning we should not use computers at all since it is possible > for them to lose power. We should not go to the store because it is > possible to get into an accident on the way. We should not breathe because > it is possible that the air is contaminated. These are all possible but > improbable events. In this specific case there is a nearly infinite list > of more probable sources of problems; your friends are concerned with > the wrong end of the list. :) No, by their reasoning they should use computers because everyone uses computers. They should use C++ because everyone uses C++. Should they use Python? Well, very few people seem to use it (relatively speaking), but it seems basically OK, kind of like Perl, which everyone uses and that makes it OK, but it's got that weird indentation thing going on, and that makes it suspect. Now from here on how the story goes is up to you. If you simply insist that the problem doesn't exist you will lose, at least in the short run, because for the moment "they" *just know* that it's a problem (in much the same way that they *just know* that C++ *isn't* a problem). If, on the other hand, you can show that the community recognizes the problem and has a solution then you win. You are the community. It's up to you. E. From nomad*** at ***freemail.absa.co.za Fri Nov 9 09:04:20 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Fri, 09 Nov 2001 16:04:20 +0200 Subject: Matrix in Python . References: <9sglpt$a3r$1@news.tpi.pl> Message-ID: On Fri, 9 Nov 2001 14:30:49 +0100, "Tomasz Lisowski" wrote: > For dealing with Matrix you need something more powerful, than Python. = >You have to realize, that the world does not look as your eyes, and your = >mind tell you. Otherwise ... Matrix has you! > > Neo :-) You mean Python is going to take over the world and keep living people in vats of goo? Jeez, and all I was trying to do was turn down the volume of my PC speakers... How does Guido feel about all of this? -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From mail at cliffpruitt.com Wed Nov 7 02:55:36 2001 From: mail at cliffpruitt.com (Cliff Pruitt) Date: Tue, 06 Nov 2001 23:55:36 -0800 Subject: New to pyton. Maybe a dumb question? Message-ID: I'm a little confused starting off. Is it possible to create an application with Python that will run on any machine or doe sthe client machine have to have a python interperater installed? I'm kind of lost as to how this all works. Thanks for answerign something so mindlessly basic. -- C. Pruitt mail at cliffpruitt.com http://www.cliffpruitt.com From danielk at aracnet.com Sun Nov 18 17:42:17 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 18 Nov 2001 14:42:17 -0800 Subject: Instantiating a class from its name References: <9t6m56$n4ld$1@ID-11957.news.dfncis.de> Message-ID: On Sun, 18 Nov 2001 06:54:24 GMT, "Chris Tavares" wrote: >Since a class object is a python expression, you can use eval in this case >and be a little less confusing: You sure can, and it sure is! Thanks Chris, Dan From mwh at python.net Mon Nov 5 12:03:42 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 5 Nov 2001 17:03:42 GMT Subject: simple eval question References: <1f5252d4.0111021241.643efe1e@posting.google.com> Message-ID: nbecker at fred.net (N Becker) writes: > What is wrong with this? > > eval ("print \"hello\"') print is a statement. eval evaluates an expression. You could try eval("sys.stdout.write('hello\n')") or exec "print 'hello'" Cheers, M. -- I've reinvented the idea of variables and types as in a programming language, something I do on every project. -- Greg Ward, September 1998 From mwh at python.net Mon Nov 12 06:30:03 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 12 Nov 2001 11:30:03 GMT Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: Just van Rossum writes: > I think three-arg getattr() is faster than catching an exception. It depends how often you expect it to fail. Personally, I would have thought masking the error at all was the wrong response, but I haven't read all of the thread that carefully... Cheers, M. -- 59. In English every word can be verbed. Would that it were so in our programming languages. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From peter at engcorp.com Mon Nov 12 21:40:59 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 12 Nov 2001 21:40:59 -0500 Subject: Are there any list comparison optimizations in Python? References: Message-ID: <3BF0883B.62473129@engcorp.com> "Jonathan P." wrote: > > One of Python's most convenient high-level features is automatic list > comparison by value and recursively. > > Does it know to optimize the compare if it has already been determined > that two items share a reference to the same object by not doing a > value compare on them anymore? I just created two million-integer lists with "[0] * 1000000" and compared them, then reassigned the second name to reference the first list and compared again. There was a noticeable pause during both compares (with "=="). Comparing two lists with different lengths *does* return "immediately". -empirically-yr's -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From m at moshez.org Sun Nov 25 05:57:54 2001 From: m at moshez.org (Moshe Zadka) Date: Sun, 25 Nov 2001 12:57:54 +0200 (IST) Subject: How To Kill a Python In-Reply-To: <5.1.0.14.0.20011125024815.009f4ca0@thewebsons.com> References: <5.1.0.14.0.20011125024815.009f4ca0@thewebsons.com> Message-ID: <20011125105754.27D5838BC@darjeeling> On Sun, 25 Nov 2001, Ben Ocean wrote: > I continually run into problems adding new software to my server that is > dependent on Python because I have 2 versions, one of which is completely > unnecessary; namely, 1.5.2. I want to kill it, or at least make it so that > when Python is called it automatically calls 2.1 instead of 1.5.2, but I > don't want to screw anything else up on the server. > How should I go about this? If you're using shebang lines, you might change the line to #!/usr/bin/python2.1 instead of #!/usr/bin/python -- The Official Moshe Zadka FAQ: http://moshez.geek The Official Moshe Zadka FAQ For Dummies: http://moshez.org Read the FAQ From lucio at movilogic.com Thu Nov 8 16:54:26 2001 From: lucio at movilogic.com (Lucio Torre) Date: Thu, 08 Nov 2001 18:54:26 -0300 Subject: I just got in! References: <9sep77$eg6$1@slb4.atl.mindspring.net> Message-ID: <3BEAFF12.5010008@movilogic.com> Andrew Dalke wrote: >Kirk Bailey: > >>I want to learn about python, write some things in it, >> > >Welcome. I've found Python very enjoyable and powerful. I >hope you find it that way as well. > >If you want some basics on Python, you may want to look at > http://www.python.org/doc/Newbies.html > >>and show that smug bunch ovver in the perl tree that snakes are way >>cooler than camels. >> > >One thing about Python people is we are less (outwardly ;) smug >then your phrase seems to suggest. Perhaps that derives from the >influence of Dutch tolerance in the early days. In any case, you >may want to tone down your rhetoric to be less divisive, as the >sense of coolness varies too wildly to be a useful distinction. > > Andrew > dalke at dalkescientific.com > > > I just need to agree. Im very pleased about the list. Its very nice to read people that are 'nice', have a fun side and are not that fundamentalists. I think the python comunity should stay this great way. congratulations. lucio. From wurmy at earthlink.net Mon Nov 26 21:05:39 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 27 Nov 2001 02:05:39 GMT Subject: function operators References: Message-ID: <3C02F4EB.1C641E04@earthlink.net> "James A. H. Skillen" wrote: > > Has anyone ever wished that Python had operators defined on functions? > For example, suppose you want the function f(x) = cos(x) + sin(x). > You could do: > > def f(x): > return cos(x) + sin(x) > > or > > f = lambda x: cos(x) + sin(x) > > but wouldn't: > > f = cos + sin Assuming this would ever be implemented, then it would work on "normal" functions, but problems would occur with other callable objects. Most notably, classes that override the + operator. In other words, if a and b are instances of a class that implements both __add__ and __call__, what would f = a + b mean? Would it mean f = a.__add__(b) or f = lambda x: a(...) + b(...) like with regular functions? Ambiguity occurs. Then again, it may be possible to write a wrapper class that holds a function, is callable through __call__, *and* implements __add__ and other operators, that do what you want... I was going to give it a try, but then I got high... ;-) > There is also another tremendously useful operator on functions: > composition. > > For want of a better symbol, how about a new keyword "on" to be > composition. > So to get the function f(x) = cos(sin(x)) I could do > > f = cos on sin > > Why? Well this is useful if you use map, filter etc. But a compose function is easily defined; for example, in 1.5.2-compatible code: def compose(f, g): return lambda x, f=f, g=g: f(g(x)) or in 2.1: from __future__ import nested_scopes def compose(f, g): return lambda x: f(g(x)) ...so whether it's worthwile to add an extra operator for this, is doubtful. > but with the new syntax I could write > > map(cos on sin, range(10)) It does look nice, though. :-) > Does this make sense, or have I been doing too much mathematics? ;-) Python isn't a functional language, but many features of such languages can be implemented with a little trickery. Regards, --Hans From ws-news at gmx.at Thu Nov 22 06:06:33 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 22 Nov 2001 12:06:33 +0100 Subject: Read MS Visual Studio Project files Message-ID: <3bfcdcfe$1@brateggebdc5.br-automation.co.at> Hello, I'd need a tool to read MS Visual Studio Project files (.dsp). I want to be able to get the 'Folders' and 'Files' from it as well as the existing configuration options. I think such a thing does exist already, but I don't seem able to find 'em on google. Thanks for your help Werner From grante at visi.com Thu Nov 8 20:43:36 2001 From: grante at visi.com (Grant Edwards) Date: Fri, 09 Nov 2001 01:43:36 GMT Subject: newbie tkinter question References: <480f610.0111081146.72a92cb0@posting.google.com> Message-ID: In article , Steve Holden wrote: > "Grant Edwards" wrote ... >> In article <480f610.0111081146.72a92cb0 at posting.google.com>, Jared wrote: >> >> > I am investigating using a python/Tkinter environemnt for apps >> > development. The target hardware environment would be pretty >> > old-fashioned - a bunch of dumb terminals (VT420's, mostly) >> >> Sheesh. Calling a VT420 a "dumb" terminal. Of all the nerve. >> >> Dumb terminals are ones that lack any sort of control mechanism >> (escape sequences and the like). None of the VTxx and VTxxx >> were dumb terminals. > > But they weren't that smart either ... They were pretty darned smart in my book. VT102 and upwards even had line/character insert modes! -- Grant Edwards grante Yow! I want EARS! I at want two ROUND BLACK visi.com EARS to make me feel warm 'n secure!! From max at alcyone.com Mon Nov 19 15:02:30 2001 From: max at alcyone.com (Erik Max Francis) Date: Mon, 19 Nov 2001 12:02:30 -0800 Subject: Help with my first CGI program??? References: <3BF95D73.2886D584@earthlink.net> Message-ID: <3BF96556.97F5D1B2@alcyone.com> Ron Stephens wrote: > Any help would be appreciated. I am getting a KEYERROR when I run my > CGI > program as a standalone python program. Maybe its just because the > standalone python program doesn't have the input data from the FORM I > use in my HTML input page to my CGI. That's correct; it's expected that it wouldn't work. > Howver, I get no error messages > from actaully running my CGI on the web (just a general serer error), > even though I set sys.stderr = sys.stdout stderr redirection is done by the Web server to an error log. Check the error log in your server to find out what's going on. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From phd at phd.pp.ru Mon Nov 12 05:17:57 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 12 Nov 2001 13:17:57 +0300 Subject: long string constants In-Reply-To: ; from fuessler@informatik.uni-mannheim.de on Mon, Nov 12, 2001 at 11:08:56AM +0100 References: Message-ID: <20011112131757.B26476@phd.pp.ru> On Mon, Nov 12, 2001 at 11:08:56AM +0100, Holger Fuessler wrote: > Now my question. Is it possible to spread very long string constants > over multiple lines?. """Very long strings are in triple quotes""" '''You can use also triple apostrophes''' No continuation required. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From uwe at rocksport.de Wed Nov 7 10:36:27 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 7 Nov 2001 15:36:27 GMT Subject: Numerical Python Bug ? Message-ID: <9sbkdr$957nk$1@hades.rz.uni-sb.de> Hi, during a *large compilation* I get problems with vectors / arrays: print sp delivers [ 100, 50,] and print 0.5*sp yields [ 0, 0, ] type(sp) is "array" and type(sp[0]) is "float". What makes me wonder is the output format. "print sp" should give [ 100., 50. ] which is different from my result above... Further: if I use print 1/2.0*sp i get the correct result [50, 25,] Is there a bug in NumPy or Python respectively ??? Last but not least: If I use alpha=0.5 print alpha I get 0.0 as output !!! One remark: all the behaviour above does not happen if I enter some vectors manually... Yours, Uwe. -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From duncan at NOSPAMrcp.co.uk Fri Nov 16 10:14:33 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 16 Nov 2001 15:14:33 +0000 (UTC) Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> <3BF4288A.FC68121F@alcyone.com> Message-ID: Erik Max Francis wrote in news:3BF4288A.FC68121F at alcyone.com: > Yes. Python has lambda functions for this, although there are some > restrictions: lambda functions have to take at least one argument > (otherwise what's the point), and they can only evaluate to expressions, > rather than whole statements. Your second point is correct, but the first one is wrong. You can have a lambda with no arguments if you wish. The point is the same as any function with no arguments, if it calls other functions which use globals (or nested scope variables) or have side effects, then the lamda doesn't access the globals or produce the side effects until it is invoked. e.g. f = open('somefile') readchop = lambda: f.readline()[:-1] for i in range(10): print readchop() is a not terribly good example. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From donn at drizzle.com Fri Nov 23 13:17:22 2001 From: donn at drizzle.com (Donn Cave) Date: Fri, 23 Nov 2001 18:17:22 -0000 Subject: Could someone explain this multidimensional list behaviour? References: None Message-ID: <1006539442.400238@yabetcha.sttl.drizzle.com> Quoth lrl at ou.edu (L): ... | >>> spam = [[0] * 3] * 3 | >>> spam | [[0, 0, 0], [0, 0, 0], [0, 0, 0]] | >>> spam[0][1] = 1 | >>> spam | [[0, 1, 0], [0, 1, 0], [0, 1, 0]] | | I was expecting after making the assignment to get this: | [[0, 1, 0], [0, 0, 0], [0, 0, 0]] Because python does the initial assignment the easy way - compute [0] * 3, then use that in [result] * 3. After all, you'd be very surprised if it didn't come out the same when written in two statements. Writing it that way just makes it clearer that all three elements of the larger list are references to the same object. | After flipping through my O'Reilly I know it has to do with the * | operator, but don't know how otherwise allocate an n x n "array" type | of structure beforehand with each element having a unique pointer, | without using some sort of ridiculous two loop setup and appends like | the following. | | >>> spam = [] | >>> for y in range(10): | inner = [] | for x in range(10): | inner.append(0) | spam.append(inner) | del inner That's overkill. The inside list was OK, because when you write inner[1] = 1, you don't care what object was there before, you're replacing it with the assignment (or rather setitem.) You only need distinct objects when you want to modify them. Donn Cave, donn at drizzle.com From tdelaney at avaya.com Thu Nov 29 17:52:48 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 30 Nov 2001 09:52:48 +1100 Subject: Copy operator (was list.remove for Noivces) Message-ID: > From: Jeff Shannon [mailto:jeff at ccvcorp.com] > "Delaney, Timothy" wrote: > > > > From: Arthur Siegel [mailto:ajs at ix.netcom.com] > > > Jeff Shannon wrote: > > > > > > But if I could find some way to demonstrate (not saying that I > > > necessarily could find a way to do so convincingly) that it would > > > indeed make Python better equipped for beginners/learners - > > > is there a shot it would find acceptance by the community? > > > > Probably not, since the only thing it would be doing would > be introducing > > syntactic sugar for something which Python already has. ..... > > Just as a minor point, the quoted section above was written > by Art Siegel, not > by me. I don't think any confusion has resulted, and I'm not > really worried > about being misattributed, just wanted to clarify this for > the record. :) It's not misattributed! Look at the indentation! What it says is that Art says that Jeff wrote nothing, and then Art said something else. It's just that I obviously cut out every piece of the message that Jeff wrote ... Tim Delaney From mikael at isy.liu.se Fri Nov 9 04:50:32 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 09 Nov 2001 10:50:32 +0100 (MET) Subject: Special celebration event for Orlijn? In-Reply-To: <3BEBA01A.2C5B468D@student.gu.edu.au> Message-ID: On 09-Nov-2001 Joal Heagney wrote: > Perhaps we should vote to rename the language in honour? At the very > least somebody should name a new module. > > "I use a cool new programming language called Orlijn!!!"-ly y'rs I was thinking more in the terms of Orlijn being a derived class with two base classes... /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 09-Nov-2001 Time: 10:48:41 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From wpmelcher at snet.net Sat Nov 24 17:52:56 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Sat, 24 Nov 2001 22:52:56 GMT Subject: Win98 PySol problem References: Message-ID: Hi Matt I managed to find a copy of the sources on a Russian site earlier today and Marcus' http://pysol.tsx.org site is up. The site that has the source file is still not up, so I'll play with the, hopefully correct, Russian copy. I found the code: > if os.name == "nt": > if dither is not None: > kw["dither"] = dither in tkutil.py in the PySol source package - I have commented out these lines in the module but now I have to deal with the creation of tkutil.pyc and pysol_21.pyc -- I think! The makefiles that I see are clearly written for a unix-like os and I will attempt to figure out how to do a build in the Win98 environment. If I get stuck, I'll ask for specific help. On the other hand, if you or others have some helpful hints I would appreciate them. FYI, since I started this snark hunt I have found, installed and begun learning how to use bzip2, gzip, powarc61 (so now I can deep six the first two), Agent Ransack (which I used to find the code to comment out), two python21 packages (I am using ActivePython-2.1.1.msi, and Komodo as well as Ghostscript and Ghostgum (to read PostScript documentation). Komodo finds a number of, presumably non-fatal, problems as well as the -dither option problem. My goodness, Grampy has been busy! -- Cheers, Bill TANSTAAFL! "Matthew Dixon Cowles" wrote in message news:CjTL7.19378$H7.3323721 at ruti.visi.com... > On Fri, 23 Nov 2001 21:37:33 GMT, Bill Melcher > wrote: > -- -- > Have fun with PySol and you may want to take a look at Python: > programming in Python is fun! Yeah, sure - I have messed with high level languages since Fortran I on the I BM 704 mainframe but am stll a largely unreconstructed (rusty) assembler programmer. > > Regards, > Matt From mwh at python.net Mon Nov 12 05:32:00 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 12 Nov 2001 10:32:00 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> Message-ID: "Frederic Giacometti" writes: > "Michael Hudson" wrote in message > news:u4ro58kzx.fsf at python.net... > > "Frederic Giacometti" writes: > > > > [schnipp] > > > Does this make sense? > > > > But isn't the point of many multithreaded apps allowing code to run > > during blocking IO operations? Your approach would knock that on the > > head. > > In the proposed design, stackless call to another thread never > blocks the thread; it inserts a frame in one of the thread frame > schedulers. Just as all C functions external to the Python > interpreter core, IO functions run outside the interpreter thread. I must be missing something. Can you sketch how, say, socket.send() would be implemented? Would you spawn a new OS thread for every C API call? I'm afraid I don't understand you to this point... Cheers, M. -- BUGS Never use this function. This function modifies its first argument. The identity of the delimiting character is lost. This function cannot be used on constant strings. -- the glibc manpage for strtok(3) From nospam at bigfoot.com Fri Nov 2 10:44:34 2001 From: nospam at bigfoot.com (Gillou) Date: Fri, 2 Nov 2001 16:44:34 +0100 Subject: problem with SQL-DMO and win32com (and a workaround) References: Message-ID: <9ruel5$2791$1@norfair.nerim.net> Hmmm, Dunno for SQL-DMO but for the MSXML parser COM object, I had a similar problem when upgrading it. I deleted the file built by makepy (in ...\win32com\gen_py), re-created it and it worked. HTH --Gillou From sholden at holdenweb.com Mon Nov 19 09:22:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Nov 2001 09:22:48 -0500 Subject: how to create database oriented ASP pages using python script? References: Message-ID: "alagu shenbagaperumal" wrote ... > hi, > how to create Active Server Pages which supports > database connectivity using python script. if u > explain with sample codes, it will be usefull. > Some links you might find useful: http://www.4guysfromrolla.com/webtech/082201-1.shtml is interesting, but doesn't mention database connectivity. http://groups.google.com/groups?hl=en&lr=lang_en&frame=right&th=bd523aa35a08 b3d3&seekm=943vlk02jai%40news2.newsguy.com#link1 Is a thread from earlier this year about the very subject you seek. Hope the link works despite mail client wrapping ... regards Steve -- http://www.holdenweb.com/ From yschwart at mail.bcpl.net Wed Nov 7 08:54:58 2001 From: yschwart at mail.bcpl.net (Yosefa Schwartz) Date: 7 Nov 2001 05:54:58 -0800 Subject: WWW::Search Message-ID: <2c4b750e.0111070554.1e5c16d8@posting.google.com> Are there any python modules that provide an API to search engines on the world wide web. Search engines such as Yahoo and Alta Vista. The API that I am looking for would parallel the WWW::Search package that perl has. Thanks. From bh at intevation.de Tue Nov 6 17:26:36 2001 From: bh at intevation.de (Bernhard Herzog) Date: 06 Nov 2001 23:26:36 +0100 Subject: CVS modules file References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: Prabhu Ramachandran writes: > hi, > > >>>>> "BH" == Bernhard Herzog writes: > > BH> Do you mean that pkg_root is the CVS module? Ouch! > > BH> Well, there's a way to achieve it without much renaming in CVS > BH> with CVS' modules file. If you create a new CVS module named > BH> app with app.py and a line like > > BH> app app &pkg_root > > BH> a cvs checkout app should create an app directory with > BH> pkg_root as subdirectory. Caveat: I'm not a CVS expert and I > BH> haven't used this feature myself yet, but it's used quite a > BH> bit in GNOME's CVS. > > Oh thanks for the hint! However, I dont have direct access to the > repository - this is a sourceforge project (http://mayavi.sf.net) > > http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mayavi/mayavi/ You've got it sitting right there in the CVSROOT module: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mayavi/CVSROOT/modules Just check out the CVSROOT module, edit the modules file and check it back in. :) Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From dalke at dalkescientific.com Mon Nov 12 23:55:05 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Mon, 12 Nov 2001 21:55:05 -0700 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> <7x8zddnroj.fsf@ruckus.brouhaha.com> Message-ID: <9sq94c$lim$1@slb1.atl.mindspring.net> Erno Kuusela wrote: >the fact that pickle shouldn't be fed untrusted data has been common >knowledge in the python user and developer communities as long as i >can remember. I've been involved with c.l.py for 6 years. I recall reading the documentation that pickles don't save code objects so should be safer than marshalls for sending data between intelligent agents. I had always assumed it was safe. It wasn't until this thread came up that I knew there was a problem. (Eg, elsewhere I posted a pickle that could be used to remove an arbitrary file.) So I don't think it's common enough. Now I need to revisit how I've done some of my quick&dirty network protocols (pickles over an http session) as I now know it's highly insecure for both the client and the server. Andrew dalke at dalkescientific.com From sholden at holdenweb.com Wed Nov 14 12:16:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 12:16:13 -0500 Subject: anonymous functions,classes? References: <3bf2a42f$1@207.229.64.20> Message-ID: "Peter Bismuti" wrote ... > Anonymous was the word I was looking for in my previous post. I want to > pass a function as an argument but don't want to have to define it globally. > The way I don't want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) > > > I'm guessing this can't be done because of Python's indenting syntax. > Correct. The nearest thing Python has to anonymous functions is lambda expressions, but of course they can't be multiline. >>> def f(ff): ... return ff(12) ... >>> f(lambda x: x*x) 144 >>> regards Steve -- http://www.holdenweb.com/ From snowcrash3 at hotmail.com Wed Nov 28 12:50:00 2001 From: snowcrash3 at hotmail.com (SnowCrash) Date: 28 Nov 2001 09:50:00 -0800 Subject: Super-newbie needs help! Message-ID: <70c31206.0111280950.7ebe06ae@posting.google.com> Hello all, Let me just preclude this posting by saying i am a Web Designer who's decided that she wants to learn programming, and this is my first stab at it. i don't pretend to understand what i am doing. Thats what you guys are here for. Anyhow, i am reading through this nice tutorial provided at hetland.org, called "instant hacking". Just the basics on Python. i am presented with my very first exercise, and am stuck-- "Write a program that continually reads in numbers from the user and adds them together until the sum reaches 100. " Now, i have some code: total = 100 sum = input ("Enter your number.") while sum < total: print "You haven't reached 100 yet!" sum = input ("give me another number") + sum print "Ok, you got me!" HUH? i don't think its right, i've changed it about 4 times before posting it, and i've downloaded the Python 2.2 but can't seem to figure out how to use the thing to check my code. i know its WILDLY simple and feel like "well, gee, if i can't understand this much, then i should quit before i feel REALLY stupid", but i am just going to keep on truckin'....Hopefully with some help from comp.lang.python. Thanks in advance, -snow- From sholden at holdenweb.com Thu Nov 29 07:43:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 07:43:00 -0500 Subject: Should I use threads here? References: <83bshmv8yf.fsf@panacea.canonical.org> <6749bb94.0111290155.5deb0e2c@posting.google.com> <9u510r$3t8q$1@mail1.wg.waii.com> Message-ID: "Martin Franklin" wrote ... > Era Akost wrote: > > >> This may be true. But the readline() solution *can't* be any worse, and > >> might be better. Readlines() will definitely not return until the called > >> program closes its standard output. Of course, if Era has no access to > >> the program's source he has no possibility of adjusting its output > >> behavior. > >> > >> regards > >> Steve > > > > Hi all, > > > > Steve, I tried your suggestion, but that didn't change the situation. > > Let me explain it again. I have a simple GUI with a button > > and a text widget. When I click the button, the following fuction is > > called: > > > > def execute(self, command): > > #command is a string containing the .exe program and its file arguments > > i, o = os.popen2(command) > > while 1: > > line = o.readline() > > if not line: > > break > > self.text.insert(END, line) > > i.close(), o.close() > > > > Now, the button on the GUI remaines clicked for a while (it seems to me > > all the time that the .exe program is running). And only after that, its > > output is displayed in the text widget. > > > > But this is not the way the .exe program behaves when it runs on > > its own. During the execution it keeps displaying the results on the > > console. And this is exactly the behaviour that I'd like for my GUI. > > Thus, I asked if threads can do something in this case. Only that I > > don't yet understand how threads work, and so on - therefore I need some > > help. > > > > Again, many thanks > > Era > > > > > Era, > > Try calling self.text.update() in the loop. > Also, are we to understand that you are doing all this inside the event callback for a button click? That sounds possible if the button isn't "popping up" again for a long time. Maybe you *do* need a thread. Report back about whether the update() calls help... regards Steve -- http://www.holdenweb.com/ From loredo at astro.cornell.edu Tue Nov 27 13:34:05 2001 From: loredo at astro.cornell.edu (Tom Loredo) Date: Tue, 27 Nov 2001 13:34:05 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: <3C03DC9D.1E57D73@astro.cornell.edu> Terry Reedy wrote: > > "Marcin 'Qrczak' Kowalczyk" wrote in message > news:slrna071tg.isc.qrczak at qrnik.zagroda... > > Tue, 27 Nov 2001 01:27:15 +0000 (UTC), Huaiyu Zhu > pisze: > > > > > - That there is no reason to associate tab with any equivalent in > spaces. > > > It should only be used as a distinct character in its own right. > > > > What should a Python interpreter do with this? > > > > if 0: > > print "0" > > print "1" > > Raise SyntaxError. AMEN!! PEP!! Yes, it would break existing code, but that code *should* be broken (in some sense it already is). -Tom Loredo From James_Althoff at i2.com Tue Nov 13 16:31:21 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 13 Nov 2001 13:31:21 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: All, Below is the first draft of PEP 276 "Simple Iterator for ints". (Available at http://python.sourceforge.net/peps/pep-0276.html) Feel free to comment (positive, negative, bipolar, or in between ;-). Please copy me on any comments that you think should be incorporated into the next revision (so that I don't unintentionally miss something on python-list). Thanks, Jim ===================================== PEP: 276 Title: Simple Iterator for ints Version: $Revision: 1.1 $ Last-Modified: $Date: 2001/11/13 20:52:37 $ Author: james_althoff at i2.com (Jim Althoff) Status: Draft Type: Standards Track Created: 12-Nov-2001 Python-Version: 2.3 Post-History: Abstract Python 2.1 added new functionality to support iterators[1]. Iterators have proven to be useful and convenient in many coding situations. It is noted that the implementation of Python's for-loop control structure uses the iterator protocol as of release 2.1. It is also noted that Python provides iterators for the following builtin types: lists, tuples, dictionaries, strings, and files. This PEP proposes the addition of an iterator for the builtin type int (types.IntType). Such an iterator would simplify the coding of certain for-loops in Python. Specification Define an iterator for types.intType (i.e., the builtin type "int") that is returned from the builtin function "iter" when called with an instance of types.intType as the argument. The returned iterator has the following behavior: - Assume that object i is an instance of types.intType (the builtin type int) and that i > 0 - iter(i) returns an iterator object - said iterator object iterates through the sequence of ints 0,1,2,...,i-1 Example: iter(5) returns an iterator object that iterates through the sequence of ints 0,1,2,3,4 - if i <= 0, iter(i) returns an "empty" iterator, i.e., one that throws StopIteration upon the first call of its "next" method In other words, the conditions and semantics of said iterator is consistent with the conditions and semantics of the range() and xrange() functions. Note that the sequence 0,1,2,...,i-1 associated with the int i is considered "natural" in the context of Python programming because it is consistent with the builtin indexing protocol of sequences in Python. Python lists and tuples, for example, are indexed starting at 0 and ending at len(object)-1 (when using positive indices). In other words, such objects are indexed with the sequence 0,1,2,...,len(object)-1 Rationale A common programming idiom is to take a collection of objects and apply some operation to each item in the collection in some established sequential order. Python provides the "for in" looping control structure for handling this common idiom. Cases arise, however, where it is necessary (or more convenient) to access each item in an "indexed" collection by iterating through each index and accessing each item in the collection using the corresponding index. For example, one might have a two-dimensional "table" object where one requires the application of some operation to the first column of each row in the table. Depending on the implementation of the table it might not be possible to access first each row and then each column as individual objects. It might, rather, be possible to access a cell in the table using a row index and a column index. In such a case it is necessary to use an idiom where one iterates through a sequence of indices (indexes) in order to access the desired items in the table. (Note that the commonly used DefaultTableModel class in Java-Swing-Jython has this very protocol). Another common example is where one needs to process two or more collections in parallel. Another example is where one needs to access, say, every second item in a collection. There are many other examples where access to items in a collection is facilitated by a computation on an index thus necessitating access to the indices rather than direct access to the items themselves. Let's call this idiom the "indexed for-loop" idiom. Some programming languages provide builtin syntax for handling this idiom. In Python the common convention for implementing the indexed for-loop idiom is to use the builtin range() or xrange() function to generate a sequence of indices as in, for example: for rowcount in range(table.getRowCount()): print table.getValueAt(rowcount, 0) or for rowcount in xrange(table.getRowCount()): print table.getValueAt(rowcount, 0) From time to time there are discussions in the Python community about the indexed for-loop idiom. It is sometimes argued that the need for using the range() or xrange() function for this design idiom is: - Not obvious (to new-to-Python programmers), - Error prone (easy to forget, even for experienced Python programmers) - Confusing and distracting for those who feel compelled to understand the differences and recommended usage of xrange() vis-a-vis range() - Unwieldy, especially when combined with the len() function, i.e., xrange(len(sequence)) - Not as convenient as equivalent mechanisms in other languages, - Annoying, a "wart", etc. And from time to time proposals are put forth for ways in which Python could provide a better mechanism for this idiom. Recent examples include PEP 204, "Range Literals", and PEP 212, "Loop Counter Iteration". Most often, such proposal include changes to Python's syntax and other "heavyweight" changes. Part of the difficulty here is that advocating new syntax implies a comprehensive solution for "general indexing" that has to include aspects like: - starting index value - ending index value - step value - open intervals versus closed intervals versus half opened intervals Finding a new syntax that is comprehensive, simple, general, Pythonic, appealing to many, easy to implement, not in conflict with existing structures, not excessively overloading of existing structures, etc. has proven to be more difficult than one might anticipate. The proposal outlined in this PEP tries to address the problem by suggesting a simple "lightweight" solution that helps the most common case by using a proven mechanism that is already available (as of Python 2.1): namely, iterators. Because for-loops already use "iterator" protocol as of Python 2.1, adding an iterator for types.IntType as proposed in this PEP would enable by default the following shortcut for the indexed for-loop idiom: for rowcount in table.getRowCount(): print table.getValueAt(rowcount, 0) The following benefits for this approach vis-a-vis the current mechanism of using the range() or xrange() functions are claimed to be: - Simpler, - Less cluttered, - Focuses on the problem at hand without the need to resort to secondary implementation-oriented functions (range() and xrange()) And compared to other proposals for change: - Requires no new syntax - Requires no new keywords - Takes advantage of the new and well-established iterator mechanism And generally: - Is consistent with iterator-based "convenience" changes already included (as of Python 2.1) for other builtin types such as: lists, tuples, dictionaries, strings, and files. Preliminary discussion on the Python interest mailing list suggests a reasonable amount of initial support for this PEP (along with some dissents/issues noted below). Backwards Compatibility The proposed mechanism is generally backwards compatible as it calls for neither new syntax nor new keywords. All existing, valid Python programs should continue to work unmodified. However, this proposal is not perfectly backwards compatible in the sense that certain statements that are currently invalid would, under the current proposal, become valid. Tim Peters has pointed out two such examples: 1) The common case where one forgets to include range() or xrange(), for example: for rowcount in table.getRowCount(): print table.getValueAt(rowcount, 0) in Python 2.2 raises a TypeError exception. Under the current proposal, the above statement would be valid and would work as (presumably) intended. Presumably, this is a good thing. As noted by Tim, this is the common case of the "forgotten range" mistake (which one currently corrects by adding a call to range() or xrange()). 2) The (hopefully) very uncommon case where one makes a typing mistake when using tuple unpacking. For example: x, = 1 in Python 2.2 raises a TypeError exception. Under the current proposal, the above statement would be valid and would set x to 0. The PEP author has no data as to how common this typing error is nor how difficult it would be to catch such an error under the current proposal. He imagines that it does not occur frequently and that it would be relatively easy to correct should it happen. Issues: Based on some preliminary discussion on the Python interest mailing list, the following concerns have been voiced: - Is it obvious that iter(5) maps to the sequence 0,1,2,3,4? Response: Given, as noted above, that Python has a strong convention for indexing sequences starting at 0 and stopping at (inclusively) the index whose value is one less than the length of the sequence, it is argued that the proposed sequence is reasonably intuitive to a Python programmer while being useful and practical. - "in" (as in "for i in x") does not match standard English usage in this case. "up to" or something similar might be better. Response: Not everyone felt that matching standard English perfectly is a requirement. It is noted that "for:else:" doesn't match standard English very well either. And few are excited about adding a new keyword, especially just to get a somewhat better match to standard English usage. - Possible ambiguity for i in 10: print i might be mistaken for for i in (10,): print i Response: The predicted ambiguity was not readily apparent to several of the posters. - It would be better to add special new syntax such as: for i in 0..10: print i Response: There are other PEPs that take this approach[2][3]. - It would be better to reuse the ellipsis literal syntax (...) Response: Shares disadvantages of other proposals that require changes to the syntax. Needs more design to determine how it would handle the general case of start,stop,step, open/closed/half-closed intervals, etc. Needs a PEP. - It would be better to reuse the slicing literal syntax attached to the int class, e.g., int[0:10] Response: Same as previous response. In addition, design consideration needs to be given to what it would mean if one uses slicing syntax after some arbitrary class other than class int. Needs a PEP. - Might dissuade newbies from using the indexed for-loop idiom when the standard "for item in collection:" idiom is clearly better. Response: The standard idiom is so nice when "it fits" that it needs neither extra "carrot" nor "stick". On the other hand, one does notice cases of overuse/misuse of the standard idiom (due, most likely, to the awkwardness of the indexed for-loop idiom), as in: for item in sequence: print sequence.index(item) - Doesn't handle the general case of start,stop,step Response: use the existing range() or xrange() mechanisms. Or, see below. Extension If one wants to handle general indexing (start,stop,step) without having to resort to using the range() or xrange() functions then the following could be incorporated into the current proposal. Add an "iter" method (or use some other preferred name) to types.IntType with the following signature: def iter(start=0, step=1): This method would have the (hopefully) obvious semantics. Then one could do, for example: x = 100 for i in x.iter(start=1, step=2): print i Under this extension (for x bound to an int), for i in x: would be equivalent to for i in x.iter(): and to for i in x.iter(start=0, step=1): This extension is consistent with the generalization provided by the current mechanism for dictionaries whereby one can use: for k in d.iterkeys(): for v in d.itervalues(): for k,v in d.iteritems(): depending on one's needs, given that for i in d: has a meaning aimed at the most common and useful case (d.iterkeys()). Implementation An implementation is not available at this time and although the author is not qualified to comment on such he will, nonetheless, speculate that this might be straightforward and, hopefully, might consist of little more than setting the tp_iter slot in types.IntType to point to a simple iterator function that would be similar to -- or perhaps even a wrapper around -- the xrange() function. References [1] PEP 234, Iterators http://python.sourceforge.net/peps/pep-0234.html [2] PEP 204, Range Literals http://python.sourceforge.net/peps/pep-0204.html [3] PEP 212, Loop Counter Iteration http://python.sourceforge.net/peps/pep-0212.html Copyright This document has been placed in the public domain. From peterb at cortland.com Fri Nov 23 00:22:50 2001 From: peterb at cortland.com (Peter Bismuti) Date: Thu, 22 Nov 2001 21:22:50 -0800 Subject: Indenting with tabs vs spaces References: Message-ID: <3bfd3552$1@207.229.64.20> Be that as it may, I think what I have written is correct in general. "David Eppstein" wrote in message news:eppstein-41FDAD.19324621112001 at news.service.uci.edu... > In article , > "Peoter Veili" wrote: > > > Indenting with tabs can be done such that it will look the same on every > > editor that uses fixed-width fonts, meaning everything will line up > > correctly, it least in the sense that really matters. Here's an example of > > what I mean: > > > > > > > > function helloThere("hello", > > "there"){ > > } > > I viewed your message with fixed-width fonts, and it came out unaligned as > you see above. So I think your claim that "it will look the same on every > editor" is false, and it is safer to stick with spaces only. > -- > David Eppstein UC Irvine Dept. of Information & Computer Science > eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ > -- > http://mail.python.org/mailman/listinfo/python-list > From pzw1 at cor-no-spam-nell.edu Thu Nov 1 12:51:05 2001 From: pzw1 at cor-no-spam-nell.edu (Peter Wang) Date: Thu, 01 Nov 2001 12:51:05 -0500 Subject: verifying type of socket object? Message-ID: <+YrhO+rceV33qbXjWckIp8NUkWP4@4ax.com> in my code, i'd like to verify that i get passed a socket object. however, i'm having some trouble figuring out what exactly represents the "socket type". the main problem is that socket.socket() doesn't return instances of socket.SocketType: >>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> socket.SocketType >>> isinstance(x, socket.SocketType) 0 >>> x >>> isinstance(x, socket._socketobject) 1 >>> my question is, how can i achieve the effect of the last isinstance() call without having to touch an underscored member of the socket module? TIA, peter From core.lists.python at core-sdi.com Thu Nov 29 11:06:58 2001 From: core.lists.python at core-sdi.com (Gerardo Richarte) Date: Thu, 29 Nov 2001 13:06:58 -0300 Subject: doesNotUnderstand ? References: Message-ID: <3C065D22.13FBEDAB@corest.com> > `__getattr__` is your friend. thanks everybody... >>> -1/1000000000000000000000000000000000000000000000L -1L add as many zeros as you whis... I can undersrtand -1 >> 1000 = -1, but not -1/10000000L ... ??? Estas crazy Macaya!? Mathematic Bye! Richie --- for a personal reply use: Gerardo Richarte From tim.one at home.com Thu Nov 8 02:21:13 2001 From: tim.one at home.com (Tim Peters) Date: Thu, 8 Nov 2001 02:21:13 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message-ID: [Tim] > python-needs-a-transfinite-cardinal-type-ly y'rs - tim [Huaiyu Zhu] > Is there a way to bound the computational resources needed for > such beasts? I sure hope not! Half the point is to use the growing popularity of Python to force HW vendors to get off their butts and produce systems with transfinite memory and speed . > I would think a type of algebraic numbers would be much more useful than > transfinite cardinals, but to do it properly perhaps requires a whole > computational algebra package. If you're talking "useful", I'm not your bot. > On a related issue: How practical would the proposed rational type be > for serious computation considering that the results of simple > operations are likely to grow in size for both numerators and > denominators? All forms of computer arithmetic are rife with surprises, from bounded ints to the constructive reals, and all points between. It takes an expert to use rationals effectively for "serious computation" -- but then serious numeric computation of any kind requires an expert. Note, though, a commercially important counter-example: rationals barely grow at all when adding a gazillion "dollars and cents" kinds of inputs, as the denominator never exceeds 100 (or falls below it either, if rationals don't bother to reduce to lowest terms except once before output -- as recent experience suggests is actually best in practice, most of the time -- and, yes, you need an expert to know when skipping normalization is going to be a time/space disaster instead). > just-trying-to-keep-the-thread-alive-ly y'rs Good job! Hitler got mentioned only once . From bmc at bmc.pt Wed Nov 21 01:20:52 2001 From: bmc at bmc.pt (bmc) Date: Wed, 21 Nov 2001 06:20:52 -0000 Subject: Python Zope Job Portugal Message-ID: BMC Lda. (www.bmc.pt ) is looking for a motivated individual to join our our R & D group. Responsibilities include developing and deploying a CRM, virtual office, groupware and document management Web-based software. Ideal candidates have the following qualifications: Strong Python and Zope development skills BS or MS in Computer Science or Engineering 2-5 years experience in the software industry Experience deploying solutions at client sites Candidates should be skilled in the following areas: Python and C/C++ Programming Web and database development (HTML, ZOPE, PostgreSQL) Linux Administration (Mail, DNS, Firewall, VPN, CVS,) Must have strong software development skills in Linux environment Must demonstrate proficiency with scripting languages such as Python Must have DBMS experience including database schemas, SQL, and database programming. XML experience is a plus. Interested parties should submit their resume to bmc at bmc.pt Relocation assistance is available for this position. From anthony at interlink.com.au Wed Nov 7 20:23:30 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 08 Nov 2001 12:23:30 +1100 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message from Gareth.McCaughan@pobox.com (Gareth McCaughan) of "Thu, 08 Nov 2001 00:39:34 -0000." Message-ID: <200111080123.fA81NUm25667@mbuna.arbhome.com.au> >>> Gareth McCaughan wrote > > python-needs-a-transfinite-cardinal-type-ly y'rs - tim > > Mmm, that would be nice. > > >>> import cardinals > >>> a = cardinals.aleph(1) > >>> print a But what about jones = cardinals.biggles() jones.fetch('cushions') gilliam = cardinals.fang() gilliam.fetch('comfy_chair') Anthony -- Anthony Baxter It's never too late to have a happy childhood. From pzw1 at cor-no-spam-nell.edu Thu Nov 15 14:54:22 2001 From: pzw1 at cor-no-spam-nell.edu (Peter Wang) Date: Thu, 15 Nov 2001 14:54:22 -0500 Subject: what happened to Python Cryptography Toolkit? Message-ID: i find quite a few references to Andrew Kuchling's Python Cryptography Toolkit on the web, but all the links to actual sources/distributions are broken. also, there doesn't seem to be any mention of it past 1995... has it been supplanted by something else? all i want is to easily do RSA, preferrably in a platform-independent manner. (if platform dependence is unavoidable, unix is preferable.) TIA, peter From sasoft at gmx.de Wed Nov 14 15:02:11 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Wed, 14 Nov 2001 15:02:11 -0500 Subject: Shell commands from within a script In-Reply-To: ; from neil@cxchange.co.za on Wed, Nov 14, 2001 at 03:42:12PM +0200 References: Message-ID: <20011114150211.A8432@cruciatuz.de> On Wed, Nov 14, 2001 at 03:42:12PM +0200, Neil Fryer wrote: > I'm really new to python so if you could please let me know how to execute a > command like say, ftp, from within a script it really would be appreciated. > As I'm only about half way through my first Python tutorial. import os os.system('ftp') ... this executes ftp from within your script. have a closer look into the os module, there are many other interesting ways to use commands, pipes, fork()'s and so on. From cbbrowne at acm.org Fri Nov 16 14:47:22 2001 From: cbbrowne at acm.org (cbbrowne at acm.org) Date: Fri, 16 Nov 2001 19:47:22 GMT Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> <7xhervy3v9.fsf@ruckus.brouhaha.com> <4nofm2bzbm.fsf@rtp.ericsson.se> <87bsi2d9bc.fsf@orion.bln.pmsf.de> Message-ID: "Pierre R. Mai" writes: > When CMU CL was ported to x86 in the 90s, keeping up this partitioning > scheme would have resulted in very bad performance, given the relative > scarcity of general purpose registers on x86 machines, and the > resulting register pressure. For that reason CMU CL on x86 needed a > conservative GC, that could deal with unboxed/untagged values in > normal registers and the stack. That is where the divergence started. > Since most development on certain areas of CMU CL happened on x86 > during the 90s, CMU CL on x86 currently has a number of features that > haven't been (fully) ported to the other platforms, like e.g. > multi-processing and the generational aspects of the conservative GC > on x86. Interesting, and certainly not something one would _expect_ to see happen. > F'up to comp.lang.lisp set, since I don't think that further > discussion is that interesting to those that use Python the language > (and not Python the CMU CL compiler). Feel free to ignore it, if > I'm mistaken... Well, to use Python, the CMU CL compiler, as a compiler for Python, the language, would represent a strangely interesting application, and one I'd think tremendously likely _not_ to happen. That's probably regrettable; it would be very nice to see some of the developments in "Python, the compiler" applied more widely. And for the application to be "Python, the language" would be almost Pythonesque. (To take a third meaning :-).) -- (reverse (concatenate 'string "moc.enworbbc@" "sirhc")) http://www.cbbrowne.com/info/languages.html :FATAL ERROR -- ATTEMPT TO USE CANADIAN COINS From frederic.giacometti at arakne.com Tue Nov 6 10:06:40 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Tue, 06 Nov 2001 15:06:40 GMT Subject: C callbacks ? Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> Message-ID: <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> "Gordon McMillan" wrote in message news:Xns91515922BE028gmcmhypernetcom at 199.171.54.214... > John S. Yates, Jr. wrote: > > > On 5 Nov 2001 13:53:28 GMT, amk at localhost.debian.org (A.M. Kuchling) > > wrote: > But making Python *truly* stackless means getting rid of all recursions, > and that is an enormous task. If you don't do that, you've got a > language feature that doesn't work in some apparently random > set of circumstances. But how do you process callbacks to Python from C code (extensions or embeded python)? One has to return to C after executing the Python code, and than C has to return to Python after executing the remainer of its code... I see maintaining hybrid behavior (iterative / recursive calls to the interpreter, and 'recursion tolerance') as a requirement... FG From bbollenbach at home.com Sat Nov 17 10:35:16 2001 From: bbollenbach at home.com (Brad Bollenbach) Date: Sat, 17 Nov 2001 15:35:16 GMT Subject: Regular Expression Help Needed References: Message-ID: "David A McInnis" wrote in message news:mailman.1005960683.29958.python-list at python.org... > Ok, I am not very good at regular expressions, so any help is greatly > appreciated. > > Here is the situation. > > I have a database table that contains a text field. This text field may or > may not contain email addresses. I know how to read the content of field to Why "might" it not contain an email address? Specifically, what kind of data is in the column? What format? An HTML webpage, XML, etc.? Either way, you probably don't want to solve this via a regular expression: that takes too much effort to get right. If it's HTML, HTMLParser (in the htmllib module) makes the solution trivial. Hope that helps, Brad From oren-py-l at hishome.net Wed Nov 14 01:25:23 2001 From: oren-py-l at hishome.net (Oren Tirosh) Date: Wed, 14 Nov 2001 01:25:23 -0500 Subject: A file object is an iterator, not a container Message-ID: <20011114012523.A91112@hishome.net> I am currently working on a framework for dataflow-oriented programming. This framework makes it easy to create dataflows by connecting together sources, transformations and destinations. It makes extensive use of the new iterators and generator functions defined in Python 2.2. A first public release is expected soon. During the design I have encountered an inconsistency in the way Python uses iterators for files: Python pretends that an open file object is a container that can create iterators while in fact an open file object already *is* an iterator with a "nonstandard" protocol (readline instead of next). The real container is the file residing on the disk, not the open file object. To see the difference, try creating two iterators from one list and two iterators from one file. You can read the two list iterators independently but you can't read the two file iterators independently. My proposal is to make an open file object obey the iterator protocol: __iter__(): return self next() return next line raise StopIteration on EOF close file on EOF Is there any chance this could still make it to the final 2.2 release or would a thorough discussion of this proposal on the list take too long? A natural future extension of this idea would be to define an unopened file object. This object will truly act as a container because it is a factory for multiple, independent iterators of itself - open files with different file descriptors. >>> f=file('/etc/passwd' [,mode, buffering, etc] ) >>> f >>> i=iter(f) # i=f.open() is equivalent >>> j=iter(f) >>> i >>> i.fileno() 4 >>> j.fileno() 5 The open() method is an alias for an unopened file's __iter__() method. Note that a closed file is not the same as an unopened file: a closed file is an exhausted iterator, not a factory for new open files. There should also be a method to iterate over files with some fixed size chunk instead of by lines. The buffering argument to open() may be reused for this purpose or a new optional argument may be defined. Oren Tirosh From qrczak at knm.org.pl Tue Nov 20 07:53:57 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Tue, 20 Nov 2001 12:53:57 +0000 (UTC) Subject: Try block problem References: <9tcnls$42k$1@news1.ucsd.edu> Message-ID: Tue, 20 Nov 2001 05:37:41 -0600, Skip Montanaro pisze: > The thing that is perhaps slightly misleading is the use of the "try" > keyword to begin both constructs. There's really no "try" connotation to > try/finally. Maybe it's because try:except: would have to be used to simulate try:finally: if it wasn't available natively. In other words try:finally: is one of things which do something non-trivial with exceptions instead of silently propagating them up. In Haskell the equivalent of try:finally: is called bracket (it includes initialization). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From cheapmail at getresponse.com Sun Nov 4 15:48:58 2001 From: cheapmail at getresponse.com (E-Mailerrr) Date: Sun, 04 Nov 2001 15:48:58 -0500 Subject: Ñïèñêè E-Mail àäðåñîâ Ìíîãî è Íåäîðîãî ! Message-ID: ??????, (Cyrillic-1251 ) SUPER - ???????????! ???? E-mail ???????. 1 ??????? 300 ????? ??????? ? ???? ????????? ??????. ?????? - ????????????? ???????????? ? ???????????. ??? ?????? - ??? ?????-???? ???? ??????, ????? ?????? e-mail ??????. ?????? ?? "??????" ! ? ?????? ????? ??????? : ???????? ???? ????, ?? ??????? ?? ?????? ?????????? ??? ???? E-MAIL ???????, ? ???????, ?? ?????? ??????, ??? ??????? ! ! ! ?? ?? ?????????? ?????????, ?? ???? ??????? ?????? E-Mail ???????. ?????? ?????? ?? WebMoney, ??? E-Gold ? ????? ???????????? ?????? ?? ????????????! ?????? ????????, ???? ?? ? ???? ??????, ?? ? ??????? 2-? ???? - ????? ! ??? ?? ?????, ???? ? ???, ??? ??, ????????? ???????? ? ?.?. , ?? ???? ??????????? ??????????? ??????? ???? (?? ??????? ?? WebMoney ????? ????? ? ?????????? ???????, ? ????? ????????? ????? ??????? ????????? ???, ? ?.?. ???? ?? ?????? ???? ??????). ---------------------------- ?? ????????? ?????? ?????? ? ?? ????????? ?????? ?????. ????????, ???? ???-?? ?????? ???????? ? ???????? ???? ???? ?? ?????? ???????. ????? ?? e-mail : mlm_info2000 at yahoo.com ----------------------------- ??? ????? ??? ?????? ?? ????? ?? ???????, ??? ????????????? ???????? ??????????, ??????? ?????? ????????? ?? ???????? ??????. ??? ?? ?????, ???? ?? ???????, ?? ??? ??????? ?? ???????? ??????? ????????? ? ????? "????????". From spamtrap at magnetic-ink.dk Thu Nov 8 01:59:18 2001 From: spamtrap at magnetic-ink.dk (Klaus Alexander Seistrup) Date: Thu, 8 Nov 2001 07:59:18 +0100 Subject: Problem with httplib and POST References: Message-ID: <01b6b30b-d975-4ec1-a6f5-8e341dc13a3b@zigzag.magnetic-ink.dk> Ray Van Dolson wrote: > h.putrequest("POST", "/management/editdns.asp?Update=1&sld_nsrec_id=4444") > [???] > params = urllib.urlencode({'hostname': HOST_HERE, 'hostip': NEW_IP, 'B1': > 'Update DNS Record'}) Have you tried h.putrequest("POST", "/management/editdns.asp") [???] params = urllib.urlencode({'hostname': HOST_HERE, 'hostip': NEW_IP, 'B1': 'Update DNS Record', 'Update': '1', 'sld_nsrec_id': '4444'}) ? // Klaus -- ><>? vandag, m?re, altyd saam From stefff01 at wanadoo.fr Sun Nov 25 20:12:12 2001 From: stefff01 at wanadoo.fr (stefff) Date: Mon, 26 Nov 2001 02:12:12 +0100 Subject: lanching a "*.exe" from Python ? Message-ID: <9ts4o1$sd7$1@wanadoo.fr> Hello, I am a new python user and I would like to know if it is possible to launch an executable in python : ie I have a c compilled program (that I want run as fast as it possible) and I intend using python for GUI and I/O managing. And all my appologizes if it's in the tutorial ! Thank in advance for any clue. St?phane From peter at engcorp.com Tue Nov 27 22:37:43 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 27 Nov 2001 22:37:43 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> Message-ID: <3C045C07.BA7B3FE6@engcorp.com> Huaiyu Zhu wrote: > > So let me repeat it once and for all: > > Question: What should tab be default to in terms of other charactors, or > screen positions, or editor actions, or anything else that is not the tab > charactor? > > Answer: It shouldn't. Phew! I'm glad you finally settled that question... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From gdemmy at layton-graphics.com Sat Nov 17 16:15:22 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 17 Nov 2001 16:15:22 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: <3BF6C202.7EB544E0@alcyone.com> Message-ID: Erik Max Francis writes: > George Demmy wrote: > > > I do a bunch of list-oriented programming with a bunch of one-off > > programs. For a variety of reasons these lists tend to have a bit > > of cruft associated with them (I don't write it -- just process > > it!). So stuff like this shows up quite a bit: > > > > data = filter(lambda x: x, crufty_list) > > This doesn't even make sense to me. filter applies the function for > each element in the sequence, and returns a new list of only those > elements for which the function returned true. Why is using the > identity function for this purpose useful? > > If you really want to select the true sequence, then from a mathematical > standpoint what you want is operator.truth, not the identity function. > Obviously they do the same thing in this context, but they have > different meanings. (Or a None passed as the function would as well.) My understanding of Pythonic truth anything other than None, (), [], {}, '', and 0 is true. I don't know what mathematical truth is -- got a approachable reference for an interested non-mathematician? If Pythonic truth were to be redefined, e.g., to true and false objects, I'd conceed the point. As a matter of fact, that would make more sense to me -- I find and object with a value of 0 to be false a little disorienting... I guess it's guessability that's partially at issue. For map and filter None implies the identity function as part of the library specification. It's not true in other contexts where it *might* be true. E.g, apply(None, "my string") raises an exception whereas map(None, "my string") -> ['m', 'y', ' ', 's', 't', 'r', 'i', 'n', 'g'] filter(None, "my string") -> 'my string' That they do might be confusing if you didn't know the specific implication of passing None to these functions were. Conversely, if you buy into the do-the-map-thing using None, then you might be surprised that apply-nothing-to x blows up. > > There are, of course, other nifty things to do with identity, and I > > find it used all the time -- far more often than many Python > > built-ins. How prevalent is identity usage in the Python community? Is > > there anyone that would rather suffer hellfire and damnation that do > > something like this? > > There's nothing wrong with using an identity function in context (though > your claim that you use it more often than many builtins is strange, > since it explicitly doesn't do anything). I'm just curious what you're > doing such that the identity function pops up very frequently. It could > be there's a better way to get what you're going after. Not *so* strange, really. I work with some libraries that take multiple functions as arguments, and occasionally you don't want some of them to do anything, or you want whatever is passed to be passed on down the line. This crops up in some functions that iterate over dictionaries, does things with the keys and values, and returns a new dictionary with the results. All that being said, the frequency of identity *misuse* will diminish, since I was politely reminded that filter-or-map(None, list) is shorthand for filter-or-map(lambda x: x, sequence) I will almost certainly use the identity function explictly or implicitly more often than xrange, ord, unicode, et al., useful though these functions be. Cheers, G -- George Demmy From sheershion at mailexpire.com Thu Nov 8 21:21:18 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Fri, 09 Nov 2001 02:21:18 -0000 Subject: unicode strings?! References: <3bea7e5f$0$36516$5039e797@newsreader01.highway.telekom.at> Message-ID: Philipp Schmid wrote: > hi, > > can anyone help me with this little example program? > > #!/usr/bin/python2 > > lala = "aslfjaslkjf lasjflasjkfals faslkfj\ > aljfa?ljfkal?fjal? jflajf" > print lala > lala = u'%s' % lala > print lala Personally I think that anyone who writes programs like that is beyond help. Try writing lyrics instead. ;-) Robert Amesz -- Sorry, couldn't resist. From db3l at fitlinxx.com Mon Nov 5 22:41:34 2001 From: db3l at fitlinxx.com (David Bolen) Date: 05 Nov 2001 22:41:34 -0500 Subject: How would I write this perl script in python? References: Message-ID: David Bolen writes: (following up to myself) > import re, fileinput > > for line in fileinput.input(): > > match = re.search(r'^(\w+\s+)(\-*\d+\.\d+)(\s+)(\-*\d+\.\d+)$',line) > if match: > val = match.group(2) - 0.775 > print "%s%s%s%s" % (match.group(1),val, > match.group(3),match.group(4)) > else: > print Nick's similar followup showed a bug in my sample (knew I should have simulated some input :-)). You need to convert match.group(2) to a floating point value for the calculation - e.g., "float(match.group(2))" -- -- 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 smoky at amexol.net Wed Nov 21 17:20:53 2001 From: smoky at amexol.net (Michael Morgan) Date: Wed, 21 Nov 2001 14:20:53 -0800 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> Message-ID: <9thaol$opg$1@newstest.laserlink.net> I ran across this link though I have not used it. I'd be inclined to agree with the other response that the syntax is just too tough. http://oomadness.tuxfamily.org/p-genetic.php Good Luck! "J.Jacob" wrote in message news:13285ea2.0111210754.13974f4d at posting.google.com... > Does anyone have code that produces correct but random Python code ? > This would be useful for a genetic programming (GP) test we want to > do. > > Suppose you need a function that accepts a list (of unknown length and > containing values of unknown type) and outputs a list of integer > values with length outputlength. > The function you are looking for would look like: > > def myFunction( inputlist, outputlength ): > # black box code here, building outputlist > return outputlist > > But you have no idea how to code the function, you only know it > accepts a list and outputs a list of integers. > You also have a way to test if the function does what you want, in > some environment script. For example if you call the function with > myFunction([3, 4], 1) you want it to return [12], being a list > containing the product of the variables in inputlist. > Suppose you cannot code the black box part yourself, now you would > like a system that does if for you. With GP you can do things like > this, it has been done before in lisp and even in C and Python seems > very suitable for it. > > Before we are going to try to implement something we would like to > know if somebody else has been doing this already. We did search > internet and there are tons of GP links but we did not find a GP > example with Python. From nomad*** at ***freemail.absa.co.za Mon Nov 5 06:52:22 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Mon, 05 Nov 2001 13:52:22 +0200 Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> <7xitcp8wb1.fsf@ruckus.brouhaha.com> Message-ID: On 05 Nov 2001 00:18:58 -0800, Paul Rubin wrote: >> 2. Another thing when doing coding if i am facing problem i tend to stop or >> rather wanted to learn everything in a day or as fast as i could which i >> believe is a wrong approach. Is there anyone kind enough to give me some >> direction in order i could code something useful. > >There's nothing wrong with wanting to learn fast. In fact you will learn Python fast - especially if yo have some programming experience. It is easily possible to learn to code in python in a pretty short time. The distinction you need to make is between learning how to code python, and how to code in python _and_ all the library modules, there is a difference between the basic language syntax and structure (quick to pickup), and the full standard implementation of the language (vast and powerful, but still easy enough to pick up _as you go along_). HTH -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From tfb+google at tfeb.org Thu Nov 15 06:24:18 2001 From: tfb+google at tfeb.org (Tim Bradshaw) Date: 15 Nov 2001 03:24:18 -0800 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> <9srbs8$pur$1@slb2.atl.mindspring.net> Message-ID: > > Tim's point was that standardizing a library is a complicated and > expensive process. My point is that the Python library > (standardized or not) works with quite different runtimes. Why > aren't there similarly widely used though non-standard libraries > for CL for "doing stuff like internet programming"? [Paul Rubin] > I think the answer has to do with how the compatibility is ensured. My guess is that for Python it works something like this: there is a canonical implementation. Libraries work in that implementation. Other implementators work to make sure that the libraries work in their implementations too. Maybe there is some common documentation, but it probably ultimately comes down to what the canonical implementation does. This is just like Unix in the early days or C, or pretty much anything really. It works pretty well as far as it goes. It means that it's really easy to do stuff like sockets or something, because you just do what the canonical implementation does. Now imagine the canonical implementation is owned by Microsoft. Suddenly it has been changed so it's really hard to make it work on any platform other than Windows. Oh, and they've hired 58 people, doubled the size of the language and specified a couple of APIs as part of it with 4000 ill-defined entrypoints each. There is now only one realistic implementation, because no-one else can keep up. 2 years later they quietly drop the language in favour of visual basic. Perhaps what you want at this point is a really carefully defined, implementor-neutral standard. > For example, back in the Perl4 days when CGI programming first > became hot, just about everyone used cgi-lib.pl even though it > wasn't part of the standard Perl library, and this was pre-CPAN. This is a completely different thing. Perl is single-implementation, standards are not relevent. --tim From prabhu at aero.iitm.ernet.in Fri Nov 16 02:45:09 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Fri, 16 Nov 2001 13:15:09 +0530 Subject: Scientific Libraries in Python In-Reply-To: <9t1pfj$k1s$1@peabody.colorado.edu> References: <9t1iqq$es0$2@peabody.colorado.edu> <3BF45CAF.9983E26A@home.net> <9t1pfj$k1s$1@peabody.colorado.edu> Message-ID: <15348.50181.739124.996436@monster.linux.in> >>>>> "FP" == fperez528 writes: FP> Chris Barker wrote: >> Nice Summary of the state of the art: I'll second that. :) Here is my take. >>> Visualization: >> plot(x,y) >> >> but you can also get access to all the properties of the plot, >> so that you can customise things as much as you like. I think >> all plots are created by a set of only three types of >> primitives, a line, a patch (surface), and a text object. It >> really works pretty well. I also believe that all plots are 3-d >> with 2-d plots being a special casse, where z=0 everywhere, and >> the view is from the top. IMHO, its not a great idea to make the same package deal with 2d and 3d. The needs and requirements are simply not the same. I agree that we need a plotting utility for both 2d and 3d. AFAIK, the scipy plt and gplt interfaces provide a good start for 2d plots. http://www.scipy.org/site_content/tutorials/plot_tutorial GracePlot is also very nice but as you say isnt tied close enough to grace. So what we need is one tool that does 2d plots and provides access to low level stuff (if you want) but also exposes a nice high level and GUI Interface. We need a similar tool for 3d. Writing a wrapper that combines these two is not hard but putting them both in the same package is a pain on both sides -- the 2d person has to worry about 3d and vice versa. So long as both 2d and 3d plots are scriptable and useable there really is not a need to tie them all together very tightly. FP> I didn't mention graphite b/c it seems dead. I know Mayavi is FP> active, it's based on a high caliber underlying toolkit (vtk) FP> and it looks very nice. I think the underlying toolkit *has* FP> to be written in C/C++. Volume rendering for large datasets is [snip] FP> I tend to think mayavi has the right approach: OpenGl is too FP> low-level. The vtk people have already done a lot of *very FP> hard* work. It would be silly to ignore that, IMO. And from a FP> recent post from mayavi's author, he seems to be working on FP> providing full python access to the system (while also FP> offering the gui). I don't want to seem biased, I don't even FP> know the mayavi author and have only superficially looked at FP> the stuff. I just have a hunch that he's going in the right FP> direction, and that (perhaps with some modifications) that's FP> the best bet for the graphical part at this point. Thanks for all the positive comments and attention! I'm very glad that MayaVi features in your Python for scientific tools so prominently. :) Here are a few things I'd like to bring to your attention about MayaVi: (0) MayaVi will not do simple x vs y plots and stuff. While it does support 2d data for contouring, streamlines, scalar/vector plots etc. its simply not made for the things that grace does so well like draw this line with these ticks, stack 4 graphs here, put this label here, that legend there, etc. etc. (1) The MayaVi CVS code is scriptable and is pending a release, I'm still stuck on the web pages etc. Yes, its scriptable and provides access to the internals but the internals are not so clean. This is because it was not designed for scriptability and this feature is new. Cleaning up the interface and making improvements is in my TODO and hopefully will be seen in future releases. (2) The biggest problem right now is that almost all of the MayaVi stuff is pretty much a one man show currently. I have to write the code, write the docs, answer questions, make the web pages, make the announcements, basically do *everything*. I do receive very useful patches and improvments from folks but I still have to do way too much. To top it all VTK is a beast and not at all easy to get installed. On a PIII 450 m/c its easily a 2+ hour build. To make it easier to install I made rpms a couple of years back but the new VTK 4.0 tree has changed many things. I also made experimental debs and Maitland Bottoms is packaging VTK debs for the next Debian release. Mayavi needs VTK to run and making VTK easier to install is an important goal but one for which I am running out of time. This whole MayaVi, VTK deal is simply my spare time project to give back to the OSS community. It is now taking up alarming amounts of my time. I am supposed to be doing my PhD in Aerospace Eng. and need to get back to serious research. Apart from all this I also have other interests. In short, I need HELP! Its pretty much impossible for me to keep up with my current schedule. It would be nice if someone could atleast take care of the web pages and documentation. It would be truly wonderful if I had more developers to help. I agree that finding a person with a good knowledge of Python, Tkinter and VTK might be hard but even if someone who is even good at one of these joins the project and gives it a good shot I'll be very happy. Of course the person has to be sincerely interested in visualization and MayaVi. I obviously don't want someone to make a mess of things and give me any more work. :) (3) Due to the above, after the next release, I'm not going to be very active with MayaVi for atleast a couple of months. :( Its not that the project is going to die, but if I dont do this I run the risk of dying. ;) Since MayaVi seems to be so well received by the community I hope someone decides to seriously help with its development. :) If that does not happen the progress will definitely be slow since it will be limited by my spare time. FP> Well, let's keep it going. I don't like cross-posting and FP> don't really know the Numeric and SciPy people, but if someone FP> knows them and is willing to drop them a reference of this FP> discussion it might be a good idea to hear what they think. Yes, I know Eric (from SciPy) well. He usually does track c.l.py but is busy. Have told him about this thread and plan to keep him posted. Travis Oliphant also seems to be looking at this thread. So we atleast have the scipy folks attention. I dont know if Konrad Hinsen is following this though. prabhu From igor.stroh at wohnheim.uni-ulm.de Mon Nov 5 17:14:29 2001 From: igor.stroh at wohnheim.uni-ulm.de (Igor Stroh) Date: Mon, 05 Nov 2001 23:14:29 +0100 Subject: PDF->Text converter/extractor References: <3be6fa21$1@sol.wohnheim.uni-ulm.de> <3be70a38$0$15115$626a54ce@news.free.fr> Message-ID: <3be70fb6$1@sol.wohnheim.uni-ulm.de> On Mon, 05 Nov 2001 22:52:57 +0100, "Bruno Li?nard" wrote: > I had written a script some time ago to extract directly from PDF file, > it's quite easy . As I had a very large volume of text to extract (some > giga of text), I now use PDFTOTEXT which comes with XPDF. I slighly > modify for my needs. If you are interested, I will look for the script > in my archives I'd greatly appreciate it :) See, I can't use pdftotext since I have several thousands of PDFs to be processed in a short amount of time... I think invoking pdftotext for each file would be pretty slow... by the way, the pdf files are _not_ in the filesystem, the whole stuff is located in a DB (ZopeDB), so I have some kind of data objects rather then real files... From theSpinningSpider at HotMail.Com Thu Nov 22 01:17:46 2001 From: theSpinningSpider at HotMail.Com (the Spinning Spider) Date: Thu, 22 Nov 2001 06:17:46 -0000 Subject: PHP vs. Python/comp.lang.php? Message-ID: <9tia10$43o$1@dahlia.singnet.com.sg> I'm finding learning Java is quite a tough challenge, like wading through a swamp. So I'm exploring PHP and Python as possible alternatives. I notice there doesn't seem to be much mention about PHP by Python people whenever they mention other languages, e.g.,see http://www.python.org/doc/Comparisons.html. Or is it because PHP is incomparable against Python? Could it be the news servers I have access to, or is there no comp.lang.php newsgroup? Is PHP too insignificant? Will Python be too intellectually challenging, like Java? From mgerrans at ix.netcom.com Wed Nov 28 17:50:39 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Wed, 28 Nov 2001 14:50:39 -0800 Subject: Database in a simple ascii file References: Message-ID: <9u3ppp$ci$1@nntp9.atl.mindspring.net> Well, one of the nice things about Python, is that it is so easy to create a little experiment to test the performance of such a scenario: import time,sys def createData( filename, itemCount ): f = open(filename,'w') for i in range(itemCount): f.write( '%06d This is item number %d of %d.\n' % (i, i, itemCount) ) f.close() def getData( filename ): data = {} lines = open(filename).readlines() for line in lines: try: data[line[:line.find(' ')]] = line[line.find(' '):] except: print 'Ignored malformed data line:',line return data def main(): N = 100000 filename = 'test.data' if '/createdata' in sys.argv: print 'Creating',filename,'with',N,'items...' createData( filename, N ) print '...Done! ' print 'Reading in data from',filename,'...' start = time.time() data = getData( filename ) print '...Done! That took ',time.time()-start,' seconds.' start = time.time() value = data["000123"] print 'It took', time.time()-start,' seconds to find this value:',value if __name__ == "__main__": main() This same idea could be customized for whatever key type you have (maybe don't want it to be a string) and you may not want the space-separator included in the value, etc. Anyway, with a the above setup, a collection of 100,000 items creates a file just under 4.5 MB. On my non-state-of-the-art system, it takes just over 2 seconds to load the file in and accessing elements is very quick once it is loaded. - mfg From root at rainerdeyke.com Wed Nov 28 23:54:52 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 29 Nov 2001 04:54:52 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C045C07.BA7B3FE6@engcorp.com> <3C05AE56.E2261313@engcorp.com> Message-ID: "Peter Hansen" wrote in message news:3C05AE56.E2261313 at engcorp.com... > Huaiyu Zhu wrote: > > Peter Hansen wrote: > > >Phew! I'm glad you finally settled that question... > > > > The whole quoted paragraph was meant to be a quote instead of a statement. > > But this thread is full of _interesting_ interpretations anyway. > > Sorry, I think I was too subtle there. What I meant was: > "I'm tired of this conversation. I'm leaving." You can run but you can't hide! What's up with that saying anyway? Is hiding more difficult than running? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From hamish_lawson at yahoo.co.uk Wed Nov 14 11:37:28 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 14 Nov 2001 08:37:28 -0800 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> Message-ID: <915a998f.0111140837.6afa5efc@posting.google.com> Laura Creighton wrote: > One defect that most GUI books I am aware of suffer from is that they > are written almost exclusively from the point of view of providing > ways for users to provide _input_ to your program ... And then, on > your first job, you have to write code that handles real-time updates I agree that it would be a very good idea to show how the different GUI toolkits handle real-time updating, as I suspect that this ability is often a significant factor in a developer's decision to employ a GUI toolkit for a cross-platform application over the universal-client claims of a web browser. Hamish Lawson From bhayes at advaoptical.de Tue Nov 13 10:23:08 2001 From: bhayes at advaoptical.de (bernard) Date: Tue, 13 Nov 2001 16:23:08 +0100 Subject: wxPython & asynchronous i/o Message-ID: <9srhiv$uih$1@rhodos.FTA-Berlin.de> I'm thinking of using wxPython in an app that requires the use of sockets. Is there any way to handle socket events via the wxPython mainloop or to use a select loop to 'implement' the wxPython mainloop - or am I on the wrong track altogether ? Any help welcome thanks - bernard From jgardn at alumni.washington.edu Tue Nov 13 08:11:33 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Tue, 13 Nov 2001 22:11:33 +0900 Subject: client server, c files In-Reply-To: References: <01111302002607.00632@linux> <01111309323600.00630@linux> Message-ID: <01111322113302.00631@linux> Benoit Cerrina wrote: > Looking at Jonathan Gardner python module I wondered: This may be a good > time to ask why is there a if_xcmdsrv.c and no if_w32cmdsrv.c with all the > client server code fow windows folded in os_mswin.c? > Benoit Simple - I don't have a windows box. This was written a couple of days ago, so it is bleeding edge, and probably hemmorhaging due to the fact I am new to this. Would you like to do it? I'm putting the stuff up at sourceforge for anyone to play with. Open Source is the way to go, eh? The codebase for the module is heavily dependent on X11. The one for windows will be entirely different because it would have to use Win32. Jonathan From printers at sendme.cz Wed Nov 28 16:56:20 2001 From: printers at sendme.cz (A) Date: Wed, 28 Nov 2001 22:56:20 +0100 Subject: KOMODO not working properly Message-ID: <3C056B94.15574.247DE4@localhost> Does anyone use KOMODO by ActiveState to write programs together with Python and particularly with wxPython? What experience do you have? It does not work properly for me. Thanks for reply Ladislav From fperez528 at yahoo.com Mon Nov 26 06:24:40 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 10:52:40 +2328 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: <9u0juj$2ng$1@peabody.colorado.edu> Hans Nowak wrote: > Ursus Horibilis wrote: >> >> Is there a way to force the Python run time system to ignore >> integer overflows? I was trying to write a 32-bit Linear >> Congruential Pseudo Random Number Generator > > Use longs: Not sure if that will work for him: longs are precisely 'long', and he may need the 32-bitness of the ints (it is a 32-bit LCPRNG, after all). Also, unless this is just an academic exercise, speed may be critical. For real world use, speed *is* critical in RNGs. Longs are dog slow. Cheers, f From tim at vegeta.ath.cx Sat Nov 10 22:47:19 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sun, 11 Nov 2001 03:47:19 GMT Subject: IsPython really O-O? References: Message-ID: graced us by uttering: > A Smalltalk guru in our organization looked at Python last weekend (after I > had made a big scene saying that it may be a solution to some of our > cross-platform issues) and came away saying that it was no more > object-oriented than Java. Well, if he didn't think Java was OO, he shouldn't bothered looking at Python. Besides, no matter how brilliant the programmer, in my experience, a Smalltalker will never acknowledge anything except Smalltalk as an OOP. Don't waste your breath. =) (For the record, I was very impressed with Smalltalk and very much enjoyed using it. I like it, but it wasn't the ideal solution to the problem I had; of course, neither is Python all the time...) > (I thought the ZODB business looked great). > Is my friend right? Is Python not "really" appropriate for > true O-O applications, A majority of people on _this_ NG will tell you Python works quite well for large OO solutions. A major problem "pure" or "true" OO advocates have with Python et al. is data hiding. Encapsulation (at least in the Python-intended sense) is implemented, but with enough hacking, a coder _could_ access an object's private data at runtime. This is a serious offense to many OO radicals, esp. Smalltalkers. OTOH, Python implements a Smalltalk feature: that of an object's _class_ being a type of _object_ as well. (Perl does _not_ do this; Perl "packages" are simply namespaces adhocked into a var.) I have no wish to draw this out, merely to bring some (hopefully) unbiased data to the discussion. If you think Python might help you, and you can take it for a test drive, try it. _Then_ decide. HTH Tim Hammerquist -- Do "grep UTF toke.c" and all will become clear. (Or as clear as anything ever is in toke.c.) -- Larry Wall in <199909091918.MAA15218 at kiev.wall.org> From phd at phd.pp.ru Fri Nov 30 11:25:33 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 30 Nov 2001 19:25:33 +0300 Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: ; from sdm7g@Virginia.EDU on Fri, Nov 30, 2001 at 11:04:08AM -0500 References: <20011130154407.S27931@phd.pp.ru> Message-ID: <20011130192533.A809@phd.pp.ru> On Fri, Nov 30, 2001 at 11:04:08AM -0500, Steven D. Majewski wrote: > > > Jonathan Gardner wrote, in part: > > > > They'd have to be [young]. I can't seem to find a place to get paid to work in > > > > Python yet. I can't imagine a guy with 3 kids trying to make a living > > > > by programming python unless he is the rare guy that has a job in it. > > > > I am 34 yo, with exactly 3 children. For more than 5 years I earn living > > by Web programing using Python and ONLY Python (I mean Python as a > > programming language; of course I use SQL, write JavaScript, but not Perl, > > for example.) > > I'm 49, omnivorous, married, with 3 children, 2 dogs and 1 cat, > programming mostly in Python, C and Lisp, with a little dabbling > in Java, C++ and Objective-C. And all those youngsters I met at > the very first Python workshop are all about 10 years older now. :))) I am sure one does not need to be a little boy to be a good programmer. (I am pretty sure it is other way around - those youngsters need to have a good learning before doing Real Job :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From root at rainerdeyke.com Fri Nov 9 09:08:11 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 09 Nov 2001 14:08:11 GMT Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: "Luigi Ballabio" wrote in message news:mailman.1005305487.25887.python-list at python.org... > This said, while it makes sense in english to say "do this for every line > IN this file", it just doesn't sound right to me to say "do this for every > number IN 10"---even though I've been once familiar with the definitions of > the set of all integers. I'd rather say "for every number UP TO 10" but > that would mean introducing a new keyword which I'm not going to suggest, > not me, sir. I consider that a fairly weak argument. Programming languages should be simple, internally consistent, fairly easy to learn, well defined, and able to express programs with minimum redundacy. English is none of these, so English should not be used a basis for creating a programming language. As an example, the for-else construct in Python is a good language construct, even if it has no equivalent in English. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tdelaney at avaya.com Thu Nov 29 22:16:29 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 30 Nov 2001 14:16:29 +1100 Subject: What's the value of "None" between 2.1.1 and 1.5.2 Message-ID: > From: ozonehole2k at yahoo.com [mailto:ozonehole2k at yahoo.com] > > In the new machine: > Python 2.1.1 (#1, Nov 11 2001, 18:19:24) > [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> a=[3,4,5,7,None,0.2,-4] > >>> print min(a) > None > >>> print max(a) > 7 > > Python 1.5.2 (#1, Sep 30 2000, 18:08:36) [GCC 2.95.3 19991030 > (prerelease)] on linux-i386 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> a=[3,4,5,7,None,0.2,-4] > >>> print min(a) > -4 > >>> print max(a) > None > >>> > > > It seems to me that "None" means -Inf in 2.2.1 but means "Inf" in > 1.5.2. Why do the Python guys change this assumption? In my > calculations, I use "None" to indicate very large estimation error. > Is there any formal symbol for this? I don't really want to fix this > type of bug again whenever Python upgrades.... Your assumptions are wrong. You should not assume - you should use the reference. Instances of different types/classes will compare in an arbitrary (but consistent) order (assuming they can compare at all). The order of None compared to other types changed between releases. It is allowed to do this. You cannot rely on the comparison order of different types unless the types specifically support comparing with each other. Tim Delaney From max at alcyone.com Thu Nov 8 13:12:30 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 08 Nov 2001 10:12:30 -0800 Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> Message-ID: <3BEACB0E.DCB6E4C6@alcyone.com> Carsten Gaebler wrote: > >>> complex('1', '1') > (1+0j) > >>> > > If complex() allows stings as arguments (like float()), what's > happened to the imaginary part? It works as expected in Python 2.1.1, so I'd say it's just a bug. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From eppstein at ics.uci.edu Wed Nov 14 19:11:06 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 14 Nov 2001 16:11:06 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: In article , James_Althoff at i2.com wrote: > If not 3), then there is the issue of having to do an extra computation for > the common case of indexing a sequence as in, e.g., > > for i in 0 .. len(sequence)-1: This is very common in C, but is it so common in Python? Isn't it usually more idiomatic to do for item in sequence ? -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From Dlal at btinternet.com Fri Nov 16 09:01:45 2001 From: Dlal at btinternet.com (DL) Date: Fri, 16 Nov 2001 14:01:45 -0000 Subject: OT:This group archived? Message-ID: <9t367u$kg6$1@neptunium.btinternet.com> Hi all, just a quick question from someone new to Python. Is this group archived anywhere to save me bothering everyone with questions which have been asked hundreds of times. Cheers, Derek. From max at alcyone.com Tue Nov 6 13:34:20 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 06 Nov 2001 10:34:20 -0800 Subject: split(None) References: <9s98o6$ilj$1@isp-m-srv06.izb.net> Message-ID: <3BE82D2C.88C8D928@alcyone.com> Oliver Fromme wrote: > So I thought that foo.split() and foo.split(None) should > return the same result. However: > > >>> "foo bar baz".split() > ['foo', 'bar', 'baz'] > > >>> "foo bar baz".split(None) > ['foo bar baz'] These behave identically in Python 2.1.1. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From anderson at hp.com Thu Nov 29 17:18:32 2001 From: anderson at hp.com (Bill Anderson) Date: Thu, 29 Nov 2001 15:18:32 -0700 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> Message-ID: <20011129.151831.971899228.1845@hp.com> In article , "Suchandra Thapa" wrote in part: ... >>Furthermore PHP kind of forces you to write web-apps in one way with >>presentation and logic mixed. Also when your web-apps can do all the >>standard fare that is the staple of PHP you will suddenly need some >>feature that's not available in PHP. Then it is much easier to use the >>Python standard library to roll your own solution. > > Actually, there are template based packages for php, and it isn't > too difficult to create a new template handling class if you don't like > the existing ones. To be fairly, a standard python cgi will also force > you to mix presentation and logic since all your html will be in print > or stdout.write statements inside your script. Not true. There are likewise a number of templating packages for Python that allowing you to "keep 'em separated". Bill From m.faassen at vet.uu.nl Thu Nov 8 17:18:32 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 8 Nov 2001 22:18:32 GMT Subject: Underscore data hiding (was python development practices?) References: Message-ID: <9sf0bo$c4u$1@newshost.accu.uu.nl> Cliff Wells wrote: > On Friday 02 November 2001 11:05, Tim Peters wrote: >> Guido didn't think so (and every complaint ever made about it was made at >> at least once before it was implemented, so the odds of a compelling new >> argument are approximately nil). > My cat doesn't like it and refuses to switch from Perl until it's fixed > (Perl's syntax is friendly to the fingerless - he can write a valid Perl > script by simply walking across the keyboard). The local cat here, Torvald, insists on programming in DTML only. *shudder* Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From tjg at craigelachie.org Tue Nov 27 12:36:30 2001 From: tjg at craigelachie.org (Timothy Grant) Date: 27 Nov 2001 09:36:30 -0800 Subject: Non-indented python Message-ID: <1006882590.938.140.camel@reepicheep> Tim Peters has been studiously avoiding this war. However, if you look carefully at your Python installation you will in all likelihood find a cool little (actually it's not so little) programme written by the Tim-bot to do just this. On Tue, 2001-11-27 at 07:23, Nicholas FitzRoy-Dale wrote: > On 27 Nov, Terry Reedy wrote: > > "Marcin 'Qrczak' Kowalczyk" wrote in message > > news:slrna071tg.isc.qrczak at qrnik.zagroda... > > >> What should a Python interpreter do with this? > >> > >> if 0: > >> print "0" > >> print "1" > > > > Raise SyntaxError. > > > > Seriously. > > > > This would be consistent with general philosophy of not guessing in > > the face of ambiguity. > > Insofar as my opinion makes any difference, I'd like to second that > suggestion. The huge tab/space war above notwithstanding, I think that > regardless of your preference, any file with mixed space/tab indenting > is inherently evil and will only cause pain. I was aimlessly toying with > the idea of writing a little utility to detect mixed space/tab indents > in files and setting it to run whenever I do a CVS checkout or update, > but I always welcome the opportunity to banish devilry on a more > far-reaching scale. :) > > -- > - Nicholas FitzRoy-Dale > http://www.lardcave.net > > Feel my three-toed wrath! > - Catie -- Stand Fast, tjg. Timothy Grant -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From johnroth at ameritech.net Tue Nov 6 17:37:50 2001 From: johnroth at ameritech.net (John Roth) Date: Tue, 6 Nov 2001 14:37:50 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: "Tim Peters" wrote in message news:mailman.1005007807.32030.python-list at python.org... > [John Roth] > > The basic sign rules for multiplication are so clear that I don't > > really need to repeat them here. If division is the inverse of > > multiplication, then the sign rules follow directly. Any definition > > of division which does not do that isn't an inverse of multiplication, > > but some other operation masquerading under the same name. > > Are you serious? In a world where 3/4 == 0, how long could any programmer > survive believing that integer division and multiplcation are "inverses"? > The antecedent is dead on arrival. Integer division is not an inverse of integer multiplication, therefore the proposed counterexample fails. > > This might be a much more useful operation in practice, but > > it is confusing to someone who expects the system to behave > > the way he was taught in grammer school. > > I can enumerate a hundred ways in which computer arithmetic confuses > beginners, and I bet you could too. It even confuses beginners that, say, > 4.00 - 1.00 gets displayed as 3 or 3. instead of 3.00. Well, yes, but that isn't (pure) mathematics. It's a particular implementation. > > In other words, (-i)/j should -(i/j). > > Newbies "know" too that if i < 0 and j > 0, then i/j < 0 (isn't that one of > the "basic sign rules" you're defending?). But-- oops! --*that* one happens > to be true of floor division, but not of truncating division. Integer > division (whether truncating, flooring, rounding, or what have you) is an > information-losing process, and the loss of information kills identities > without prejudice. See my comment above. I'm not refering to integer division. We've been around that circuit too many times to make it really appealing to do so again. I'm refering to either rational (in the future) or real division, in both of which division is supposed to be the exact inverse of multiplication. John Roth From graz at mindless.com Sun Nov 4 15:54:40 2001 From: graz at mindless.com (Graham Ashton) Date: Sun, 04 Nov 2001 20:54:40 GMT Subject: python-gtk documentation References: <9rvbch$4l1$1@antares.worldonline.fr> Message-ID: In article <9rvbch$4l1$1 at antares.worldonline.fr>, "Jerome" wrote: > Hello > > Where can I find a gtk-python documentation ?? I need widget and > function descriptions ... This is the only stuff I know about: http://www.gnome.org/~james/pygtk-docs/ When read/searched in conjunction with the gtk.py documentation (with pydoc) and the GTK+ reference stuff (for C) it's not too difficult to piece things together. There's a mailing list too: http://www.daa.com.au/mailman/listinfo/pygtk - Graham From chris.gonnerman at newcenturycomputers.net Sun Nov 4 09:44:07 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sun, 4 Nov 2001 08:44:07 -0600 Subject: bg and fg References: <20011104112551.A14309@cruciatuz.de> Message-ID: <001101c1653f$3f9a33e0$0101010a@local> ----- Original Message ----- From: "Stefan Antoni" > - i am using linux > - i got a script that takes the time.ctime string and > compares it with a set time. if the time is the same > as the set time, it will do something. > - the script is a non-gui application (see bottom of this mail) > > question: > 1. how can i move my process in the background after i > started it (like: myscript & -> but automatically). if os.fork(): sys.exit(0) ... is the basic code (full daemon mode takes a bit more work). > 2. how do i move it back in the foreground when the > action for the set time is performed? You can't. The shell does it by keeping a "grip" on the process, and so it can return it to the foreground when told to. AFAIK you can't tell the shell to do this programmatically. From hfoffani at yahoo.com Mon Nov 26 07:02:51 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Mon, 26 Nov 2001 13:02:51 +0100 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> <3C014329.7B828AE8@alcyone.com> <3c014926.1812080@news> Message-ID: <20011126070333.456$KR@news.newsreader.com> "Fred Flintsone" <__x__ll at yahoo.com> escribi?: > > I did download the 2.1.1 but noticed afterwards a suggestion for me to > d/l "ActiveState," which is a larger d/l, so I'm assuming it has > important goodies bundled in it. > Having full text search on the documentations is important for newbies as they usually don't know where to find the explanation they need. The ActiveState package has many more things included that you may or may not use or need. It includes the Python docs in MS html help format. If the standard distribution you downloaded is enough for you so far, you may found the "Python Shelf" (a collection of python related docs) useful. Check it out at http://www.orgmf.com.ar/condor/pytstuff.html Regards, -Hernan From jdunnett at uoguelph.ca Fri Nov 16 10:26:40 2001 From: jdunnett at uoguelph.ca (Jeffrey Dunnett) Date: 16 Nov 2001 15:26:40 GMT Subject: Regex and Tkinter Message-ID: <9t3b7g$t69$1@testinfo.cs.uoguelph.ca> What I am trying to do is implement a find, find next option on a Tkinter\Python program usings reg. expressions what I am not sure about how to do is how to A) Get the information location in the string where the regex was found B) Hightlight the text in the text box on scree. So far I have a created text box with some text in it and am doing this def findregegx(self): #Gets the regex from a entry widget created earlier in the class self.expression = self.regexp_entry.get() #Gets the text from the text field created earlier, self. index = 1.0 self.search_text = self.display.articleArea.listbox.get(self.index, END) #Searching for the regex found = re.search(self.expression, self.search_text) print found.group() I figure that I can hightlight the text by using tags in some way but I am not quite certain how to go about finding where the regext is in the text field. Any help would be appreciated. Jeff Dunnett From max at alcyone.com Tue Nov 13 19:36:00 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 13 Nov 2001 16:36:00 -0800 Subject: Python implementations (was: Benefits of moving from Python to Common Lisp?) References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> Message-ID: <3BF1BC70.F6F8ED7B@alcyone.com> Cameron Laird wrote: > attempts to index them. You meant http://starbase.neosoft.com/~claird/comp.lang.python/python_varieties.html -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From ws-news at gmx.at Fri Nov 23 09:30:37 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 23 Nov 2001 15:30:37 +0100 Subject: What's this: run_pyc_file: nested_scopes: 0? References: <99ksvtsp9uipajsfkqehgbi9hc0f8el4mq@4ax.com> Message-ID: <3bfe5e53$1@brateggebdc5.br-automation.co.at> Hi, this message is printed when you specify the flags parameter to a call to PyRun_SimpleFileExFlags PyRun_AnyFileExFlags this functions are used, an a flags parameter is passed, in Py_Main, the function that actually provides the entry for the python executable. How do you run your code? If the messages bothers you, you should be safe removing the line fprintf(stderr, "run_pyc_file: nested_scopes: %d\n", flags->cf_nested_scopes); in line 1079 of the file Python/pythonrun.c. hth Werner "Dale Strickland-Clark" wrote in message news:99ksvtsp9uipajsfkqehgbi9hc0f8el4mq at 4ax.com... > This message has started to appear at the end of each use of a system > we're developing: > > run_pyc_file: nested_scopes: 0 > > It's not one of our messages and my hunch is that it coincides with > us using compileall to ensure the main module is compiled. > > Any ideas what it is and how I can get rid of it? > > Python 2.1 > > Cheers. > -- > Dale Strickland-Clark > Riverhall Systems Ltd From alext_lisSPAMFILTERXYZZYts at blueyonder.co.uk Wed Nov 14 21:25:54 2001 From: alext_lisSPAMFILTERXYZZYts at blueyonder.co.uk (Alex) Date: Thu, 15 Nov 2001 02:25:54 GMT Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> Message-ID: On 13 Nov 2001 21:37:37 -0800, cpr at emsoftware.com (Chris Ryland) wrote: ... >(a) could be tackled, if someone were seriously inclined, by getting >the Python folks to agree on an intermediate Lisp-like syntax (lists), >and letting people use either the normal Python syntax or the >lower-level syntax, which would then admit of macros and "easy little >languages". Wouldn't that be great? Sort of Dylan with a meta-programming emphasis... We're also not that far from the land of Parrot, and should be proposing that Parrot use a syntax-tree intermediate language (like Forth) instead of bytecode (like .NET and Java), There was some discussion of these approaches for Scheme implementations - see c.l.scheme subject "bytecode v. syntax tree" from last August. One pointer from there was to work by Anton Ertl on compiler back-ends: http://www.complang.tuwien.ac.at/projects/backends.html Now that would be *different*.... cheers alex From mwh at python.net Fri Nov 9 06:45:51 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 9 Nov 2001 11:45:51 GMT Subject: Defining inheritance in C extensions References: Message-ID: Timo Savola writes: > Hello. I'm new to this list, and relatively new to Python (played around > with it every now and then, and used it as a calculator :). Greetings. > Now I'm doing an extension module, or rather a system that I want to > control via Python. I have a C++ class hierarchy that I want to be > accessible from Python. Have you looked at Boost::Python? I haven't, but I've heard it's good for this sort of thing. > I can't figure out how to make a type object a subclass of another > type object, so that I can do type checking in the Python wrappers > of my methods. This has only *very recently* become possible, so if you wan't to know how, it's "use the source, Luke." > I've been browsing the Extending and Embedding section of the Python > documentation (version 2.2). Is it just me, or has the Defining New > Types section fallen short? It doesn't say anything about /* > Attribute descriptor and subclassing stuff */... See above; hopefully documentation will get written before Python 2.2 is out. Trouble is, there are very few people competent to write such documentation, and half of them are on paternity leave. > Is there a more extensive reference to extending Python, Don't think so. I wanted to write one once, but it's hard and I ran out of time/steam. > or maybe some comprehensive example code on the subject? Much of the Python source itself is written in the same style as you write extensions in. Particularly the stuff in Modules/ -- that's in precisely the same style, as those files *are* extending Python... > Thanks in advance. :) Cheers, M. -- There's a difference between random people with stripy jumpers, and a respected scientist with a reputation. -- Steve Kitson, ucam.chat From nikander at mindspring.com Sun Nov 11 15:47:18 2001 From: nikander at mindspring.com (Robert Nikander) Date: Sun, 11 Nov 2001 15:47:18 -0500 Subject: C modules with gcc 3.0.x Message-ID: <20011111.154717.381570572.10034@localhost.localdomain> Has anyone been using gcc 3 with python C modules? When gcc 2.95 compiles the module everything works fine, but if I use gcc 3 I get this.... Python 2.2b1 (#2, Nov 11 2001, 12:36:39) [GCC 2.95.3 20010315 (release - Linux-Mandrake 8.0 for PPC)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import spam Traceback (most recent call last): File "", line 1, in ? ImportError: libgcc_s.so.1: cannot load shared object file: No such file or directory >>> >>> Rob From aaron.ginn at motorola.com Mon Nov 5 16:15:06 2001 From: aaron.ginn at motorola.com (Aaron Ginn) Date: 05 Nov 2001 14:15:06 -0700 Subject: How would I write this perl script in python? Message-ID: I rarely use Perl except in cases where it is not obvious how to do something in Python that I already know how to do in Perl. I'm curious what the best way to rewrite the following Perl script in Python is. -------------------------------------------------- #!/usr/bin/perl -w use strict; use diagnostics; my $val = 0; while (<>) { if (/^(\w+\s+)(\-*\d+\.\d+)(\s+)(\-*\d+\.\d+)$/) { $val = $2 - 0.775; printf "%s%s%s%s\n", $1, $val, $3, $4; } else { print; } } -------------------------------------------------- In the above script, I subtract 0.775 from the value found in $2 and replace $2 with the new value ($val). I'm not sure how to isolate the different parts of the regexp in Python as I have done in Perl by using parentheses and then referring to the parts as $1, $2, $3, etc. I've used Python's re module many times, but mostly only for searching. It seems I always revert to Perl when I have a complicated (or not so complicated) search and replace task to perform. -- Aaron J. Ginn Phone: 480-814-4463 Motorola SemiCustom Solutions Pager: 877-586-2318 1300 N. Alma School Rd. Fax : 480-814-4058 Chandler, AZ 85224 M/D CH260 mailto:aaron.ginn at motorola.com From ssmith619 at hotmail.com Mon Nov 19 18:52:59 2001 From: ssmith619 at hotmail.com (Stephen Smith) Date: Mon, 19 Nov 2001 23:52:59 GMT Subject: Free Python Server Message-ID: Hey, does anyone know of any free web hosting solutions that offer Python, and no banners or pop-up ads? From jgardn at alumni.washington.edu Wed Nov 28 22:45:50 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 29 Nov 2001 12:45:50 +0900 Subject: The Editor Poll results are in! In-Reply-To: References: <3bfd7f87@news.airtel.net> Message-ID: <200111290349.fAT3nNT31519@my.knctv.co.kr> On Thursday 29 November 2001 12:27 pm, marduk wrote: > I move for a recount! > Yeah, right, I'm on to your scheme! This is what'll happen. First hthe lawyers will swarm c.l.p, tying up traffic for months to come. Then the counters will be dropping chads like dandruff. And then what about the military absentee ballots? At the end of this mess, the mess that is to be your proposed recount, I predict the winner will be: George W. Bush, c.l.p's favorite editor. Jonathan From jjl at pobox.com Wed Nov 28 07:22:05 2001 From: jjl at pobox.com (John J. Lee) Date: Wed, 28 Nov 2001 12:22:05 +0000 Subject: std. python from cygwin: the final word (?) Message-ID: After several, surprising long, threads, the collective brain power of c.l.python and the cygwin mailing list has produced the following magical shell incantations: #!/bin/sh python='/d/Program Files/Python21/python' if [ "$1" = "" ]; then exec "$python"; fi cp=`cygpath -w $1` shift exec "$python" "$cp" ${1+"$@"} which, finally, seems to actually launch the standard Windows Python exectuable from cygwin reasonably well. Of course, you may still have trouble with paths in the arguments, but that can be dealt with in Python, thankfully. Just stick the above script in cygwin's /usr/local/bin in a file named python. John From logiplexsoftware at earthlink.net Fri Nov 2 12:34:18 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 09:34:18 -0800 Subject: Underscore data hiding (was python development practices?) In-Reply-To: References: <7xy9lquj5a.fsf@ruckus.brouhaha.com> Message-ID: <01110209341800.09296@logiplex1.logiplex.net> On Friday 02 November 2001 04:19, Steve Holden wrote: > I don't see why. It's a documented part of the language, so a change would > create backward incompatibility known to be anathema to the development > team. People keep insisting that the Python development team won't introduce changes that break backward compatability. This may be true for the most part, but it is definitely not written in stone (or even Python). From the 2.0 docs for socket.bind(): "Bind the socket to address. The socket must not already be bound. (The format of address depends on the address family -- see above.) Note: This method has historically accepted a pair of parameters for AF_INET addresses instead of only a tuple. This was never intentional and is no longer be available in Python 2.0. " There are a couple of other places (which I don't recall at the moment) where things were "fixed" in such a way that you would have to change existing code. Granted this is a rather trivial example. However, I would definitely be wary of making my code depend upon something like the name-mangling scheme which is clearly a hack and actually seems a likely place to see a future change. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From loewis at informatik.hu-berlin.de Tue Nov 6 14:04:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 06 Nov 2001 20:04:23 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Michael Hudson writes: > > - it adds 17 new members to the frame object, doubling the number > > of members. Usage of some of these members isn't obvious to me. > > See below about map & friends. If they are all just for the variables in map etc., a better solution must be found - don't think it is desirable to have them in every frame, if they are just used inside map. However, from inspecting the patch, I doubt this is the case. Some of them are general-purpose, but I couldn't easily figure out what, for example, this first-instruction business is good for. > So when map wants to call the Python function, it needs to stuff all > the local data it cares about into a frame object (see above), push > this frame object onto the (Python) stack, *return* to the interpreter > in such a way that the mapping function is called next and then every > time(!) that returns have the interpreter call back into map again. Why couldn't map behave as if it was a plain Python function, implemented as def map(fun,args): res = [] for a in args: res.append(fun(a)) [I know that map is implemented in a more-involved way; it should still be possible to find its Python equivalent, then think how stackless would execute this equivalent] For the additions to frame_state, that would mean that map should reserve a number of localsplus variables, instead of outright adding to frame_state on the C level. > > - The code adds PREPARE macros into each branch of ceval. Why? > > - It adds a long list of explicitly not-supported opcodes into > > the ceval switch, instead of using 'default:'. No explanation > > for that change is given, other than 'unused opcodes go here'. > > Is it necessary to separately maintain them? Why? > > This was an optimization Chris used to try and get back some of the > performance lost during the stackless changes. IIRC, he handles > exceptions and return values as "pseudo-opcodes" rather than using the > WHY_foo constants the current ceval.c uses. I never really understood > this part. If it is an optimization, I think we should take a step back and first try to understand what it tries to optimize, and how it does that. Perhaps we find that it isn't needed at all, and that the problem could be solved in a different way. If you don't understand it, it can't go into Python. > I think integrating stackless into the core is a fairly huge amount of > work. I'd like to think I could do it, given several months of > full-time effort (which isn't going to happen). About the only likely > way I see for it to get in is for it to become important to Zope > Corp. for some reason, and them paying Tim or Guido (or Chris) to do > it. I don't think these are the options. I don't volunteer to support this code myself, either, but if somebody would step forward and claim that she understands it all, and is willing to present it to Guido in a way that he understands it also, and if all the hackish parts of it would be replaced by understandable code, I think it could go into Python. It just needs a determined volunteer to work on it. Regards, Martin From ajs at ix.netcom.com Wed Nov 28 19:49:34 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Wed, 28 Nov 2001 19:49:34 -0500 Subject: Copy operator (was list.remove for Noivces) Message-ID: <000901c1786f$cba9f260$a9e1fea9@carol> Andreas writes - >Well, I never had a problem with understanding the Python semantics. There >are other languages that do have similiar semantics. (Actually most OO >languages use only object references, not values) I am asking you to imagine coming to Python as a blank slate. I happen not to need to imagine it. I am quite sure I would have no trouble with the Python semantics, if I had the concepts. It is getting the concepts down, *with Python*, that is the subject matter. >Python 2.2b1 Standard library: >.py size: 183031 6110941 >import copy: 9 times >shallow [:] copy: 75 times How many times did they make the wrong choice between [:] and =, or some such. I expect None. That's where I want to be. Art From warkid at storm.ru Thu Nov 8 14:53:51 2001 From: warkid at storm.ru (Kerim Borchaev) Date: Thu, 8 Nov 2001 22:53:51 +0300 Subject: GC question In-Reply-To: <20011108111846.A12007@glacier.arctrix.com> References: <20011108111846.A12007@glacier.arctrix.com> Message-ID: <16954.011108@storm.ru> Hello Neil. Thursday, November 08, 2001, 10:18:46 PM, you wrote: NS> The DEBUG_LEAK setting sets DEBUG_SAVEALL. That means that all objects NS> in unreachable cycles are added to gc.garbage. If nested scopes are NS> used reference cycles can easily be created (they are in your program). you mean something like this: fun -> C -> C.m -> fun ? But such depencies are resolved even without GC? NS> Other than the fact that DEBUG_LEAK is badly named if you enable nested NS> scopes, is there a problem? What are you trying to achieve? I'm trying to control memory leakage in my code. I need to know which objects wasn't deallocated in proper moment. Best regards, Kerim mailto:warkid at storm.ru From pete at shinners.org Fri Nov 23 20:07:21 2001 From: pete at shinners.org (Pete Shinners) Date: Sat, 24 Nov 2001 01:07:21 GMT Subject: prep my types for 2.2? Message-ID: <3BFEF3DF.5030103@shinners.org> i've got several extension types that i'd like to get prepared for python-2.2. currently i have a function that constructs the object and a "type" variable available.. Myobject() type(Myobject()) is MyobjectType from what i can see in python-2.2, these become the same thing. instead of a function to construct my objects, i just make it so you can call the type directly. i've been browsing over the 2.2 sourcecode recently (looking at the int object). i've got a couple questions.. first, i can't figure out exactly what function slots and TP flags i need to use to enable this behavior? did i overlook this in the docs somewhere? (couldn't find) the other question, what is the best way to make this work for both python-2.2 and earlier releases? it looks like if i hook something nice for 2.2 up in the Type structure, that won't work for python-2.1. so it 2.1 i'll need to fallback to the classes function/type like i already have? can i make it so python-2.1 can construct objects from the Type? From tjreedy at home.com Fri Nov 2 09:47:45 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 02 Nov 2001 14:47:45 GMT Subject: Exception handling wart in Python References: Message-ID: "Leo Lipelis" wrote in message news:pan.2001.11.02.01.07.16.112.704 at myspamrealbox.com... > Besides, let's not compare to another language with even more problems and > say, but they are worse, thus we don't need to improve :). Fair enough. >Who cares if Java is too verbose? Point is, Python can be made better > by getting rid of the "self.__" in front of every object attribute. You are welcome to use 's' or whatever instead of 'self' (as I do for private use), thus saving yourself 3 keystrokes each time. Except for magic methods, you only need '__' if you want to enforce private-variableness. I do not find 's.' terribly burdensome. With a good editor, you could translate ^U or whatever to ____ for magic method names. However, aside from this, your proposal would eliminate the distinction between attributes and local/global vars. > For instance, why not > assume that ALL variables are instance variables, and have the other ones > use some special notation? The absolute majority of attributes you will > use are instance attributes. Why penalize the common case? That's bad > engineering. You should always penalize the fringe case. Doesn't that > make sense to you? If you have 2 class attributes and 20 instance > attributes, why would you penalize the 20 instead of 2? That's insane. Do you have the false idea that instance attributes *must* be prefaced by '__'? Otherwise, your statements make no sense to me. In any case, I think that at least half the variable references I have seen in methods have been to local variables that have been passed in as arguements or generated by assignment. The latter includes self attributes that have localized for efficiency. IE def meth(s, arg1, arg2): v1 = s.some_attribute If s.some_attibute is needed several times (for instance, within a loop) copying it to a local var saves looking it up over and over. This is a common idiom among knowledgeable Pythoneers. Terry J. Reedy From gbreed at cix.compulink.co.uk Thu Nov 15 12:44:35 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: Thu, 15 Nov 2001 17:44:35 +0000 (UTC) Subject: IsPython really O-O? References: Message-ID: <9t0uu3$6i6$1@thorium.cix.co.uk> Ken Seehof wrote: > ... in fact > here's a recipe describing how to add or replace a method in an existing > class > using the 'new' module: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81982 AIUI, that involves a circular reference. If anybody wants to try some benchmarking, compare it with the following: dynamicModule = "__dynamic__" def setDynamicClass(object): if object.__class__.__module__ != dynamicModule: class klass(object.__class__): """dynamic class for hacking""" klass.__name__ = object.__class__.__name__ klass.__module__ = dynamicModule object.__class__ = klass def addMethod(object, function): setDynamicClass(object) setattr(object.__class__, function.__name__, function) Graham From boud at rempt.xs4all.nl Wed Nov 14 02:24:46 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 14 Nov 2001 07:24:46 GMT Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <2b326e2e.0111130531.7a85a0b8@posting.google.com> Message-ID: <9st67u$h7u$1@news1.xs4all.nl> Robert Amesz wrote: > Steven Rumbalski wrote: >> Michael 'Mickey' Lauer >> wrote in message news:<3beedf26 at nntp.server.uni-frankfurt.de>... >> >>> What do you think would be a good application to show the basics >>> and a few more sophisticated topics in programming GUI >>> applications with Python? >> >> My $.02: >> >> How about a simple text editor? Whatever application you present >> you should probably have either an appendix or an early chapter >> explaining the code that will stay the same across each >> implementation. > That's trivial if you use a standard display component (e.g. the > wxTextCtrl or wxStyledTextCtrl for wxPython) or very hard if you're > starting from scratch. Not so very hard, it appears. In my book on PyQt I have built a complete example around a standard text editor control (QMultiLineEdit), because there were all kinds of things I wanted to show, like working with dialogs and so on. But now I'm extending this with an editor control that's completely written in Python, and it turns out to be very feasible. The actual editor part is done, and the redisplay mostly. I'm using Craig Finseth's book, The Craft of Text Editing (http://www.finseth.com/~fin/craft/index.html), as a guide, so you can say that I'm working on the first Python implementation of Emacs :-). -- Boudewijn Rempt | http://www.valdyas.org From deliberatus at my995internet.com Thu Nov 8 23:50:12 2001 From: deliberatus at my995internet.com (Kirk Bailey) Date: Thu, 08 Nov 2001 23:50:12 -0500 Subject: TinyList References: <3BEA20DC.C16E6379@my995internet.com> <004601c1686b$61e6f580$f1232818@wall1.pa.home.com> <3BEABCE1.76E31AF9@my995internet.com> <013801c168ac$85b3c7e0$f1232818@wall1.pa.home.com> Message-ID: <3BEB6084.85B73442@my995internet.com> John Derrickson at PsyPlan wrote: > > Greetings! > > If I had registered TinyList as a trademark, we could have a conflict. > But I didn't and don't intend to. Go ahead, use it for your program. THANK YOU! :-) > If > you don't challenge me, I won't challenge you. DONE DEAL. > Tinylist sounds like a > good name for your program. Besides, these are only program names. I > assume you don't mind my ancient, functionally stabilized, TinyList > program popping up in searches. Not in the least. > Actually, I'd be happy to list a link to > your site at my site. When there is a site for tiny list, that's fine, and recopical is an idea. Something like 'if you were looking for the dos program to list files to a printer, CLICK HERE. If you were looking for the Mail List Manager, CLICK HERE. > > Python is an interesting language choice. Do you like it? Have you > considered Perl or PHP? Will Tinylist be open source? When can I see it? I am currently hosting a site for minorfish ( http://www.minorfish.org/ ) a very nice mlm in perl, and perl drives me nuts. I want to add a function and cannot grok how it works! Just one, but useful- a tag to include in the footer file for a list. MF uses it's own tags in files like we would do ssi in html pages. In fact, for the web pages they ARE used as ssi! LEt me give you an example: first , the actual output of a footer on a list hosted there: +---FOOTER FILE TO HELP YOU USE MINORFISH-----Click [REPLY] to reply---+ | CLICK to Unsubscribe: | | mailto:minorfish at minorfish.org?subject=unsubscribe%20python101 | | | | For help CLICK: mailto:minorfish at minorfish.org?subject=help | +----------------------------------------------------------------------+ This list is hosted by a clench of chain smoking python hackers at http://www.minorfish.org/cgi-bin/minorfish 'cause we can. Underpowered by minorfish, the list server for some of us! http://www.minorfish.org/ ~/cgi-bin/fishstuff/schools/python101 and here is the entire footer file that produced this output: " +---FOOTER FILE TO HELP YOU USE MINORFISH-----Click [REPLY] to reply---+ | CLICK to Unsubscribe: | | mailto:minorfish@?subject=unsubscribe%20 | | | | For help CLICK: mailto:minorfish@?subject=help | +----------------------------------------------------------------------+ This list is hosted by a clench of chain smoking python hackers at http://www./cgi-bin/minorfish 'cause we can. Underpowered by minorfish, the list server for some of us! http://www.minorfish.org/ ~/cgi-bin/fishstuff/schools/ " (Quotes added, the file is everything BETWEEN them.) Dig. All I rubbed was the number of spaces on line3 so the box lines up. Had I not used a box, but a line, I could omit that action. This functionalyity is so damn cool I want to duplicate and add to it. Minorfish's creator has taken the idea of ssi and applied it to email lists in effect, and I want to add a and To the thing. Alas, I do not control it, and the devloped is not too enthused for the idea, so I need to write something totally new, and due to ease of use, I chose python. and as this is of some intrest to the python list, I am taking the liberty of CC'ing it to that list also. > > Felicitations, John G. Derrickson > Wrote fast. Goofs happen. Tell me. > => Please copy this message with your reply. <= > > ----- Original Message ----- > From: "Kirk Bailey" > To: "John Derrickson at PsyPlan" > Sent: Thursday, November 08, 2001 12:12 PM > Subject: Re: TinyList > > oh, ok. So if I wrote a Mailing List Manager (in Python) called > Tinylist, as it is in a different context, this should not cause > confusion, correct? > > John Derrickson at PsyPlan wrote: > > > > Greetings! > > > > TinyList prints a text file to an HP-compatible laser printer using > the > > supplied soft font file 4 points high, 22 characters/inch, 15 > > lines/inch, 2 columns/page, both sides of paper. > > > > It's an old MS-DOS program but works in Windows. > > > > I haven't used TinyList in years. I suppose it still works. > > > > Felicitations, John G. Derrickson > > Wrote fast. Goofs happen. Tell me. > > => Please copy this message with your reply. <= > > > > ----- Original Message ----- > > From: "Kirk Bailey" > > To: > > Sent: Thursday, November 08, 2001 1:06 AM > > Subject: TinyList > > > > Tell me about tinylist. > > > > -- > > Respectfully, > > -Kirk D Bailey (C)2001 > > Addme! icq #27840081 > > end > > My Sites: > > http://www.howlermonkey.net/ - free REAL email! list service > soon! > > http://www.sacredelectron.org/ - Rants! Spleenvents! > > http://www.minorfish.org/ - The list server for some of us! > > -- > Respectfully, > -Kirk D Bailey (C)2001 > Addme! icq #27840081 > end > My Sites: > http://www.howlermonkey.net/ - free REAL email! list service soon! > http://www.sacredelectron.org/ - Rants! Spleenvents! > http://www.minorfish.org/ - The list server for some of us! -- Respectfully, -Kirk D Bailey (C)2001 Addme! icq #27840081 end My Sites: http://www.howlermonkey.net/ - free REAL email! list service soon! http://www.sacredelectron.org/ - Rants! Spleenvents! http://www.minorfish.org/ - The list server for some of us! From chris.gonnerman at newcenturycomputers.net Sun Nov 18 14:24:33 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Sun, 18 Nov 2001 13:24:33 -0600 Subject: RANSOM DEMAND: Image Held Hostage! References: <5.1.0.14.0.20011118100745.00a12170@thewebsons.com> Message-ID: <001d01c17066$adf3dda0$0101010a@local> ----- Original Message ----- From: "Ben Ocean" > I need a way to size up images via script. Now, in that inferior scripting > language known as PHP, *they* have such a tool: getimagesize(). When you say "size up" you mean to retrieve the image dimensions? All this time I thought you wanted to *resize* the images! > Can it be > that God's gift to scripting languages, Python, can't compete here? If it's > true that PHP has one up on us here, how can I write a script that bridges > this dastardly gap? There are two options that come to mind... the Pythonware Imaging Library at pythonware.com, and the GDmodule (which I currently maintain) at http://newcenturycomputers.net/projects/gdmodule.html Using GDmodule, you'd say import gd img = gd.image("filename.goes.here.jpg") print img.size() to print the tuple of (x,y) dimensions of the picture. Actually changing the size would be harder, requiring allocation of a new empty image of the correct size, followed by using the img.copyResizedTo() method. From shalehperry at home.com Sun Nov 18 13:09:18 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sun, 18 Nov 2001 10:09:18 -0800 (PST) Subject: SGMLParser error on HTML comment In-Reply-To: Message-ID: > > > > > > > > if this is an exact paste here lies your problem, the tag is , probably making the closing tags second hyphen option as well. If you look at sgmllib.py you will see that this is very easy. From horatio at qpsf.edu.au Sun Nov 25 07:22:35 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Sun, 25 Nov 2001 22:22:35 +1000 (EST) Subject: Scientific Libraries in Python In-Reply-To: <9t1iqq$es0$2@peabody.colorado.edu> Message-ID: G'day. On Thu, 15 Nov 2001, Fernando [ISO-8859-1] P?rez wrote: > I'd like to draft a rough map of the problem landscape. Having read this excellent mud map of the problem space, and the followups, I'd like to add my my $0.01 (would be $0.02 but the exchange rate on the Aussie dollar is fairly embarrassing right now). In order of priority, these are the tools I want in a single codebase: SciPy (Enthought) - general code library - BSD license http://www.scipy.org/ ScientificPython (Hinsen) - general code library - Python license http://starship.python.net/crew/hinsen/scientific.html MayaVi (Ramachandra) - 3D visualization over VTK - GPL http://mayavi.sourceforge.net/ PyGSL (Gabriel et al) - Python bindings for GSL - GPL http://www.cgabriel.org/sw/pygsl/ SciGraphica (Feiguin et al) - 2D graphing package over GTK+ - GPL http://scigraphica.sourceforge.net/ mxNumber (Lemburg) - Python bindings for GMP - OSI/Python license http://www.lemburg.com/files/python/mxNumber.html SciGraphica looks to be shaping up as the MayaVi of the 2D plotting domain. It is apparently written in C and embeds Python, rather than the other way around, but mention is made of command-prompt interaction with plots and worksheets, which raises the possibility of exposing it as a library in the style of scipy.plt. mxNumber is part of the excellent mx-Extensions packages. This project is definitely alive and well, and that makes it the best choice for a GMP binding. The list of scientific packages above requires at least the libraries: ATLAS (Whaley & Petitet) - self-optimizing CBLAS - BSD license http://math-atlas.sourceforge.net/ VTK (Martin et al) - 3D visualization on GTK - personal copyright http://www.visualizationtoolkit.org/ GSL (Galassi et al) - mathematical (non-Numeric) library - GPL http://sources.redhat.com/gsl/ GNU MP (Granlund et al) - arbitrary precision arithmetic library - GPL http://www.swox.com/gmp/ Numeric (Dubois et al) - efficient numerical array type - OSI http://www.pfdubois.com/numpy/ mxTools (Lemburg) - set of utility modules - OSI/Python http://www.lemburg.com/files/python/eGenix-mx-Extensions.html GTK+ and GTKExtra - GIMP toolkit and extra widget set - LGPL http://www.gtk.org/, http://gtkextra.sourceforge.net/ This list is not complete, but I've included it as a rough draft of what would be in Chris Barker's "Scientific Python Distribution". They neither need nor want to be integrated into a Grand Unified Scientific Library, but they would have to be packaged in such a Distribution. Most of these are just the underlying C libraries upon which the scientific Python libraries are built. mxTools isn't, but it makes the list because of mxNumber, and because the general functionality it provides is useful. Numeric Python, of course, makes whichever list it feels like. (: I've left it out of both lists because there's an announcement on the NumPy home page that it is being reimplemented from scratch by Perry Greenfield and company. This looks (to my untrained eye) like they're going ahead with the Numeric 2 proposed in PEP 209, and are going for inclusion in the Python standard library. Implications for the unified scientific library are left as an exercise for the reader. Could we have comments from anybody on that project team? For a sane naming structure, I still reckon a deep package structure rooted at Scientific is the ideal, but again, that's a secondary issue. Now... licensing. While the top two projects are both less...restrictive, I reluctantly have to concede that these lists have an awful lot of GPL code that would be difficult or impossible to do without. The eventual license, therefore, looks like GPL or (if we're lucky) LGPL. I can even live with that if it'll get me a coherent scientific library, but others might have a different viewpoint. What would those viewpoints be? hoping-he's-not-an-unwitting-pawn-of-the-PSU'ly yours, Horatio From chris.gonnerman at newcenturycomputers.net Mon Nov 5 08:19:33 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Mon, 5 Nov 2001 07:19:33 -0600 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: <002e01c165fc$86402800$0101010a@local> ----- Original Message ----- From: "pawn" > I'm trying to convert a few simple CGI scripts from Perl to Python, > and was shocked to learn that the Python interpreter silently ignores > the setuid bit. Don't be shocked. It's not really the interpreter's business, it's the OS. Perl (if I remember right) does have a special setuid-perl interpreter, but IMHO that's a hack. > I really don't know how to get around this. Since the server is hosted > remotely I can't recompile python to allow setuid, and I can't make my > files world read/writable - I need my python CGIs to run with MY uid. You wouldn't need to recompile, just set the bits on the program file if you owned it. It's actually a webserver thing. Apache has a setuid module just to handle this; if the remote site is using Apache you could ask about it. > I read somewhere about using a wrapper C program but it seems really > convoluted, as well as requiring a different wrapper for each CGI. Robin Becker supplied one in another post, so I won't bother digging up my old solution (which I wrote long ago for shell scripts). A single wrapper can handle the entire system. The main question is, can you put a compiled CGI on the remote system? (That is, will they allow it to run?) > Is there any solution, or should I stick to / am I stuck with Perl? Ultimately this is a problem for the remote site administration. Have you asked them? From cjw at sympatico.ca Wed Nov 28 10:28:48 2001 From: cjw at sympatico.ca (Colin J. Williams) Date: Wed, 28 Nov 2001 10:28:48 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C046EB4.55B36D9D@cosc.canterbury.ac.nz> Message-ID: <3C0502B0.1F73497C@sympatico.ca> An HTML attachment was scrubbed... URL: From qrczak at knm.org.pl Fri Nov 23 12:31:51 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 23 Nov 2001 17:31:51 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: Wed, 21 Nov 2001 23:00:35 -0500, Dave Cinege pisze: > Not so. It's completely logical. A single byte, per indented block > instead of some variable, arbitary number. This would be a bad idea: - using tab width of any other size than 8 is evil, - 8 is too much for indentation in programming; 2 to 4 is good. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From chrishbarker at home.net Fri Nov 30 15:15:45 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 30 Nov 2001 12:15:45 -0800 Subject: floating Pt. Division errors in Windows 2000 References: <05DN7.34897$H7.4336901@ruti.visi.com> Message-ID: <3C07E8F1.25E5CA24@home.net> Leon Webster wrote: > When I execute this on my laptop (win2k machine, pentium III), I get the > following answer: > > 0.80000000000000004 > > The same program on Linux provides the right answer (0.8), as does a program > written in Java. not, it doesn't. From my Linux box: >>> a = 3 >>> b = 4 >>> b/(2.0 + a) 0.80000000000000004 The difference is probably an older version of Python, not Linux vs. Win2k. Older versions of Python rounded the result displayed in the interpreter for you to make it look more pretty. The same is probably true for your JAVA program. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From seeger at sitewaerts.de Wed Nov 21 04:22:54 2001 From: seeger at sitewaerts.de (Felix Seeger) Date: Wed, 21 Nov 2001 10:22:54 +0100 Subject: writnig my first programm Message-ID: <9tfrf5$27hfr$1@ID-79019.news.dfncis.de> Hi Maybe this idear is to big for the first time, but I need this Programm. I hope you can give me some help. How can I do it, are there modules or code from other developers. I have: I have some scripts (bash) for my servers. Just for getting the status, starting servers, creating a new db and others. There are 10 servers with more than 2 scripts on each. I think 5 people will use this scripts. Problem: It's difficult to go to each server (with ssh) and run the scripts ;) Solution: A "adminclient <--> server <--> server-client" programm (all scripts are stored in the server and they will be given to the server-client if someone runs a command from the adminclient. The adminclient could be a GUI or a WebInterface. It's nice because the Server has always an uptodate version of the scripts. What do you think, is this possible ? Do you have better idears ? Do you know any finished code that I can use for learning ? thanks have fun HAL From nomad*** at ***freemail.absa.co.za Wed Nov 14 04:43:32 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Wed, 14 Nov 2001 11:43:32 +0200 Subject: Open a windows database file with a path name? References: Message-ID: On 10 Nov 2001 01:59:22 -0800, osuchw at ecn.ab.ca (waldekO) wrote: >Nomad wrote in message news:... >> Hi, >> >> Is there anyway that I can open a database (MSAccess in this case) >> using the path and file name rather than a DSN? I can't seem to get >> it to work. >> >> TIA > >try this: > >>>> from win32com.client import Dispatch, constants >>>> eng = Dispatch('DAO.DBEngine.36') >>>> db = eng.OpenDatabase('c:/db1.mdb') >>>> rs = db.OpenRecordset('select * from tblHolidays') >>>> rs.Fields('ID').Value >1 >>>> rs.MoveNext() >>>> rs.Fields('ID').Value >2 Cheers, That's pretty much what I was looking for, but I think I'll go for the ADO version sent by Bill Bell. Thanks anyway. -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From hgg9140 at seanet.com Wed Nov 14 16:49:43 2001 From: hgg9140 at seanet.com (Harry George) Date: 14 Nov 2001 13:49:43 -0800 Subject: Request for Validation of Python as Development Language References: Message-ID: "A. Keyton Weissinger" writes: > Does anyone have a more recent list of commercial products out there that > use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima > Online. I'd like more. Do you insist on COTS? Our use has been entirely with open source. We do: RDBMS (MySQL and Postgresql) COM and CORBA (e.g., to CAD engines and to expert systems) csv files XML, XSchema, XSLT CGI's to access translator services and to access databases GUI's for forms completion assorted other "scripting" tasks We also do a lot of in-house semantic translations among stovepipe communities. Typically prepare reader/writer adapters for whatever data formats they have, then translate to central neutral representation, then back out to some other format. > > The information in the books and the python.org site is a bit dated. > > I'm pretty new to the language and I'd like to use it for more stuff at > work. I'm beginning to feel some of the stigma of it being a "scripting > language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for > those who care) and I'd like to introduce Python into the mix. But I say > "scripting language" and people head to the hills yelling "PERL!" which is a > bit disconcerting (especially since I like Perl too, though not as much as > Python). They need to hear "object oriented application development > language" or I need to buck up and realize I'm barking up the wrong tree. > > Thank you! > > Keyton > > -- Harry George hgg9140 at seanet.com From kragen at canonical.org Fri Nov 23 22:35:59 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 23 Nov 2001 22:35:59 -0500 Subject: Tkinter without the window References: <6hu1vn92lb.fsf@hare.demon.co.uk> Message-ID: <83u1vkvo0w.fsf@panacea.canonical.org> Les Smithson writes: > I have a working Tkinter application that uses a canvas to draw > graphics in an X window. Is it possible for Tkinter to draw the same > graphics straight to a PNG/JPG/whatever file without going through a > windowing system? No. But you could use Xvfb to draw the graphics in a windowing system that doesn't display on any physical device, and then use xwd or some similar program to make the PNG or JPG from it. > I have in mind using this application for an External script in a Zope > server. With enough work, Xvfb could be used for this. From george at cc.gatech.edu Sun Nov 18 12:27:09 2001 From: george at cc.gatech.edu (George Thomas) Date: Sun, 18 Nov 2001 12:27:09 -0500 (EST) Subject: SGMLParser error on HTML comment In-Reply-To: Message-ID: Hi, Here are the opening lines of the file. I'd appreciate any fix/workaround. The 4DOM parser also had similar issues, if I remember right. I tried trapping the SGMLParseError, but now I have to find a way to quell the traceback. rgds and thanks ----------------------------------------------------------------------- George Thomas 'wIjwI' Resident,Planet Earth,Third Rock from the Sun ----------------------------------------------------------------------- reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') ----------------------------------------------------------------------- From alex at shindich.com Fri Nov 30 03:11:29 2001 From: alex at shindich.com (Alex Shindich) Date: 30 Nov 2001 00:11:29 -0800 Subject: Implied Interfaces Message-ID: <7c905859.0111300011.1f63ff21@posting.google.com> In April, Curt and I wrote and posted a pattern called Implied Interface. The intent of the original paper was to show that Python indeed supported interfaces. In June we spent a lot of time polishing the paper in preparation for the PLoP 2001 conference. I thought that some of you may be interested in seeing the final version of the pattern. So here it is: http://www.shindich.com/sources/patterns/implied.html Regards, Alex Shindich From emile at fenx.com Tue Nov 13 22:55:50 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 13 Nov 2001 19:55:50 -0800 Subject: Need call by Name or any other solution...!?! References: <263c4e12.0111131731.3a7b49f2@posting.google.com> Message-ID: <9ssqa5$159kfj$1@ID-11957.news.dfncis.de> "Th. Heidenreich" wrote in message news:263c4e12.0111131731.3a7b49f2 at posting.google.com... > Hi, > > I?ve got the following problem: I want to assign a number of variables > (which are not constant) a value by an entry box. Better look at the > code: > > > def confirm(self): > print self.right > > def __init__(self, nof_entries, categories): > self.right = [] > for i in range(nof_entries): > list_label = Label(text = categories[i], relief="flat") > list_label.grid( row = i+2 , column = 0) > self.right.append(chr(65+i)) # just to have something in there More than just something, this is putting the 'A' in self.right that you're seeing below. > right_label.append(Entry( relief = "sunken", bd = 2, textvariable = > self.right[i])) # **** THATS THE THING THAT DOSN?T WORK **** > right_label[i].grid(row = i+2 , column = 1) > > b_confirm = Button(text = "Confirm", command = self.confirm) > b_confirm.grid(row = laenge+3, column = 0, columnspan = 2) > > ... > > > self.right[0] for example refers to a variable named "A" - but it > should refer to a variable CONTAINING "A", so how can I assign a Where is this 'A' you want it to be instead of the 'A' you put in it above? > textvariable to an entry of an array?? Or has anyone another idea how > to do this??? > You'll probably want to use getattr(container_of_A, self.right[i]) or container_of_A[self.right[i]) HTH, -- Emile van Sebille emile at fenx.com --------- From stadt at cs.utwente.nl Mon Nov 5 07:59:39 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Mon, 05 Nov 2001 13:59:39 +0100 Subject: time.daylight (Daylight Saving Time) Message-ID: <3BE68D3B.28AEA20E@cs.utwente.nl> Hi, I'm using time.tzname[time.daylight] to display the time zone. This worked fine as long a Daylight Saving Time (DST) was valid, since time.tzname is e.g. this: >>> tzname ('MET', 'MEST') time.__docs__ shows this, concerning DST: --- DST (Daylight Savings Time) flag (-1, 0 or 1) If the DST flag is 0, the time is given in the regular time zone; if it is 1, the time is given in the DST time zone; if it is -1, mktime() should guess based on the date and time. --- However, now that DST is over, time.daylight keeps on being 1 (on the 5 systems located in different time zones that I've tried). There's no time.py, so I'm clueless about how time.daylight is supposed to be updated. Any ideas? Is it perhaps only set at compile time (just guessing). Richard. From skip at pobox.com Mon Nov 19 09:28:36 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 19 Nov 2001 08:28:36 -0600 Subject: pygtk In-Reply-To: References: Message-ID: <15353.5908.741926.998821@beluga.mojam.com> Sylvain> this is a little off topic, but does anybody knows how to give Sylvain> the focus to a particular window using pygtk ? (I wish the Sylvain> designed window to take focus and to come to the foreground if Sylvain> another window hided it). w.grab_focus() does the trick using the new Gtk 2.0 API. I haven't used the earlier API, but I assume it's similar. To raise a widget, get its GdkWindow and call raise_(): w.window.raise_() -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From gdemmy at layton-graphics.com Sat Nov 17 09:53:22 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 17 Nov 2001 09:53:22 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? Message-ID: I do a bunch of list-oriented programming with a bunch of one-off programs. For a variety of reasons these lists tend to have a bit of cruft associated with them (I don't write it -- just process it!). So stuff like this shows up quite a bit: data = filter(lambda x: x, crufty_list) I did it so often, that stuff like this shows up: identity = lambda x: x # like this in practice (lazy) def identity(x): # Pythonic -- shows up in profiler, etc return x data = filter(identity, crufty_list) There are, of course, other nifty things to do with identity, and I find it used all the time -- far more often than many Python built-ins. How prevalent is identity usage in the Python community? Is there anyone that would rather suffer hellfire and damnation that do something like this? Curiously, G -- George Demmy From virus_catcher at oceanic.com Tue Nov 27 13:30:39 2001 From: virus_catcher at oceanic.com (virus_catcher at oceanic.com) Date: Tue, 27 Nov 2001 08:30:39 -1000 Subject: InterScan NT Alert Message-ID: Receiver, AntiVirus Catcher has detected virus(es) in the e-mail attachment. The Sender has been notified. Date: Tue, 27 Nov 2001 08:30:39 -1000 Method: Mail From: <_printers at sendme.cz> To: File: news_doc.DOC.scr Action: clean failed - deleted Virus: WORM_BADTRANS.B From loewis at informatik.hu-berlin.de Mon Nov 5 04:22:42 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Nov 2001 10:22:42 +0100 Subject: Tkinter, pickle (or shelve) and marshal References: Message-ID: Grzegorz Dostatni writes: > I am looking for a beautifull, Pythonic way to solve this ;-) The Pythonic way for pickling objects is to implement a __getstate__/__setstate__ pair. You can have __getstate__ return whatever you want, and have __setstate__ do an "window-reopening" actions you may need. In doing so, you'll find that Tkinter widgets currently don't implement __getstate__/__setstate__. I see two alternatives: 1. Derive from each Widget class you use, and add those methods into the derived class. Then use your derived widget classes instead of the original ones. This is the clean OO way of life. 2. Come up with a generic implementation of getstate/setstate, and "inject" them into some Tkinter base class. There are again different ways to do that; one is to put the methods into a separate class, and assign to Tkinter.Misc.__bases__. This is the hacky, introspectional way of life. HTH, Martin From andymac at bullseye.apana.org.au Wed Nov 14 03:51:19 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 14 Nov 2001 19:51:19 +1100 (EDT) Subject: Problem with .pth files under linux In-Reply-To: <9ss77q$7d7$1@peabody.colorado.edu> Message-ID: On Tue, 13 Nov 2001, Fernando [ISO-8859-1] P?rez wrote: > I'm sure this is simple and stupid, but I still don't know what's going on. I > have some modules without a package structure (no __init__.py) but which have > a .pth file. Specifically, Numeric. It comes in its own directory: > site-packages/Numeric, and in site-packages I have a file Numeric.pth whose > contents is simply 'Numeric' (no quotes). > > Yet import Numeric doesn't work! I solved it by hand-coding Numeric into > sys.path, but it annoys me and I have the same problem with other modules > I'll need to use soon. Is site-packages in sys.path? (or added to sys.path by site.py?) -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From fredrik at pythonware.com Thu Nov 29 13:08:16 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 29 Nov 2001 18:08:16 GMT Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <9u5d00$6aald$1@ID-59885.news.dfncis.de> Message-ID: Thomas Heller wrote: > Sometimes I hear some rumour about Perforce, but I never tried it. not sure it supports Laura's specific need, but generally speaking, Perforce rules. (what Python programmer can resist a system that can generate all output as marshalled Python objects? ;-) From peoter_veliki at hotmail.com Wed Nov 21 13:18:26 2001 From: peoter_veliki at hotmail.com (Peoter Veliki) Date: Wed, 21 Nov 2001 10:18:26 -0800 Subject: using python with MS WSH? .NET? References: Message-ID: Can Python be used with MS Windows Script Host (WSH)? What about for use with .NET? What are the limitations of using Python in windows? I am very new to the MS world, don't flame if these are silly questions. Thanks. From tjreedy at home.com Sun Nov 11 10:20:21 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 11 Nov 2001 15:20:21 GMT Subject: Is this considered black magic? References: Message-ID: "Laura Creighton" wrote in message news:mailman.1005485895.7082.python-list at python.org... > I want to do something which is conceptually very simple. Given a list of > objects, call make everybody call the same method you want to run. Sort > of like apply(), but for methods. > > This is what I came up with: > ... > def foreach(name_key, object_list, *args): > print 'foreach: args are ' + `args` > for object in object_list: > try: > object.__class__.__dict__[name_key](object, *args) > except KeyError: > pass >... > But is it white, grey, or black magic? > Is there a better way I should have done? try: getattr(object, name_key)(*args) > Suggestions on what to name the function gratefully welcomed. methmap or mapmeth Terry J. Reedy From frederic.giacometti at arakne.com Sat Nov 10 15:39:24 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Sat, 10 Nov 2001 20:39:24 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> "Michael Hudson" wrote in message news:u4ro58kzx.fsf at python.net... > "Frederic Giacometti" writes: > > [schnipp] > > Does this make sense? > > But isn't the point of many multithreaded apps allowing code to run > during blocking IO operations? Your approach would knock that on the > head. In the proposed design, stackless call to another thread never blocks the thread; it inserts a frame in one of the thread frame schedulers. Just as all C functions external to the Python interpreter core, IO functions run outside the interpreter thread. FG From jim at home.com Mon Nov 26 18:09:07 2001 From: jim at home.com (Jim Meier) Date: Mon, 26 Nov 2001 23:09:07 GMT Subject: fork & exec a process? References: <87667x7o58.fsf@home.com> Message-ID: <87pu651663.fsf@home.com> > I recommend to create a popen2.Popen3 instance, and then use its > .wait() method (or .poll(), to check for completion). ah! that is certainly a well-hidden function :) Thank you very much, this is exactly what i was looking for. -Jim From fungho at sinaman.com Wed Nov 28 02:46:00 2001 From: fungho at sinaman.com (Stephen) Date: 27 Nov 2001 23:46:00 -0800 Subject: a question of using regular expression Message-ID: I am now using org.apache.regexp as the regular expression library in my Java code. I meet a difficulty in implementating the following regular expression, I don't know how to describe it (because of my poor English), so I take an example: String sText0 = "good morning!"; String sText1 = "morning! you are very good!"; RE r = new RE("???????????"); // I have no idea in this actually, I just want to get the string which has string "good" at the start. Therefore, in this case, sText0 can be got only. How can I do this? Thanks! Stephen From nikander at mindspring.com Sun Nov 11 14:36:37 2001 From: nikander at mindspring.com (Robert Nikander) Date: Sun, 11 Nov 2001 14:36:37 -0500 Subject: AM_PATH_PYTHON m4 macro Message-ID: <20011111.143636.1080416554.8081@localhost.localdomain> Hi, I have been trying to build the latest pygtk. It complains that it can't find the AM_PATH_PYTHON m4 macro. It doesn't seem to come with Python 2.0 or 2.2. Does anyone know where it is? Thanks, Rob From mwh at python.net Mon Nov 26 12:28:45 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 26 Nov 2001 17:28:45 GMT Subject: bugs in `gc.get_referents()' References: Message-ID: Zooko writes: > [Would this be more appropriate for the Python developers' list?] You're looking for http://sourceforge.net/tracker/?group_id=5470&atid=105470 > Hello Pythonistas, Pythonics and Pythonifiers! > > I'm using Python 2.2b2 as compiled and packaged by debian. > > I've been using `gc.get_objects()' and `gc.get_referents()' (since renamed > `gc.get_referrers()') to find out how my app Mojo Nation[1] uses memory. > > (Thank you to the implementors of those functions! It has been a > great help!) > > There are two apparent bugs: first, the return value from get_referents() > *always* contains a number of entries that do not refer to the object in > question, and it is always the same entries. Wild, wild stab in the dark: try running gc.collect() first. It's hard to see how this could be happening from staring at the code. It's not very complicated. [...] > The second bug is that about once every few hours of use, > get_referents() seg faults. I think it might be more likely to do > that when I have a larger collection of objects in memory -- maybe > the time to traverse the larger set of objects reveals a race > condition? It's possible, I'd hazard. You could try surrounding your calls to calls to gc.enable/gc.disable. What do the stack traces show? > I'm running gc.get_referents() in an interactive interpreter while > several threads are simultaneously working and mutating the data! I *doubt* threads are running during the call to gc.get_referrers. Could be wrong. > Also some of those threads are using native code which might be > failing to DECREF properly. If that's the case, then you've got problems all your own, no? > I would be rather interested in digging into the implementation of > get_referents() myself, but first I'd like to hear from the > Pythonistas whether these bugs are surprising or unsurprising, Well, the functions are pretty new. > whether the code has been changed since 2.2b2, Only the name changes, I think. > if there is any sort of "starting point" for digging into it that > they recommend, etc. $ less Modules/gcmodule.c I think. 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 invalid_email at www.skeleton-man.f2s.com Fri Nov 30 18:14:20 2001 From: invalid_email at www.skeleton-man.f2s.com (Skeleton Man) Date: Sat, 1 Dec 2001 10:14:20 +1100 Subject: New updates needed for an old computer language humor piece References: <3c070c3f$1_1@news.iprimus.com.au> <3C0782A9.C48A0FF1@engcorp.com> Message-ID: <3c0811cb$1_2@news.iprimus.com.au> You aren't likely to shoot yourself in the foot with that *L* The only reason it looks so confusing is coz it has to be condensed to a few lines.. and of course japhs are meant to be confusing... Any more light humour ? -- Regards, Chris ---- -Begin Xmas Signature------ *__=*Time::HiRes::usleep=>my at m=map{$_+=$_%2?-1:+1}map ord, split//=>'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////'. 'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////'; unshift @m=>(32)x at m;require Time::HiRes;for(0.. at m){ print map(chr, at m[0..(@m/2-1)])=>"\b"x(@m/2);push at m=> shift at m=>__(0170*0xA**3);} From phr-n2001d at nightsong.com Sat Nov 3 01:37:37 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 22:37:37 -0800 Subject: Feature Wish: "%" Extension References: Message-ID: <7xpu708imm.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > 05470> > > Unfortunately, it's got no review yet and 2.2 feature freeze is in effect. Oh crap. I had some similar patches I meant to get around to. Even libraries are feature frozen? From ecastro at cicei.ulpgc.es Wed Nov 14 05:58:50 2001 From: ecastro at cicei.ulpgc.es (Enrique) Date: 14 Nov 2001 10:58:50 GMT Subject: Problem installing VTKPython References: <3BF153BA.77D0566C@cicei.ulpgc.es> Message-ID: <3BF24F4B.A962BD16@cicei.ulpgc.es> Prabhu Ramachandran wrote: > > >>>>> "EC" == Enrique writes: > > EC> MS-Windows PC I have downloaded VTKcore.exe and VTKPython.exe. > EC> Installation of VTKcore.exe simply copies vtkdll.dll into > EC> c:\windows\system. > > I guess you downloaded these from the VTK site? These were built for > Python 1.5.2 and not for 2.1. I suggest that you check out Les > Schaffer's DLL's for Python 2.1: > > http://basic.astrian.net/godzilla/ > > Mark Hadfield made some notes on his installation on Win32. His > message is here: > > http://www.geocrawler.com/archives/3/12167/2001/6/0/5915914/ > > If you have more problems mail the mayavi-users list that I've CC'd to > here. > > prabhu Thanks for the tip, prabhu The version problem is not obvious from the error message Now I can play with yours MayaVi, seems impressive at first look a good piece of work! I?ll check the users list Thanks Enrique From sandysj at juno.com Thu Nov 1 11:40:29 2001 From: sandysj at juno.com (Jeff Sandys) Date: Thu, 1 Nov 2001 16:40:29 GMT Subject: in string Message-ID: <3BE17AFD.1655EEF8@juno.com> I kind of understand why this (below) doesn't work. What would you have to do to make it work? (to make 'eggs' in 'spam and eggs' return 1) Or what does: string member test needs char left operand mean? Python 1.5.2 (#2, Apr 4 2000, 13:12:48) [C] on aix4 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a = 'spam and eggs' >>> 'e' in a 1 >>> 'eggs' in a Traceback (innermost last): File "", line 1, in ? TypeError: string member test needs char left operand >>> I suppose I should just use the re package ;) Thanks, Jeff Sandys From neal at metaslash.com Mon Nov 12 21:54:09 2001 From: neal at metaslash.com (Neal Norwitz) Date: Mon, 12 Nov 2001 21:54:09 -0500 Subject: Linux/Alpha memory leaks References: Message-ID: <3BF08B51.8B706BD1@metaslash.com> Peter ?strand wrote: > > I have some problems with memory leaks in a web application, written in > Python. It works good on Sparc/Solaris and Linux/i386 (uses < 10 MB on > these platforms), but in Linux/Alpha the application consumes > 50 MB in > less than 24 hours. Since the Python application works good on two other > platforms, I assume the problem is either Python or glibc. More details: > > I've tried Python 2.1.1 and 2.2b1+, compiled with gcc 3.0.2. The app uses > the following modules: > > cgi codeop cStringIO dircache errno fcgi Formtools gettext HTMLcolors > HTMLgen HTMLutil os os.path popen2 pwd random re readline select socket > stat string sys sz_fcgi thread time traceback types > > Any ideas or hints on how I can debug this problem? Check out this patch which has been applied (9-Nov): http://sourceforge.net/tracker/index.php?func=detail&aid=478006&group_id=5470&atid=105470 That may address your problem. Specifically, it closes a leak in 2.2b1+. I don't know if it affects 2.1.1. There were a few other memory leak patchs that have been applied recently. Neal From weismann at netvision.net.il Fri Nov 9 17:25:48 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Sat, 10 Nov 2001 00:25:48 +0200 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> Message-ID: <02d901c1696d$7c192920$9792003e@rashome> I followed your "orders" and defined def handle_comment(self , com) : But after running the parser for few days , I encountered this error message File "C:\PYTHON21\linksExtractor.py", line 29, in activateAndClear self.feed(str) File "C:\Python21\lib\sgmllib.py", line 91, in feed self.goahead(0) File "C:\Python21\lib\sgmllib.py", line 158, in goahead k = self.parse_declaration(i) File "C:\Python21\lib\sgmllib.py", line 238, in parse_declaration raise SGMLParseError( SGMLParseError: unexpected char in declaration: '<' I can only guess The parser met a "< " and not a " To: "Amit Weisman" Sent: Wednesday, November 07, 2001 10:36 AM Subject: Re: " (mailed; will be posted if/when the message gets > through to my newsserver) > > hi amit, > > > I wasn't clear enougth . > > exactly my point ;-) > > > I know one should declare functions as > > def do_TAGNAME > > def start_TAGNAME > > def end_TAGNAME > > > > How do I declare function for the " > in addition the do/start/end methods, sgmllib lets you > define general handlers for stuff like entities, comments, > etc. to deal with things that start with " > def handle_comment(self, comment) > > or > > def handle_decl(self, data) > > (see the library reference for more info) > > > > From gh_pythonlist at gmx.de Sun Nov 11 16:14:25 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 11 Nov 2001 22:14:25 +0100 Subject: C modules with gcc 3.0.x In-Reply-To: <20011111.154717.381570572.10034@localhost.localdomain> References: <20011111.154717.381570572.10034@localhost.localdomain> Message-ID: <20011111221422.A943@lilith.hqd-internal> On Sun, Nov 11, 2001 at 03:47:18PM -0500, Robert Nikander wrote: > Has anyone been using gcc 3 with python C modules? When gcc 2.95 compiles > the module everything works fine, but if I use gcc 3 I get this.... > > Python 2.2b1 (#2, Nov 11 2001, 12:36:39) [GCC 2.95.3 20010315 (release - > Linux-Mandrake 8.0 for PPC)] on linux2 Type "help", "copyright", "credits" > or "license" for more information. > >>> import spam > Traceback (most recent call last): > File "", line 1, in ? > ImportError: libgcc_s.so.1: cannot load shared object file: No such file > or directory Well, programs compiled with gcc 3.x need a runtime library called libgcc_s. This one cannot be found in your linker's search path. Your options are: - set LD_LIBRARY_PATH to the directory this library can be found (I think it will be in $GCC3_ROOT/lib) - use the runtime_library_dirs of your setup.py to add the "-R" option to gcc. This should work, but in reality, it doesn't . It's either a bug in distutils or in my gcc (2.95.3). - Add the $GCC3_ROOT/lib directory to your dynamic loader's search path (/etc/ld.so.conf) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From peter at engcorp.com Thu Nov 22 19:01:37 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 22 Nov 2001 19:01:37 -0500 Subject: Indenting with tabs vs spaces References: <3bfd3552$1@207.229.64.20> Message-ID: <3BFD91E1.CA378A5B@engcorp.com> Top-posting error corrected... Peter Bismuti wrote: > "David Eppstein" wrote: > > "Peoter Veili" wrote: > > > > > Indenting with tabs can be done such that it will look the same on every > > > editor that uses fixed-width fonts, meaning everything will line up > > > correctly, it least in the sense that really matters. Here's an example > > > of what I mean: > > > > > > function helloThere("hello", > > > "there"){ > > > } > > > > I viewed your message with fixed-width fonts, and it came out unaligned as > > you see above. So I think your claim that "it will look the same on every > > editor" is false, and it is safer to stick with spaces only. > > > Be that as it may, I think what I have written is correct in general. Unfortunately, you are wrong to think that, as it is quite false. Maybe if you rewrote it as follows it would be "correct in general": """ Indenting with tabs can be done in such a way that it will look correct on some editors. """ -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From DTSRV10-SA at dutchtone.nl Thu Nov 29 15:06:10 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Thu, 29 Nov 2001 21:06:10 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C7187B@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = _dragonax at infinito.it Recipient(s) = python-list at python.org Subject = Scanning Time = 11/29/2001 21:06:09 Action on virus found: The attachment images.DOC.pif exists WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From max at alcyone.com Sat Nov 17 16:39:14 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 17 Nov 2001 13:39:14 -0800 Subject: identity = lambda x: x -- a Pythonic idiom? References: <3BF6C202.7EB544E0@alcyone.com> Message-ID: <3BF6D902.BC8742FA@alcyone.com> George Demmy wrote: > My understanding of Pythonic truth anything other than None, (), [], > {}, '', and 0 is true. I don't know what mathematical truth is -- got > a approachable reference for an interested non-mathematician? When you're using filter, the function you need maps an object to a truth value, but the identity function maps an object to itself. In Python this happens to be the same thing, but what you "really mean" is lambda x: operator.truth(x). -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From graeme at saebex.com Tue Nov 27 01:48:44 2001 From: graeme at saebex.com (Graeme Longman) Date: Tue, 27 Nov 2001 08:48:44 +0200 Subject: HOWTO: Programming S/MIME in Python with M2Crypto In-Reply-To: <20011127001748.B783@madcap.dyndns.org> Message-ID: Hi, >From my understanding you don't need to make any changes to Outlook to receive digitally signed mail. I have been using your your HOWTO to generate the certificates and the mime string of the signature. I have also managed to get the example, Sending S/MIME messages via SMTP, working with Outlook. I can't seem to get the earlier examples working though. I have tried fiddling with the mime string before sending it via SMTP but haven't had much luck. The same error message, "Can't open this item. An error occured in the underlying security system" always seems to 'pop-up', even though the actual mime of the email seems to correspond exactly to a working example. I know that in the HOWTO you don't actually send the example in 'Sign' but have you managed to send and receive this example. If you have successfully then maybe it is the 'Outlook' issue. Thanks for the help, Graeme -----Original Message----- From: ngps at madcap.dyndns.org [mailto:ngps at madcap.dyndns.org]On Behalf Of Ng Pheng Siong Sent: 26 November 2001 18:18 To: Graeme Longman Subject: Re: HOWTO: Programming S/MIME in Python with M2Crypto On Mon, Nov 26, 2001 at 11:28:40AM +0200, Graeme Longman wrote: > "Can't open this item. An error occured in the underlying security system" Whoops, replied on Usenet before I saw this. Essentially, I've never tested M2Crypto.SMIME with Outlook. If you can show me how to set up Outlook with keys and certs, I'll give it a go. Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From peter at engcorp.com Tue Nov 27 23:37:37 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 27 Nov 2001 23:37:37 -0500 Subject: how to call external functions from python References: Message-ID: <3C046A11.175B9FB5@engcorp.com> weeang wrote: > > i need help on the following: > > 1) find all files in inbox directory and zip them > 2) move the zipped file to outbox > 3) copy the zipped file to a remote directory What's an inbox? An outbox? There is no general implementation of such things, so your question must be platform and/or application-dependent. Knowing you are on Windows doesn't actually help. Do you mean Outlook? Probably not, since you mentioned you'll move to Linux. > i m using python 2.1, using windows for my initial testing. however, > i will subsequently use the script on a linux box instead. Maybe describing what your general objectives are, rather than the specific steps you think will get you there, would help. *Why* are you trying to do these things? There might be better options. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jdadson at ix.netcom.com Mon Nov 5 19:54:55 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 06 Nov 2001 00:54:55 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> <3BE7269A.692326EF@chello.nl> Message-ID: <3BE734BB.51C4488D@ix.netcom.com> Roeland Rengelink wrote: > > Jive Dadson wrote: > > > > Chris Barker wrote: > > > > > > While nothing is actually set in stone, some things are pretty well > > > cemented in. > > > > > > Jive Dadson wrote: > > > > Thanks. Before I submit a formal proposal, let me run it by you guys. > > > > > > That is a good idea, most PEPs start as a discussion here. AN a whle lot > > > more start that way and nver make it to a PEP. > > > > > > > I've looked through all the PEPS and I was surprised that my suggestion > > > > is not already there. So, here it is. Please comment. > > > > > > You can bet that this has been proposed by people new to Python again > > > and again and again ... > > > > What does that tell you? > > > > That people who are new to a language tend to perceive that language in > terms of languages they have used previously. I can't say that answer disappoints me, because I expected it. > The most common requests > for language additions by new users tend to fall in the "can't you add > this really nice feature from language X to Python" category. > ... > > You must have misunderstood what I wrote. I'm not proposing anything > > that would make it "lowly dynamic". > > > > Well, you use the term 'variable declaration' which for most of us > carries the connotation of both the definition of a name, and a > restriction of the type of values that can be assigned to it. aka static > typing. If you had read what I wrote, you would know I didn't mean anything like that. > The request for some kind of static typing is quite common. Off topic. > ... > > > > I didn't propose anything like that. The compiler will know that > > "initialized" is not local to init_everything because it is not declared > > there with a "def". That has absolutely nothing to do with anything > > outside the function init_everything. > > > > Yes you did ;)] Did not. (Did too.) Did not. > > Most local variables shadowing global names, are intended to be local. > Therefore, the only reasonable thing for your 'option explicit' to do, > would be to raise an Error with "undefined variable initialized in > init_everything". That's right. If you had read my the message you are arguing with, you would see that I proposed exactly that, even spelling out the syntax of the exception message. I'm dumping the rest of your message unread. Bye now. Jive From darnold02 at sprynet.com Wed Nov 21 07:11:33 2001 From: darnold02 at sprynet.com (Don Arnold) Date: Wed, 21 Nov 2001 12:11:33 GMT Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> Message-ID: <9tg5jm$9qg$1@slb2.atl.mindspring.net> Removing the root.mainloop() call does work, although Lutz specifically says you need it. I didn't realize he must only be referring to standalone Tkinter apps. Thanks for the response, Don On 20-Nov-2001, Prabhu Ramachandran wrote: > >>>>> "DA" == Don Arnold writes: > > DA> def quit(): print "Hello, I must be going" # import sys # > DA> sys.exit() root.quit() > > DA> root = Tk() widget = Button(root, text="Hello, event world", > DA> command = quit) widget.pack() root.mainloop() > > Well, what happens when you remove the root.mainloop()? > > Your other errors will occur simply because of the way you have > defined quit. Change it like so: > > >>> from Tkinter import * > >>> root = Tk() > >>> def quit(): > ... print "Hello, I must be going" > ... root.destroy() > ... > >>> widget = Button(root, text="Hello, event world", command = quit) > >>> widget.pack() > >>> # click on button > >>> Hello, I must be going > > This should definitely work. > > prabhu From sabren at manifestation.com Wed Nov 28 13:02:56 2001 From: sabren at manifestation.com (Michal Wallace) Date: Wed, 28 Nov 2001 13:02:56 -0500 (EST) Subject: Super-newbie needs help! In-Reply-To: <70c31206.0111280950.7ebe06ae@posting.google.com> Message-ID: On 28 Nov 2001, SnowCrash wrote: > "Write a program that continually reads in numbers from the user and > adds them together until the sum reaches 100. " > > Now, i have some code: > total = 100 > sum = input ("Enter your number.") > while sum < total: > print "You haven't reached 100 yet!" > sum = input ("give me another number") + sum > > print "Ok, you got me!" > > HUH? i don't think its right, i've changed it about 4 times before > posting it, and i've downloaded the Python 2.2 but can't seem to > figure out how to use the thing to check my code. i know its WILDLY > simple and feel like "well, gee, if i can't understand this much, then > i should quit before i feel REALLY stupid", but i am just going to > keep on truckin'....Hopefully with some help from comp.lang.python. The code looks about right to me. Just save it to a text file called something like "sum.py" and then run: "python sum.py" Or better yet, load it into the IDLE program that came with python, and hit F5 to run it. Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From ws at mystrobl.de Sun Nov 18 02:23:56 2001 From: ws at mystrobl.de (Wolfgang Strobl) Date: Sun, 18 Nov 2001 08:23:56 +0100 Subject: What is Type Error? References: <3BF75BFF.7070107@stu.ust.hk> Message-ID: On Sun, 18 Nov 2001 14:58:07 +0800, Calvin wrote : >Greetings, > I'm developing a simlator for LCD and get stuck with the Type Error. The >attached is my LCD.py file, when compile I got the following error: ... >self.__energy[n]=1/2(self.__lc.k1(self.__azimuth[n])*d_azimuth**2+self.__lc.k2(self.__azimuth[n])*d_twist**2 >+self.__lc.k3(self.__azimuth[n])*d_twist**2) >TypeError: object of type 'int' is not callable > >could anybody point out how can I solve it, I just got no ideas :( >>> print 1/2(3) Traceback (most recent call last): File "", line 1, in ? TypeError: object of type 'int' is not callable >>> print 1/2 * 3 0 >>> print 1/2.0 * 3 1.5 >>> -- Thank you for observing all safety precautions From frederic.giacometti at arakne.com Mon Nov 5 22:52:59 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Tue, 06 Nov 2001 03:52:59 GMT Subject: Is Stackless Python DEAD? References: Message-ID: > Frederic Giacometti wrote: > >This words seems to point out that the actual reason is not technical... > >This is definitely not a word from the realm of engineering, but more from > >someone sense of his core self being disturbed by an outsider. > > Not at all. Stackless would have ramifications not just for a few > files in the core, but also for all the extension modules that come > with Python and for all the authors of third-party extension modules. > In terms of number of files affected, "intrusive" isn't a bad word to > describe the Stackless patches. Yes, but the word 'intrusive' normally refers to a negative connotation; and the expression 'too intrusive' means what it means... From Peter.Milliken at GTECH.COM Thu Nov 29 22:46:40 2001 From: Peter.Milliken at GTECH.COM (Milliken, Peter) Date: Thu, 29 Nov 2001 22:46:40 -0500 Subject: Python evangelists unite! Message-ID: <0DFA7478F1E5D311B90900508B1208CF565555@ausmail02.mis.gtech.com> Ah, you said the magic in your opening lines "C++....". A maintainers life line - job security forever! The number of "large" projects that have used C++ just make me laugh all the way to the bank :-). A more cruddy language for implementing large projects I have never seen. But, as one manager used to argue, "I can get plenty of C++ programmers...." - despite the technical arguments for why C++ is a disaster of a language for large projects. I have no argument that python has probably saved your bacon many a time on a C++ project - but the base of the argument is floored. "...several thousand line program that quickly became unmanageable in C++...." :-). Python is a better language than C++ - I would lay C++ somewhere down the bottom of any list for implementing "largish" projects (I term "large" projects in millions of lines not thousands - sorry, I can't resist bragging :-)). As for the French - "Au contraire..." - I never could deal with the fancy stuff :-) In my opinion (:-)), C (and hence it's backward compatible "big brother") are "old" languages - neither of which I would choose from a software engineering principle perspective - but here I get onto ground that has been argued before (see the extensive thread on whether to implement an Air Traffic Controller in Python [comp.lang.python] - many people who participated in that thread know my opinions :-)). As for the poor coding habits of the projects that you have participated, you have my sympathy many times over :-). People keep making the same mistakes, that is one of the nice things about the software industry - nobody (appears) to want to learn from previous pioneers (how many people reading this have Steve McConnells book, Code Complete on their shelve - excellent book because if you read and practice that you will save yourself about 15-20 yrs of blundering around the coding world :-)). It all keeps people like me in a job (I currently work maintaining a "largish" C product :-)). So, sorry mate, I accept you have a place for Python, but all you are proving is my original statement. That different languages have different places. Have you ever seen the purported interview with Stroustrop about C++? I personally believe it to be true! :-). So, "Au contaire" to you too (and thanks for taking the bait :-)) Peter > -----Original Message----- > From: Jonathan Gardner [mailto:jgardn at alumni.washington.edu] > Sent: Friday, November 30, 2001 1:04 PM > To: Peter Milliken; python-list at python.org > Subject: Re: Python evangelists unite! > > > On Friday 30 November 2001 08:18 am, Peter Milliken wrote: > > I use Python as a good, quick and dirty hacking language. > For real (read > > production) stuff that I expect a customer to run or will > require more than > > a single person working for a couple of hours, I look > elsewhere :-). Sure > > there are examples of Python being used for "large" jobs - and very > > successful they have been too - but these people are > masochists (IMO) :-). > > They could have been more productive with other languages > that provide > > better support for generic software engineering > principles/standards. > > > > Au contraire... > > I find large projects benefit the most from python. I have a > several thousand > line program that quickly became unmanageable in C++. In > python, everything > just blends together seamlessly. When something goes wrong, I > don't have to > whip out a debugger because it is so easy to read the old > code, and I can > follow it with my finger better than a debugger could. > > The parts are extremely interchangeable, modifiable, and > reworkable. I can go > in and change any class, even the design, and it still pretty > much works. > When it doesn't, it is easy enough to debug. And the function > parameters? > THANK HEAVENS that someone has the sense to do what python > does when you have > like 2 million arguments to a function - NAMED PARAMETERS. > And one more word: > dir()/__doc__. Every time I wonder what something does, I > boot up the command > line, import it, and start dir'ing it and __doc__'in it. > Without even looking > at the code, I have figured out the most important parts, > because I have > documented it as I wrote it. > > With C/C++ you have messy defines and stuff you have to > manage in addition to > the code. And the code is unreadable, even if you are a > professional C++ > programmer. You have to remember what members there are, > whether they are > protected, public, or private, and whether the other guy is a > friend, child > class, or nobody at all. Not to mention you have to watch the > memory and > freeing it all the time - but not if someone else is still > using it! Keep > reference counts on pieces of data that are dynamic and used > by more than one > pointer; then there is the list/array management that has to > go on, the > off-by-one errors and the every to inevitable type-casting > problems... You > get the idea. It's a lot to remember as you debug old code. > It feels like > building a house with tiny pebbles and little sticks and > pieces of string. > > > There, that should bring the 'vangelists out of the > woodwork! :-) It's just > > too easy, they rise like starving trout - each language has > it's strengths > > and weaknesses. Python has some very nice features, I use > it a good deal. > > But it definitely has its place! > > > > I agree with you that there are limitations to Python; I > disagree with you > that Python was not meant for large projects. > > > In the meantime, my advice is don't get "emotionally" > hooked into the > > language. Analyse its strengths and weaknesses, consider > other languages > > and their strengths and weaknesses and then you can hold an > intelligent > > conversation with another programmer! :-) > > > > Exactly. Why do *you* use a language? The answer should > always be something > reasonable. It should never be emotional. Well, unless you > are a teenager, > then everything is emotional. =) > > Jonathan > From ballabio at mac.com Thu Nov 1 07:09:46 2001 From: ballabio at mac.com (Luigi Ballabio) Date: Thu, 1 Nov 2001 13:09:46 +0100 Subject: hola nesesito su ayuda (translated - well, kind of) In-Reply-To: <3BE0738C.3080201@movilogic.com> References: <3BE0738C.3080201@movilogic.com> Message-ID: >fernando orellana wrote: > >>hola que tal soy leandro vivo en un pueblito de argentina y estudio >>analista de sistemas. >> >>el punto es que estoy en la materia de computacion y estamos >>aprendiendo a programar con python me parace que esta rebueno, >>tanto como sus tutoriales. >> >>bueno les escribo porque tengo una duda nesecito hacer un sistenma >>de matriculacion y tengo que ingresar los nombres de los alunmos, >>asi como su correo, su numero de legajo y las materias que va a >>tomar, donde deveria meter estas variables?, en listas o >>diccionario o talves hacerlo con clases ? bueno si me pueden dar >>una mano mejor y si nescesitan mas datos o que sean mas puntuales >>diganme y yo les escribo de nuevo. >> >>desde ya muchas gracias por su atencion y perdonen mi molestia. >> >> suerte y gracias un saludo leo. Here is (I think) what Leandro asked above so that we all can try and help him: "I need to implement a registration system for students. I need to input the student name as well as its address, its registration number and the courses that he's going to take. Where should I keep these variables---in a list, a dictionary, or should I put them in a class?" Bye, Luigi -- From dcinege at psychosis.com Sat Nov 24 20:05:35 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Sat, 24 Nov 2001 20:05:35 -0500 Subject: Non-Indented python In-Reply-To: <3BFFACFB.36AF1DB2@engcorp.com> References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> Message-ID: On Saturday 24 November 2001 9:21, Peter Hansen wrote: > Unfortunately, since the definition of a tab is ambiguous and > inconsistent, # ascii tab ASCII 0/9 is decimal 009, hex 09, octal 011, bits 00001001: called ^I, HT, TAB Official name: Character Tabulation Other names: Horizontal Tab, \t It's what it's always been for at least 30 years... > Unfortunately, some people insist on using tabs with tabstop > sizes other than 8, # ascii tabstop ? Do relize this WHOLE TIME you are arguing a term that is only relevent for a particular (set of) ascii editor? There is no such thing as a 'tabstop' in the binary world. > In the end, if people mixed tabs which were not the typical > size A tab is a byte == 9. If you have a 'different sized' tab, it's called a different character, and not a tab! -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From qrczak at knm.org.pl Tue Nov 27 07:31:44 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Tue, 27 Nov 2001 12:31:44 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> Message-ID: Tue, 27 Nov 2001 01:27:15 +0000 (UTC), Huaiyu Zhu pisze: > - That there is no reason to associate tab with any equivalent in spaces. > It should only be used as a distinct character in its own right. What should a Python interpreter do with this? if 0: print "0" print "1" > There is no problem in using it the right way - as a place-holder of > indentation level. There is. When some lines use tabs and others use spaces, different tab sizes may cause different interpretations. But there is no problem with mixing tab and spaces if a tab *always* moves to the next multiple of 8 columns. That's why especially in a language with meaningful indentation it's important to have a consistent tab size. Mixing tabs and spaces is not recommended because some people use tabs in a wrong way (with a size different than 8), but I would not forbid it. One should not be forced to use tabs only because other lines in this file use tabs. Just keep a consistent tab size of 8 and problems disappear. > For example, got a problem with mixing tab and space? Well, just don't do > it. They are two different characters. It's the same as mixing w with vv > or mixing m with rn. So should Python reject lines indented with spaces? If it should allow either spaces or tabs (as currently), it's not like mixing w with vv. > Why would it matter to you how other people are displaying a particular > character on screen? Because the semantics of a Python program depends on the physical column when a line starts, after translation of tabs to spaces. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From montanaro at tttech.com Mon Nov 12 02:24:23 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Mon, 12 Nov 2001 08:24:23 +0100 Subject: Is this considered black magic? In-Reply-To: References: <200111111337.fABDb7eR012232@ratthing-b246.strakt.com> Message-ID: After rereading my own post, I think classcol = c.get("__class__") print classcol.get("__name__") should maybe be print c.get("__class__").get("__name__") to more strongly emphasize the correspondence with chaining attributes starting with a single object. Skip From QnickQm at alum.mit.edu Fri Nov 30 08:28:08 2001 From: QnickQm at alum.mit.edu (Nick Mathewson) Date: Fri, 30 Nov 2001 13:28:08 GMT Subject: New updates needed for an old computer language humor piece References: Message-ID: [comp.lang.{perl|logo} trimmed.] In article , Ric Werme wrote: > The following wandered into my mail box for the first time in a year > or two. Since I've been learning a bit of Python this year, it seems > to me an update is needed. Basic Python You shoot yourself in the foot. Python (Heavily Optimized) You save a reference to the getting-shot method of your foot so that you can shoot yourself over and over without having to take aim each time. Python (<2.2 member lookup) You ask your foot about getting shot. It doesn't know how to answer, so you check its address book. There's nothing about getting shot there, so you ask your foot about Footness, and check Footness's address book. Python (2.2 member lookup) You ask your foot about Footness, you ask Footness about "getting shot", and you tell "getting shot" about your foot. This yields a bound getting-shot methods ready to convey bullets to your foot. Python (Old-style iteration) You want to shoot the toes off your foot. You train your foot to consider your toes as members of a list from one to five. You count off, shooting at the toe your foot indicates. When your foot complains that there is no sixth toe, your toes will be gone. Python (New-style iteration) You want to shoot the toes off your foot. You wiggle them one by one, shooting the wiggling toes. When there are no more, you're done. Python (With generators) You want to shoot the toes off your foot. You ask your foot to tell you about all of your toes, but to please pause for a while after each one so you can shoot it. After you shoot, your foot begins where it left off. Python (c.l.py Flamewar version) "I've never held this kind of gun before, but its (indentation/ floating-point semantics/__future__ directives) make me utterly certain that everyone who does must be shooting themselves in the foot!" Python (Psyco version) Just as you're about to shoot yourself in the foot, your foot notices it's about to get shot by a bullet, the bullet notices it's about to hit your foot, and each immediately conforms to the other's shape. Future foot-bullet contacts will be far faster. Python (Time Machine version). You try to shoot yourself in the foot, only to realize that there's no need, since Guido thoughtfully shot you in the foot years ago. Apologies-to-Cyrano-ly Y'rs, -- Nick Matthewsen aa 1011011011 Remove Q's to respond. No spam. From phr-n2001d at nightsong.com Fri Nov 9 18:27:26 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 15:27:26 -0800 Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <7xzo5v34pt.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > > for i in 10: > > doSomething(i) > >... > This isn't even half as disgusting as most people will say it is . I > rather like it! Write a PEP. The trouble is as someone else noted, "for i in 10" replaces "for i in range(10)". But how do you handle range(1,10)? "for i in 1,10" does precisely the wrong thing. How about a way to use slices as iterators, with a little syntax so you can say "for i in 1...10"? 1...10 would get parsed as a slice object, that might or might not actually contain the Ellipsis. From jussij at zeusedit.com Wed Nov 28 21:37:56 2001 From: jussij at zeusedit.com (Jussi Jumppanen) Date: Thu, 29 Nov 2001 13:37:56 +1100 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> <9u21ch$bonls$1@fido.engr.sgi.com> <3C0562F4.7EE7D682@home.net> Message-ID: <3C059F84.6333@zeusedit.com> Chris Barker wrote: > Frankly, I wouldn't even care which, > although tabs may be a better choice because while "any decent editor" > can be taught to insert N spaces when a tab key is pressed, apparently > not all editors are "decent". I have found that using tabs for indenting > is the only viable option for me on the Mac, and I have to change to all > spaces when I move code to *nix/Windows, because the editors/IDEs I use > there assume spaces. A real pain. You are just using the wrong Windows editors/IDEs :) Most of the better editors/IDEs have no problems with tabs/spaces or even a mixture of the two. Jussi Jumppanen Author of: Zeus for Windows, Win32 (Brief, Emacs, etc) FTP Text Editor "The C/C++, Java, HTML, Pascal, Cobol, Fortran programmer's text editor" Home Page: http://www.zeusedit.com From kragen at canonical.org Wed Nov 21 15:38:55 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 21 Nov 2001 15:38:55 -0500 Subject: String formatting char References: <9tdde1$q6j$1@news1.wdf.sap-ag.de> <1h2nvt4gid8b1o9vv39ubqrmr7af05eb70@4ax.com> Message-ID: <83wv0jvoyo.fsf@panacea.canonical.org> Dale Strickland-Clark writes: > "Daniel Dittmar" wrote: > >The %(varname)s formatting can be implemented using the re.sub method: > > That's neat and gives you complete flexibility over the the > substitution syntax - you could use !var!, for example but assumes a > string substition. > > Also it would be much slower than the built-in function. It is indeed slower; whether this matters or not for your application is something you should think about. How many times are you doing % on how many different format strings and how fast does your application currently run? My benchmarking: Python 2.1.1 (#1, Oct 24 2001, 10:59:24) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import Speed >>> Speed.seconds_per_call(lambda: "This is a %(silly)s string for happiness" % {'silly': 'orange'}) 1.4125577446059787e-05 >>> import re >>> myre = re.compile(r'%\(([^)]+)\)s') >>> Speed.seconds_per_call(lambda: myre.sub(lambda match: {'silly': 'orange'}[match.group(1)], "This is a %(silly)s string for happiness")) 0.00017021971215807361 So there you have it: 170 microseconds for re.sub, 14 microseconds for builtin %. I think the other complaint, namely that you don't get all of printf's flexibility (to do %d, %f, %20.30s, etc.) is more significant. From p.vrijlandt at aig.azn.nl Wed Nov 21 06:49:14 2001 From: p.vrijlandt at aig.azn.nl (Patrick Vrijlandt) Date: Wed, 21 Nov 2001 12:49:14 +0100 Subject: DDE Client? References: Message-ID: <9tg4bp$k4k$1@odysseus.uci.kun.nl> This is all magic: import dde server = dde.CreateServer() server.Create('') conversation = dde.CreateConversation(self.server) conversation.ConnectTo(application, service) I'm afraid python dde leaks memory, but I haven't checked the source and have no confirmation from the author. If your application crashes after a few thousand dde-calls, think of this. -- Patrick "David Brady" schreef in bericht news:mailman.1006302086.2966.python-list at python.org... > Hi all, > > Recently I asked how Python could be used to perform > DDE, and the answer I got was something like "check > out win32all", which I have done. I am now at wit's > end. > > I have an application running that has a DDE server in > it. I know the name of server, the topic, and the > item I want to retrieve from it. I imagine from > reading ActiveState's documentation that if I have a > PyDDEConv object handy, I can call its > Connect(server,topic) method to get the topic, from > which I can get an item, from which I can make > requests. > > So, the question of the hour is, how in the heck do I > get a PyDDEConv object in the first place? > > Thanks, > > -dB > > ===== > David Brady > daves_spam_dodging_account at yahoo.com > I'm feeling very surreal today... or *AM* I? > > __________________________________________________ > Do You Yahoo!? > Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. > http://geocities.yahoo.com/ps/info1 > From modman at altavista.com Wed Nov 14 12:03:34 2001 From: modman at altavista.com (Modman) Date: 14 Nov 2001 09:03:34 -0800 Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: Michael Hudson wrote in message news:... > Roy Smith writes: > > > ianb at colorstudy.com (Ian Bicking) wrote: > > > If you look under the hood, Python is much more like Smalltalk than > > > Java. > > > > I'm having trouble parsing that. Which of the following did you mean? > > > > 1) Python is more like Smalltalk that Python is like Java > > 2) Python is more like Smalltalk than Java is like Smalltalk > > I think 1). > > Cheers, > M. both mean the same thing. Python is closer to smalltalk than Java is so the ST guru buddie was a bit off base to be compairing Py to J. From buzmeg at newsguy.com Thu Nov 1 16:57:29 2001 From: buzmeg at newsguy.com (buzmeg at newsguy.com) Date: 1 Nov 2001 13:57:29 -0800 Subject: fcntl semantics Message-ID: <9rsgg902rct@drn.newsguy.com> I've had to deal with fcntl directly for a while now and was thinking of moving my C programs to Python. However, the OS dependence of the packed structure used to access fcntl pretty much stops that idea cold. So, my question is: Why does fcntl use a packed struct as it's third argument? And why does it throw away the return code in that case? That particular mechanism actually goes out of its way to lose data. The complier knows the correct form of struct to put the data in when it compiles the modules, throws it away, the user has to dig out what that structure was, and then hard code it into the Python code. Additionally, it throws away the error/return code when you pass it a packed struct as the final argument. I can think of several ways that it could be coded, but the one I find the most appealing is: fcntl(fd,op,arg): arg is a hash -- keys are fcntl struct member names -- vals are values return value is a hash in same form Exception raised on error with return/error value in exception object All the information from the C function fcntl is accessible without any of the nasty OS/compiler dependence. It even allows future extension to the fcntl structs to be accomodated without changing the language semantics. It also doesn't require in place modification of data so it has a low surprise factor. In addition, the type of arg is different and identifiable from the previous form of fcntl (thus, previous semantics can even be preserved if desired). I would really like to know if there is a good reason for requiring packed data for fcntl (Perl does the same blasted thing), and, if not, the proper mechanism for attempting to get this changed in the language. I would even write the code, if required. Thanks, Andy L. From fredrik at pythonware.com Wed Nov 7 12:14:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 17:14:46 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: Steve Holden wrote: > > The fact that Ada is the only language that truly was designed, > [...] > Please. This sweeping generalisation lays all your other arguments waste. oh, give him a little slack. it might be true that the computer science department at his university isn't exactly the best one in Sweden (hardly his fault), but he has a point there: Ada wasn't just designed once, but twice. unlike e.g. Scheme, which we all know was discovered, not designed. (and we all know that the van Rossum's don't know anything about design ;-) From sironja at web.de Thu Nov 22 05:32:27 2001 From: sironja at web.de (Vlado) Date: 22 Nov 2001 02:32:27 -0800 Subject: PyClass_New and __getattr__ Message-ID: <9370329.0111220232.670574e2@posting.google.com> Hi, here a short question; I'm extending python through some C++ classes. I have defined a new type with PyClass_New() and added __getattr__ and __setattr__ to the class dictionary. However, these two get/set methods are not being called if class member resolve fails. An explicit call succeeds though, e.g. >>>t=Test() >>>t.i Traceback (most recent call last): File "", line 1, in ? AttributeError: Test instance has no attribute 'i' >>>t.__getattr__(t,'i') ok, test_getattr called Am i missing something? Thank you. Vlado ps. using Python21 and Python22a3 on win32 From stadt at cs.utwente.nl Mon Nov 5 18:32:37 2001 From: stadt at cs.utwente.nl (Richard van de Stadt) Date: Tue, 06 Nov 2001 00:32:37 +0100 Subject: time.daylight (Daylight Saving Time) References: <3BE68D3B.28AEA20E@cs.utwente.nl> Message-ID: <3BE72195.59BDD708@cs.utwente.nl> Matthew Dixon Cowles wrote: > > On Mon, 05 Nov 2001 13:59:39 +0100, Richard van de Stadt > wrote: > > >Hi, > > Hi! > > >I'm using time.tzname[time.daylight] to display the time zone. This worked > >fine as long a Daylight Saving Time (DST) was valid [...] > I think you want something more like: > > >>> import time > >>> timeTuple=time.localtime(time.time()) > >>> time.tzname[timeTuple[8]] > 'CST' > > You might want to check that daylight is nonzero first. Got it. Thanks. Richard. From jdadson at ix.netcom.com Wed Nov 7 21:48:48 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 08 Nov 2001 02:48:48 GMT Subject: C-extension in Python -- returning results References: Message-ID: <3BE9F266.A2794615@ix.netcom.com> Have you tested this thing in a stand-alone C program on the same data that's getting the failure under Python? I suspect your C code is actually generating an indeterminant result. You can pepper your C code with assert(_finite(number)); That will assert false if "number" is not valid (NAN, INF, IND, or whatever). Just skimming over the C code, it appears that you are using Gaussian elimination or some such technique. That probably won't get it. Equations for fitting data to a polynomial are frequenlty ill-conditioned. To have a fighting chance numerically, you probably need to use singular value decomposition or some other more robust technique. But even at that, the polynomial you finally get might be alarmingly wild - not interpolating well at all. I suggest you might want to re-think the model. Why a polynomial? Why specifically five degrees? Is there some theoretical reason? You might consider using some less parametrical approach like a neural network trained with weight decay. Talk to the folks in sci.math.num-analysis. Also, the folks in sci.stat.math are good at this sort of thing. Jive From arigo at ulb.ac.be Wed Nov 14 10:19:40 2001 From: arigo at ulb.ac.be (Armin Rigo) Date: Wed, 14 Nov 2001 16:19:40 +0100 Subject: Psyco 0.3.2 Message-ID: Hello everybody, A bugfix release of Psyco: http://homepages.ulb.ac.be/~arigo/psyco/ Just a quite note. I am starting to run out of free time for Psyco. I would like to put efforts in helping people understand how Psyco works, so that it can be developped up to a really usable state -- it is currently more of a proof-of-concept, but it would be just too bad to loose this opportunity, I guess. Besides, I believe that with some more work we could really turn the current version into something great. That's just too much for me alone now (I should be doing a math Ph.D. these days you know ;-). So my request is, Does anyone feel like investing some time in Psyco just on the basis of the current preliminary results ? Shall I write a technical in-depth overview ? A bientot, Armin. From jeff at ccvcorp.com Wed Nov 7 19:41:18 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 07 Nov 2001 16:41:18 -0800 Subject: integer to ascii References: <3be90fbc$0$232$edfadb0f@dspool01.news.tele.dk> Message-ID: <3BE9D4AE.A6DF3145@ccvcorp.com> Max M wrote: > "harry" wrote in message > news:VX7G7.18181$5e2.4403261 at news1.telusplanet.net... > > > instead of '5' as the output, how do i make the output as '23' -> string > > concatnation instead of integer. > > There are a few ways of doing it: > > rows = `2` > ( or rows = '%d' % 2 ) > columns = str(3) > joined = rows + columns > > or > > rows = 2 > columns = 3 > joined = `rows` + str(columns) > > all depending on how you want to use you variables afterwards. Or: rows = 2 columns = 3 joined = "%d%d" % (rows,columns) String formatting is your friend. It is *much* faster than concatenation with +, too (though this won't show up unless you're doing it in a tight loop...) Jeff Shannon Technician/Programmer Credit International From achim.domma at syynx.de Mon Nov 5 13:54:39 2001 From: achim.domma at syynx.de (Achim Domma) Date: Mon, 5 Nov 2001 19:54:39 +0100 Subject: Considering getting into Python... Any Pros-Cons? References: <3BE614BA.BAB07827@seebelow.org> Message-ID: <9s6n4k$lt8$01$1@news.t-online.com> Hi, > Although I think this is a good idea, I haven't personally done it, for > whatever reason. Instead, I've typically coded speed-sensitive things > entirely in C/C++, and non-speed-senstive things entirely in Python. I have used the boost library to use Python and C++ together. In my opinion this is the most powerfull language combination available at the moment. Beside some very specialized things (you will still need SQL to query a database) I don't know of any problem that I could be solved faster and cleaner in other languages. Another important 'pro' of python is the free choice of how to develop code. You can 'hack' a small script together very fast and don't have to care about OO programming, but in larger projects you have all OO features available. Generic programming is also no problem. I hate languages like Java which force you to use only on paradigma. greetings Achim From ohgr81 at earthlink.net Fri Nov 30 08:05:08 2001 From: ohgr81 at earthlink.net (oh gr"eight" "one") Date: Fri, 30 Nov 2001 13:05:08 GMT Subject: design pattern Message-ID: For Sale: Design Pattern CD Elements of Reusable Object-Oriented Software by Erich Gamma Richard Helm Ralph Johnson John Vlissides Basically, this is the famous GOF book on CD in HTML format. Asking $25 which includes shipping within continental USA media rate. I will sell it to other places on Earth, but additional shipping and very high bank charge for foreign checks will have to be considered. If interested please e-mail me. My e-mail addy is ikickss # yahoo dot XXX (Please replace # with @ and XXX with com.) Thanks for reading. From fredrik at pythonware.com Tue Nov 27 12:09:18 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 27 Nov 2001 17:09:18 GMT Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> Message-ID: <2NPM7.568$_06.167730@newsb.telia.net> Yong Lu wrote: > Agree, and maybe the index should be a little more comprehensive. what did you look for? "formatting, string" and "string formatting" and "string documentation" are all in the library reference index... ...and there's an entire chapter dedicated to output formatting in the tutorial. From mwh at python.net Thu Nov 29 05:44:17 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 29 Nov 2001 10:44:17 GMT Subject: *args and **opts oddities (?) References: <3C05F634.6EAB5E1@darwin.in-berlin.de> Message-ID: Dinu Gherman writes: > Hi, > > I'm trying to transform *args and **opts parameters and pretend > they were passed in some transformed way. What I find is an un- > expected phenomenon that makes me use indices in the code below > (in function transform1) to get the behaviour I want. Is there > any good explanation for this? > > Thanks, > > Dinu > > > # unexpected result: lines (1) and (2) are not equal > > def transform0(*args, **opts): > print 't', args, opts > return args, opts > > def call0(*args, **opts): > print args, opts # (1) > args, opts = transform0(args, opts) Think about what this does; it calls transform0 with two positional arguments, the tuple `args', and the dictionary `opts'. These then go into the `*args' parameter of transform0, and the dictionary `opts' is empty -- because there weren't any keyword arguments. Did you want to write args, opts = transform0(*args, **opts) ? Cheers, M. -- The Oxford Bottled Beer Database heartily disapproves of the excessive consumption of alcohol. No, really. -- http://www.bottledbeer.co.uk/beergames.html (sadly now 404 compliant) From daniel.dittmar at sap.com Tue Nov 6 11:09:42 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Tue, 6 Nov 2001 17:09:42 +0100 Subject: count in 'for ... in ...' References: <9s90mr$osk$00$1@news.t-online.com> Message-ID: <9s9204$a73$1@news1.wdf.sap-ag.de> I'm generally using something like: class IndexLoop: def __init__ (self, list): self.list = list def __getitem__ (self, index): return index, self.list [index] use as in for index, entry in IndexLoop (list): ... Daniel From cgw at alum.mit.edu Tue Nov 27 18:07:15 2001 From: cgw at alum.mit.edu (Charles G Waldman) Date: Tue, 27 Nov 2001 17:07:15 -0600 Subject: C++ debugger for python/scintilla? In-Reply-To: <000301c17796$09f78260$1d4bb43f@kens> References: <000301c17796$09f78260$1d4bb43f@kens> Message-ID: <15364.7331.881561.622291@nyx.dyndns.org> Ken Seehof writes: > Any know how I might go about implementing a C/C++ debugger in > python for debugging python extensions? Is such a project being > worked on? > > The main features that I need are: > 1. place a breakpoint in a python extension source code file > 2. invoke a python callback when a breakpoint (or exception) is hit > 3. step through extension source code > 4. access the symbol table > > Is anyone using PyGDB? Is it what I'm looking for? At first > glance, it appears to be inside-out compared to what I want. PyGDB > apparently is a python script that uses gdb to debug python code, > rather than a python module that debugs extensions (in other words, > PyGDB set breakpoints in python code, but I want to set breakpoints > in C++ code inside extensions). Perhaps I can use gdb.py directly > as a module? PyGDB has two modes - C mode and Python mode. In C mode, you can print out values of C expressions, or put breakpoints at any line in any C file - it plays just like GDB. In Python mode, you print Python expressions and place breakpoints on any Python line. It's really a hack, the Python breakpoint feature works by putting a break inside ceval, where the "SET_LINENO" opcode is handled - every time this breakpoint is hit, PyGDB checks the Python line number and file to check if they are in the list of Python breakpoints. The bad news: thanks to the current job situation, I'm no longer doing full-time Python work and currently have very little time to hack Python (although I would dearly love to change this). PyGDB is in a state where it kinda works, but it's very fragile (it doesn't always track GDB state perfectly) and hackish at this point. I'd like to see it turn into something more real... if anybody wants to work with me on this, I will try to help... at least you can take the current PyGDB as a starting point. From wurmy at earthlink.net Tue Nov 27 12:38:59 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 27 Nov 2001 17:38:59 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3c029caa.260513688@news.laplaza.org> Message-ID: <3C03CFAC.6A29863@earthlink.net> Max wrote: > >There need not be 50 conflicting opinions. One only needs two editors: > > > > - Vim > > - Emacs > > > >=) > > > >Tim Hammerquist > > Why two editors? Will not one or the other do? Yes, but which one that is has been an age-old dispute. :-) (Hint: I use the one that has the same name as a Dutch cleaning solution. :-) --Hans From brian at rk-speed-rugby.dk Wed Nov 7 04:10:30 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 07 Nov 2001 10:10:30 +0100 Subject: Teaching python (programming) to children References: Message-ID: "Carlos Gaston Alvarez" writes: [snip] Carlos, these are all really good points, which I agree on, particularly of course the distinction between the language used for programming and the language of the documentation. The idea with a game to improve seems to be quite interesting. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From philh at comuno.freeserve.co.uk Fri Nov 23 11:38:26 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 23 Nov 2001 16:38:26 +0000 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: On Fri, 23 Nov 2001 05:08:06 GMT, stephen cox wrote: >> 2. I also need something practical to get away from the borg; I made >> a big mistake during the 1990s and moved from Clipper to Visual Basic, > >MS's new .NET Framework is impressive. And believe it or not it works. And >you can use Python as you lang of choice if you prefer. Also supported are >J#, C#, C, Cobol, and of course VB (ASP w/VB. No more VBA). Another shocker >is that the Framework is available for free. That's free beer not free speech, right? I doubt very much that it is free (as in beer), in the sense that the only reason they would be willing to distribute it without you giving them money is that it would be hard for you to do much with it without paying MS in other ways. Like with IE; you can download it without cost, but you need to buy other MS stuff to use it (Windows). > And MS is porting it to Linux I will believe this when it happens. >and FreeBSD. Ditto this. Remember folks, MS's strategy is to attempt to lock you in to a MS-only world. If you write you code for a MSA platform, and then you find that it doesn't run on non-MS platforms, and that you are subject to gratuitous incompatibilities, upgrade treadmills, and extortionate software rental agreements, don't come crying to me. Because it'll be your own fault. > Also you do not need Visual Studio I agree. You don't need MS at all. FORMAT C: and install Linux. > (which is crap. Even the new >one). I use Dreamweaver for design work, and do my scripting in ASP, or PHP >depending on the job. I'm also learning Python.. and plan to use Python to >replace PHP and ASP. For most jobs Python is better than PHP. Though for simple, web-based applications PHP is good. >Oh, I too made the same mistake moving from xBase (Fox, dBase, Clipper) to >VB and regret it. Although FoxPro was acquired by MS a few years ago, they >still treat it like a step child. It's the best damn desktop DBMS in the >world. And the play it down all the time. That's because it doesn't fit in with their plans of locking users in. They only bought it so they could migrate FoxPro users to their other products such as Access. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From delgado at eva17.Mathematik.Uni-Bielefeld.DE Fri Nov 30 19:06:45 2001 From: delgado at eva17.Mathematik.Uni-Bielefeld.DE (Olaf Delgado) Date: 30 Nov 2001 19:06:45 MET Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: In article , Erann Gat wrote: [...] > >biff() # Line 0 >for x in l: # Line 1 > foo() # Line 2 > baz() # Line 3 ># end for >bar() # Line 4 > >What I am suggesting is no different, except that instead of "# end for" I >want to use ";". The reason is simple: it's less typing, and it's easier >to modify emacs python-mode to detect a trailing semicolon than an >end-block comment. Yes, but IMO it would be far too easy to mess up the trailing semicolons when adding lines to or removing lines from the end of a block. Here's another suggestion: legalize a semicolon on a line by itself. Thus the code above would look something like this: biff() # Line 0 for x in l: # Line 1 foo() # Line 2 baz() # Line 3 ; bar() # Line 4 This I think is much easier to keep track of by a human programmer. The solitary semicolon should be equivalent to whitespace, so code like for x in l: ; bar() would still be illegal. My two cents. -- //// Olaf Delgado Friedrichs, Dept. of Chemistry, Olaf Arizona State University, Tempe AZ 85287, USA `=' phone +1-480-965-6570 fax +1-480-965-2747 http://www.mathematik.uni-bielefeld.de/~delgado From news at davidglasser.net Sun Nov 25 20:47:36 2001 From: news at davidglasser.net (David Glasser) Date: Sun, 25 Nov 2001 20:47:36 -0500 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> <3bfecd77@brateggebdc5.br-automation.co.at> <97ae44ee.0111232129.550244cd@posting.google.com> Message-ID: <1f3g4du.1a187a45257e4N%news@davidglasser.net> Martin von Loewis wrote: > I believe the algorithm used is cryptographically weak. As the > comments suggest, the algorithm is the one used by the German Enigma > machine from WWII. For those, a team lead by Alan Turing eventually > implemented computing hardware that would break the new codes every > day. I wonder if it's legal to download Python in France... after all, it comes with NAZI ENCRYPTION SOFTWARE! -- David Glasser news at davidglasser.net http://www.davidglasser.net/ From kragen at pobox.com Fri Nov 30 17:23:11 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 30 Nov 2001 17:23:11 -0500 Subject: popen with separete stdout/stderr deadlock. References: <3c069454@news.bezeqint.net> Message-ID: <831yifvqy8.fsf@panacea.canonical.org> Eyal Lotem writes: > When running popen with a separate stdout/stderr, can I use read() on the > resulting stdout file? it seems to 'hang', and I'm assuming stderr's buffer > is stuck on write (as it is all filled up), and my stdout read() is stuck > on waiting for EOF, which will never come. Deadlock. > > Is this really what's happening and how can it be avoided? Could be. import select and use select.select to avoid it. From prabhu at aero.iitm.ernet.in Mon Nov 5 07:43:30 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 5 Nov 2001 18:13:30 +0530 Subject: How much is set in stone? In-Reply-To: <7x4ro94uuh.fsf@ruckus.brouhaha.com> References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE623BF.9F4EA0F2@seebelow.org> <7x4ro94uuh.fsf@ruckus.brouhaha.com> Message-ID: <15334.35186.342916.40540@monster.linux.in> >>>>> "PR" == Paul Rubin writes: >> Therefore, this simple but powerful idea gives you nearly all >> of the benefit of variable declarations, yet none of the >> baggage. PR> Of course it doesn't. If you misspell a symbol in some rarely PR> used path through the code, it's quite possible your testing PR> will miss it. Compile time checking wouldn't. To catch these, maybe you should look at: http://pychecker.sourceforge.net/ prabhu From DeVerter at robinsonmechanical.com Fri Nov 9 17:42:12 2001 From: DeVerter at robinsonmechanical.com (DeVerter at robinsonmechanical.com) Date: Fri, 9 Nov 2001 15:42:12 -0700 Subject: count in 'for ... in ...' Message-ID: Or try this: for s in my_list: print str(my_list.index(s)+1) + ". " + s Mark d. Uwe Schmitt To: python-list at python.org Sent by: cc: python-list-admin@ Subject: Re: count in 'for ... in ...' python.org 11/06/01 08:58 AM Achim Domma wrote: | Hi, | if I have a list of strings and want to display with a count in front of it | I usualy do something like: | for i in range(len(my_list)): | print i,". ",my_list[i] | but I think the | for s in my_list: | print ... What about the following ? idx=0 for s in my_list: print idx,".",s idx+=1 Greetings, Uwe -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 -- http://mail.python.org/mailman/listinfo/python-list From sholden at holdenweb.com Fri Nov 2 09:00:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 09:00:20 -0500 Subject: references ??? References: <9rtpsc$13j2@newton.cc.rl.ac.uk> Message-ID: "Thomas Weidner" wrote ... > In <9rtpsc$13j2 at newton.cc.rl.ac.uk>, Richard Brodie wrote: > > > > "Thomas Weidner" wrote in message > > news:pan.2001.11.01.17.30.27.280.2271 at gmx.net... > > > > > >> I think anybody here knows what references,like in java,c++ or perl, > >> are. How can i use references in python ? > > > > Implicitly. Consider the following: > > > >>>> a = [1,2,3] > >>>> b = a > >>>> b[1] = 20 > >>>> print a > > [1, 20, 3] > > Interesting.... > Is this also possible for single values like ints ? > How do i make clear if i want a copy of a or a reference to it ? Generally, this only matters if the object is mutable (i.e. can change in place). This is the case for lists, for which you would use either copy.copy() or copy.deepcopy(), depending on how deeply you want to do the copying. Simple assignment always binds the name on the left-hand side to the object referenced on the right-hand side. regards Steve -- http://www.holdenweb.com/ From peter at engcorp.com Fri Nov 9 21:32:45 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 09 Nov 2001 21:32:45 -0500 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> Message-ID: <3BEC91CD.2D54508D@engcorp.com> David Andreas Alderud wrote: > > Python is without doubt a very good language, but it's not good for the > beginner because they will pick up bad practices, mostly because of the > loose type paradigm. This, of course, represents a value judgment on your part that loose typing (and by the way, Python is *strongly* typed, but dynamically so) is a bad thing. In any case I would argue that the habits beginners would pick up learning Python would serve them well in the future. When they get to a statically typed language, or a weakly typed one (Python is neither), they will question *its* value and ease of use. > For teaching programming I strongly belive that Ada95 is by far the best, it > teaches the students how to write good code; No, good teachers who promote consistent coding style, modular design, unit testing, and so forth teach students how to write good code. The language has very little to do with it, except insofar as some languages get in the way of that, while others do not. Python does not. > I do believe that at least in > universities Python should be the language of choice beyond the first year > studies, unless doing hardware or AI programming. Python has proven very effective for hardware programming. Yes, via a DLL or driver or something, but then again very little of what constitutes "hardware programming" involves access to the hardware, and most involves what you *do* with that access. AI programming is apparently best done with LISP according to some, but I've found Python nice for, say, genetic algorithms, so I wouldn't say it represents a necessarily *bad* choice. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fdrake at acm.org Thu Nov 15 12:35:24 2001 From: fdrake at acm.org (Fred L. Drake) Date: Thu, 15 Nov 2001 12:35:24 -0500 (EST) Subject: [development doc updates] Message-ID: <20011115173524.741DD28697@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Added a chapter on Tkinter & friends, contributed by Mike Clarkson. There are a few additional updates as well. From cliechti at gmx.net Tue Nov 27 19:59:27 2001 From: cliechti at gmx.net (Chris Liechti) Date: 28 Nov 2001 01:59:27 +0100 Subject: GUI/data object oriented design question References: <20011127180304.6aa502e6.gry@ll.mit.edu> Message-ID: [posted and mailed] george young wrote in news:20011127180304.6aa502e6.gry at ll.mit.edu: > I think this may work, but the explicit manipulation of "data_type" > etc. seems pretty kludgy. Is there some "pattern" that solves this? > > My first thought was for each GUI object to have a reference to it's > respective data object, e.g. a StepWin has a Step reference. But then > the Run has to maintain it's own parallel list of Steps, while the > RunWin has it's list of StepWins. And the resulting references needed > by callbacks get very ugly. thats called "Model-View-Controller" (MVC). your GUI component (View) has to get its value from the Model. a Controller e.g. a button changes the state of the Model. the "callback" is solved by the "observer pattern". e.g you implement a "update(source, args)" method in you GUI components and register it at the Model. the Model is then responsible to call all "update"s when it changes. such an oberservable class (register, remove, call observers) can be programmed very generally and you just inherint from that class when a Model needs it (very easy as python as multiple inheritance) here's an implemenation example: http://mail.python.org/pipermail/python-list/2001-January/026166.html > I've been staring at this stuff far too long and would be very grateful > for some suggestions. I hope I've explained the problem enough... hope i've undertand you question correctly... chris -- Chris From dalke at dalkescientific.com Tue Nov 13 14:16:32 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 12:16:32 -0700 Subject: bool() or similar References: <9srjeu$ijn$1@isp-m-srv06.izb.net> Message-ID: <9srrfr$b3v$1@slb6.atl.mindspring.net> Oliver Fromme: >However, I wonder if there is a good way to convert some- >thing to a boolean value (0 or 1), given any type of object? >Such as a bool() function, which works in the same way as >int() or str(). I.e. it would return 0 when given either >0, "", an empty sequence or an empty mapping, and 1 other- >wise. >>> for x in (0, 1, 2, (), (1,), ((),), [], ["Q"], "hello", ""): ... print repr(x), operator.truth(x) ... 0 0 1 1 2 1 () 0 (1,) 1 ((),) 1 [] 0 ['Q'] 1 'hello' 1 '' 0 >>> Andrew dalke at dalkescientific.com From Cashad at naturallife.ca Sun Nov 18 13:02:40 2001 From: Cashad at naturallife.ca (Cashad at naturallife.ca) Date: Sun, 18 Nov 2001 11:02:40 -0700 Subject: $71000 - 15 yr old made "AS SEEN ON ABC 20/20" Message-ID: <219480-220011101818240694@naturallife.ca> AS SEEN ON ABC's 20/20: The amazing story of a 15 yr. old boy who made over $70,000 on the internet in a matter of weeks. He designed the EASIEST HOME BUSINESS EVER. It's honest, it's not multi-level and best of all, IT'S SIMPLE. You won't be bugging your friends and family. A little time spent each day and only $25 invested and the program begins to work for itself. I figured if a 15 year old boy can do it so can I (a 34 year old IT Manager). For more information email me at cashad at naturallife.ca I had gotten a few of emails about this program, but just deleted them. My curiosity was killing me. So, I finally decided not to delete it. I figured, "hey, it can't hurt to check it out". That decision has changed my life. Here you have the very same opportunity in front of you. If you take just five minutes to read through a program that could make a huge difference in your financial status. This is the type of opportunity we all pray will come along. Since this program aired on National TV, thousands are joining every Hour. You'll earn cash in a matter of a couple of weeks! I did. More information by emailing me at cashad at naturallife.ca THIS IS NOT A SCAM ABC 20/20 PROVED THAT AND ITS JUST TOO....SIMPLE!!!! WE DO NOT SPAM. You are receiving this information via opt-in only. And you may opt-out at any time. If you are not interested and want confirmation of removal, and in compliance with proposed federal legislation (H.R. 3113 and S. 2542) and ll enacted state legislation, reply to this email with 'remove' in the Subject line. From colinmeeks at rogers.com Mon Nov 26 09:14:23 2001 From: colinmeeks at rogers.com (Colin Meeks) Date: Mon, 26 Nov 2001 14:14:23 GMT Subject: HTTPLIB - Problem retrieving a page References: Message-ID: <37sM7.7568$2Fd.3180@news1.bloor.is> Hi Oleg > I tested the site a bit and found that it responds Error404 to HTTP/0.9 > requests (I tested it with netcat). HTTP/1.0 and HTTP/1.1 requests are ok. > So the reason is (or at least may be) that your version of Python library > does not send HTTP version with request. Try to verify this (that is, look > into headers that httplib sends; use debugging proxy or fake http server > for testing - there are a number of pure python tools for this task). I tested this on my own box using Apache and in the logs it says the requests are in fact HTTP/1.1,however when I turn HTTPLIB debugging on it says the GET is HTTP/1.0. Here is the debug info: connect: (www.meeks.ca, 80) send: 'GET /index.htm HTTP/1.0\r\n' send: 'Accept: text/html\r\n' send: 'Accept: text/plain\r\n' send: '\r\n' reply: 'HTTP/1.1 404 Not Found\r\n' header: Date: Mon, 26 Nov 2001 14:10:50 GMT header: Server: Apache/1.3.20 (Unix) FrontPage/5.0.2.2510 mod_ssl/2.8.4 OpenSSL/0.9.6b header: Connection: close header: Content-Type: text/html; charset=iso-8859-1 Any firther ideas of what to try?? I'm using ActiveState Python 2.1.212 Regards Colin --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.286 / Virus Database: 152 - Release Date: 09/10/2001 From eric at quadgames.com Fri Nov 16 06:43:41 2001 From: eric at quadgames.com (Eric van Riet Paap) Date: Fri, 16 Nov 2001 12:43:41 +0100 Subject: Python+PIL in ActiveX control Message-ID: <1005911091.924654@news.knoware.nl> Hi all, I was trying to embed the Python interpreter in a windows ActiveX control. The control I was working on can read and display tga files. To make it more powerful I wanted to embed the Python Image Library (and Python) in the control. However: I ran into very odd problem! I've made an activex method the would execute some python code, in the line off: Py_Initialize(); PyRun_SimpleString("a=3\n"); The problem is that Py_Initialize(); seem to working, but when the next line is executed the control rapidely consumes all available memory and starts swapping to disk. The control can be found in: http://quadgames.com/dev/ You must first register the control with the register.bat script. After that the two test examples (source included) can be run, they have identical functionality, but one is written with Macromedia Director 8.5 (Shockwave) and the other with VisualBasic6.0. When you press the Python button in these programs while the task manager is open you see what I mean! You can kill the program when yoedon't wait too long, but be careful that you don't have important programs open!!! enjoy, Eric van Riet Paap, QuadGames.com Oudegracht a/d Werf 309 3511 PC Utrecht, The Netherlands From ws-news at gmx.at Fri Nov 16 13:07:37 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 19:07:37 +0100 Subject: python vs ecmascript References: Message-ID: <3bf556ac$1@brateggebdc5.br-automation.co.at> Hi, my last contact with JavaScript is quite a bit in the past and limited to client-side web scripting. So maybe I'm not completely up to date what JavaScript and its features is concerned. Anyway "Peoter Veili" wrote in message news:mailman.1005928823.20662.python-list at python.org... > Anyone familiar with ECMAscript (JavaScript)? How does it compare to > Python? ..... Isn't Javascript pretty limited what the creating of objects in the language itself concerns? In Python you can create classes as to your desire, and starting with Python 2.2 you can even derive your classes from builtin types. The powerful builtin types like Dictionary, List and Tuple are also worth mentioning. Especially because they are intrinsic concepts of the language and not awfully glued on like this happened with VB's Collection class for example. Are there any similar concepts in JavaScript? Another argument for Python is it's amazing community. Some of Python's concepts may be strange at first view, but once you're accustomed to Python's way of doing things, this will no longer annoy you. Python does not coerce each and everything to a string for you. But on the other hand, you can freely define, how your objects should behave when they are converted to strings. AND you can define how operators like + and - should work with your objects. There are a lot of nice features in Python, which all to mention would be 1) difficult because it's to easy to miss one and 2) would make this post into a book. I think you try to find out how to do things with Python rather than translating concepts from other languages literally. If you miss some feature, you will usually be able to find a Pythonic way to do it (e. g. in this news-group). But if you cannot live w/o curly braces as block delimiters, then Python would be not your tool. ... > also a bit annoyed at some things like having to wrap objects in a str() > before > printing, I don't see why this can't be automatic. This thing about only > having > two scopes, local and global, I don't see the logic. Is this by design, or > is it > simply a current limitation? The book I have says it may change in the > future. ... 1) You can define your own functions and methods to accept everything and treat it properly if you like. So this is not really a limitation in a technical sense. You can also use backticks ` instead of str() if this is more convinent for you. 2) Python 2.1 introduced nested scopes as an optional feature, Python 2.2 will make it the standard behaviour. Search the Python docs for 'nested scopes' to find out more. hava fun (with Python) Werner I studied ECMAscript last year, people have an aversion to it > from doing web client programming, but it is a high-powered OO scripting > language in its own right. Clearly the one downside of ECMAscript vs Python > is that Python has been around longer and has a large set of existing > libraries. > Besides that is there any major advantage that Python has? I am new to > Python > but already I am seeing some limitations that don't exist in ECMAscript. I > am > also a bit annoyed at some things like having to wrap objects in a str() > before > printing, I don't see why this can't be automatic. This thing about only > having > two scopes, local and global, I don't see the logic. Is this by design, or > is it > simply a current limitation? The book I have says it may change in the > future. > > > From loewis at informatik.hu-berlin.de Mon Nov 5 15:03:50 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Nov 2001 21:03:50 +0100 Subject: Where is xml.dom.core? References: Message-ID: lars at larsshack.org (Lars Kellogg-Stedman) writes: > I'd like to start using python for some XML generation. I've got python > 2.1.1 and PyXML 0.6.6, but all of the tutorials and examples I've come > across start out with: > > from xml.dom import core Where did you read that? I recommend to read the tutorial at http://py-howto.sourceforge.net/xml-howto/xml-howto.html Regards, Martin From peter at engcorp.com Mon Nov 19 20:05:36 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 19 Nov 2001 20:05:36 -0500 Subject: Newbie-ish question References: <_ZeK7.505628$ME2.63350791@typhoon.kc.rr.com> Message-ID: <3BF9AC60.F069AD2D@engcorp.com> Patrick Moorman wrote: > > I have a directory containing a large number of files in the format xy.txt > where x is a string of numbers and/or letters and y is a sequential number > with either 2 or 3 digits. Example: 1foo23012.txt or foo12305.txt. How > would I go about identifying all of the files in a sequence and moving them > to their own sub-directory. It might help us understand the problem further if you could explain what it was about: mv 1foo23*.txt subdir (for Windows substitute "move") which doesn't do what you want? Do you have lots of other files which have the same pattern but aren't in sequential order or something? (Or was this merely a learning exercise, in which case Sean's comment is still key...) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nhytro at t-online.de Fri Nov 2 03:09:24 2001 From: nhytro at t-online.de (Sharriff Aina) Date: Fri, 2 Nov 2001 09:09:24 +0100 Subject: Packaging problems with PMW Message-ID: <000801c16375$aff24c20$6b0852d9@isis> Hi! My application is a script that uses PMW and tkinter. The application that I?m trying to distribute consists of 2 files; the main script and an OptionDB file to globally configure the tkinter widgets. I have used the "Bundlepmw.py" script to create pmw.py for packaging purposes. I have tried Mr. Hellers "Py2exe" and Mr. Mcmilllans "installer", both create executables, but sadly the excutables created don?t work!, both complain that "PmwColor" is missing. Can someone well versed in python distribution create some kind of "hello world" ? both packagers have have simple documentation that I understand and have read a couple of times but they don?t cater for the case of using PMW or separate OptionDB files. For instance, where does one put the genereatd PMW.py library? I put it in the directory where my script lies, i?m not sure if this is correct though. Thanks for any help on this issue. Sharrff P.s. is there some way to inteface this list? I would like to reply to threads directly and not just post to "python-list at python.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From phr-n2001d at nightsong.com Fri Nov 9 21:35:28 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 18:35:28 -0800 Subject: How much is set in stone? References: Message-ID: <7xadxv9wun.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > I invite anyone who cares to study the bug lists for Perl, gcc and > Python, and draw an informed conclusion from that. You (Paul) have > spread FUD about 2.1.1 before, and I can assure you we didn't pay > everyone on c.l.py to refrain from posting "me too!", neither to > write about their Python apps running for months at a time. Your > experience remains unique, irreproducible (last I heard), and > *could* be caused by any number of computer problems, both hardware > and software. While *a priori* a crash in a Python program is most > likely a bug in Python, the lack of any confirming reports also > requires explanation. It's not intended as FUD. Other people did report similar crashes. It's conceivable that my crashes weren't caused by Python bugs, but signs don't point that way. Comparing Python with Perl, generally I find Python better designed but its implementation more likely to take short cuts. The security issue with pickle.loads that we spent a long time discussing is something I think the perl developers would not have tolerated. There's all kinds of other missing functionality in the runtime system as well, that doesn't result directly in unrobust programs, but does make it more difficult to write robustly. A lot of this ng is about the resulting issues. I think Python is promising and exciting and I like programming in it. It's just inaccurate to say it's as far along in development as some other languages. From tim.one at home.com Mon Nov 12 14:05:37 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 12 Nov 2001 14:05:37 -0500 Subject: Tkinter Crash under PythonWin In-Reply-To: <3bf01850.1296461609@news1.on.sympatico.ca> Message-ID: [Robert Roy] > PythonWin and Tkinter do not play nicely together. Neither do IDLE and Tkinter, unless you know exactly what you're doing. This isn't easy to fix; it's an open issue in PEP 42. From soporte at integralab.com Fri Nov 30 12:39:50 2001 From: soporte at integralab.com (soporte at integralab.com) Date: Fri, 30 Nov 2001 18:39:50 +0100 Subject: ANNOUNCE WeakList Message-ID: <007901c179c6$03721c20$f575393e@integralabzenon> I have forgotten the most important thing: http://www.integralab.com/integralab/andres -------------- next part -------------- An HTML attachment was scrubbed... URL: From aeoo at myspamrealbox.com Fri Nov 2 18:08:41 2001 From: aeoo at myspamrealbox.com (Leo Lipelis) Date: Fri, 02 Nov 2001 18:08:41 -0500 Subject: Exception handling wart in Python References: Message-ID: On Fri, 02 Nov 2001 14:37:22 -0500, Huaiyu Zhu wrote: > On Thu, 01 Nov 2001 19:35:46 -0500, Leo Lipelis > wrote: > > Exception is a mechanism to treat low probability situations so that > they do not distract the main flow of the program. Python allows you to > ignore them or handle them any way you like, so that you can concentrate > on the main thing you are doing. Java forces you to treat them all > explicitly, which sort of defeats its purpose. It becomes essentially a > glorified condition-goto structure. Since in any real world situation > the probability distribution of cases are far from uniform, I find > Python style exceptions far more efficient. I agree with your sentiment here. You present your points clearly here. However, what I want does not take away anything from Python as it is now. It's not something that would *force* anything, or even something that would *have* to become part of the compiler. It would be a standard tool that would be available to those who *want* to check if they are leaving out some unhandled exceptions. To actually *wait* for most common exceptions to happen is definitely one strategy. But somehow I don't feel that this is a "scientific" (for the lack of the better word) way of doing it. Regarding the binding problem with: a, b = c(d) This really goes to the issue of generic programming. It seems like every function in Python is generic, but in reality it is not so. In the real world (in Python) there is a class of functions that can be and truly are generic, and there is a much bigger class of functions (in Python) that really only make sense with particular data types. Perhaps, it would be a good idea to give the exception flow checker tool some hints in the source code about the function being generic or not. That way you can avoid the problem of seemingly being asked to handle *all* possible exceptions in generic functions. Or, perhaps, it might be a good idea to assume that all generic functions do not belong inside class objects. Perhaps only class object methods should be checked for exception handling? From garys at ihug.com.au Sun Nov 4 02:58:09 2001 From: garys at ihug.com.au (Gary Stephenson) Date: Sun, 4 Nov 2001 18:58:09 +1100 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> Message-ID: <9s2rob$5p8$1@bugstomper.ihug.com.au> I think in fact it was "There once was a man from Peru, Whose limericks always ended at line two" cheers gary From thomas.heller at ion-tof.com Thu Nov 29 15:05:28 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 29 Nov 2001 21:05:28 +0100 Subject: Python to .dll ? References: <9u63rp$v5g$06$1@news.t-online.com> Message-ID: <9u64ab$6ip54$1@ID-59885.news.dfncis.de> "Dennis Conrad" wrote in message news:9u63rp$v5g$06$1 at news.t-online.com... > Hi, > > Is there a possibility to create a (win32) .dll from a Python-script? I know > there is py2exe, maybe there is something like py2dll...? > No, currently py2exe does not support this. For what do you need it (in other words, what functions should this dll export)? Thomas From grahamd at dscpl.com.au Mon Nov 5 18:38:23 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 5 Nov 2001 15:38:23 -0800 Subject: Process intercommunication References: Message-ID: Mikael Olofsson wrote in message news:... > Hi all! > > Here is what I want to do, in short: I want two processes to be able > communicate with each other. Naturally, these processes are supposed > to be executed Python code. And we are on Solaris. > > More precisely: > > Process A is supposed to be running all the time, while process B will > only live for a short period of time. Both processes are supposed to > live on the same machine. After collecting some data, B needs to > communicate that data to A and A is supposed to acknowledge to B that > the received data is OK. B is therefore supposed to identify A, and set > up a two-way communication link to A (with A's help, I suppose). After > the necessary comunication has taken place, the communication link is > supposed to be shut down, and B will soon die. B is only supposed to > know under what name A is running. Depending on your requirements, you might consider an XML-RPC based solution. There are a number of toolkis available for Python which support XML-RPC and by using such an approach you need not have to worry about writing any significant code to respond to socket requests nor to handling the marshalling or unmarshalling of data as the toolkits do this for you. For a complete example of a simple XML-RPC based system have a look at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81612 If you search around on the same site you should find other XML-RPC examples using other server side toolkits as well. From wurmy at earthlink.net Fri Nov 16 09:19:58 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Fri, 16 Nov 2001 14:19:58 GMT Subject: OT:This group archived? References: <9t367u$kg6$1@neptunium.btinternet.com> Message-ID: <3BF5208A.B77392CE@earthlink.net> DL wrote: > > Hi all, > > just a quick question from someone new to Python. Is this group archived > anywhere to save me > bothering everyone with questions which have been asked hundreds of times. Sure: check out http://www.python.org/pipermail/python-list/ From qrczak at knm.org.pl Fri Nov 30 12:51:54 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 30 Nov 2001 17:51:54 +0000 (UTC) Subject: Non-Indented python References: <3C0678DF.2DFE924A@home.net> Message-ID: Fri, 30 Nov 2001 16:29:06 +0000 (UTC), Michael Abbott pisze: >> Just ban non-standard tab sizes and the problem is solved. > > Well, you have to ban something. I'm banning non-standard tab sizes, nothing more. > The problem with banning non-standard tab sizes is that as soon as > someone makes a small mistake you can have a real mess to deal with. I don't understand. What mistake? Well, if somebody breaks the single rule I propose, the text might get screwed up. But no rule can protect against ignoring that rule. What problems could arise if the rule is followed? > Unless you mandate that everyone runs the same editor as you do, > tabs are going to trip you up. Why?! Not at all! Any editor will do, as long as it treats tabs as jump-to-next-multiple-of-8-columns (almost all do that or can do that). > What is the point of using hard tabs, anyway? Tradition. I don't use them but I see them in other people's files very often. > They simply add an invisible source of possible confusion. There is no confusion if you keep the tab size constant. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From dpetrac at yahoo.com Wed Nov 7 06:05:03 2001 From: dpetrac at yahoo.com (Danijel) Date: Wed, 7 Nov 2001 12:05:03 +0100 Subject: Focus problem Message-ID: <9sb4bj$smv$1@sunce.iskon.hr> Hi! Is there a way to track focus change on window/control? I can't find that. ...and second question: How can I create "user defined" events? (possibly one of solution of my problem)... Tnx, Danijel From usenet at NOSPAM-irmen.cjb.net Fri Nov 30 10:46:28 2001 From: usenet at NOSPAM-irmen.cjb.net (Irmen de Jong) Date: Fri, 30 Nov 2001 16:46:28 +0100 Subject: ANN: Pyro 2.2 is available Message-ID: You can get the latest Pyro version (2.2) at http://pyro.sourceforge.net What is Pyro? Pyro is an acronym for PYthon Remote Objects. It is a basic Distributed Object Technology system written entirely in Python. It is extremely easy to implement a distributed system with Pyro, because all network communication code is abstracted and hidden from your application. You just get a remote Python object and invoke methods on the object on the other machine. Pyro offers you a Name Server, an Event Service, mobile objects, remote exceptions, dynamic proxies, remote attribute access, automatic reconnection, a detailed manual, and many examples to get you started right away. Irmen de Jong From peter at engcorp.com Wed Nov 28 18:32:17 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 18:32:17 -0500 Subject: Database in a simple ascii file References: <3C04F826.CB408C9D@engcorp.com> Message-ID: <3C057401.367523F4@engcorp.com> Cameron Laird wrote: > > Peter Hansen wrote: [...] > >Why focus on performance when you have no idea how fast > >you want your program to be? Recent advances in software > >development are teaching programmers *never* to optimize > >until the program works, and only when there is a clear > >requirement for more performance. > > > >If you are really concerned about performance, you will > >always be able to get more than a 10 times speedup by > >switching to a compiled language over Python. Use of > >Python should imply you are more interested in readability > >and ease of use, and thus speed of *development*, over > >speed of execution. > > > >(Shorter answer: don't grow any grey hairs over it.) > . > . > . > Peter and I agree on so many large conclusions, > and differ on so many details. Would that I had avoided details, and just left it at my first paragraph above! :) I was hoping merely to dissuade another relatively inexperienced programmer from wasting too much of his life worrying excessively about performance issues. > My own suspicion about the situation the original > poster describes is that I/O time dominates, and > that neither "switching to a compiled language" nor > a fancier persistence method will help by even a > factor of two (maybe not 10%) in comparison with > judiciously straightforward Python coding. You are almost certainly quite right. Yet another reason to avoid worrying about it ... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sholden at holdenweb.com Tue Nov 6 10:46:11 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 6 Nov 2001 10:46:11 -0500 Subject: old pyc with new py References: <3BE880FD.B604E77A@gol.ge> Message-ID: "Giorgi Lekishvili" wrote in message news:3BE880FD.B604E77A at gol.ge... > Hello! > > When I find an error i my scripts, and improve them, recompilation has > no effect: > > ++++++++++++++ > Traceback (innermost last): > File "T:\tests\init.py", line 8, in ? > d=PyPLS2DataSet(fi) > File "D:\Python20\ChemoPyc\PyPLS2DataSet.py", line 20, in __init__ > PyPLSDataSet.__init__(self, filename, 3, format) > File "D:\Python20\ChemoPyc\PyPLSDataSet.py", line 11, in __init__ > PyChemDataSet.__init__(self, filename, pr, format) > File "D:\Python20\ChemoPyc\PyChemDataSet.py", line 42, in __init__ > self.comment, self.Npred, self.Nobj, self.flags, self.ObjID, > self.ObjNames, self.Mdata, self.headers=get_data(filename) > File "D:\Python20\ChemoPyc\auxil.py", line 20, in get_data > ObjID=None > NameError: There is no variable named 'NONE' > +++++++++++++++++++ > > as you see, the correct keyword is set(None instead of NONE), but python > applies the old stuff. Note, that I delete the *.pyc and *.pyo files > before invoking the sourcfiles like follows: > from mylib import myfunc Giorgi: The problem here is because a repeated import does not cause the module to be executed a second time. To force this you have to use the reload() function. Given a module tm1.py: # # tm1 version 1 # def myfunc(): return NONE I get an error after I import the function and run it. If I then change the module's code, and repeat the statements which caused the error, I see: >>> from tm1 import myfunc >>> myfunc() Traceback (most recent call last): File "", line 1, in ? File "tm1.py", line 5, in myfunc return None NameError: global name 'NONE' is not defined It picks up the right source line, but it's still executing the old code. Very confusing! What you need to do is: >>> reload(tm1) >>> from tm1 import myfunc >>> myfunc() >>> The module reload() forces the "from tm1 import myfunc" to pick up the iupdated compiled version. regards Steve -- http://www.holdenweb.com/ From eppstein at ics.uci.edu Thu Nov 29 21:11:32 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 29 Nov 2001 18:11:32 -0800 Subject: The Ideals of a Python Hacker (was: Poll Results) References: <3bfd7f87@news.airtel.net> Message-ID: In article , Jonathan Gardner wrote: > Interesting... how does Python and veganism go together? Head Waiter (Michael Palin): This is a vegetarian restaurant only, we serve no animal flesh of any kind. We're not only proud of that, we're smug about it. So if you were to come in here asking me to rip open a small defenseless chicken, so you could chew its skin and eat its intestines, then I'm afraid I'd have to ask you to leave. Likewise if you were to ask us to slice the sides of a cow and serve it with small pieces of its liver... or indeed drain the life blood from a pig before cutting off one of its legs... or carve the living giblets from a sheep and serve them with the fresh brains, bowels, guts and spleen of a small rabbit... WE WOULDN'T DO IT. Not for food anyway. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From chorg at operamail.com Sun Nov 4 21:29:46 2001 From: chorg at operamail.com (chorg) Date: Mon, 05 Nov 2001 02:29:46 GMT Subject: newbie: Standard Module documentation Message-ID: Hello, I'm a python newbie. I am wondering if there is a standard place to find documetation of modules -- kind of like Perl's perldoc. Or, how can I find out what methods and properties are in an instance of a class? From sholden at holdenweb.com Fri Nov 30 18:03:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 18:03:20 -0500 Subject: Using Python with a webserver References: Message-ID: "Steve Holden" wrote... > > C:\Python20\python -u > It should, of course, have been #!C:\Python20\python -u Sorry. -- http://www.holdenweb.com/ From wurmy at earthlink.net Wed Nov 14 13:33:50 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 14 Nov 2001 18:33:50 GMT Subject: How program a particilar algorithm ? References: <9sua59$3lh$1@wanadoo.fr> Message-ID: <3BF2B900.862EC64F@earthlink.net> Michel Bonnifait wrote: > > Hello, > I think my question is more on programming than specifically on programming > with Python. > I want to generate all possible lists with elements from another one. For > example, from a list like [1,2,3,4] i want to program an algorithm which > will give this result > [[1,2],[1,3],[1,4],[1,2,3],[1,2,4],[1,3,4],[1,2,3,4],[2,3],[2,4],[2,3,4],[3, > 4]] > It's seems to me it should be a recursive programming answer but i can't > find it. > thanks in advance for your help ! This code seems to work: def perms(lst): if len(lst) == 1: return [lst] # return first element of list, combined with perms head, tail = lst[0], lst[1:] ptail = perms(tail) phead = [[head]+p for p in ptail] return phead + ptail + perms([head]) lst = [1, 2, 3, 4] for p in perms(lst): print p This question has been asked on the ng before, so you might be able to find other (better?) replies by doing a google search or so. HTH, --Hans From phd at phd.pp.ru Wed Nov 28 10:38:25 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 18:38:25 +0300 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) In-Reply-To: ; from DeepBlue@DeepBlue.org on Wed, Nov 28, 2001 at 09:30:34AM -0600 References: <9tia10$43o$1@dahlia.singnet.com.sg> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: <20011128183825.D8311@phd.pp.ru> On Wed, Nov 28, 2001 at 09:30:34AM -0600, DeepBlue wrote: > > Look at Visual C++. Portability? Compatability? Ha. > > > > Look what they did to Java, HTTP, HTML, and JavaScript. > > > What did they do to Java, HTTP, HTML, and JavaScript? Screwed it in all incompatible ways. > > Microsoft is in the business of making money, not software. > > > Is Sun and Netscape any different? No. That's why they are dangerous. But thank goodness, they do not have enough power, at least now. And M$ alread has more than enough. 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 Wed Nov 7 12:14:45 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 17:14:45 GMT Subject: " Message-ID: <9_dG7.4761$R43.760842@newsb.telia.net> Amit Weisman wrote: > I wasn't clear enougth . > I know one should declare functions as > def do_TAGNAME > def start_TAGNAME > def end_TAGNAME > > How do I declare function for the " > Python wouldn't accept def start_! ...... in addition the do/start/end methods, sgmllib lets you define general handlers for stuff like entities, comments, etc. to deal with things that start with " From logiplexsoftware at earthlink.net Fri Nov 16 12:59:35 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 16 Nov 2001 09:59:35 -0800 Subject: python vs ecmascript In-Reply-To: References: Message-ID: <01111609593502.02629@logiplex1.logiplex.net> On Friday 16 November 2001 08:17, Peoter Veili wrote: > Anyone familiar with ECMAscript (JavaScript)? How does it compare to > Python? I studied ECMAscript last year, people have an aversion to it > from doing web client programming, but it is a high-powered OO scripting > language in its own right. Clearly the one downside of ECMAscript vs > Python is that Python has been around longer and has a large set of > existing libraries. > Besides that is there any major advantage that Python has? I am new to > Python > but already I am seeing some limitations that don't exist in ECMAscript. I > am > also a bit annoyed at some things like having to wrap objects in a str() > before > printing, I don't see why this can't be automatic. Since when? The print statement automatically invokes str() on its arguments. >From the documentation: This thing about only > having > two scopes, local and global, I don't see the logic. Is this by design, > or is it > simply a current limitation? The book I have says it may change in the > future. If you are using Python 2.1: from __future__ import nested_scopes Will give you what you are looking for. Perhaps you perceive limitations in Python (compared to ECMAscript) because you know how to do things in ECMAscript but not in Python. The only way you're going to really find out which you'll like better is to sit down and start writing programs in them. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From christy_girl99 at yahoo.com Sun Nov 11 01:06:43 2001 From: christy_girl99 at yahoo.com (christy_girl99 at yahoo.com) Date: Sun, 11 Nov 2001 06:06:43 -0000 Subject: prims algorithm Message-ID: <9sl4hj+vq7s@eGroups.com> Can anyone show me how to do Prims algorithm in python? I'm supposed to find a minimum spanning tree of a weighted undirected graph using Prims algorithm. I can do it in C++, but Python is giving me major problems. I'm just learning this language and its pretty nuts, compared to C/C++. Thanks in advance Christy From d_blade8 at hotmail.com Tue Nov 13 00:02:19 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 12 Nov 2001 21:02:19 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> Message-ID: <7396d2b2.0111122102.2058f188@posting.google.com> Okay, my other post should be up soon, but I thought I would throw this out. First off, I should say I am not a VB person, so I have to work at converting VB code into win32client compatible commands. However, the Help File in the MS Excel Help has me stumpted. Here is the page I am using as a basis and afterwards is just a cut and paste of my attempts (at an interactive prompt) to insert a hyper link. Hyperlinks Collection Object Represents the collection of hyperlinks for a worksheet or range. Each hyperlink is represented by a Hyperlink object. Using the Hyperlinks Collection Use the Hyperlinks property to return the Hyperlinks collection. The following example checks the hyperlinks on worksheet one for a link that contains the word “Microsoft.” For Each h in Worksheets(1).Hyperlinks If Instr(h.Name, "Microsoft") <> 0 Then h.Follow Next Use the Add method to create a hyperlink and add it to the Hyperlinks collection. The following example creates a new hyperlink for cell E5. With Worksheets(1) .Hyperlinks.Add .Range("E5"), "http://www.gohere.com" End With Okay, here is my interactive attempts. Hopefully, seeing these will help you see what I am doing wrong (I am SURE it is something simple, but it's ticking me off). Also, as a side note, in PythonWin, I cannot run a Commakepy on Excel 9 (I'll add that attempt to the bottom of my code so you can all see what I mean). Thanks a bunch. fPythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> ro Traceback (most recent call last): File "", line 1, in ? NameError: name 'ro' is not defined >>> >>> from win32com.client import Dispatch >>> xlApp = Dispatch("Excel.Application") >>> xlApp.Workbooks.Add() >>> OK = xlApp.Workbooks(1).Sheets(1) >>> OK.Range("B2:C5").Value = "Range Insert" >>> xlApp.Visible = 1 >>> xlApp.Hyperlinks.Add.Cells("B5"), 'http://www.gohere.com" Traceback ( File "", line 1 xlApp.Hyperlinks.Add.Cells("B5"), 'http://www.gohere.com" ^ SyntaxError: invalid token >>> xlApp.Hyperlinks.Add.Cells("B5"), 'http://www.gohere.com' Traceback (most recent call last): File "", line 1, in ? File "C:\Python21\win32com\client\dynamic.py", line 438, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Hyperlinks >>> xlApp.Hyperlinks.Add.Cells("B5") = 'http://www.gohere.com' Traceback (SyntaxError: can't assign to function call >>> >>> xlApp.Hyperlinks.Add.Cells("B5").Value = 'http://www.gohere.com' Traceback (most recent call last): File "", line 1, in ? File "C:\Python21\win32com\client\dynamic.py", line 438, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: Excel.Application.Hyperlinks >>> OK.Hyperlinks.Add.Cells("B5").Value = 'http://www.gohere.com' Traceback (most recent call last): File "", line 1, in ? AttributeError: Cells >>> OK.Hyperlinks.Add.Cells("B5"), 'http://www.gohere.com' Traceback (most recent call last): File "", line 1, in ? AttributeError: Cells >>> xlApp.Workbooks(1).Hyperlinks.Add.Range("B5"), "http:\\www.gohere.com" Traceback (most recent call last): File "", line 1, in ? File "C:\Python21\win32com\client\dynamic.py", line 438, in __getattr__ raise AttributeError, "%s.%s" % (self._username_, attr) AttributeError: .Hyperlinks >>> xlApp.Worksheets(1).Hyperlinks.Add.Range("B5"), "http:\\www.gohere.com" Traceback (most recent call last): File "", line 1, in ? AttributeError: Range >>> xlApp.Worksheets(1).Hyperlinks.Add.Range("B5") = "http:\\www.gohere.com" Traceback (SyntaxError: can't assign to function call >>> xlApp.Worksheets(1).Hyperlinks.Add.Range("B5").Value = "http:\\www.gohere.com" Traceback (most recent call last): File "", line 1, in ? AttributeError: Range >>> xlApp.Worksheets(1).Hyperlinks.Add.Range("B5"), "http:\\www.gohere.com" Traceback (most recent call last): File "", line 1, in ? AttributeError: Range >>> xlApp.Worksheets(1).Hyperlinks.Add.Ranges("B5"), "http:\\www.gohere.com" Traceback (most recent call last): File "", line 1, in ? AttributeError: Ranges >>> xlApp.Worksheets(1).Hyperlinks.Add.Cells("B5"), "http:\\www.gohere.com" Traceback (most recent call last): File "", line 1, in ? AttributeError: Cells >>> xlApp.Worksheets(1).Hyperlinks.Add("http:\\goher.com").Cells("B5") Traceback (most recent call last): File "", line 1, in ? File ">", line 2, in Add ValueError: argument is not a COM object >>> xlApp.Worksheets(1).Hyperlinks.Add(Cells("B5"), "http:\\www.gohere.com") Traceback (most recent call last): File "", line 1, in ? NameError: name 'Cells' is not defined >>> xlApp.Worksheets(1).Hyperlinks.Add(.Cells("B5"), "http:\\www.gohere.com") Traceback ( File "", line 1 xlApp.Worksheets(1).Hyperlinks.Add(.Cells("B5"), "http:\\www.gohere.com") ^ SyntaxError: invalid syntax >>> OK > >>> print OK > >>> print "%s" % OK > >>> OK.Hyperlinks.Add .Range("E5"), "http://www.gohere.com" Traceback (most recent call last): File "", line 1, in ? AttributeError: Range >>> xlApp.Worksheets(1).Hyperlinks.Add(.Range("B5"), "http:\\www.gohere.com") Traceback ( File "", line 1 xlApp.Worksheets(1).Hyperlinks.Add(.Range("B5"), "http:\\www.gohere.com") ^ SyntaxError: invalid syntax >>> >>> OK.Hyperlinks.Add("http:\\hek.com") Traceback (most recent call last): File "", line 1, in ? File ">", line 2, in Add ValueError: argument is not a COM object >>> OK.Hyperlinks.Add(OK.Cells("B4")) Traceback (most recent call last): File "", line 1, in ? File "C:\Python21\win32com\client\dynamic.py", line 151, in __call__ return self._get_good_object_(apply(self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None) com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352571), 1) >>> OK.Hyperlinks.Add(OK.Cells("B4"), "http://getalife.com") Traceback (most recent call last): File "", line 1, in ? File "C:\Python21\win32com\client\dynamic.py", line 151, in __call__ return self._get_good_object_(apply(self._oleobj_.Invoke,allArgs),self._olerepr_.defaultDispatchName,None) com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147352571), 1) >>> Generating to C:\Python21\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x3.py Failed to execute command: from win32com.client import makepy;makepy.main() Traceback (most recent call last): File "C:\Python21\Pythonwin\pywin\framework\toolmenu.py", line 103, in HandleToolCommand exec "%s\n" % pyCmd File "", line 1, in ? File "C:\Python21\win32com\client\makepy.py", line 350, in main GenerateFromTypeLibSpec(arg, f, verboseLevel = verboseLevel, bForDemand = bForDemand, bBuildHidden = hiddenSpec) File "C:\Python21\win32com\client\makepy.py", line 254, in GenerateFromTypeLibSpec gen.generate(fileUse, bForDemand) File "C:\Python21\win32com\client\genpy.py", line 692, in generate self.do_generate() File "C:\Python21\win32com\client\genpy.py", line 746, in do_generate oleItems, enumItems, recordItems, vtableItems = self.BuildOleItemsFromType() File "C:\Python21\win32com\client\genpy.py", line 604, in BuildOleItemsFromType newItem = DispatchItem(info, attr, doc) File "C:\Python21\win32com\client\genpy.py", line 227, in __init__ build.DispatchItem.__init__(self, typeinfo, attr, doc) File "C:\Python21\win32com\client\build.py", line 107, in __init__ self.Build(typeinfo, attr, bForUser) File "C:\Python21\win32com\client\build.py", line 269, in Build self._AddFunc_(typeinfo,fdesc,bForUser) File "C:\Python21\win32com\client\build.py", line 176, in _AddFunc_ typerepr, resultCLSID, resultDoc = _ResolveType(typerepr, typeinfo) File "C:\Python21\win32com\client\build.py", line 440, in _ResolveType subrepr, sub_clsid, sub_doc = _ResolveType(subrepr, itypeinfo) File "C:\Python21\win32com\client\build.py", line 452, in _ResolveType resultTypeInfo = itypeinfo.GetRefTypeInfo(subrepr) com_error: (-2147312566, 'Error loading type library/DLL.', None, None) >>> >>> From mark at laptop.local Tue Nov 13 20:30:51 2001 From: mark at laptop.local (mark at laptop.local) Date: 13 Nov 2001 20:30:51 -0500 Subject: How do you get persistent database connections with Python? Message-ID: <9sshgb$eh4$1@laptop.local> How do you create persistent database connections with Apache, Python, and PostgreSQL? Any generic methods of creating persistent database connections would be helpful. I have been trying like crazy to find information on the topic, but I can't find any useful information. I am using mod_python and also pyGreSQL modules. I can switch to others if need be, Thanks! Please respond to articles @gnujobs.com if you want to mail me directly. Mark From dag4004 at caramail.com Fri Nov 9 04:56:05 2001 From: dag4004 at caramail.com (free) Date: Fri, 9 Nov 2001 10:56:05 +0100 Subject: Error ??? Message-ID: <3beba775$0$9966$626a54ce@news.free.fr> Hello, I embedded Python in an application and we i run it I have this message but i don't understand : Could not find platform independent libraries Could not find platform dependent libraries 'import site' failed; use -v for traceback What does'it mean ? Merci From Gareth.McCaughan at pobox.com Wed Nov 28 05:11:41 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 28 Nov 2001 10:11:41 +0000 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C046EB4.55B36D9D@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote: > James_Althoff at i2.com wrote: > > > > Since this looks like a suggestion for replacing xrange in the general > > case, did you have any thoughts on how one might specify a step value? > > Not any particularly good ones. Maybe > > for 0 <= i/3 < 10: > > to give 0, 3, 6, 9. But that's probably > a bit too perverse! -1. The values of i/3 over that sequence are 0,1,2,3. Ick. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From logiplexsoftware at earthlink.net Mon Nov 5 12:41:53 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 5 Nov 2001 09:41:53 -0800 Subject: Freeware Python editor In-Reply-To: <3be786c8.5732843@127.0.0.1> References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> Message-ID: <01110509400601.18194@logiplex1.logiplex.net> On Sunday 04 November 2001 10:24, Fish wrote: > My name's David Craig. I live in Shepardville, British Columbia, Canada. > I'm 38 years old, six foot one, 193lbs on a good day. I've been married > for 14 years, have three children and a dog. My IP address is... well, > wait, you don't need to know that. > > How about you, Emile? You willing to reveal all your personal details to > the net? > > And how do you know that I'm not making it all up? > > Anyway, the problem here isn't whether I'm using an alias or not. The > problem is with idiots who continue to harp on tiresomely about "free" > software, every time someone uses the word "free"... even when that person > uses a long-established term that quite clearly has *nothing* to do with > open-source. No, the problem is with people who can't stop reading those posts and complaining about them. Grow up and get used to people doing things you don't like. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From seb at tesco.net Fri Nov 2 19:59:15 2001 From: seb at tesco.net (seb) Date: Sat, 03 Nov 2001 00:59:15 GMT Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> <3mxE7.5808$gl5.151284@atlpnn01.usenetserver.com> Message-ID: <3be33e53.16184822@news.tesco.net> On Fri, 2 Nov 2001 08:42:42 -0500, "Steve Holden" wrote: >"Leo Lipelis" wrote ... >[...] >> This is also nonsense. Sure you can catch all exceptions and examine >them. >> But in order to code anything intelligent, you again have to know ahead of >> time what these exceptions might be. At the very *LEAST* you need a list >> of *all possible* exceptions in an entire Python code base, including >> Python standard module library! But how much better would it be if you >> could narrow the scope to the most likely exceptions. >> >Presumably all Python written to date is therefore "non-intelligent"? Sounds >to me like you've got a project on your hands. Unless you're just bitching >about this because you think somebody else will "fix" it if you make enough >noise. > > > print open("anyoldfile.txt", "r").read() > >because open can raise several exceptions which this statement fails to >handle. Yup, that's horseshit all right. Just as a matter of interest, what >would be your "approved" alternative for the above one-liner? Sorry if my >response comes off as aggressive, which isn't in the spirit of this >newsgroup. I'm actually trying to teach you something here! > >didn't-realise-i-cared-so-much-ly y'rs - steve >-- >http://www.holdenweb.com/ > okay, to be technically correct this is about return codes rather than exceptions, but in the spirit... http://www.jsquared.co.uk/jennyl/verity.htm The quite excellent Verity Stob (and her sister Parity) -ly. seb. From jgardn at alumni.washington.edu Tue Nov 13 08:07:51 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Tue, 13 Nov 2001 22:07:51 +0900 Subject: Python Vim Module - works In-Reply-To: <01111309323600.00630@linux> References: <01111302002607.00632@linux> <01111309323600.00630@linux> Message-ID: <01111322075101.00631@linux> Jonathan Gardner wrote: > > On Tuesday 13 November 2001 02:00 am, Jonathan Gardner wrote: It's 2:00 > > AM here in Seoul, so I won't be getting any answers out for a few > > hours... =) If you can get it to compile (just edit the Makefile to make > > it point to the right place...) try this with Vim 6.0: > > Now it's 9:30 AM in Seoul, and somebody told me that I didn't attach > anything. Sorry all! Here is the software attached. > Man, I feel really stupid... first I don't attach anything, and then I attached a bad set of files. This time I triple-checked it, so it should work with only a little bit of tinkering. Jonathan -------------- next part -------------- A non-text attachment was scrubbed... Name: python_vim.tar.gz Type: application/x-gzip Size: 10020 bytes Desc: This one should really work! URL: From andy47 at halfcooked.com Sun Nov 11 18:52:27 2001 From: andy47 at halfcooked.com (Andy Todd) Date: 11 Nov 2001 23:52:27 GMT Subject: Gratuitous post References: Message-ID: "Steven D. Majewski" wrote in : > > >On 9 Nov 2001, Martijn Faassen wrote: > >> Steve Holden wrote: >> > Free software. >> >> Doing your service for the PSU, hm? I'm not sure if > >Free Python! > >-- The Python Liberation Front > Splitter! -- Peoples Front for the Liberation of Python -- Content free posts a speciality From phr-n2001d at nightsong.com Fri Nov 9 20:46:44 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 17:46:44 -0800 Subject: Teaching python (programming) to children References: Message-ID: <7xitcjtn23.fsf@ruckus.brouhaha.com> "Arthur Siegel" writes: > Again, IMO - the acceptance of programming instruction incorporated > somehow into core curricula is up against enough - without making > its acceptance dependent on the acceptance of some particular educational > theory/philosophy. > > Let's accept that learning math, for example, is a good thing, and > demonstrate an enhanced curricula incorporating some programming > that will accelerate and deepen that process. "The cognitive skill of > diagnosing and correcting errors" might in fact be more fundamental > (and important) than understanding math concepts - who am I to > argue with the MindStorms crowd. I will tell you that to the untrained > ear, it sounds like horeshit. In the Mindstorms situation, we're talking about very young kids, like age 6-8 or so. Normally nobody thinks of kids that young as needing "programming instruction" or training in software development. Here's an article from Papert's website about it called "Tomorrow's Classrooms", that gives a sense of what he wanted to accomplish: http://www.papert.org/articles/TomorrowsClassrooms.html Basically he was trying to follow up the ideas of Jean Piaget, the child development researcher. Perhaps the ideas are horseshit, but Time Magazine apparently didn't think so--it printed Papert's article on Piaget in its special issue on "The Century's Greatest Minds". From max at alcyone.com Sun Nov 18 14:20:39 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 18 Nov 2001 11:20:39 -0800 Subject: RANSOM DEMAND: Image Held Hostage! References: Message-ID: <3BF80A07.E2B1E113@alcyone.com> Ben Ocean wrote: > I need a way to size up images via script. Now, in that inferior > scripting > language known as PHP, *they* have such a tool: getimagesize(). Can it > be > that God's gift to scripting languages, Python, can't compete here? If > it's > true that PHP has one up on us here, how can I write a script that > bridges > this dastardly gap? You'll need a graphics Python library. Try PIL. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From fperez528 at yahoo.com Wed Nov 14 10:25:11 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 15 Nov 2001 14:53:11 +2328 Subject: Size of an object in memory? References: <9sspa2$ku3$1@peabody.colorado.edu> Message-ID: <9t1djl$b00$1@peabody.colorado.edu> Michael Hudson wrote: > Fernando P?rez writes: > >> Is there any way (at runtime, dynamically) to obtain the size in >> bytes of a given object in memory? > > Didn't we do this a few days ago? See this thread: > > http://groups.google.com/groups?hl=en&threadm=_6FG7.33159%24i4.5175661%40news0.telusplanet.net&rnum=1 > > but, in short, no, and you don't really want to know. > Sorry to bug, but I'm new to the list and I'm not sure which thread you're talking about. If I hit the link you provide I get a blank in google. Could you repost the correct link if you have it handy? >> Since multiple names may be bound to the same object, is it possible >> to obtain the size of the underlying object and a list of all other >> names bound to it? > > Not easily. Or maybe not at all. Oh, hang on: see gc.get_referents. > This may be new in Python 2.2, though. > Thanks for the tip. I'll look into it when I get 2.2 on. Cheers, F. From joonas at olen.to Thu Nov 1 12:31:48 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 01 Nov 2001 19:31:48 +0200 Subject: special character handling References: Message-ID: <3BE18704.1CC2F63F@olen.to> "Michael P. Soulier" wrote: > > Hello. > > When I'm coding in PHP, my job is made very easy due to the existence of > functions that automagickally protect special characters with backslashes, > translate special html characters to their corresponding html entities, strip > all but allowed html tags, etc. I've looked in latest Python docs, and the > Vaults of Parnassus, and I have yet to find such generic, ready-to-use > functions. > It's true that I could create some of this using the existing internet and > markup data handling classes, but the point is that they're not made yet. > Before I go to the trouble of writing such a library, as I'd rather use Python > than PHP, does anyone know if someone has beaten me to it? > > I'm thinking of such generic functions as > > addslashes(), stripslashes(), striphtml(), etc. > > If not, anyone here is of course welcome to help me write such a library, > and I'll ensure that it ends up in tvops sgmllib module can strip HTML. See example at http://mail.python.org/pipermail/python-list/2001-May/041075.html Builtin repr() function is very useful for some escaping tasks. Here's an sql example where user_input can contain unsafe data. >>> user_input = "';\ndrop table usertable; select * from usertable where name like ';" >>> print "select * from usertable where name like %s" % repr(user_input) #with repr select * from usertable where name like "'; drop table usertable; select * from usertable where name like '"; >>> print "select * from usertable where name like '%s'" % (user_input) #without repr select * from usertable where name like ''; drop table usertable; select * from usertable where name like ''; As you can see the repr() function handles all unsafe characters. >>> print repr(""" '`" """) ' \'`" ' -- Joonas Paalasmaa From phd at phd.pp.ru Thu Nov 29 08:03:49 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 16:03:49 +0300 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) In-Reply-To: ; from sholden@holdenweb.com on Thu, Nov 29, 2001 at 07:52:30AM -0500 References: Message-ID: <20011129160349.S16265@phd.pp.ru> On Thu, Nov 29, 2001 at 07:52:30AM -0500, Steve Holden wrote: > > > According to Microsoft, open source is un-American. And, also according > > > to Microsoft, they are responsible for open source. I guess Microsoft > > > must be un-American. > > > > Certainly :))) > > > Microsoft is a Russian plot! The cold war isn't over! Quick! Someone tell > the PS Russian? May be, but I dout it. It looks more like an alien invasion. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From kragen at canonical.org Sat Nov 24 01:46:48 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 24 Nov 2001 01:46:48 -0500 Subject: Could someone explain this multidimensional list behaviour? References: <1103_1006507526@t4q4p0> Message-ID: <83g074vf6v.fsf@panacea.canonical.org> Aaron Sterling writes: > The second for loop should not be necessary. something like: > > spam = [] > for y in range(n): > spam.append([0] * n) You can also write that with map() as map(lambda y: [0] * n, range(n)) or with a list comprehension as [[0] * n for y in range(n)]. Hope this helps. From claird at starbase.neosoft.com Tue Nov 27 18:54:05 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 27 Nov 2001 17:54:05 -0600 Subject: Two questions about Python.. References: <3BF99E55.2C300858@hotmail.com> <83r8qj6gi8.fsf@panacea.canonical.org> Message-ID: <124312AFE15AC2A7.3108D1F50CF59A6C.A4102B9233F78776@lp.airnews.net> In article <83r8qj6gi8.fsf at panacea.canonical.org>, Kragen Sitaker wrote: >Ville Vainio writes: > >> Ken writes: >> > I'm looking into using Python for a project, and was wondering how does >> > Python rank up against other scripting languages for speed? > >It's about as fast as Perl, much faster than Tcl or sh, and much >slower than Lua, a good Scheme, FORTH, or GhostScript, in my >experience. HTH. > And it depends, of course, on the kind of project of interest. Numeric makes Python a world-beater for many problems, for example. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From ecastro at cicei.ulpgc.es Tue Nov 13 12:05:28 2001 From: ecastro at cicei.ulpgc.es (Enrique) Date: 13 Nov 2001 17:05:28 GMT Subject: Problem installing VTKPython Message-ID: <3BF153BA.77D0566C@cicei.ulpgc.es> Hi, I am trying to check the visualization program MayaVi, a python application that uses VTK and VTKpython. I work in a MS-Windows PC I have downloaded VTKcore.exe and VTKPython.exe. Installation of VTKcore.exe simply copies vtkdll.dll into c:\windows\system. When I try any script in VTK python I get a message complaining about a missing DLL: vtkpython. I have vtkpython.dll in the DLLs folder of python installation, and in the vtkpython folder. However I cannot import vtkpython, the error message is: Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> import vtkpython Traceback (most recent call last): File "", line 1, in ? ImportError: DLL load failed: One of the library files needed to run this applic ation cannot be found. I am missing something, but I do not know what TIA Enrique From gmcm at hypernet.com Sat Nov 10 17:52:38 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 10 Nov 2001 22:52:38 GMT Subject: Proposal for a modified import mechanism. References: <4XfH7.123829$IR4.37302021@news1.denver1.co.home.com> Message-ID: Rainer Deyke wrote: > Frederic Giacometti wrote: >> I'd rather introduce a __parent__ module attribute (in addition to the >> existing __name__) so that, for instance, the following would do your >> job: >> >> from __parent__.__parent__.toto import something > > This wouldn't work without additional changes to the import mechanism, > since the bindings of names are not used to resolve imports. Let's not > add any more special cases. I don't understand what you mean. The current import mechanism already checks for a __parent__, and if there is one, tries a relative import. This has been discussed before. IIRC, the main objections were that all the ways of spelling it were considered too ugly. Importing is a mapping between two hierarchical namespaces. The first of these has some concept of "relative", but no way to spell it. Imagine trying to work with a filesystem with those characteristics. Like Frederic, I'm convinced that Python needs to learn to spell "relative" imports differently from "absolute" imports. Personally, I favor doing it with the verb, not by introducing path-like names. >> I'm personnally against anything that enlarges the search path >> uselessly; because the obvious reason of increased name space >> collision, increased run-time overhead etc... > > The best way to avoid name collisions is to keep top-level names at an > absolute minimum by placing modules in a deep hierarchy. While I'd say the best way is to say what you mean. A deep hierarchy introduces its own overhead. > Run-time > overhead may also be reduced this way, since many operating systems do > a linear search over all files in a directory when opening a file. Hmm. I experimented with an importer that cached os.listdir. There's some kind of a threshold percentage-of-modules-hit over which the os.listdir approach has an advantage, (my first-order guess is around 15%). It's definitely a loss when only a few of the modules in that directory end up being imported. As for os efficiency, I think that's pretty thoroughly stomped on by the fact that Python will attempt to open 2, 3 or 4 files per entry on sys.path. A successful relative import is minorly faster than the equivalent absolute import, but obviously there's an net cost with a "try relative first, then try absolute" strategy. The more "try relative to the one we just tried" steps you stick in there, the costlier it becomes. From amk at glass.indy.progeny.com Fri Nov 23 17:38:50 2001 From: amk at glass.indy.progeny.com (A.M. Kuchling) Date: 23 Nov 2001 22:38:50 GMT Subject: Simple (I think) regex question References: Message-ID: <9tmj5q$ab1$1@bob.news.rcn.net> On Wed, 21 Nov 2001 22:03:58 GMT, Michael Kelly wrote: >My question is this: In a sub(), how do set the replacement string to be as >long as the first matched substring? (i.e., the len() of \1). I've tried Provide a function to compute the replacement string: import re def repl(match): return '*' * len(match.group()) s = 'this is a test' print re.sub('\w{4}', repl, s) This outputs '**** is a ****'. --amk From paul at boddie.net Wed Nov 28 08:25:09 2001 From: paul at boddie.net (Paul Boddie) Date: 28 Nov 2001 05:25:09 -0800 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <23891c90.0111280525.68760dec@posting.google.com> Paul Rubin wrote in message news:<7xelmjbgwz.fsf at ruckus.brouhaha.com>... > > CVS is a layer over RCS that lets multiple people work on the same > files at the same time, and automatically merges their changes at > check-in. I don't see any point to it for a one person project. RCS > is a lot simpler. I use RCS for one-person projects and couldn't live > without it. But I haven't found a reason to deal with the increased > complexity of CVS. Is there one? It's been ages since I last worked with RCS, but I did work with SCCS extensively not so long ago and I would say that there are numerous advantages to using CVS in preference to the other two. For example, it's possible to change into another directory and check out a completely different release to the one you're working on (useful for testing stuff), or even the same release (useful for putting release packages together), whilst keeping your existing work separate and unaffected. These activities may seem to be things that only multi-person projects would demand, but by focusing on the different roles in a project, things can become a lot more convenient (and reliable) for one person working on their own. After all, software development rarely involves only one kind of activity. As far as ease of use is concerned, I wouldn't say that CVS is really any harder than RCS, although the more interesting features of CVS can take time to master. However, I doubt that people would attempt similar or equivalent things in RCS so readily. If you can master "ci", "cout" and "rcsdiff", you can surely master "cvs commit", "cvs update"/"cvs checkout" and "cvs diff". Paul From sebascabot at sympatico.ca Thu Nov 22 06:49:55 2001 From: sebascabot at sympatico.ca (Sébastien Cabot) Date: Thu, 22 Nov 2001 03:49:55 -0800 Subject: Tkinter displaying an image in a button References: <3BFC3295.20FC3F02@alex2.labs.agilent.com> Message-ID: <%Y2L7.14855$QC5.2230883@news20.bellglobal.com> First in Tkinter.py we have: class PhotoImage(Image): """Widget which can display colored images in GIF, PPM/PGM format.""" This mean for me no ".jpg". Now for the problem: Look's like the PhotoImage object got a sys.getrefcount(img) == 0 and is garbage collected right away, even if the Button object still need this object. So this work: from Tkinter import * root = Tk() i = PhotoImage(file="but1.gif") Button(root, image=i).pack() root.mainloop() And this don't work: from Tkinter import * root = Tk() Button(root, image=PhotoImage(file="but.gif")).pack() root.mainloop() No doubt, this is a refcount bug in Tkinter. Now a quick patch to get around this bug is to keep your PhotoImage allocate for all the duration of your application. Be carefull, PhotoImage must be call only after the Tk() call. So a solution could be: from Tkinter import * class App: def __init__(self, parent): global BUT1 Button(parent, image=BUT1).pack() root = Tk() BUT1 = PhotoImage(file="but1.gif") App(root) root.mainloop() Hope this will help. (Note: I tested this with Python 2.1.1 on Debian) Good Luck! Bye. "David R. Smith" wrote in message news:3BFC3295.20FC3F02 at alex2.labs.agilent.com... > The first code snippet below successfully displays an image, whereas the > second just shows gray where the image should be. What's wrong with the > class version, and what do I have to do to get it to work? > (I am using Python 2.0.1 on Debian.) > > adTHANKSvance > David Smith > > > > from Tkinter import * > import Image, ImageTk > root = Tk() > img = Image.open('SonicCruiser.jpg') > phi = ImageTk.PhotoImage(img) > button = Button(root, image=phi) > button.pack() > root.mainloop() > > > > from Tkinter import * > import Image, ImageTk > class App: > def __init__(self, master): > img = Image.open('SonicCruiser.jpg') > phi = ImageTk.PhotoImage(img) > button = Button( master, image=phi ) > button.pack() > root = Tk() > app = App(root) > root.mainloop() From lac at strakt.com Tue Nov 13 04:25:25 2001 From: lac at strakt.com (Laura Creighton) Date: Tue, 13 Nov 2001 10:25:25 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Cliff Wells of "Mon, 12 Nov 2001 12:56:06 PST." <01111212560602.01611@logiplex1.logiplex.net> References: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> <01111212560602.01611@logiplex1.logiplex.net> Message-ID: <200111130925.fAD9PPua015737@ratthing-b246.strakt.com> Unless I am misunderstanding this terribly, Cliff Wells, whose educational experiences were so dreadful that he nearly dropped out of school and had to be rescued by a heroic mathematician teacher, wants to base social policy on granting teachers enough personal freedom that they can circumvent the evil policies crafted by powerful academic elites that are both so incompetant that they mandate evil or foolishness, and so corrupt or stupid that they will not change when you point this out to them. I think that this is what I just heard. Laura Creighton From mwh at python.net Mon Nov 5 11:55:30 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 5 Nov 2001 16:55:30 GMT Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: hungjunglu at yahoo.com (Hung Jung Lu) writes: [schnipp] > Or is there a good way of teaching to make it less traumatic for > beginners to grasp the concepts of dictionary, name spaces, assignment > by reference? I suspect the simple measure of not teaching them C first will do for this one. I.e. I don't think it the true newbie who hits these problems, rather someone coming from C. It's not learning how Python works that confuses, it's the unlearning of how other languages work that's hard. In my opinion, anyway. I could be wrong. I do think there are other reasons why Python isn't a perfect teaching language (eg. getting Python to run fast being a strange and non-transferable skill), but I doubt this one. Cheers, M. -- ARTHUR: The ravenours bugblatter beast of Traal ... is it safe? FORD: Oh yes, it's perfectly safe ... it's just us who are in trouble. -- The Hitch-Hikers Guide to the Galaxy, Episode 6 From laurent.pointal at laposte.net Tue Nov 20 13:20:50 2001 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 20 Nov 2001 18:20:50 GMT Subject: Still on python GUI toolkit References: Message-ID: [posted and mailed] Luca Fini wrote in news:Pine.LNX.4.33.0111201217030.31638-100000 at localhost.localdomain: > I'm trying to make a sound decision of which GUI toolkit to use for a > new software project (it is the control and supervision system for a > complex scientific instrument). My target system is Linux both for > development and for the final system, although portability to Windows > coud be a plus. Hello, I have just gone to a Workshop about TACO/TANGO at the European Synchrotron Radiation Facility (Grenoble, France) last week. These tools are for distributed control systems on very large scientific instruments, but near discussions about these tools, there were discussions on experiment control and GUI. See http://www.esrf.fr/taco/workshop/ and http://www.esrf.fr/taco/workshop/programme.html Our own work: http://www.esrf.fr/taco/workshop/pointalSlides.pdf All the different institute present have projects based on Python for scripting. For GUI, there seem to be no clear choice (ESRF use Tkinter, FRM-II use QT, we use wxPython for GUI and IgorPro for plots). One interesting thing which appear during discussion is the possibility to use Python for scripting, Java and all its RAD and graphic tools for GUI, and to link them together (use right tool at the right place). For our futur projects (I work at on beamlines at LURE, Orsay-France), we may go to the following architecture (still to be tested and evaluated): GUI in Java | CORBA ORB for Java (OpenORB or other) | | | CORBA ORB for Python (omniORBpy) | scripting and processing in Python With such a solution, you must define a CORBA object interface, code your object in Python using omniORBpy for the CORBA stuff (really very easy), and use Java to code a client doing GUI and eventually plots (this is the side I must explore, but seeing Java tools, beans assembly possibilities seem promising). I'm not sure its the perfect solution for high speed realtime display of huge images, but for 80x80 image with 8bpp grayscale, it may not be a problem. We have already a running experiment with wxPython for the GUI, but we use Igor Pro (commercial, on windows) for plots. The integration with Igor Pro is done via CORBA with omniORBpy in Python, and an Igor Pro plugin using omniORB and creating a CORBA object in the Igor process. Python act as a client for the Igor Pro CORBA object, this object simply define an interface to receive data (simple, 1D, 2D), and users use Igor Pro as they do when they read a file (maths on data, plots)... but data come magically from Python script and Igor takes care of updating maths and plots. With current speed of computers, this kind of solution work nicely. And you can focus on another thing than developing another new data plot system. This allow to have data acquisition and GUI and plots on different computers (here we have in mind the possibility for scientists to have remote status display, and eventually remote control for 24h/24 running experiments). This can be adapted on Linux (omniORB is multi-platform), you have just to find a data plot program allowing plugins (OpenDave was demonstrated at the Workshop, looks promising, but not stable enough curently for realtime plots - maybe at beginning of 2002 when they need it on production experiment). > ... > I'm still trying to make a choice between PyQt and wxWindows and I'd > like comments and suggestions on this point. How, my suggestions are not on these... > > Many thanks, > > l.f. A+ Laurent. From jedimike at mac.com Wed Nov 21 17:03:58 2001 From: jedimike at mac.com (Michael Kelly) Date: Wed, 21 Nov 2001 22:03:58 GMT Subject: Simple (I think) regex question Message-ID: Hello all, I've used Perl quite a bit, but am very new to Python, and am still getting used to things. I'm not sure if I'm explaining this correctly or clearly, but here goes: My question is this: In a sub(), how do set the replacement string to be as long as the first matched substring? (i.e., the len() of \1). I've tried setting this as the replacement: '*' * len(r'\1') (the idea is to replace the matched string with *'s, no matter how long it is) The above example, of course, replaces everything with "**", since the len() of "\1" is 2. Any help would be greatly appreciated. Thanks! -Michael Kelly Email: jedimike at mac.com The Web: http://www.jedimike.net From grante at visi.com Tue Nov 6 00:37:58 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 06 Nov 2001 05:37:58 GMT Subject: RE Module Question. References: Message-ID: In article , Adonis Vargas wrote: > i am trying to fidn specific word within a string and am unable to > findanything suitable for it, > > test = "this is a test" > if "test" in test: print "found string." You have two choices: 1) Use the index method: it returns integer if string is found, throws exception if it isn't: test = "this is a test" try: i = test.index("test") print "found at position",i except ValueError: print "not found" 2) Use the find method: it returns -1 if string not found test = "this is a test" i = test.find("test") if i >= 0: print "found at position",i else: print "not found" If all you want is a boolean test, then find() is probably simpler option: if test.find("test") >= 0: print "found string" -- Grant Edwards grante Yow! Youth of today! Join at me in a mass rally visi.com for traditional mental attitudes! From bit_bucket5 at hotmail.com Thu Nov 15 20:33:35 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Fri, 16 Nov 2001 01:33:35 GMT Subject: Python & cgi on win98--tinyweb problems, etc References: <7x8zd7zfh8.fsf@ruckus.brouhaha.com> Message-ID: On 15 Nov 2001 17:12:03 -0800, Paul Rubin wrote: >Chris Stromberger writes: >> Any other recommendations for small simple web servers for this >> project? > >How about the HttpServer class that's already in the Python library? Hadn't thought of that. Do you mean CGIHTTPServer? The docs say "Note: This module is Unix dependent since it creates the CGI process using os.fork() and os.exec()." so that won't work for win98, unless I'm missing something. From sholden at holdenweb.com Fri Nov 9 16:29:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Nov 2001 16:29:47 -0500 Subject: Strange __str__ behavior References: <9shev1$136lad$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" wrote ... > wrote ... > > I am defining a class w/ method __str__. If I put a print statement > > inside __str__, and if I then use the print statement to display an > > instance of the class, I get an extra space in the output. > > > > > > > > Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit (Intel)] on > > win32 > > Type "help", "copyright", "credits" or "license" for more information. > > >>> class Test: > > ... def __str__(self): > > ... print "In method Test.__str__" > > ... return "String representation of instance." > > ... > > >>> test = Test() > > >>> print test # causes extra space problem > > In method Test.__str__ > > String representation of instance. > > > > > > > > > I don't get the same thing on win2k > > F:\Python22>python > ActivePython 2.2 Alpha 2 build 1 (ActiveState) > Python 2.2a2+ (#22, Sep 5 2001, 14:10:41) [MSC 32 bit (Intel)] on win32 > >>> class Test: > ... def __str__(self): > ... print "in __str__" > ... return "str(self)" > ... > >>> test = Test() > >>> print test > in __str__ ^ Yes, you do! > str(self) > >>> [ ... ] regards Steve -- http://www.holdenweb.com/ From fperez528 at yahoo.com Wed Nov 28 17:31:25 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 29 Nov 2001 21:59:25 +2328 Subject: extracting a pattern using RE References: Message-ID: <9u73pe$b61$1@peabody.colorado.edu> Peoter Veliki wrote: > > In perl you can use variables within regular expressions to extract > patterns, something like this: > [snip] See http://py-howto.sourceforge.net/regex/regex.html I come from a Perl regexp background, and I use this so much that I keep a local copy in my hard disk. The pure regexp syntax is basically perl, but their usage is different enough that while you shift mental gears this document will be a life saver. cheers, f From huaiyu at gauss.almadan.ibm.com Wed Nov 7 14:48:59 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 7 Nov 2001 19:48:59 +0000 (UTC) Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> <9s9949$hm5$1@news.service.uci.edu> <8ef9bea6.0111061428.28c46fc0@posting.google.com> <8ef9bea6.0111070030.d9c3793@posting.google.com> Message-ID: On 7 Nov 2001 00:30:13 -0800, Hung Jung Lu wrote: > >> It is has nothing to do with namespace. > >Now you are confused. You think you can do Python without namespaces. I did not know I thought that. Thank you for telling me what I thought. :-) > > statement modification on the globals() namespace dictionary >----------------+------------------------------------------------------ >>>> a = [] | (1) yes, entry with key 'a' inserted >>>> x = a | (2) yes, entry with key 'x' inserted >>>> x.append(1) | (3) no, no action on globals() namespace dictionary >>>> print a | >[1] | >>>> x = [] | (4) yes, value of the entry with key 'x' updated >>>> print a | >[1] | > >The difference in (3) and (4) is simply whether action has been >performed on the namespace dictionary, regarding the entry with key >'x'. Oh, now I see what you mean. You are saying anything that concerns names is a namespace problem. Of course that would be everywhere. But that's exactly why you find it difficult to explain to newbies. Have you considered the alternative approach? That is to separate the two issues: 1. name binding vs mutation, 2. name binding in different namespaces. To explain the example, you only need to touch upon the first issue. And it is considerably easier, as your one sentence summary quoted above shows. I would only call the second issue as namespace problem. However, as long as the first one is well understood, the second is not hard either - It's just the scoping rules. [snip long-winded discussion about namespace mechanisms] >However, that's not a task for beginners. Me having to spend 4 >postings on this thread should tell you something: many people don't >see the whole Python. Or maybe many people don't see the point of weighing in the knowledge of the whole Python in order to explain this simple example? >>feeling-exhausted-explaining-this-many-times-ly yr's > >Believe me, I am more exhausted than you are. :) > Maybe that's because you are trying to explain too much in one go? divide-and-conquer-works-ly yr's Huaiyu From hungjunglu at yahoo.com Fri Nov 30 11:46:00 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 30 Nov 2001 08:46:00 -0800 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> <8ef9bea6.0111291148.1c5d4fa@posting.google.com> <3C06D1BC.F8B46749@engcorp.com> Message-ID: <8ef9bea6.0111300846.7ca55e9d@posting.google.com> Peter Hansen wrote in message news:<3C06D1BC.F8B46749 at engcorp.com>... > Our conclusion was that while SourceSafe *might* be suitable for > a one-person situation, it was absolutely unsuited, and downright > *dangerous*, for a team environment. I know that from experience. SourceSafe is not safe, I've experienced crash before, in an environment of about 30 programmers. (Visual Studio 5, a few years ago already.) However, after recovery, and using a lot more disk space, the problem did not reoccur, ever. (Your comment on "SourceSafe *might* be suitable for a one-person situation" may really hurt the pride of Micro$oft, given that Visual SourceSafe is used in gigantic corporations, often up to hundreds of programmers at the same time.) If I considered switching to CVS, it's because I don't trust SourceSafe very much anymore. However, my experience with CVS was quite disappointing. So, I still rely on SourceSafe, but just with additional measures for backups. > shell Linux clients. Perhaps Hung's experience with CVS on > Windows was several years ago, and things might have changed.) No, it was just two months ago. Just compare documentation style of CVS materials from www.cvshome.org with the documentation style of Python. A whole world of difference. CVS documentation is really bad, in my opinion. Unprofessional and immature, if I may add. I have tried CVS years ago, I have tried CVS two months ago. My opinion is, if I get frustrated, thousands more people out there probably have had the same experience. Enterprise Visual Studio nowadays goes for $300 or less. It sets up in matter of minutes. In a world where time is money, trying to convince the Windows world to use CVS is just a tough sell. CVS is still much attached to the Unix world. As I said, I'd give it a few more years. It'll get better. Hung Jung From drs at alex2.labs.agilent.com Wed Nov 21 18:02:45 2001 From: drs at alex2.labs.agilent.com (David R. Smith) Date: Wed, 21 Nov 2001 15:02:45 -0800 Subject: Tkinter displaying an image in a button Message-ID: <3BFC3295.20FC3F02@alex2.labs.agilent.com> The first code snippet below successfully displays an image, whereas the second just shows gray where the image should be. What's wrong with the class version, and what do I have to do to get it to work? (I am using Python 2.0.1 on Debian.) adTHANKSvance David Smith from Tkinter import * import Image, ImageTk root = Tk() img = Image.open('SonicCruiser.jpg') phi = ImageTk.PhotoImage(img) button = Button(root, image=phi) button.pack() root.mainloop() from Tkinter import * import Image, ImageTk class App: def __init__(self, master): img = Image.open('SonicCruiser.jpg') phi = ImageTk.PhotoImage(img) button = Button( master, image=phi ) button.pack() root = Tk() app = App(root) root.mainloop() From bh at intevation.de Sun Nov 25 07:45:26 2001 From: bh at intevation.de (Bernhard Herzog) Date: 25 Nov 2001 13:45:26 +0100 Subject: Does Anybody Know How To Get Tkinter Working?? References: Message-ID: Ben Ocean writes: > I just configured Tcl--itworks--and I went to configure tk (both latest > stable distros) on my RH71 box and ran into all sorts of errors on > *make*. Both installations are in /usr/lib and I'm in as root. It exits > with Error 1. Here's how the errors start: > > [root at hermes unix]# make > gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall > -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix > -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps > -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 > -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 > -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED > /usr/lib/tk8.4a3/unix/../generic/tk3d.c > In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or directory I don't have any Red Hat system here, but you probably just have to install the X development package. I don't know what it's called on RH, though. HTH Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From qrczak at knm.org.pl Tue Nov 13 12:55:16 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Tue, 13 Nov 2001 17:55:16 +0000 (UTC) Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> <9sq85f$kdd$1@peabody.colorado.edu> Message-ID: Mon, 12 Nov 2001 21:38:09 +2328, Fernando P?rez pisze: > By the way, you should use long integers so that the factorials > don't blow up in your face for large numbers. Or use a recent version of Python (e.g. 2.2b1) which automatically switch to long integers instead of raising OverflowError. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From greg at cosc.canterbury.ac.nz Mon Nov 26 20:14:37 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Tue, 27 Nov 2001 14:14:37 +1300 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> While trying to think of a range syntax that looks unambiguously half-open without clashing with list or tuple constructors, the following blindingly obvious solution occurred to me: for 0 <= i < 5: ... -- 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 stuart at bmsi.com Sun Nov 4 17:24:40 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Sun, 04 Nov 2001 17:24:40 -0500 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> <3BE5A1A7.75C7EC9C@attglobal.net> Message-ID: <9s4f79$8b3$1@nntp2-cm.news.eni.net> In article <3BE5A1A7.75C7EC9C at attglobal.net>, "Pierre Rouleau" wrote: > Actually, i knew that i can execute a single program inside a command > shell and get the return code. What i want is to execute a large set of > commands inside the same shell process and being able to get the return > code for exach one of the calls. > > For example, i would like to be able to do someting like: > > myShell = Process('cmd') > error = myShell.execute('make myproject') if (error == 0) : > myShell.execute('ls') > myShell.execute('pj ci makefile') > > > I want to be able to issue a whole list of line commands whithout having > to create a new process on every one of them. When you run commands in a traditional shell script, it creates a new process for every one of them! The equivalent of the above is: #!/usr/bin/python import os error = os.system('make myproject') if error == 0: os.system('ls') os.system('pj ci makefile') The equivalent bourne shell would be: #!/bin/sh make myproject if [ "$?" == 0]; then ls pj ci makefile fi The number of 'fork' and 'exec' calls is exactly the same for both script languages. It is very convenient to run subprocesses in bourne shell, however bourne quickly becomes impenetrable when there is a lot of internal processing. While python syntax is somewhat clumsier than bourne for running external programs, internal processing is quite elegant. In both cases, a new process is created for each command. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From frederic.giacometti at arakne.com Sat Nov 10 13:13:47 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Sat, 10 Nov 2001 10:13:47 -0800 Subject: Proposal for a modified import mechanism. References: Message-ID: <3BED6E5B.8E142057@arakne.com> > > I'd like to ask the Python developers if they'd consider > > (a) changing the way the current import works to do what I > proposed, or, > > (b) add a new keyword like 'rimport' (or something) that does this > recursive search through parent packages and loads modules. This > was actually suggested by Gordon McMillan. Gordon actually > suggested something stronger -- import only supports absolute > names, rimport is relative import and rrimport is a recursive > relative import. But this would break the current import since > import currently aupports some relative lookup. So maybe import > and rimport is a workable solution? I'd rather introduce a __parent__ module attribute (in addition to the existing __name__) so that, for instance, the following would do your job: from __parent__.__parent__.toto import something In its spirit, this is similar to the '..' of the file systems. For top-level modules, __parent__ would be None. I'm personnally against anything that enlarges the search path uselessly; because the obvious reason of increased name space collision, increased run-time overhead etc... Frederic Giacometti From logiplexsoftware at earthlink.net Fri Nov 9 18:37:23 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 15:37:23 -0800 Subject: String Search. In-Reply-To: References: Message-ID: <01110915372309.01414@logiplex1.logiplex.net> On Friday 09 November 2001 15:20, Adonis Vargas wrote: > if "*something*is*" in "something is written here": return true import re s = "hello, world" if re.search("wor", s) is not None: print "found it" else: print "didn't find it" -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From skip at pobox.com Fri Nov 30 15:34:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 30 Nov 2001 14:34:34 -0600 Subject: A modest indentation proposal In-Reply-To: References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: <15367.60762.329658.848272@beluga.mojam.com> > Skip: > > In Python, if it looks right, it is right. > > No, that's not true. Consider the following two alternative code > fragments: > > if x: > foo() > baz() > > if x: > foo() > baz() > > They both look right, but they can't both be right. One or the other of the above alternatives will appear correct to the programmer. "If it looks right, it is right" means that if the programmer looks at the second snippet and thinks, "yup, foo() and baz() should only be executed if x is true", then it's right. The equivalent in C (visually) is if (x) foo(); baz(); It is a common mistake for a C programmer to look at that and think "yup, foo() and baz() should only be executed if x is true". Of course, that snippet means something entirely different than its indentation implies. Which is what I was getting at. As others have pointed out, in most languages, indentation is relevant for the humans that read the program, but generally not relevant for the compilers and interpreters that analyze and execute it. In Python that difference doesn't exist. Indentation is important to the humans *and* to the Python interpreter. There are fewer chances to make these sorts of mistakes in Python than in the class of languages descended from C (C, C++, Java, ...). Perl avoids this problem by requiring BLOCKs to always be delimited by { & }. BASIC of most flavors (and Pascal) uses BEGIN and END I believe. Guido chose a different approach than taken by the designers of those languages, but it's only different, not worse. Many Python programmers, myself included, would argue that it's better, though I expect most Perl and VB programmers would probably disagree. Cut-and-paste has been suggested as a source of problems in Python. I've also found that not to be a problem, given good editor support for rigidly moving chunks of code left and right. Python-mode uses C-c > and C-c < to do this. Works like a champ in those situations where I do cut-and-paste. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From christophertavares at earthlink.net Fri Nov 2 00:34:14 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Fri, 02 Nov 2001 05:34:14 GMT Subject: How to pass objects to a function? References: <4a0341c8.0111011723.53246ecd@posting.google.com> Message-ID: "Shankar" wrote in message news:4a0341c8.0111011723.53246ecd at posting.google.com... > I am a python newbie. > > How do I pass a user defined object to a function? > > if I have something like > > def func(session, url): > ... > .... > > and session is supposed to be an object of httpsession class, how > would the interpreter know about it? I suppose all arguments are > treated as strings. > so, if I invoke a method such as session.getreply() or something I > would get an error. The httpsession class is expected to have derived > classes too. > (that should not matter to the problem in hand anyway). > Arguments are not treated as strings - they're passed as object references. Just try it - you'll find that it just works. As long as the object you pass actually has the methods you're calling, it'll work just fine. > Also, if anybody has used the httplib.py module, can someone tell me > how to do a request.redirect() if the replycode is 302. > Can't help here. -Chris From rmfw at fast.net Sat Nov 10 20:04:52 2001 From: rmfw at fast.net (Ryan Wendt) Date: Sat, 10 Nov 2001 20:04:52 -0500 Subject: Online tutorials Message-ID: Does anyone know of any good tutorials? I have gone through all the tutorials on the python.org site, so I know the basics, but I would like to learn more than that. Thanks, Ryan Wendt CEO, President Envisage Computing rmfw at fast.net From fperez528 at yahoo.com Tue Nov 20 11:34:56 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 21 Nov 2001 16:02:56 +2328 Subject: which one to choose - NumPy or Scientific Python References: <9thboj$ud4@r02n01.cac.psu.edu> Message-ID: <9thc04$slu$1@peabody.colorado.edu> Rajarshi Guha wrote: > Hi, > I've been doing most of my science related work using C - but for some > new work I'm starting (neural nets, QSAR etc) I'm thinking of using python. > I know there are 2 sets of libs - NumPy and Scientific Python. > > Are there any suggestion as to which one is better or more suitable - I > won't need heavy duty number crunching. I do need arrays, basic statistical > functions (I could code these myself - but their presence would be nice) > I use SciPy, which includes Numeric, and also Scientific. There's enough non-overlap between the two for both to be useful. And yes, people are discussing some uniformization of this so that questions like yours don't have to be asked. It would be real nice to have *one* set of modules for scientific work. Join the party... F. From hfoffani at yahoo.com Sun Nov 11 13:44:23 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Sun, 11 Nov 2001 19:44:23 +0100 Subject: HTTP proxy variable References: Message-ID: <20011111134501.318$SA@news.newsreader.com> "amit weisman" escribi? en el mensaje news:mailman.1005491354.22778.python-list at python.org... >Hi >How does one change the http proxy and ftp proxy of a user ? Amit! It's really hard for us to guess your needs. Please don't be so shy when asking for help! :-) Are you talking about setting http proxy with urllib ? If so, read the doc Python Library Reference chapter 11.3 urrlib. At the bottom of urlopen() description it explains how to set the proxy data. Hope this helps, -Hern?n. From dennis at codegrinder.org Thu Nov 29 14:56:20 2001 From: dennis at codegrinder.org (Dennis Conrad) Date: Thu, 29 Nov 2001 20:56:20 +0100 Subject: Python to .dll ? Message-ID: <9u63rp$v5g$06$1@news.t-online.com> Hi, Is there a possibility to create a (win32) .dll from a Python-script? I know there is py2exe, maybe there is something like py2dll...? Thank you very much Dennis From seb at tesco.net Mon Nov 5 19:34:33 2001 From: seb at tesco.net (seb) Date: Tue, 06 Nov 2001 00:34:33 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s43jo$bku$1@news8.svr.pol.co.uk> <9s538j$qo1$1@bugstomper.ihug.com.au> Message-ID: <3be72ae0.2762662@news.tesco.net> On Mon, 5 Nov 2001 15:18:28 +1100, "Gary Stephenson" wrote: >> > The patriot (scoundrel??) in me wishes to point out that Spike was / is >an >> > Australian - though I imagine many Brits would be somewhat upset to >learn >> > this . >> >> Yet he was born in India and (now) holds an Irish passport (as a result of >> having an Irish father (English mother? not sure)). Has he ever held an >> Australian passport? > >Umm, errr, you've got me there! I'd forgotten that he was born in India. >We here downunder have just always claimed him as one of our own - and will >continue to do so, you festering putrid pile of maggot infested batsh*t, I >blow my nose at you, I fart in your general direction ... and if you want >to argue any further about it I suggest you need the room down the hall! > This is abuse! ) > >gary > > Knew he was born in India and was clearly Irish. Australian, though? You buggers try to claim everything. Dane Edna should be enough-ly. obMilligan: Said Hamlet to Ophelia 'I'll do a sketch of thee What kind of pencil shall I use 2B or not 2B? har, har. seb. From daniel.dittmar at sap.com Tue Nov 20 06:05:37 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Tue, 20 Nov 2001 12:05:37 +0100 Subject: String formatting char References: Message-ID: <9tdde1$q6j$1@news1.wdf.sap-ag.de> "Dale Strickland-Clark" wrote in message > The string formatting operator, %, is a mighty powerful beastie when > used in mapping mode if the map is an object of your own. [...] > Is there some way to alter the format escape character from % to > something else? The %(varname)s formatting can be implemented using the re.sub method: class FancyLookup (UserDict): def replace (self, match): key = match.group (1) return self [key] lookup = FancyLookup () result = re.sub (r'%\(([^)]+)\)s', lookup.replace, input) You could add a 'sub' method to your FancyLookup class, thus having the actual regular expression in only one place. Daniel From lucio at movilogic.com Fri Nov 2 13:49:04 2001 From: lucio at movilogic.com (Lucio Torre) Date: Fri, 02 Nov 2001 15:49:04 -0300 Subject: ANNOUNCE: PySteroids 2.0 Message-ID: <3BE2EAA0.7080305@movilogic.com> Im happy! this is public release of pysteroids 2.0. my asteroids game done with pygame. Nothing near paradigm shifting in games, but its my baby. check it out at: http://vampira.dyndns.org/zope/software/ lucio. From hartanto at telusplanet.net Thu Nov 8 19:28:18 2001 From: hartanto at telusplanet.net (harry) Date: Fri, 09 Nov 2001 00:28:18 GMT Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: actually, i think char data type in c is 1 byte (8bit) "harry" wrote in message news:_6FG7.33159$i4.5175661 at news0.telusplanet.net... > if you put data into dictionary, how do we calculate the data size? > > key:data > > example: > > dict = {"key1":1,2,3,4; "key2": "hello", [1,2,3]} > > how much is the data structure will cost? how to calculate it? > > if in c++ : char array1[8] will cost 8 x 8 bytes = 64 bytes > > From logiplexsoftware at earthlink.net Tue Nov 13 12:15:00 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 13 Nov 2001 09:15:00 -0800 Subject: Teaching python (programming) to children In-Reply-To: <200111130925.fAD9PPua015737@ratthing-b246.strakt.com> References: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> <01111212560602.01611@logiplex1.logiplex.net> <200111130925.fAD9PPua015737@ratthing-b246.strakt.com> Message-ID: <01111309150002.02982@logiplex1.logiplex.net> One more thing: why is it people always want to form committees to delegate policy when they think that policy will correspond to their personal beliefs? Why are they always so surprised and disappointed when it doesn't? Genius is rare in individuals; it's rarer still in groups. Ask yourself, would you rather take art classes from the Public Art Commission or Andrew Wyeth? I'll suffer 100 bad teachers as long as I'm granted the opportunity to learn from the one good one. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From SSchukat at dspace.de Tue Nov 27 02:40:46 2001 From: SSchukat at dspace.de (Stefan Schukat) Date: Tue, 27 Nov 2001 08:40:46 +0100 Subject: AW: [help] Driving Visual Studio From Python Message-ID: <84257D042AA7D411B3F700D0B7DB9B7C13AF58@newsintern.dspace.de> Hi, you are using dynamic invocation through "win32com.client.Dispatch" therefore your makepy generated wrapper is possibly of no help. Try to import the generated wrapper or use win32com.client.gencache.EnsureDispatch. Otherwise the code you are looking for is: import win32com.client app = win32com.client.gencache.EnsureDispatch( 'MSDev.Application') app.AddProject("MyProj", "c:\myproj", "Console Application", 1) Bur unfortunaly there is no code to read the project properties. You could only add or remove settings in the following way (For the first configuration in the first project) if app.Projects[1].Type == "Build": app.Projects[1].Configurations[1].AddFileSettings("myfile.cpp", "/D_DEFINEME") or: app.ActiveProject.Configurations[1].AddFileSettings("myfile.cpp", "/D_DEFINEME") app.ActiveConfiguration.AddFileSettings("myfile.cpp", "/D_DEFINEME") if a configuration object is available Conf.RemoveToolSettings("cl.exe", "/GX") Conf.AddToolSettings("cl.exe", "/D_DEFINEME") Conf.RemoveFileSettings("stdafx.cpp", "/WX") Bye Stefan > > > Hello All, > > I am an old unix developer finally moving to Windows Visual > C++. I have > been using python on Unix since 96, > and have been really happy with python as a scripting/tools language. > > I need to drive visual studio to create projects, add configurations, > and add files to projects. > > The COM extensions make it look like it is possible to do this, but I > am having trouble getting > it going. > > I have ran makepy and added the visual studio type libs. > > I copied the following code from a post > > ----------------------------------------- > import win32com.client > app = win32com.client.Dispatch( 'MSDev.Application') > > wnd = app.ActiveWindow > if wnd.Type == 'Text': > print wnd.Selection > app = None > ------------------------------------------ > > This prints on the selected test. > > I can't seem to get the syntax to obtain and print out project > properties, or to add a project > > > Could someone help my out by giving me the python code to try to get > this to go, I am missing something > very basic here. > > Thanks > Mike > > PS. I added the MSDEV links to the visual studio docs > ++++++++++++++++++ > DeveStudio Link to add project > > http://msdn.microsoft.com/library/default.asp?url=/library/en- us/vcug98/html/vcrefaddprojectmethod.asp Link to Visual Studio Application Object http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html /_asug_application_object.asp From not.this at seebelow.org Sun Nov 4 22:41:42 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sun, 04 Nov 2001 21:41:42 -0600 Subject: Freeware Python editor References: <9ruu6l09ah@drn.newsguy.com> <9s4bqc$heq$1@newshost.accu.uu.nl> Message-ID: <3BE60A76.BD73AF17@seebelow.org> Martijn Faassen wrote: > > Grant Griffin wrote: > [snip long discourse on free beer] > > I think this post extended the lifetime of the universe by a couple of million > years at least, single handedly. I'm impressed. :) Thanks, Martijn--glad I could help. :-) like-free-software-development-itself,-trolling-can-really-work-only -as-a-community-effort--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 phr-n2001d at nightsong.com Thu Nov 15 09:44:10 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 06:44:10 -0800 Subject: Newbie questions References: Message-ID: <7xzo5ojdqd.fsf@ruckus.brouhaha.com> "David Grenier" writes: Change this: > while type(champ)=='instance': to: while isinstance(champ, cons): The problem is that type(champ) doesn't return a string, so your test always is false. From niemeyer at conectiva.com Mon Nov 12 17:31:50 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Mon, 12 Nov 2001 20:31:50 -0200 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) In-Reply-To: <20011112102612.A1723@gerg.ca>; from gward@python.net on Mon, Nov 12, 2001 at 10:26:12AM -0500 References: <20011112175357.F26476@phd.pp.ru> <20011112102612.A1723@gerg.ca> Message-ID: <20011112203150.A8294@ibook.distro.conectiva> > > Or mix options and arguments? > > > > --file outfile infile -q > > Not yet; I deliberately punted on this because most other Unix > command-line parsing libraries are lazy and don't bother to scan all > arguments for options. (I think scanning all arguments is the preferred > behaviour, but for historical reasons it should probably be optional > behaviour. I could be wrong...) This seems desirable. It's usual for people (at least I have seen many doing this, including myself) to type a whole line, and then remember about a command line option and include it at the end. Btw, congratulations. I haven't used the library so far, but seems very flexible, and a nice option to include in standard library. Meanwhile, you could want to pack the library in a single file, to be easier to include in other projects. Anyway, this should be easy to achieve by someone wanting to do so. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From cpr at emsoftware.com Sat Nov 17 11:51:45 2001 From: cpr at emsoftware.com (Chris Ryland) Date: 17 Nov 2001 08:51:45 -0800 Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> Message-ID: <8827e15d.0111170851.1c7969ce@posting.google.com> "Stuart D. Gathman" wrote in message news:<9t1ml4$vhi$1 at nntp1-cm.news.eni.net>... > I have been putting my thoughts toward the elusive goal of making python > as fast as some LISP dialects. Actually, Jeremy Hylton of PythonLabs is already working on something that's along these lines (though not as wasteful ;-). Dunno if it's been PEPped or not, but you might check at . --Chris Ryland, Em Software From mwh at python.net Wed Nov 14 07:39:20 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 12:39:20 GMT Subject: Size of an object in memory? References: <9sspa2$ku3$1@peabody.colorado.edu> Message-ID: Fernando P?rez writes: > Is there any way (at runtime, dynamically) to obtain the size in > bytes of a given object in memory? Didn't we do this a few days ago? See this thread: http://groups.google.com/groups?hl=en&threadm=_6FG7.33159%24i4.5175661%40news0.telusplanet.net&rnum=1 but, in short, no, and you don't really want to know. > Since multiple names may be bound to the same object, is it possible > to obtain the size of the underlying object and a list of all other > names bound to it? Not easily. Or maybe not at all. Oh, hang on: see gc.get_referents. This may be new in Python 2.2, though. > I'm writing a runtime object inspector, using the very nice inspect > module, but inspect doesn't seem to provide this kind of > information. It's not obvious (to me) that the information returned by gc.get_referents will be useful, but it may be. Maybe it should be used in inspect? Cheers, M. -- First time I've gotten a programming job that required a drug test. I was worried they were going to say "you don't have enough LSD in your system to do Unix programming". -- Paul Tomblin -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From tim at vegeta.ath.cx Tue Nov 13 18:04:45 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 13 Nov 2001 23:04:45 GMT Subject: IsPython really O-O? References: <9sl891$eik$1@slb7.atl.mindspring.net> <9sqeq6$qu5$1@slb1.atl.mindspring.net> Message-ID: Matt Gerrans graced us by uttering: > Tim Hammerquist wrote > >> If you really need to raise a discussion, the posters >> comp.lang.smalltalk... > > Okay, I'm off to the smalltalk group to declare that "Python is more OO than > Smalltalk!" Who will ensure that I get a decent burial? They may be too deeply involved debating RDBMS vs OODBMS to even see your post. ;) >> $ cat debate >> #!/usr/local/bin/python >> >> assert time is infinite >> steve = Zealot(SmallTalk) >> matt = Advocate(Python) >> >> while isinstance(steve, Zealot): >> try: >> matt.argue() >> if isconvinced(steve): >> break >> pigs.fly() >> steve.say("I'm not convinced.") >> except: >> steve.say("Hah! You can't prove it!") >> >> $ chmod 700 debate >> $ debate and echo "They all lived happily ever after." This last should have been: $ debate && echo "They all lived happily ever after." Thus, && tests the exit value of debate, debate can never return true, (since at no point is steve .convinced), and no one ever lives happily ever after. Cynical yet apropos. > Cute, I like it! (although I don't claim to be a Python Advocate -- I > advocate using the best tool for the job, which means the more tools you know > how to use, the better your odds are). Touch?. This means I won't be garroted for mentioning Perl elsewhere in this thread? ;) Tim Hammerquist -- No violence, gentlemen -- no violence, I beg of you! Consider the furniture! -- Sherlock Holmes From manus at bullfrog-tech.com Mon Nov 26 22:00:33 2001 From: manus at bullfrog-tech.com (Manus Hand) Date: Mon, 26 Nov 2001 20:00:33 -0700 Subject: Problem in a str subclass Message-ID: <3C0301D0.2D50E454@bullfrog-tech.com> Can anyone explain why I get the following result? Python 2.2b2 (#1, Nov 26 2001, 20:03:34) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class X(str): ... def __init__(self, xx = None): ... if not xx: xx = 'ye olde default value' ... str.__init__(self, xx) ... >>> x = X('yo yo yo') >>> x 'yo yo yo' >>> x = X() >>> x '' >>> I can't see why X() is not set to 'ye olde default value' Stumped, Manus From tim at vegeta.ath.cx Wed Nov 14 20:16:10 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 15 Nov 2001 01:16:10 GMT Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: Modman graced us by uttering: [ snipped pieces of a Python thread that became a Smalltalk thread, that then degenerated into a Perl/Latin thread ] > just thought I could try to tie this back into the main topic :-) Why bother? I'm only assuming from the Newsgroups: header that this thread was originally about Python. ;) Oh wait, now I remember. There was a pterodactyl flying outside my window and someone posted regarding a cow orker who denounced Python's OO-ness... ly 'yrs, Tim Hammerquist -- Usenet is essentially a HUGE group of people passing notes in class. -- R. Kadel From mgerrans at ix.netcom.com Wed Nov 14 15:31:35 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Wed, 14 Nov 2001 12:31:35 -0800 Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> <3BF2C948.87C9B103@alcyone.com> Message-ID: <9sukag$9mc$1@slb7.atl.mindspring.net> In any case, a 1-dimensional graph is not adequate, but most of us will probably struggle to visualize the several hundred (or so) -dimensional graph to accurately describe the differences between the three... - mfg From phr-n2001d at nightsong.com Sat Nov 10 00:32:20 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 21:32:20 -0800 Subject: How much is set in stone? References: Message-ID: <7x668jxkbf.fsf@ruckus.brouhaha.com> slinkp23 at yahoo.com (Paul Winkler) writes: > On Fri, 9 Nov 2001 16:49:17 -0800, Cliff Wells > wrote: > >On Friday 09 November 2001 16:39, Tim Peters wrote: > > > >> about 2.1.1 before, and I can assure you we didn't pay everyone on c.l.py > > > >Who's "we", Tim? I see you've finally shown yo > > > > Why do people's posts keep getting cut off on this ng? > Is there some kind of consp lo From donn at u.washington.edu Thu Nov 1 18:21:21 2001 From: donn at u.washington.edu (Donn Cave) Date: 1 Nov 2001 23:21:21 GMT Subject: fcntl semantics References: <9rsgg902rct@drn.newsguy.com> Message-ID: <9rsldh$26fe$1@nntp6.u.washington.edu> Quoth buzmeg at newsguy.com: | I've had to deal with fcntl directly for a while now and was thinking of moving | my C programs to Python. However, the OS dependence of the packed structure | used to access fcntl pretty much stops that idea cold. So, my question is: | | Why does fcntl use a packed struct as it's third argument? And why does it | throw away the return code in that case? | | That particular mechanism actually goes out of its way to lose data. The | complier knows the correct form of struct to put the data in when it compiles | the modules, throws it away, the user has to dig out what that structure was, | and then hard code it into the Python code. Additionally, it throws away the | error/return code when you pass it a packed struct as the final argument. | | I can think of several ways that it could be coded, but the one I find the most | appealing is: | | fcntl(fd,op,arg): | arg is a hash -- keys are fcntl struct member names -- vals are values | return value is a hash in same form | Exception raised on error with return/error value in exception object | | All the information from the C function fcntl is accessible without any of the | nasty OS/compiler dependence. It even allows future extension to the fcntl | structs to be accomodated without changing the language semantics. It also | doesn't require in place modification of data so it has a low surprise factor. | In addition, the type of arg is different and identifiable from the previous | form of fcntl (thus, previous semantics can even be preserved if desired). | | I would really like to know if there is a good reason for requiring packed data | for fcntl (Perl does the same blasted thing), and, if not, the proper mechanism | for attempting to get this changed in the language. I would even write the | code, if required. Are you really talking about fcntl()? The only struct parameter that I can think of for fcntl() is struct flock, and fcntlmodule already provides a lockf function that wraps that. Why does it throw away the return code? It doesn't! Python should never return an error code, it should raise an exception, as it will in this case, and the C return code is used to do that, the only thing it's good for. In general, I would expect lockf to be the model for packed structs. When there's enough call for a particular ioctl that it's worth building support for the struct into fcntmodule, then it will end up with its own function entry point, and typically the input would be a tuple. If you try to write a generic ioctl for all structs, with a dictionary input like you describe, I think you'll see that it doesn't get you much more than that. Now one thing you might try, if you would like a fun project, is a automatic module builder that would, as needed, construct C modules that work exactly like you describe. When you need a new struct, or new field in the same struct, or new symbolic constant, then it builds or rebuilds the function to accommodate it. As long as you do your development and testing on a computer with a C compiler, for every supported platform, then that should work out fine. The advantage is that no Python+C programmer is needed there, just someone with a C compiler. The function could even build its own new module on demand (if it's a Python function that imports a C module.) Donn Cave, donn at u.washington.edu From loewis at informatik.hu-berlin.de Tue Nov 6 14:05:56 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 06 Nov 2001 20:05:56 +0100 Subject: Reading PDF files . References: Message-ID: Amit Weisman writes: > Is there a module for reading PDF files ? Please have a look at www.reportlab.com Regards, Martin From gmcm at hypernet.com Wed Nov 21 07:50:34 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 21 Nov 2001 12:50:34 GMT Subject: importing SWIG extension DLL from VC++ References: <9ZzK7.40081$Ze5.22244774@news1.rdc1.md.home.com> Message-ID: Refrigerator Johnny wrote: > From VC++, I cant seem to import an extension DLL made with SWIG? > for example: > po = PyImport_ImportModule("import simple"); > po = PyRun_String("simple.jbtestfn()",Py_eval_input, pdict, pdict); PyObject *po = PyImport_ImportModule("simple"); PyObject *md = PyModule_GetDict(po); PyObject *fn = PyDict_GetItemString(md, "jbtestfn"); PyObject *rs = PyObject_CallFunction(fnm, ""); or maybe PyRun_SimpleString("import simple;simple.jbtestfn()"); If you want the result, you need to go the low-level route. - Gordon From qrczak at knm.org.pl Thu Nov 22 14:24:44 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Thu, 22 Nov 2001 19:24:44 +0000 (UTC) Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: Thu, 22 Nov 2001 18:51:07 GMT, Erik Johnson pisze: > is there a logical reason why it was implemented as a string method > rather than a list method? AFAIK because it's not necessarily a list but any sequence and we don't want to require implementing join from all types which want to behave like sequences. OTOH there are not many string-like types. There also used to be some reasons concerning the dictinction between byte strings and Unicode strings - AFAIR the separator used to decide about the type of the result - but at least in Python 2.2 everything is transparently recoded to Unicode when at least one of involved strings is a Unicode string. > Does it seem backwards to you or does it make intuitive sense to you? It seems backwards for me - the sequence is more important than the separator - but I wouldn't treat it as a list method either. More as a global function. But I'm strange in that I don't believe in OOP as a universal way of life. At least the traditional OO view which makes an interface of an operation dependant on which object is used to choose the implementation. The essence is that join doesn't need to be implemented separately for various sequence types, and implementations for both flavors of strings are already coupled. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From wurmy at earthlink.net Thu Nov 29 22:22:26 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Fri, 30 Nov 2001 03:22:26 GMT Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: Message-ID: <3C06FB65.B27A6A12@earthlink.net> Ozone Hole near South Pole wrote: > > Hi, > > I have written a simulation in python 1.5.2.... It used to work fine. > > When I logged on a new machine which has Python 2.1.1 installed, my > simulation > has gone wild. Later on, I figured that out one weird thing about the > value of "None": > > In the new machine: > Python 2.1.1 (#1, Nov 11 2001, 18:19:24) > [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> a=[3,4,5,7,None,0.2,-4] > >>> print min(a) > None > >>> print max(a) > 7 > > Python 1.5.2 (#1, Sep 30 2000, 18:08:36) [GCC 2.95.3 19991030 > (prerelease)] on linux-i386 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam > >>> a=[3,4,5,7,None,0.2,-4] > >>> print min(a) > -4 > >>> print max(a) > None > >>> > > It seems to me that "None" means -Inf in 2.2.1 but means "Inf" in > 1.5.2. Why do the Python guys change this assumption? In my > calculations, I use "None" to indicate very large estimation error. > Is there any formal symbol for this? I don't really want to fix this > type of bug again whenever Python upgrades.... None doesn't really have a numerical value; its value is, well, none! In theory you can stick all kinds of objects in comparisons, the only problem is that the results may be undefined, and may change between Python versions or maybe even sessions. In other words, what happens to work today, might not work tomorrow, in cases like this. Instead of relying on the behavior that None happens to show in a given version, you could use e.g. 1e1000 for a large number. If that isn't enough, you could consider rolling your own class that always compares as larger (or smaller) than another object: >>> class MuchoGrande: def __cmp__(self, other): return 1 # larger than anything else def __repr__(self): return "MuchoGrande" >>> muchogrande = MuchoGrande() >>> z = [1, 2, 1e100, muchogrande, -7, -900] >>> z [1, 2, 1e+100, MuchoGrande, -7, -900] >>> z.sort() >>> z [-900, -7, 1, 2, 1e+100, MuchoGrande] >>> min(z) -900 >>> max(z) MuchoGrande HTH, --Hans From gmuller at worldonline.nl Tue Nov 6 15:08:13 2001 From: gmuller at worldonline.nl (GerritM) Date: Tue, 6 Nov 2001 21:08:13 +0100 Subject: Teaching python (programming) to children References: <7xsnbs65ke.fsf@ruckus.brouhaha.com> <9s77qb.3vv4gtl.1@kserver.org> <3BE827B7.D5616361@juno.com> <9s8gql.3vv9mlp.1@kserver.org> Message-ID: <9s9g5l$ipf$1@nereid.worldonline.nl> <..snip...> > Yes, it was just about five years ago or so, when my daughter was right > about that age (and my son was three years older), that I wrote a small > LOGO-like program in Turbo Pascal. It was interactive. So they could > give the turtle commands like > LEFT 90 > MOVE 100 > > and so forth, and draw little designs on the computer. (Seeing the > results immediately.) > > A few months back, my daughter asked me about "that turtle program" that > I had let them "play with" and she said she had liked it and would like > to try it again. > > Of course, I don't have Turbo Pascal installed any more, nor do I know > where that code got to that I wrote. When I suggested *really* learning > to program, she seemed less interested. (I did get my son going on some > Python this past summer.) So, for now it appears to be The Sims for > computer entertainment. :/ > > -- > Sheila King > http://www.thinkspot.net/sheila/ > http://www.k12groups.org/ > did you have a look at the turtle package in the standard python distribution? It does all of the "trivial" moves and more. Written by Guido. I myself have customized it some time ago by making a dutch translation of the commands. Regards Gerrit -- www.extra.research.philips.com/natlab/sysarch From skip at pobox.com Tue Nov 13 04:28:18 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 13 Nov 2001 10:28:18 +0100 Subject: Is this considered black magic? In-Reply-To: References: Message-ID: <15344.59314.729789.319489@beluga.mojam.com> Laura> I have a new problem. I've just lost a major amount of precision Laura> in my language usage. What is the collective noun for Laura> 'attributes that aren't methods (you can't call them)'? What's about method the attributes you call data attribute the attributes you don't call attribute either, when you don't care which -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From opengeometry at yahoo.ca Sat Nov 17 04:38:33 2001 From: opengeometry at yahoo.ca (William Park) Date: Sat, 17 Nov 2001 04:38:33 -0500 Subject: Regular Expression Help Needed In-Reply-To: ; from christophertavares@earthlink.net on Sat, Nov 17, 2001 at 03:00:00AM +0000 References: Message-ID: <20011117043833.B499@node0.opengeometry.ca> On Sat, Nov 17, 2001 at 03:00:00AM +0000, Chris Tavares wrote: > "David A McInnis" wrote in message > news:mailman.1005960683.29958.python-list at python.org... > > Ok, I am not very good at regular expressions, so any help is > > greatly appreciated. > > > > Here is the situation. > > > > I have a database table that contains a text field. This text field > > may or may not contain email addresses. I know how to read the > > content of field to a string. Now what I need is a regular > > expression that I could use to identify any email addresses in the > > string. Since the email can be in mixed case, I need a solution > > that is case insensitive. > > > > So, there may be one or more email addresses in the string. When I > > find one, I need to added it to a list variable and look for other > > addresses in the string. > > > > Thanks, > > > > David McInnis > > > > Get a copy of _Mastering Regular Expressions_, by Jeffrey Friedl, from > O'Reilly press. The regular expression you want is in the back. > > Be warned - it's over 4000 characters long, and it still doesn't work > in all cases. Email addresses are not a regular language, and > therefore cannot be completely matched by regular expressions. > > -Chris What's wrong with '[\w.]+@\w+(\.\w+)*' ? -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From jeff at ccvcorp.com Tue Nov 27 17:50:37 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 27 Nov 2001 14:50:37 -0800 Subject: list.remove for Novices References: Message-ID: <3C0418BD.AAC0D96D@ccvcorp.com> Arthur Siegel wrote: > How about this one. A copy operator - <=> or something. So now > all the world is on notice from day one = is different that <=>. > Which do you mean? Well, Python already *does* have several ways to indicate copying, though not specifically in a single simple operator like that. list2 = list1[:] #create a copy import copy list2 = copy.copy(list1) #copies a list list2 = copy.deepcopy(list1) #even better Yes, beginners are likely to get bitten by a few things. This will happen regardless of what language they use. Trust me, it's a lot easier to track down an assignment/copy error, or the list.reverse() gotcha, than to track down the bugs caused by referencing free()'d memory in C... I don't think that changing the language to avoid these will help matters much. What *might* help, is changing the documentation. If you think that having these things clearly explained in the tutorial would help, by all means, submit a patch for the tutorial! That's probably much more effective (and more likely to be accepted) than altering the language would be... (Note that I consider myself almost a beginner--my programming knowledge is entirely self-taught, starting with C, then C++, and now Python. I've been bitten by both of the traps that you mention. But... any language will have pitfalls to watch out for, provided that it's powerful enough to be useful. With no reference but Python, it may not be obvious, but really--these are *simple* traps to catch and avoid, compared to those of certain other languages...) Jeff Shannon Technician/Programmer Credit International From mind.tech at verizon.net Sun Nov 25 15:14:45 2001 From: mind.tech at verizon.net (Power-Tech) Date: Sun, 25 Nov 2001 20:14:45 GMT Subject: WINDOWS USERS???? Message-ID: <3C0151C3.2903A9F5@verizon.net> Hello, I've downloaded the regular Python and had some problems running the .py files, today I found that "ActivePython" should be the best download for windows users.... Can anyone throw some light on this? I am also a first time programmer (which means my only previous experience was with HTML, and some scripting language), does anybody knows about a good tutorial online for someone in my situation? Is this group too advanced for me? I appreciate your attention Willie From sag at hydrosphere.com Tue Nov 27 12:00:52 2001 From: sag at hydrosphere.com (Sue Giller) Date: Tue, 27 Nov 2001 10:00:52 -0700 Subject: Using reduce with masked arrays Message-ID: <20011127165925656.AAA41@mail.climatedata.com@SUEW2000> I am using 2 (and more) dimensional masked arrays with some numeric data, and using the reduce functionality on the arrays. I use the masking because some of the values in the arrays are 'missing' and should not be included in the results of the reduction. For example, assume a 5 x 2 array, with masked valued for the 4th entry for both of the 2nd dimension cells. If I want to sum along the 2nd dimension, I would expect to get a 'missing' value for the 4th entry because both of the entries for the sum are 'missing'. Instead, I get 0, which might be a valid number in my data space and the returned 1 dimensional array has no mask associated with it. Is this expected behavior for masked arrays or a bug or am I misusing the mask concept? Does anyone know how to get the reduction to produce a masked value? >>> import MA >>> a = MA.array([[1,2,3,-99,5],[10,20,30,-99,50]]) >>> a [[ 1, 2, 3,-99, 5,] [ 10, 20, 30,-99, 50,]] >>> m = MA.masked_values(a, -99) >>> m array(data = [[ 1, 2, 3,-99, 5,] [ 10, 20, 30,-99, 50,]], mask = [[0,0,0,1,0,] [0,0,0,1,0,]], fill_value=-99) >>> r = MA.sum(m) >>> r array([11,22,33, 0,55,]) >>> t = MA.getmask(r) >>> print t None From NOSpawnPAM at lightspawn.org Mon Nov 5 06:48:59 2001 From: NOSpawnPAM at lightspawn.org (pawn) Date: 5 Nov 2001 03:48:59 -0800 Subject: no setuid for CGI scripts? Message-ID: <4b4c5d99.0111050348.6d7c9406@posting.google.com> I'm trying to convert a few simple CGI scripts from Perl to Python, and was shocked to learn that the Python interpreter silently ignores the setuid bit. I really don't know how to get around this. Since the server is hosted remotely I can't recompile python to allow setuid, and I can't make my files world read/writable - I need my python CGIs to run with MY uid. I read somewhere about using a wrapper C program but it seems really convoluted, as well as requiring a different wrapper for each CGI. Is there any solution, or should I stick to / am I stuck with Perl? From mwh at python.net Sat Nov 10 10:47:57 2001 From: mwh at python.net (Michael Hudson) Date: Sat, 10 Nov 2001 15:47:57 GMT Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: Martin von Loewis writes: > i.e. 12 bytes per entry. With three keys, the dictionary will have > eight entries in 2.0, giving 96 bytes of entries. Actually, I think in 2.0 the dict will have four entries. I realise this isn't what the code claim{s,ed}, but for the sake of pedantry... (I only remember this because it led to obscure bugs in the compiler in 2.1 betas...) generally-in-awe-at-your-thoroughness-ly y'rs, M. -- I never realized it before, but having looked that over I'm certain I'd rather have my eyes burned out by zombies with flaming dung sticks than work on a conscientious Unicode regex engine. -- Tim Peters, 3 Dec 1998 From sholden at holdenweb.com Mon Nov 5 14:32:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Nov 2001 14:32:00 -0500 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: "Hung Jung Lu" wrote ... > Nomad wrote in >... > > IMHO, python would be one of (if not _the_) best language to teach > > beginning programming - not just children, but as you mention, there > > is the difficulty with the "englishness" of the language (or almost > > any other programming language). > > I have my doubts about Python being the first programming language to > teach. I see all too many newbies running into the problem of > namespaces. How do you explain to them that "from xyz import *" is a > bad thing, if they don't even understand what's going on behind the > scene? You don't. You simplify, so they initially don't even realise it's possible. If they don't know they can do something, beginners aren't as likely to get into trouble by abusing the feature. > Also, how in the world can beginners understand what a hash > table mean? Are we going to tell them something like: "oh well, think > of Python dictionary as a magic black box, you'll understand it later > when you take a course in C/C++"? > You appear to be making the mistake of assuming that the beginner *must* understand the implementation of an object to be able to use it. If this were the case we would never learn to drive a car, or to speak natural languages. A good teacher manages to select useful, and usable, simplifying assumptions which the beginner can comprehend in terms of their present understanding. A magic black box isn't a bad way to understand dictionaries - certainly it's easier for the beginner than looking into hash functions, buckets, collision chains, and all the other mess that (may) live under there, and would simply server to confuse. > Python seems very friendly, at first sight. But unless you really > understand the dictionary and namespace (and name binding) mechanisms > behind it, you'll run into surprises in no time. And at that moment, > there is simply no way that it could be explained in easy terms to > beginners, when they don't understand things like pointers, > references, memory stack and heap, hash tables. > Certainly the beginner should be taught to expect the unexpected, since it should not be hidden from them that their understanding is simplified. When their mental model ceases to fit the language they are probably ready to have it expanded. But if I accepted your argument, that would logically imply that a begineer would have to understand RISC/CISC instruction sets and the von Neumann model before they could write a program in BASIC. > I do believe Python should be part of a programmer's school > curriculum, but I really doubt it can be a good first language to > learn, unless some technicality questions are addressed properly. > This is where we differ. I would ignore the difficult bits until they insistently present themselves to the beginner. "Why doesn't it work like you taught me" is a great question for a beginner, and until it is asked the taught level of understanding is adequate. > Or is there a good way of teaching to make it less traumatic for > beginners to grasp the concepts of dictionary, name spaces, assignment > by reference? It is just really really annoying that every single > newbie has to be explained on these issues, and many of them end up > without understanding it. I can't imagine teachers having a good time > at these issues. I mean, it's OK to make students understand these > Python issues, but the time required is not negligible, and the > knowledge gained is limited in scope: these peculiarities are very > Python specific. And it's doubly frustrating when after spending all > the time, the students end up without understanding it. What can you > do? It's not the fault of the average students or the average > teachers, when the language itself has a non-trivial component that's > hard to explain/understand. > Here I believe your focus on what a "newbie" is has changed, to include programmers arriving at Python via some other language. A programmer who is familiar with C, or C++, or any other single language, will bring a whole set of assumptions with them -- and they do, repeatedly, try to transfer their existing knopwledge to the new language. One who has programmed in several languages will ask more sensible questions, but they will still need to know Python specifics. THey will simply have a larger base of referent concepts to call upon for explanation and enlightenment. I therefore believe that "Python for C Programmers" would, and should, be a very different class from "Python for Beginners": the former would have to focus on differences between the two langugae environments, while the latter could use many simplifying analogies without ever having to discuss exactly how lists, tuples, dictionaries and classes are structured and implemented. regards Steve -- http://www.holdenweb.com/ From gry at ll.mit.edu Thu Nov 29 14:18:42 2001 From: gry at ll.mit.edu (george young) Date: Thu, 29 Nov 2001 14:18:42 -0500 Subject: using access databases from python References: <3C0672A8.86BD7D43@ecn.purdue.edu> Message-ID: <20011129141842.5d909e5f.gry@ll.mit.edu> On Thu, 29 Nov 2001 12:38:48 -0500 "Christopher N. Deckard" wrote: > Do to M$ Access's inability to correctly export data from its > database, I am searching for other ways to dump an access database > to tab delimited files. I was wondering if there is an access > database python module. Even if it only works on Windows, that's > fine. I just need to get data out of Access to put it into a > Postgres database. > > If something like that doesn't exist, how else can I do it? You might look at: http://sevainc.com/Access/ [description from http://www3.us.postgresql.org/interfaces.html]: Tool to convert from Access97 to PosgtreSQL This web site also describes several issues encountered while upsizing an Access database to PostgreSQL and what was done to work around them. PostgreSQL 7.1 is required for this to work. -- I cannot think why the whole bed of the ocean is not one solid mass of oysters, so prolific they seem. Ah, I am wandering! Strange how the brain controls the brain! -- Sherlock Holmes in "The Dying Detective" From gtalvola at nameconnector.com Thu Nov 1 18:07:15 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Thu, 01 Nov 2001 18:07:15 -0500 Subject: problem with SQL-DMO and win32com (and a workaround) Message-ID: <5.1.0.14.0.20011101175756.03761ec0@infratest1.nameconnector.com> SQL-DMO is a COM library that you use to administer MS SQL Server programmatically. I was happily using the version of SQL-DMO that comes with SQL Server 7.0 with no problems. Now that I upgraded to the SQL-DMO that comes with SQL Server 2000, I get the following error (using Python 2.1 and win32all 139 or 140): >>> from win32com.client import gencache >>> s = gencache.EnsureDispatch('SQLDMO.SQLServer') >>> s.Connect('DBSERVER') >>> s.Databases('MyDatabase') Traceback (most recent call last): File "", line 1, in ? File "win32com\gen_py\10010001-E260-11CF-AE68-00AA004A34D5x0x8x0\Databases.py", line 70, in __call__ if ret is not None: ret = win32com.client.Dispatch(ret, '__call__', '{10020300-E260-11CF-AE68-00AA004A34D5}', UnicodeToString=0) File "win32com\client\__init__.py", line 95, in Dispatch return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, UnicodeToString, clsctx) File "win32com\client\__init__.py", line 35, in __WrapDispatch klass = gencache.GetClassForCLSID(resultCLSID) File "win32com\client\gencache.py", line 131, in GetClassForCLSID mod = GetModuleForCLSID(clsid) File "win32com\client\gencache.py", line 179, in GetModuleForCLSID __import__(sub_mod_name) File "win32com\gen_py\10010001-E260-11CF-AE68-00AA004A34D5x0x8x0\Database.py", line 48, in ? __import__('win32com.gen_py.10010001-E260-11CF-AE68-00AA004A34D5x0x8x0._Database2') File "win32com\gen_py\10010001-E260-11CF-AE68-00AA004A34D5x0x8x0\_Database2.py", line 23, in ? class _Database2(DispatchBaseClass): NameError: name 'DispatchBaseClass' is not defined If I instead use: >>> s = gencache.EnsureDispatch('SQLDMO.SQLServer', 0) it works without errors. So that's the workaround. But it's slower and takes more memory. If anyone (i.e. Mark Hammond :-)) would like to try to track this down, I can zip up and email the broken auto-generated files. Just let me know. -- - Geoff Talvola gtalvola at NameConnector.com From nhodgson at bigpond.net.au Tue Nov 27 21:10:32 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 28 Nov 2001 02:10:32 GMT Subject: C++ debugger for python/scintilla? References: <3C043024.EA1@zeusedit.com> Message-ID: Jussi Jumppanen: > The one problem I found was that for any of the Windows MS-DOS > based system (ie Win 95,98,Me etc) I had to add this method to > the pdb.py before any debug output was displayed. > > # Added new method to flush buffers so Zeus can capture output > def postcmd(self, stop, line): > # flush the output buffers > sys.stdout.flush() > sys.stderr.flush() > return stop Did you know about the -u option for running Python in unbuffered mode? Neil From jeff at ccvcorp.com Wed Nov 7 19:52:49 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 07 Nov 2001 16:52:49 -0800 Subject: Focus problem References: <9sb4bj$smv$1@sunce.iskon.hr> Message-ID: <3BE9D760.ADCB0041@ccvcorp.com> Danijel wrote: > Hi! > Is there a way to track focus change on window/control? I can't find that. I believe that the EVT_KILL_FOCUS() will do what you need--check into the docs on that. Also, since this *is* a wxPython-specific question, you may get a more thorough response if you ask it on the wxPython-users mailing list instead of the main Python list. (You can find the wxPython list through www.wxPython.org) Jeff Shannon Technician/Programmer Credit International From clpy at snakefarm.org Fri Nov 30 09:22:21 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 30 Nov 2001 15:22:21 +0100 Subject: xmlrpc tutorial? References: <3C063569.8230ADD0@snakefarm.org> Message-ID: <3C07961D.9A7970FA@snakefarm.org> Dave Butler wrote: > http://www.onlamp.com/pub/a/python/2000/11/22/xmlrpcclient.html Thanks for the link. The corresponding server documentation is exactly what I was looking for: http://www.onlamp.com/pub/a/python/2001/01/17/xmlrpcserver.html However, there seems to be a problem with restarting the server. I have to wait a minute or so to avoid an 'address is already in use' error. I vaguely remember this has been addressed in the past on c.l.py. Is there any solution? cg. -- For dealing with Matrix you need something more powerful than Python. Otherwise ... Matrix has you! -- scenes from comp.lang.python From chrishbarker at home.net Mon Nov 5 13:02:15 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 05 Nov 2001 10:02:15 -0800 Subject: Problem formatting Python docs with MikTeX References: Message-ID: <3BE6D427.94B85DF5@home.net> Michael Abbott wrote: > Unfortunately, the import of manual.cls shows that I have a serious > problem: the TEXINPUTS path is evidently being searched (by MixTex) in the > wrong order. There is a manual.cls in my Python texinputs directory, but > MikTeX is kindly picking up the version in its own distribution. (Note > that the TEXINPUTS path clearly *is* being successfully searched later on.) > > Ouch! > > Any suggestions on how to proceed? The only hack I can think of is to take > all the files in the Python directory, hunt down any aliases in the MikTeX > directory and destroy or hide them. Not pretty. I don't remember the details, but when I went to build some of the Python docs on my Mac with OzTeX, I just put manual.cls in the same directory as the docs. That way I din't have to mess with TEXINPUTS or anything. Whether this makes sense depends on what you wnat to do. I was only editing the Ma moduels reference at the time. All in all, the whole package works a flawlessly on *nix, so I ended up doing all the work on my Linux box. Good lcuk, -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From tdelaney at avaya.com Wed Nov 7 18:57:28 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 8 Nov 2001 10:57:28 +1100 Subject: Steve Irwin (was: Australian Disco) Message-ID: > From: Fredrik Lundh [mailto:fredrik at pythonware.com] > > Gary Stephenson wrote: > > Umm, I'm not really sure this is a claim we should be > making! Next thing > > you'll have us claiming responsibility for making disco > popular - and then > > they'll just have to shoot us! ;-) > > but Steve Irwin is your fault, right? Actually, much as Steve Irwin is a joke, he's also bloody good at what he does. His over-the-top "Australian" antics are soley for the benefit of his US viewers. I still get a shakey feeling in my stomach when I think of him being tasted by a fierce snake - even knowing that he lived, that really scared me. For those who don't know, the fierce snake is the eastern banded taipan, the most venomous snake in the world. Immediately after hatching, it contains enough venom to kill 100 rats (or was it 100 humans? I forget). An adult human generally has time to walk about 50 metres before death ... Taronga Park Zoo (in Sydney) had a fire in its reptile house a couple of years back, and as a result we lost many of our venom sources for producing anti-venom - including all captive fierce snakes. Steve Irwin went out and captured an entire nest of just-hatched fierce snakes. He made a program about finding the nest, observing the mother, etc - and part of it was him - staying *very* still - while the mother tasted him. That takes cahonies *this big* ... if it had bitten him there is almost zero chance he would be around today, even though I'm sure they had lots of the anti-venom with them. Tim Delaney From uwe at rocksport.de Fri Nov 9 05:55:47 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 9 Nov 2001 10:55:47 GMT Subject: What does *x mean? References: Message-ID: <9sgcnj$9d0s8$1@hades.rz.uni-sb.de> Erann Gat wrote: | I've heard people mention "the new *x syntax". Does Python have a prefix | * operator now? What does it do? (It's not mentioned in the online | language reference at python.org.) Email replies preferred. Thanks! There is just a thread "variable function call" which might help you. Yours, Uwe. -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From nt_colonel at hotmail.com Mon Nov 12 11:04:50 2001 From: nt_colonel at hotmail.com (T Malcolm) Date: 12 Nov 2001 08:04:50 -0800 Subject: WSC in python clears method arguments References: Message-ID: > > Well, see, the COM Component isn't a pure Python module. > > All of my Python is in a Windows Script Component(WSC)...an xml file > > parsed by the ActiveX Scripting engine. Classes are set off with > > tags, and the COM interface is also described > > using XML tags. Since this isn't a proper python class there's no > > "self" first argument on the methods, thus causing half of my > > problems. Everything calls, and it works just great, but it eats the > > values stored in my argument variables. > > Blerch. So are you trying to execute Python client-side with this? > > Let's see some more code! What's the environment? > > regards > Steve I have a pair of VBScripts as a COM Client to this Windows Script Component containing Python (COM Server). The VBScripts are task scheduled on a Win2k machine. The VBS gets COM instances using the regular old Set objWhatever = CreateObject("ProgID") but when you call a method like this: objWhatever.cwd(directory) the variable "directory" which would have held a string (like "/FTP/ouput") before calling holds "" after calling, which in VB terms would be Empty (or vbNullString, if you prefer). Its possible that VBScript could be translating whatever is being return in the arglist (or not, as the case may be) into a string equivalent because it kinda likes to type cast variables after you first use them. The beautiful part of these WSC's is that they're easy to register/unregister and the only thing you have to do to make the typelib is right-click and choose "Generate Type Library" (although it generates a new GUID for the typelib every time you do that). I read somewhere MS invented these WSC's because of security problems with ASP giving up source code(which could give away DB passwords) and ASP developers loathed recompiling and re-registering VB COM components just to debug their code. Here's the whole WSC COM component (ezFTPcomponent.wsc). The tag replaces where you would normally define a python class. Sort of. ---- ---- I appreciate you helping me with this thing. -- Tom From dasitor at hotmail.com Tue Nov 13 10:21:17 2001 From: dasitor at hotmail.com (dasitor at hotmail.com) Date: Tue, 13 Nov 2001 17:21:17 +0200 Subject: Just need some example code... Message-ID: <3BF13A6D.C992005E@hotmail.com> Hi, A year ago I wrote several small programs in Python, and I'm quite satisfied with the results. Now I want to create a GUI integrating all this tools. My idea is to have a floating toolbar in which each button starts a different program. Each application runs in a different window with menus, etc. Several apps can be running at the same time and they can be closed independently. I'm using Windows, but I want it to run also in Linux. I've started the implementation in Tkinter (is this the right choice?), but I don't quite understand the documentation. A simplified example of how to implement such a windows system would be a great help. Thanks in advance. -- DAVID From richardSPAM at geotek.co.uk Thu Nov 29 05:06:37 2001 From: richardSPAM at geotek.co.uk (Richard Chamberlain) Date: Thu, 29 Nov 2001 10:06:37 -0000 Subject: Super-newbie needs help! References: <70c31206.0111280950.7ebe06ae@posting.google.com> <688b0ugij04trlh2aufriqil00nklvje80@4ax.com> Message-ID: "Daniel Klein" wrote in message news:688b0ugij04trlh2aufriqil00nklvje80 at 4ax.com... > Without looking at any of the responses so far, this is what I've come > up with... > > while 1: > try: > sum = int(raw_input("Enter your number: ")) > except ValueError: > print "You did not enter a number!" > else: > if sum < 100: > print "You haven't reached 100 yet! > continue > else: > break > > Hope this helps, > Daniel Klein except you missed out the actually summing. sum=0 while 1: try: sum+=int(raw_input("Enter your number: ")) # or sum=sum+int(raw_input("Enter your number: ")) except ValueError: print "You did not enter a number!" else: if sum < 100: print "You haven't reached 100 yet!" continue else: break Richard From sholden at holdenweb.com Wed Nov 7 09:45:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Nov 2001 09:45:27 -0500 Subject: Exception holes, again. References: <9s6spi$ksk$1@newsreaderm1.core.theplanet.net> Message-ID: "Dale Strickland-Clark" wrote ... > Thanks that looks promising. > > This whole area is still a dogs breakfast, though. > > The fact that I have to spend 2 hours hunting around to find out how > to catch an exception is a nonsense. No, it's an indication that PythonWin's documentation needs improving. The fact that you made this last posting is clearly an indication that you are pissed off about it. Just remember all the *good* things you've got from Python ;-) smile-and-the-world-smiles-with-you-ly y'rs - steve -- http://www.holdenweb.com/ From loewis at informatik.hu-berlin.de Tue Nov 20 09:25:48 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Nov 2001 15:25:48 +0100 Subject: Python to compile to Java-bytecode References: <61f6bfa8.0111200558.2f52ad44@posting.google.com> Message-ID: gaya at infomail.lacaixa.es (Toni Gaya) writes: > There is any project that allows compile a Python program to Java > bytecode, as py2exe does compiling a python program to a .exe? Jython does that. Regards, Martin From garrett at bgb.cc Tue Nov 13 19:31:14 2001 From: garrett at bgb.cc (Don Garrett) Date: Wed, 14 Nov 2001 00:31:14 GMT Subject: Non-obvious name bindings References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> Message-ID: <3BF1BB43.6B4E667B@bgb.cc> Actually, I would argue that the 'e' in the for loop should be temporary as well. I might also argue that these temporary variables shouldn't be assignable inside the body of the loop. However, I don't personally consider this a major issue, just a matter of personnal preference. Emile van Sebille wrote: > > ----- Original Message ----- > From: "Kerim Borchaev" > Newsgroups: comp.lang.python > Sent: Monday, November 05, 2001 4:49 AM > Subject: Non-obvious name bindings > > > Hello! > > > > It seemed that it was my failure of understanding python but the > > fact that introducing variable in list comprehension binds it to > > functions scope(as every declaration means to?) is not really > > obvious. > > > > I mean this: > > > > >>> [e for e in ['exists']] > > ['exists'] > > >>> e > > 'exists' > > > > And I'm still confused - those "temporary" variables declaration > > looks so "innocent", and in most cases (in every case for list > > comprehensions I guess?) it's everyones intension not to use this > > variable somewhere outside the loop. > > > > What are your thoughts? > > If you look at the structure as shorthand for a for loop and list.append it > may make more sense: > > >>> [e for e in 'exists'] > ['e', 'x', 'i', 's', 't', 's'] > >>> e > 's' > > >>> for e in 'exists': > print e, > e x i s t s > >>> e > 's' > > HTH, > > Emile van Sebille > emile at fenx.com > > --------- -- Don Garrett http://www.bgb-consulting.com/garrett/ BGB Consulting dgarrett at acm.org From sholden at holdenweb.com Tue Nov 13 07:59:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 07:59:59 -0500 Subject: Teaching python (programming) to children References: <200111101633.fAAGXPua010988@ratthing-b246.strakt.com> Message-ID: <%L8I7.9670$vQ1.365978@atlpnn01.usenetserver.com> "Cliff Wells" wrote in message news:mailman.1005596777.32500.python-list at python.org... > On Saturday 10 November 2001 08:33, Laura Creighton wrote: > > > > > I have a problem. I can't pick the _students_ that come into my > > classroom. And wherever I have come across a student that learned > > calculus from the graphing-calculator school, I have found somebody > > who does not understand, really understand, what 'this function is > > increasing' _means_. They are incapable of doing their own visualization > > of that. Fortunately for me, I don't run into these people that often. > > But they are crippled, so much that it shows. It is evident in trying > > to have the simplest of conversations with them. They have little or > > no mathematical intuition at all. > [ ... ] > I have serious doubts about programs designed by fiat. The problem hasn't > been solved, it's simply been taken out of the hands of the teachers and put > into the hands of a committee composed of... well, quite possibly mediocre > teachers. So now we will be enforcing a curriculum designed by mediocre > teachers onto brilliant teachers. Not so good. I agree that something needs > to be done, but I think perhaps it should be done at the time of hiring > teachers rather than trying to fix them after they've been hired. > > Think about this: if such a curriculum could be designed that it wouldn't > matter if the teacher were excellent or mediocre, why couldn't that > curriculum be issued as a software program that the students could follow > without a teacher? Doesn't seem likely, does it? No curriculum will ever > replace the need for good teachers, and no curriculum will ever make a poor > teacher into a good one. > Richard Feynman's notes on the choice of high-school physics texts, were extremely revealing. I fear they still reflect the majority of educational design, in which the material isn't even sensibly considered by many of the participants, who are unequipped to do so by training or (dis)inclination. loved-chemistry-until-i-got-a-bad-teacher-ly y'rs - steve -- http://www.holdenweb.com/ From amitabh_jain at yahoo.com Sat Nov 17 01:03:13 2001 From: amitabh_jain at yahoo.com (Amitabh) Date: 16 Nov 2001 22:03:13 -0800 Subject: Obfuscator for Python? References: Message-ID: Thx folks fr all the replies. These are v useful. Cheers Amitabh From sholden at holdenweb.com Thu Nov 29 15:35:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 15:35:13 -0500 Subject: message returned by poplib to email.Messge instance References: Message-ID: <018701c17915$59e8fd00$6f01a8c0@holdenweb.com> Aaron: Sorry I was off the beam. I'm not using 2.2 or email yet. Because I suspected you might be right about the dashes, I took a look at a MIME-compliant email with an attachment, which I know to be correctly displayed in Outlook Express and Netscape Navigator, and therefore complies with standards ... Crap! it looks like those dashes belong in there, though I never remember seeing them before! And there's a final set following the last terminator. Perhaps I need to read the RFCs again... The real problem appears to be after the "To:" header. The Unix-style "From" line appears after a blank line, which according to RFC 822 (and, presumably, 2822) terminates the headers. Which means that there is no Content-Type header, and therefore no boundary. Maybe this is a bug in the library, I dunno. Or maybe it's just that the header invalidly includes a blank line. regards Steve -- http://www.holdenweb.com/ ----- Original Message ----- From: "Aaron Sterling" Newsgroups: comp.lang.python To: "Steve Holden" Sent: Thursday, November 29, 2001 3:12 PM Subject: Re: message returned by poplib to email.Messge instance > >It's possibly as simple as the ommission of carriage returns? Offhand I > >don't remember for sure, but I suspect that missing CR's can cause problems. > >Here's an example I use in "Python Web Programming" - it uses a StringIO to> > >stringify the message, but apart form that it's probably not too different > >from your code (cStringIO would be faster...): > [snip] > > Thanks for the reply, and I don't mean to be picky, but that's not what I need :-). even with '\r\n'.join(lines), I am still > getting the same problem. I am able to read the message fine. The problem is that the factory function, > message_from_string in the email package does not return an object tree that is indicative of the messages multipart > nature. What I am working on is a program similiar to CVS, but distributed so that you do not need a central > repository or server on the internet. It works by sending updates through a pipe over the internet. The nature of this > pipe is irrelevent, but for starters I am using email. I have defined a module, mail, with two function: > > make_mail_update(update_list): > """returns a mime message with two attachements. the update objects are pickled in 0. The authorization > is in 1""" > > read_mail_update(update_list): > """authenticate the update and then return the unpickled update object""" > > although it refers to an update object, it can be any object > > >>> import mail > >>> test = mail.update_make_mail([0, 1, 2, 3 ,4]) > >>> mail.read_mail_update(test) > [0, 1, 2, 3, 4] > > I need the mime capabilities of the email package, and i need the message to be recognized as multipart. I extract > the relevent information in read_mail_update(message) using: > > pickled_update = messgage.get_payload(0).get_payload().strip() > > This works fine as long as i dont send it over the network. When I do, the get_payload method of the message > object acts as if it is not a multipart message. Even doing it straight from the interpreter, using no logic associated > with my program, I get the same problem: > > Python 2.2b2 (#26, Nov 16 2001, 11:44:11) [MSC 32 bit (Intel)] on win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> import poplib > >>> import email > >>> pop = poplib.POP3('pop.hotpop.com') > >>> pop.user('dhaaron') > '+OK' > >>> pop.pass_('JHGF)(*&') > '+OK' > >>> pop.stat() > (2, 2350) > >>> message = pop.retr(1) > >>> pop.quit() > '+OK' > >>> junk, lines, junk = message > >>> i = 0 > >>> for line in lines: > print i, line > i += 1 > > > 0 Received: from smtp10.atl.mindspring.net (smtp10.atl.mindspring.net [207.69.200.246]) > 1 by mx2.hotpop.com (Postfix) with ESMTP id 2147E178035 > 2 for ; Thu, 29 Nov 2001 18:51:28 +0000 (UTC) > 3 Received: from user-2ivf29o.dialup.mindspring.com ([165.247.137.56]) > 4 by smtp10.atl.mindspring.net with esmtp (Exim 3.33 #1) > 5 id 169WHQ-000264-00 > 6 for dhaaron at hotpop.com; Thu, 29 Nov 2001 13:51:28 -0500 > 7 Message-Id: > 8 From: dhaaron at hotpop.com > 9 Date: Thu, 29 Nov 2001 13:51:28 -0500 > 10 To: undisclosed-recipients:; > 11 > 12 From nobody Thu Nov 29 13:51:20 2001 > 13 Content-Type: multipart/mixed; boundary="===============69927062638266468==" > 14 MIME-Version: 1.0 > 15 Subject: DDES updates > 16 From: > 17 To: > 18 > 19 --===============69927062638266468== > 20 Content-Type: text/plain; charset="us-ascii" > 21 MIME-Version: 1.0 > 22 Content-Transfer-Encoding: 7bit > 23 > 24 (lp0 > 25 I1 > 26 aI2 > 27 aI3 > 28 aI4 > 29 a. > 30 > 31 --===============69927062638266468== > 32 Content-Type: text/plain; charset="us-ascii" > 33 MIME-Version: 1.0 > 34 Content-Transfer-Encoding: 7bit > 35 > 36 authentification not yet implemented > 37 > 38 --===============69927062638266468==-- > >>> mime_message = email.message_from_string('\r\n'.join(lines)) > >>> mime_message.is_multipart() > 0 > >>> > > > as you can clearly see, It is a multi part message. The one thing I can think of is the definition of the boundary in line > 13. this does not match exactly lines 19, 31, 38. Is this complient with the mime standard? > > > > From tim.one at home.com Sat Nov 17 15:09:38 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Nov 2001 15:09:38 -0500 Subject: enhancing dictionary update method and the dict type constructor In-Reply-To: <3BF6AF04.5000209@post.harvard.edu> Message-ID: [Alexis Layton] > This message proposes two minor enhancements. Since I've missed the > feature freeze for Python 2.2, this would be for the next version. > > The first enhacement improves the definition of the dictionary "update" > method, the second enhancement broadens the dictionary type constructor. > > In Python 2.2, the new dictionary type factory function "dict" > (previously known as "dictionary" in 2.2b1) takes either a mapping > object or a sequence of key, value pairs as its argument. > > I would like to propose that the dictionary method "update" be broadened > to take a similar argument type. Sorry, Guido already rejected this idea (proposed by me) in a PythonLabs mtg a few weeks ago. Your hypothetical adict.update(pairs) can be spelled adict.update(dict(pairs)) in 2.2. I agree with the rejection: it's marginally cool for the factory constructor to convert from different representations, but there was no intent that sequence-of-pairs be a generally accepted alternative representation for dicts (kinda similarly, 24 + int("42") works but not 24 + "42" -- Python is conservative about magical conversions). > In addition, I believe it would be generally useful if the sequence > form allowed singleton sequences to represent keys that should be > omitted from the dictionary, thus: > > d = {'a': 1, 'b': 2} > d.update([('a',), ('b', 0), ('c', 3)]) > print d > {'c': 3, 'b': 0} Since d.update(pairs) is dead on arrival, enhancements to it probably don't stand a better chance . I especially squirm at this one, since, e.g., it would mean that d.update("oops") deletes the keys "o", "p" and "s" from d ("oops" is a sequence of 1-sequences), and that's way too obscure. > I propose that non-existant keys specified in such an update sequence be > silently ignored. > > Given such an expansion of update, it seems to me the more useful > constructor for dictionaries would be something more akin to: > > def dict(*mss): > d = { } > for map_or_sequence in mss: > d.update(map_or_sequence) > return d > > This permits several useful idioms, such as the common case in > environment binding where a dictionary represents a symbol table and one > must construct a subsidiary dictionary in which one binding has changed: > > d2 = dict(d, ('v', 3)) d2 = d.copy() d['v'] = 3 > It also permits the "union" of two or more dictionaries: dict(d1, d2). d = d1.copy() d.update(d2) > ASIDE: what is the proper term for this, since keys in d2 can override > those in d1? "update", as in d.update(). The Python C API is a little richer: PyDict_Update actually calls PyDict_Merge with an "override" flag; PyDict_Merge can be told to let the keys of either input dict "win". > Finally, for years I've had a little utility function (called "dict" by > the way) which constructs dictionaries in which all the keys are > identifiers anyway using the keyword syntax: > > def dict(**kw): return kw > > The reason is mostly to pre-load certain stupid little look-up tables > using a more convenient syntax: dict(a=1, b=2, c=3), etc. Yes, it's a pleasant technique. The good news is that, except for the name, it's not being taken away. > The type constructor could also have a **kw behavior which is the final > update into the new dictionary, as if dict was defined to be: > > def dict(*mss, **kw): > d = { } > for ms in mss: > d.update(ms) > d.update(kw) > return d At this point I would despair of explaining what the dict() function does, and it's not our goal to build in all possible 3-line functions . There have been about a dozen other ideas for extending the dict() function too; adding sequence-of-pairs was our best stab at implementing the most useful one; most others appear to have an audience of one. From syver-en at online.no Thu Nov 29 13:31:54 2001 From: syver-en at online.no (Syver Enstad) Date: 29 Nov 2001 19:31:54 +0100 Subject: using access databases from python References: <3C0672A8.86BD7D43@ecn.purdue.edu> Message-ID: "Christopher N. Deckard" writes: Download the win32extensions from www.activestate.com then you can access Access via com (dao or ado). You can also access via ODBC, there are several ODBC modules around, I think mxODBC is regarded as being the best. > Do to M$ Access's inability to correctly export data from its > database, I am searching for other ways to dump an access database > to tab delimited files. I was wondering if there is an access > database python module. Even if it only works on Windows, that's > fine. I just need to get data out of Access to put it into a > Postgres database. -- Vennlig hilsen Syver Enstad From s.schwarzer at ndh.net Thu Nov 29 18:10:58 2001 From: s.schwarzer at ndh.net (Stefan Schwarzer) Date: Fri, 30 Nov 2001 00:10:58 +0100 Subject: connecting from Windows client to Informix server References: <3C028F05.1B09E208@ics.muni.cz> Message-ID: <3C06C082.3CBD1E11@ndh.net> Hello Ondrej, Ondrej Krajicek wrote: > I know that there are several modules which implement > informix connectivity. Is there anyone > who uses them on Windows box (Windows client, > Solaris server) ? Does it work ? Does it work well ? > Which informix module is the right choice ? we use informixdb 1.3 from http://starship.python.net/crew/sturner/informixdb.html It's DB API 1.0 compliant (not 2.0, though). Which version of the Informix server do you use? The version mentioned above will fail on LVARCHARs and LOBs, if I remember correctly. In this case I could look for an adapted version we have here. Stefan From pinard at iro.umontreal.ca Sat Nov 24 11:18:32 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 24 Nov 2001 11:18:32 -0500 Subject: Keeping Python loaded In-Reply-To: <9tndpi$qbe$1@slb0.atl.mindspring.net> References: <9tndpi$qbe$1@slb0.atl.mindspring.net> Message-ID: [Matt Gerrans] > Is there some existing facility for keeping Python running in memory at > all times, If you merely want to spare disk acceses under Unix, a possible approach might be to set the sticky bit on the Python executable. You might need to be super-user to do that: chmod 1755 /usr/bin/python On the other hand, on Linux at least, the disk cache maintained by the system might be helpful to the point of not even having to resort to the above trick. However, if you want to spare the CPU needed for Python initialisation and such, the above does not help, you need more specialised solutions. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From hartanto at telusplanet.net Thu Nov 8 19:07:22 2001 From: hartanto at telusplanet.net (harry) Date: Fri, 09 Nov 2001 00:07:22 GMT Subject: data size Message-ID: <_6FG7.33159$i4.5175661@news0.telusplanet.net> if you put data into dictionary, how do we calculate the data size? key:data example: dict = {"key1":1,2,3,4; "key2": "hello", [1,2,3]} how much is the data structure will cost? how to calculate it? if in c++ : char array1[8] will cost 8 x 8 bytes = 64 bytes From James_Althoff at i2.com Wed Nov 28 20:45:27 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 17:45:27 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: David Eppstein wrote: >I would rather view a for-loop as > "for" expression: >where (currently) the expression must have as its top level operation the >"in" operation and the lhs must be a variable. The variable is set in all >possible ways that make the expression true. From this point of view, "for >x in 5" looks really ugly, and "for 0 <= x < 5" makes a lot more sense: we >now simply allow one more kind of expression in a for loop, one where the >top level is a three-way comparison and the middle side of the comparison >must be a variable. I would have guessed, though, that given the current direction of Python vis-a-vis iterators that for 0 <= x < 5: would have to mean something like "0 <= x < 5" is special syntax built into the for-loop statement that generates an iterator that enumerates the integers 0,1,2,3,4. It happens to look just like an expression which *outside* the context of a for-loop evaluates to 0 or 1 instead of producing an iterator (as was pointed out previously by Peter Hansen). Jim From fdrake at acm.org Sun Nov 18 00:10:58 2001 From: fdrake at acm.org (Fred L. Drake) Date: Sun, 18 Nov 2001 00:10:58 -0500 (EST) Subject: [development doc updates] Message-ID: <20011118051058.E6F6328697@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Update to docs beyond Python 2.2 beta 2: Clarified a couple of points in the SAX API descriptions for startElement() and startElementNS(). Better description of gc.garbage value (gc module). Cleaned up & slightly modernized some sample code in the Python/C API and Extending & Embedding manuals. From peter at engcorp.com Sat Nov 17 12:34:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 17 Nov 2001 12:34:51 -0500 Subject: Question to those who know both Java & Python pretty well... References: <2a6e94ef.0111170759.5fe7027a@posting.google.com> Message-ID: <3BF69FBB.9C329E0F@engcorp.com> Spendius wrote: > > I don't know Python AT ALL, and am a beginner in Java, but > I happened to fall on articles and/or web pages that made > me considering starting working with Python. Does this language > have some specific purposes (like file processing, web etc.) ? > Are its graphical capabilities as rich and various as Java's ? I suggest you start with http://www.google.com/search?q=comparison+java+python or http://www.google.com/search?q=comparing+java+python and come back and ask a few more questions once you've done a little preliminary research. > I'm expecting serious answers, please... Thanks a lot ! Why do you think you'd get any others? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From duncan at NOSPAMrcp.co.uk Thu Nov 8 04:16:17 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Thu, 8 Nov 2001 09:16:17 +0000 (UTC) Subject: Returning a python value to the calling bat file References: Message-ID: "Jeff Schroeder" wrote in news:zTdG7.174$ZE3.29961 at paloalto-snr1.gtei.net: > I have a NT Shell bat file that calls a python script to do some > processing, then want that python to return the value to the calling > bat file. How do I do that? > > Thanks in advance, > Jeff > > sys.exit(n) sets errorlevel to n, where n is an integer. If you want to return strings then read up on the /F option of the FOR command or (better) convert the rest of the batch file into Python as well. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From wade at lightlink.com Mon Nov 26 19:12:47 2001 From: wade at lightlink.com (Wade Leftwich) Date: 26 Nov 2001 16:12:47 -0800 Subject: Zope database vs. MySQL References: Message-ID: <5b4785ee.0111261612.4db78cb4@posting.google.com> Mitch -- I use Zope and MSSQL together, and they make an excellent team. Code, formatting and configuration info live in the ZODB, and data in SQL. If your data is mostly tabular, imported from hte outside world, this works well. On the other hand, if the data is more document oriented, then the ODB is a better place for it. Wade Leftwich Ithaca, NY "Mich Hiker" wrote in message news:... > I'm a new Zope user - developing web-based curriculum materials for a school > district. Can anyone tell me the advantages of configuring MySQL to use in > tandem with Zope over using Zope's built-in database? I've heard Zope is > faster using it's own DB, but others have told me it is limited and I should > go with MySQL. Any thoughts? > > Thanks. From niemeyer at conectiva.com Wed Nov 21 11:34:29 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Wed, 21 Nov 2001 14:34:29 -0200 Subject: Python execution speed In-Reply-To: <15353.48507.707597.713284@beluga.mojam.com> References: <3BF9AF6B.6329BDF5@engcorp.com> <15353.48507.707597.713284@beluga.mojam.com> Message-ID: <20011121143429.B2559@ibook.distro.conectiva> > I think the general interest in "compiled Python" can be summed up in two > statements: > > * It would allow Python programmers have their cake and eat it too > (higher-level programming and (near) compiled language speed). > > * "More is never enough." (I credit this statement to Bob Saltzman, a > long-time sysadmin type guy I knew in my days at GE. I have no idea > where Bob got it.) [...] Good points. When we talk about speed in programming languages, it won't ever be enough. If you have a very complex algorithm, you will benefit a lot from speed improvements. If you have a simple algorithm, you'll benefit a little bit. But we must understand that, if you improve an interpreter's speed, everyone developing or using code in that language will benefit from that without any efforts, and that means spare cpu for other tasks. -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From max at alcyone.com Fri Nov 23 14:39:46 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Nov 2001 11:39:46 -0800 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <3BFC0365.21FB6AA1@alcyone.com> <9tm7go$atu$1@newshost.accu.uu.nl> Message-ID: <3BFEA602.FEF2FC2C@alcyone.com> Martijn Faassen wrote: > Cool; I've recently been thinking about that. Any results, info, etc, > you > have on your experiments? They look to be at least as good as using LISP as the genetic language as in Koza's work. How you repopulate the population each generation can get tricky, however; a wholesale approach can lead to diversity problems. A stabilizing approach is during the fitness tests to randomly select two programs, evaluate their fitness (perhaps by trial against each other), then perform crossover and mutation and replace the less fit program with their offspring (and doing this n times in a population size of n you call a generation). Even though this seems strange at first, it's really necessary since diversity problems (where many of the programs start resembling each other) can lead to a degenerate case where more and more resemble each other with small defects; after a few generations programs start looking like stutterers (a bunch of programs that look like A B C D E will result in programs that might look like A B B B D C C D D C D D E ...). There's a paper called "Stack-based genetic programming" by Perkis I could send you (via email) if you're interested. > I've worked with a simple virtual machine designed to the same > constraints too (every sequence of instructions is a legal program), > but this VM didn't have a stack *or* a set of registers; instead there > were some instructions to move read/insert/delete heads onto their > own instruction set. This allowed me to write an ancestor replicator > would > copy itself. That's different from genetic programming though, moving > more towards artificial life. I also have another artificial life system that involves a virtual machine language as well, although it has a full instruction set, registers including some shared registers, the ability for processes to fork into new ones, always-legal instructions (well, illegal instructions set an exception register, but they don't halt the process), indirection, and an assembler with labels support (!). The two systems are called Qu and Jupiter, respectively, by the way; I've been planning on releasing them publicly for quite some time but haven't quite had the energy to package them up. Maybe someone with sufficient interest in playing could light a fire under my butt. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From not.this at seebelow.org Mon Nov 5 00:29:35 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sun, 04 Nov 2001 23:29:35 -0600 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> Message-ID: <3BE623BF.9F4EA0F2@seebelow.org> Jive Dadson wrote: ... > Other languages have started life with the feature that the first > occurrence of an identifier defines it. ... > Visual Basic (and perhaps other Basics, so far as I know) implement a > way to have your cake and yet not spoil the old cake. Perl has an option like this. However, I like the way Python does it better. In Perl, you can use an unitialized variable (unless you disallow that via the option). Then, unitialized variables get automatically initialized to sensible "zero" or "empty" values on first use. Whenever I used the auto-initialize thing, I regretted it. However, I found the declaritive form to be awkward. Python's system is basically "you must write to a variable before you can read it". This has the net effect of catching the kind of error you refer to, in nearly all cases--and I haven't had a significant problem with the cases that can get missed. Therefore, this simple but powerful idea gives you nearly all of the benefit of variable declarations, yet none of the baggage. Also, to do automatic zeroing of undeclared variables, Perl has to use special punctuation as a back-door way of declaring the type of the variable. Then, you have to carry along this punctuation as you _use_ the variable. Again, I like Python's approach better. Since there is no automatic declaration, the types of variables are specified when you assign to them: x = 1 # x is an integer x = 1.0 # x is a float x = [] # x is a list x = {} # x is a dictionary print y # oops!--"y" hasn't been assigned (declared) yet wish-I'd-thought-of-that-ly y'rs, =g2 -- _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From virus_catcher at oceanic.com Wed Nov 28 13:37:08 2001 From: virus_catcher at oceanic.com (virus_catcher at oceanic.com) Date: Wed, 28 Nov 2001 08:37:08 -1000 Subject: InterScan NT Alert Message-ID: Receiver, AntiVirus Catcher has detected virus(es) in the e-mail attachment. The Sender has been notified. Date: Wed, 28 Nov 2001 08:37:08 -1000 Method: Mail From: <_p.aiale at bcc.tin.it> To: File: YOU_are_FAT!.MP3.scr Action: clean failed - deleted Virus: WORM_BADTRANS.B From aaldv97 at student.remove-this-part.vxu.se Tue Nov 13 08:53:37 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Tue, 13 Nov 2001 14:53:37 +0100 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> <9sp073$k6d$1@news.lth.se> <9sq30e$4hp$1@slb1.atl.mindspring.net> Message-ID: <9sr8np$771$1@news.lth.se> > When I started programming I didn't know how the hardware worked. > Nearly 20 years later, I still don't know. Frankly, I know just > enough to say things like "dopants", "Fermi surface" and "binary > logic gate" then handwave up to the C view of the system. And that's great, however, when I was teaching the 4:th graders they constantly asked me on how computers worked, so I showed the everything from the ALU of the CPU up to operatingsystem interrupts with the MC68k as a base, naturally. I'd say 85% of the 10 year olds got a pretty good idea on the subject because they hardly ever asked and I heard them explain to students in other classes, which was cool. > I tried learning the peek/pokes people used for performance and > gave up because it didn't make sense to me. I've written perhaps > 500 lines of assembly in my life. I imagine it's hard to go from Python to any other language because it's easy to become lazy, even I've become lazy. > I still use dictionaries, heavily. For commentary, see > > http://aspn.activestate.com/ASPN/Mail/Message/python-Tutor/538598 Ordinary hashtables are bad in worst case, i.e. no better than simple lists, I normally design datastructures for a specific problem, though in all fairness I once used Python to implement a DMBS when I first learned Python. > I taught myself programming. I learned with BASIC, which effectively > had two data types: number and text. I didn't know the difference > between an integer and a real (they're just numbers, right)? Eg, I > recall wondering why I couldn't stick things into an array at position > arr(1.2) -- why was that the same as arr(1)? That's why BNF is so nice :) > This from a person whose first non-trivial code was a program to > compute gcd and lcm. It wasn't until I was 16 when I started using > QBASIC where I could specify data types, and I did so only *after* > I wrote the code and wanted the performance. > > Ada, as I recall, doesn't have that flexibility. So I figure it > would have been that much harder for me to figure things out. True, but there are nice packages for Ada which solve this with OO. > Part of my job now is getting research scientists to figure out > that programming is fun. These are people usually with a PhD in > chemistry, physics or biology who have had a bit of C or FORTRAN > training and on-the-job learning of shell programming. I've > seen them learning different languages (C, C++, Tcl, Perl, Python, > and a slew of domain specific languages). Of those, Tcl and Python > make the most sense to them. Things like the interactive mode, > strong dynamic typing, exceptions, gc, readability, and a practical > view of the world make things easy enough for them. Of those, > Python is the only one that programmers also enjoy. So I code > in Python. > > I can't imagine teaching them Ada. I've read through an Ada > primer. It didn't give me anywhere near the joy that reading the > Python tutorial gave me. The Python tutorial is nice, but I don't think it's fair to compare them as they are intended for different audiences. > Though 'tis true, they aren't children, so I've strayed off topic. > I can't imagine learning Ada on my own in 7th grade. I could > have done Python, except I would have needed a better editor than > Python's current text version. BASIC with line numbers > makes it possible to edit a single line of code. I believe Python is a better choice than BASIC, though VB and BB are pretty good for being BASIC. > Not sure about the current IDEs either. I heard one talk where > the presenter chose Tcl (withone of the object extensions) over > Python because it was easier for her coworkers to change a single > method interactively, rather than having to reload the whole > module, with all the trickiness that entails. There is no absolute truth about what language to choose; I'd pick Ada, you pick BASIC, and someone else would pick Logo. The important thing is to get the student to code, without ever writing code it doesn't matter what language one uses. From philh at comuno.freeserve.co.uk Mon Nov 26 14:15:39 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 26 Nov 2001 19:15:39 +0000 Subject: Non-Indented python References: Message-ID: On 26 Nov 2001 13:20:35 -0500, David Bolen wrote: >philh at comuno.freeserve.co.uk (phil hunt) writes: > >> On 22 Nov 2001 00:25:28 -0500, David Bolen wrote: >> >Chris Liechti writes: >> > >> >> tabs are specified as 8 characters. only programmers that use tabs to >> >> indent make them 4 or 3 characters... >> > >> >Well, you have to be a little careful how you phrase this. I'm not >> >aware of any global document or specification that actually makes a >> >pronouncement that tabs are 8 characters >> >> I am aware of one such document. It's called the "Python Reference >> Manual": > >That only specifies how the Python parser treats tabs, not a global >definition that covers more than Python. It's pretty damn global as far as the Python language goes!! Consider which ng you are having this discussion on. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From lac at strakt.com Mon Nov 19 05:59:23 2001 From: lac at strakt.com (Laura Creighton) Date: Mon, 19 Nov 2001 11:59:23 +0100 Subject: ssl error In-Reply-To: Message from Reid Nichol of "Sun, 18 Nov 2001 01:38:47 CST." <%yJJ7.1850$7b2.60534@news1.mts.net> References: <%yJJ7.1850$7b2.60534@news1.mts.net> Message-ID: <200111191059.fAJAxNua025644@ratthing-b246.strakt.com> > Reid Nichol > Gerhard H?ring wrote: > > > On Sat, Nov 17, 2001 at 01:40:22PM -0600, Reid Nichol wrote: > >> I got a client/server app that I am triing to build and am having > >> problems. > >> [snip] > > > > The Python builtin SSL doesn't support servers, but only SSL clients. > > > > On my homepage (see sig), you can find a short, unfinished overview of > the > > available alternatives. Use the "Python/SSL" link. I'd probably go for > > M2Crypto. > > > > HTH, > > > > Gerhard > > Do you know if there is any plans to fix this issue? > > ----- > If you truly love the memory, you must set it free()! > We've got a working version. You can have our code if you like. You too Gerhard H?ring, if you like. Goodness gracious, a discussion about this on python-devel. We're all too damn busy writing code to be an advocate for our own code, and besides, somebody may have done it better. Would it be possible to give our code to somebody competant who can make sure that we either get to be the new standard (unlikely but possible) or any good ideas we came up with that nobody else has makes it into the new standard? I've already got enough work for 3 whole lifetimes, as does everybody else around here, but if the idea of handing this to somebody does not fly, on the 'defend your own code, idiot' protocol, _somebody_ from around here will have to. And the man who wrote most of this was a summer intern, and is supposed to be being a student now. Laura Creighton From skip at pobox.com Thu Nov 1 14:08:13 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 13:08:13 -0600 Subject: Problems with dbhash in Python-2.1? In-Reply-To: <9rs60o$b0n$1@panix2.panix.com> References: <9rs60o$b0n$1@panix2.panix.com> Message-ID: <15329.40349.581138.259916@beluga.mojam.com> Roy> I've got an application written in Python-2.0, which used the Roy> dbhash module.... The solaris guy reports the following stack Roy> trace: ... Roy> ImportError: No module named bsddb Roy> The Debian guy got some other strange error involving bsddb (which Roy> unfortunately I didn't save, because when he down-graded to 2.0 the Roy> problem went away). My guess would be the Python 2.1 distutils couldn't find the include files needed to build bsddb. You may have to install Berkeley DB or twiddle the Modules/Setup file to point make to the correct include files and libraries. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From db3l at fitlinxx.com Wed Nov 28 18:15:15 2001 From: db3l at fitlinxx.com (David Bolen) Date: 28 Nov 2001 18:15:15 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin writes: > CVS is a layer over RCS that lets multiple people work on the same > files at the same time, and automatically merges their changes at > check-in. I don't see any point to it for a one person project. RCS > is a lot simpler. I use RCS for one-person projects and couldn't live > without it. But I haven't found a reason to deal with the increased > complexity of CVS. Is there one? Actually, CVS hasn't really been a layer above RCS for some time now, although it did start that way. The file formats are compatible, but CVS has internal routines for handling I/O to them nowadays. And yes, I routinely stick with CVS for all my personal projects as well. The automatic recursion and manipulation of full project directories are much more efficient than trying to do it with RCS as soon as you get above one or two files. It's also more convenient to have a single repository for all my personal work rather than RCS subdirectories strewn around the filesystem, or individual ",v" files within source directories. I may sometimes do direct ci/co with RCS if I'm truly working on a single standlone file, but generally even then I just create a new CVS directory to work from. -- -- 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 tjreedy at home.com Sun Nov 11 02:16:41 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 11 Nov 2001 07:16:41 GMT Subject: Splitting on a regex w/o consuming delimiter References: Message-ID: "Lars Kellogg-Stedman" wrote in message news:slrn9us6kv.3id.lars at flowers.house.larsshack.org... > Given a string such as: > > sample = 'one two @three @four five @six' > > I want to split it on the '@' character, but I want the '@' character to be > retained in each sequence. That is, I'd like the above string split into: > > one two > @three > @four five > @six You could do '@'.split(sample)' (which deletes at) and then add back to all but first. Terry J. Reedy From philh at comuno.freeserve.co.uk Thu Nov 29 17:45:24 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 29 Nov 2001 22:45:24 +0000 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> <8ef9bea6.0111291148.1c5d4fa@posting.google.com> Message-ID: On 29 Nov 2001 16:56:09 -0500, David Bolen wrote: > >I don't know how much to expect over time - CVS has been around quite >a while (at least 10+ years) and I'd guess is unlikely to undergo >major shifts quickly at this point, but perhaps I'm wrong. CVS itself probably won't. GUI and web front ends probably will. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From max at alcyone.com Thu Nov 15 15:41:46 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 15 Nov 2001 12:41:46 -0800 Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> Message-ID: <3BF4288A.FC68121F@alcyone.com> Peter Bismuti wrote: > I want to pass a function as an argument but don't want to have to > define it > globally. > I think the proper terminology for this is "anonymous". > > The way I *don't* want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) ... > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? Yes. Python has lambda functions for this, although there are some restrictions: lambda functions have to take at least one argument (otherwise what's the point), and they can only evaluate to expressions, rather than whole statements. >>> map(lambda x: 2*x, range(10)) [0, 2, 4, 6, 8, 10, 12, 14, 16, 18] -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From hartanto at telusplanet.net Wed Nov 7 05:22:45 2001 From: hartanto at telusplanet.net (harry) Date: Wed, 07 Nov 2001 10:22:45 GMT Subject: integer to ascii Message-ID: >>rows = 2 >>columns = 3 >>joined = rows + columns >>joined 5 instead of '5' as the output, how do i make the output as '23' -> string concatnation instead of integer. thanks. From tim at bladerman.com Thu Nov 1 07:45:51 2001 From: tim at bladerman.com (Tim Gahnström /Bladerman) Date: Thu, 01 Nov 2001 12:45:51 GMT Subject: starting externel program (win32) References: <3be121cb.89811609@news.easynews.net> Message-ID: <3ubE7.3791$Z_1.667483@newsc.telia.net> "Marcus Stojek" skrev i meddelandet > from a script I want to start an external program (win32). This should > be done in a way that is equivalent to typing the name and options at > the dos prompt. The program must not be influenced by exiting the > script. > Do I have to use system(), spawnv() or spawnve() or something else? The simplest is to use os.spawnv(os.P_NOWAIT,"notepad.exe",[]) This will start notepad.exe and return the pid of the process while ypour script keeps running. os.spawnv(os.P_WAIT,"notepad.exe",[]) Will wait wile notepad run, when notepad is closed it will return the exitcode (usually 0) Look in the os.py for more dokumentation of the variants, ithe doc there is pretty good I think. Tim From wtanksle at dolphin.openprojects.net Fri Nov 16 18:59:09 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 16 Nov 2001 23:59:09 GMT Subject: Recap: PEP 276 Simple Iterator for ints References: Message-ID: On Fri, 16 Nov 2001 14:46:51 -0800, James_Althoff at i2.com wrote: >It seems to me that, given the need (or desire) for both a list constructor >and an iterator, you either provide both -- and add extra >ugliness/complexity to your syntax and/or calling conventions in the >process (the "x" in "xrange", for example) -- or you provide the iterator >in convenient form and the list constructor in less convenient form (as you >propose by using the list function on the return of an iterator from a >slice on integers). Or you don't provide the iterator at all and don't >worry about big lists. My comment was put in to encourage folks to take >this tradeoff into account when detailing similar proposals. It isn't even a tradeoff. You can provide both __getitem__ and __iter__, and you're set. Providing __getitem__ doesn't mean you're a list or tuple; it just means you're a sequence. If you do that the way range() has in the past, you're an idiot. There's absolutely no reason to store all the integers in a range which you could instead store start,stop,and step, and generate them as needed. >Jim -- -William "Billy" Tanksley From mikael at isy.liu.se Wed Nov 14 11:57:20 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 14 Nov 2001 17:57:20 +0100 (MET) Subject: sending a function on the fly? In-Reply-To: <3bf2a06f$1@207.229.64.20> Message-ID: On 14-Nov-2001 Peter Bismuti wrote: > In ECMAscript you can send a function as an argument that is defined on the > fly such as: > > callMyFunction(new Function(){ blah blah }) > > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? Use lambdas, like so: callMyFunction(lambda x,y:x*y) However, lambdas are limited to rather simple functions (basically one-liners). /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 14-Nov-2001 Time: 17:52:50 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From cs1spw at bath.ac.uk Thu Nov 29 16:59:34 2001 From: cs1spw at bath.ac.uk (Simon Willison) Date: 29 Nov 2001 13:59:34 -0800 Subject: Design tips requested for OOP forum system (using pickle) Message-ID: I'm something of a Python newbie but I'm keen to learn so I've decided to throw myself in at the deep end. My objective is to "learn" python (or at least get to a stage where I feel confident writing larger applications in it) and at the same time get the hang of object orientated design for a "real" software system (I've been slowly learning OOP over the last few months and I'm itching to try it out). Anyway - I've decided to code a flat threaded web forum system (similar to UBB or vBulletin) in Python using pickled objects in flat files to store the data (rather than using a database or a delimited flat file format of some sort). I'm doing this primarily as a learning exercise, so performance and scalability aren't that important. I'm having trouble figuring out the best way to design the classes for the forum. Here's what I have so far: User - an object representing a single forum user account Forum - an object representing a forum (e.g "General Chat" or "Site Suggestions") Thread - an object representing a thread Post - an object representing an actual post In addition I'm keen on having Moderator and Admin classes which extend User and are used for forum accounts with extra ablities. Post objects will be held in an array within a Thread object (representing the thread the posts were posted on). Thread objects will be held in an array within a Forum object. One thing I haven't quite figured out yet is how to relate posts to the user object for the user that posted that post. Should I look at storing some kind of user ID and then searching through my user objects for an object with that ID stored within it every time I display a post? That sounds horribly inefficient - performance is not a major concern for this software as it's intended for personal small scale use but I don't want to write something that's virtually unusable due to performance problems... I'm also not entirely sure how to do things like ordering posts witin threads by date - should I ensure they are in order within the array or sort the objects by their date property (which I assume will require me to write my own ordering algorithm, presumably not hard but something I've never had to do before). My final problem (I think) is how to split pickled data up. Should I have an OverallForum object which contains ALL the objects (and data) within it and pickle/unpickle the whole thing for every page view (sounds inefficient) or pickle individual forums in their own files. If I store individual forums in their own file how will I maintain references to User objects possibly pickled elsewhere? Any tips / pointers / warnings that I'm going about this project completely the wrong way would be more than welcome :) Thanks, Simon From root at rainerdeyke.com Fri Nov 9 15:53:18 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 09 Nov 2001 20:53:18 GMT Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <2nXG7.94004$IR4.35624942@news1.denver1.co.home.com> "Steven D. Majewski" wrote in message news:mailman.1005321732.23772.python-list at python.org... > Currently, trailing commas are optionally allowed on all tuples > except singleton's where they are required. (That in itself is a > confusing syntactical wart that I'ld like to use the time machine > to remove! ). Don't you think that the extremely different behaviour > of the last of these compared to the others could be a needless > cause of confusion? > > for i in 3,2,1: print i > > for i in 3,2,: print i > > for i in 3,2: print i > > for i in 3,: print i > > for i in 3: print i for i in [3],[2],[1]: print i for i in [3],[2],: print i for i in [3],[2]: print i for i in [3],: print i for i in [3]: print i If this causes confusion, then it's good to have, because then people can move beyond confusion toward understanding. An unadorned expression 'e' is not treated as the single element tuple '(e,)' anywhere else in the language. The principle of least surprise says that integers shouldn't get special treatment in this case. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From jdgorman at ieee.org Thu Nov 15 02:45:10 2001 From: jdgorman at ieee.org (John D. Gorman) Date: Thu, 15 Nov 2001 07:45:10 GMT Subject: Extending with C/C++ References: <5a4226f0.0111142234.33ea1590@posting.google.com> Message-ID: <3BF36FE4.EAC8F175@ieee.org> Kevin, There's a copy of compile.py in Hammond & Robinson's Python Programming for Win32; see Chap 22. The O'Reilley site has a zip bundle of examples at: http://examples.oreilly.com/pythonwin32/ . I haven't used it with Python2.1/2.2. It'll definitely need some modifications. You also need Mark Hammond's win32 extensions if you don't already have them (bundled w/ ActiveState's Active Python, available at the following link otherwise: http://aspn.activestate.com/ASPN/Downloads/ActivePython/Extensions/Win32all ) That said, you should really use distutils. It has support for Win32 and assumes MSVC (cl.exe, etc.) Check out the setup.py and setup_all.py scripts in the Numeric module at numpy.sourceforge.net. It'll definitely make things easier if you ever have to distribute your code too. Kevin Cazabon wrote: > I'm trying to wrap a C/C++ DLL with a Python interface to one > function... I'm not much of a C programmer, so I was using the > "cookbook" approach listed in the Python docs. > > However, the link to David Ascher's "compile.py" that is supposed to > be able to generate a MSC project file is broken (so are the links on > David's Starship Python page). > > Any suggestions? Does that module still work with Python 2.1.1? Are > there easier ways to do it? > > Or better yet, has anyone already wrapped the driver interface for > Aladdin's HASP library? (doubtful) > > Any suggestions are appreciated! > > Kevin Cazabon > kevin at cazabon.com From rdsteph at earthlink.net Fri Nov 23 16:08:30 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Fri, 23 Nov 2001 21:08:30 GMT Subject: Python Liberation Front Message-ID: <3BFEBC23.B20A656F@earthlink.net> http://www.awaretek.com/plf.html I have written book reviews on 15 Python books and posted them here. I know, its embarrassing, but after reading so many books due to my slow learning ;-)) I had to do something useful with them. Maybe the reviews will be of interest to others when comparing Python books. I will add more later and if anyone else sends any reviews, I'll add them to. Also I have a brief report on the Lightweight Languages Conference held at MIT on Saturday Nov. 17. I attended it and it was great! Also an online script that lets users input simple data on preferences and then it ranks 10 programming languages compared to the user's preferences and chooses a winner ;-)). This online script is JavaScript but I also have posted Python source code to do the same thing plus a couple of other things. The basic idea I guess is that maybe this new site will be of use or interest to newbies when they are choosing a language. I will add more as I get time. Ron Stephens http://www.awaretek.com/plf.html From phr-n2001d at nightsong.com Wed Nov 14 18:11:44 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 14 Nov 2001 15:11:44 -0800 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> Message-ID: <7xy9l9ne1b.fsf@ruckus.brouhaha.com> Bob Bane writes: > > (b) is only a matter of time & will. > > > > It's also a matter of having a non-moving target to aim at. When Python > has a specification stronger than N portable implementations and a test > suite, compiler writers will have a target worth expending effort to hit. Well, Lisp compilers have been developed for specific dialects plenty of times. However, most Lisp compilers have depended on type declaration pragmas to generate good code, AFAIK. Python would need a language extension to support something like that. From david.abrahams at rcn.com Fri Nov 30 11:13:06 2001 From: david.abrahams at rcn.com (David Abrahams) Date: Fri, 30 Nov 2001 11:13:06 -0500 Subject: Possible PEP: smart modules Message-ID: <9u8arr$367$1@bob.news.rcn.net> In my work on Boost.Python (www.boost.org) a colleague suggested the implementation of "cross-module overloading". Boost.Python allows function overloading within a module or class as a way of reflecting the structure of the C++ program being wrapped. That means, for example, that in: import MyExtensionModule MyExtensionModule.f("hello there") MyExtensionModule.f(42) MyExtensionModule.f("this", "way", "please") The invocations of f() might all call different functions. How would this work "cross-module"? from MyExtension1 import f from MyExtension2 import f f(42) # calls MyExtension1.f f("hello") # calls MyExtension2.f We can't do this right now because the second import will unconditionally overwrite the current definition of f. I propose that we give the modules some control over what happens when their names are imported into an existing namespace. If that were possible, the second import might notice that there was already a callable object named "f" and replace the name being imported with some collection of functions which implemented the overloading (that's how the single-module overloading mechanism works now). So, as a straw man, let me propose a syntax. If a module defines an __import__ function as follows: __import__(source-module, source-name, target-module, target-name) it will be called for each name being imported from that module into another. In other words, source-module will always be the module in which the __import__ function is defined, and target-module will be the module into which the names are being imported. source-name is distinguished from target-name in order to support "from Module import A as B". -- =================================================== David Abrahams, C++ library designer for hire resume: http://users.rcn.com/abrahams/resume.html C++ Booster (http://www.boost.org) email: david.abrahams at rcn.com =================================================== From root at rainerdeyke.com Mon Nov 5 21:32:05 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Tue, 06 Nov 2001 02:32:05 GMT Subject: Program very slow to finish References: Message-ID: "Tim Peters" wrote in message news:mailman.1005002107.13101.python-list at python.org... > No, it was a good first approximation, but measurement speaks louder than > argument . I fiddled Python's dict dealloc routine like so: > > for (ep = mp->ma_table; fill > 0; ep++) { > if (ep->me_key) { > --fill; > //Py_DECREF(ep->me_key); > //Py_XDECREF(ep->me_value); > /* New code follows. */ > ep->me_key->ob_refcnt -= 1; > if (ep->me_value) > ep->me_value->ob_refcnt -= 1; > } > } > > This does everything the DECREF macros did *except* to call the platform > free() on the now-dead string-object keys. It also doesn't call the destroyed objects' destructors. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From ws-news at gmx.at Thu Nov 22 14:24:07 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 22 Nov 2001 20:24:07 +0100 Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: <3bfd519d@brateggebdc5.br-automation.co.at> Hi, "Erik Johnson" wrote in message news:3BFD49D8.F7A4C6CC at earthlink.net... .... > s = "".join(l) > > This works fine, but it seems syntactically backwards to me: > > # s = l.join("") > > makes much more sense to me. The thingy I want to do something to is my > list. I am just trying to learn Python, so no doubt there will be some > Python things I will just have to get used to, but is there a logical > reason why it was implemented as a string method rather than a list > method? Does it seem backwards to you or does it make intuitive sense to > you? Comments? (other than of the "it's moot" flavor) > .... For one thing, "".join does not just work for lists. It also works for all other sequences. e. g. >>> "-".join("Works with all sequences") 'W-o-r-k-s- -w-i-t-h- -a-l-l- -s-e-q-u-e-n-c-e-s' or with your own classes, if they act as sequences: >>> class TestSeq: ... def __init__(self, num_item): ... self._num_item=num_item ... def __getitem__(self, index): ... if 0 <= index <= self._num_item: ... return str(index) ... else: ... raise IndexError, "Index out of range." ... def __len__(self): ... return self._num_item ... >>> t = TestSeq(20) >>> "#".join(t) '0#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20' Why not just read the above as 'use _"#"_ to _join_ the items in _t_ into a string'? Then it sounds a lot more logical. best regards Werner From support at internetdiscovery.com Fri Nov 23 16:48:50 2001 From: support at internetdiscovery.com (Mike Clarkson) Date: Fri, 23 Nov 2001 21:48:50 GMT Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> <3bf9f33a.5900599@24.0.228.33> <9tf4fo$fb5$1@nntp9.atl.mindspring.net> Message-ID: <3bfec43c.2822417@nntp.ix.netcom.com> On Wed, 21 Nov 2001 02:46:15 GMT, "Don Arnold" wrote: >Here's the simple code I was trying to run (from 'Programming Python', 2nd >ed): Thanks for the explicit example. The problem is in your code, not with Idle. >from Tkinter import * This is unfortunately the cause of the problem in this case. In Python, if you're having troubles, remove all the 'import *' you can find and replace them with 'import' for safety. >def quit(): > print "Hello, I must be going" > root.quit() The problem here is that root is not your root - it's a default root in Tkinter that came in with your 'import *'. The is an evil timesaving feature of Tkinter that I would like to see removed. It is the first instance of a Tk(), which in this case happens to be Idle's. So your quit() says 'quit Idle'. >root = Tk() This root is your root, which is a different root from quit(). >widget = Button(root, text="Hello, event world", command = quit) >widget.pack() >root.mainloop() This is correct, but it should be followed by a root.destroy(). root.quit() quits the mainloop, but *does not destroy myroot*. My revised version of your program is: import Tkinter global myroot myroot = Tkinter.Tk() def quit(): print "Hello, I must be going" # import sys # sys.exit() myroot.quit() widget = Tkinter.Button(myroot, text="Hello, event world", command = quit) widget.pack() myroot.mainloop() myroot.destroy() >When I run it in IDLE, the tk window pops fine. Clicking the button once >outputs the message to the interactive window as expected, but doesn't >shutdown the tk window. Clicking the button a second time shuts down the tk >window, and IDLE along with it. I just found that if I delete(root) in the >interactive window before the 2nd click, the tk window closes and I raise a >NameError exception on 'root', but at least IDLE stays up and running. My revised version of your program does what you expect, and doesn't kill Idle, because root.quit() isn't called. Maybe you should send a note to the author of Programming Python to say that using Tkinter's default root is confusing, and perhaps the example could be rewritten. >Sorry for being vague earlier. Thank's for the explicit example. Actually there is still a problem left here (the Tcl interpreter is not completely and cleanly destroyed by myroot.destroy()), but that's another issue. >Hope this helps, It did - it helped me find a bug in my Tkinter debugging tools! (http://tix.sourceforge.net/Tide in Tkinspect.py) Mike. From mjackson at wrc.xerox.com Sun Nov 4 15:03:06 2001 From: mjackson at wrc.xerox.com (Mark Jackson) Date: 4 Nov 2001 20:03:06 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <570711d44a.simon@satin.callan.demon.co.uk> Message-ID: <9s46tq$78j$1@news.wrc.xerox.com> Simon Callan writes: > In message <9s2hl0$u6o$1 at bugstomper.ihug.com.au> > "Gary Stephenson" wrote: > > He was also I believe the author of the immortal limerick: > > > > "There was a young man from Wooloomooloo (*) > > Whose limericks always finished on line two." > > > > (* - or somewhere ending in "oo" - can't remember now) > > Which inevitably has the followup rhyme > "There was a young man from Verdun". Which is just as inevitably followed* by the one about the young man from Tokyo. [*or not; can't tell] -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson After a recent trip to New York one French journalist remarked that leafing through a copy of /Forbes/ or /Fortune/ is like reading the operating manual of a strangely sanctimonious pirate ship. - Adam Gopnik From James_Althoff at i2.com Wed Nov 14 19:54:54 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 14 Nov 2001 16:54:54 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: David Eppstein wrote: >James_Althoff at i2.com wrote: >> If not 3), then there is the issue of having to do an extra computation for >> the common case of indexing a sequence as in, e.g., >> >> for i in 0 .. len(sequence)-1: > >This is very common in C, but is it so common in Python? >Isn't it usually more idiomatic to do > for item in sequence >? Yes, that is the common idiom. PEP 276 is aimed at cases where "for item in sequence" doesn't work as in, for example: for rowcount in xrange(table.getRowCount()): # valid Python print table.getValueAt(rowcount,0) for rowcount in table.getRowCount(): # as proposed in PEP 276 print table.getValueAt(rowcount,0) for rowcount in [0 .. table.getRowCount()-1]: # Haskell-esque syntax print table.getValueAt(rowcount,0) In this example: for row in table.getRows(): doesn't work because there is no "table.getRows()" method that can be called. Hence, the need for indexing. As noted in the PEP, the commonly used (in Jython) Java/Swing/Jython class DefaultTableModel is an example where there is a "getValueAt" method (that requires a row index and a column index) but no "getRows" method. Jim From darnold02 at sprynet.com Fri Nov 30 19:42:13 2001 From: darnold02 at sprynet.com (Don Arnold) Date: Sat, 1 Dec 2001 00:42:13 GMT Subject: Database in a simple ascii file References: Message-ID: <9u9950$k9q$1@slb4.atl.mindspring.net> On 30-Nov-2001, Lucio Torre wrote: > Steve Holden wrote: > > >"Rafael Mentz Aquino" wrote ... > > > >>Hi, > >> > >>How many lines can I have in a simple ascii file before > >>I start to loose performance when I open this file and > >>put all the lines in a dict, turning the first column into the key > >>and the rest of the line into a list associated to that key. > >> > >>(my file has just 100 lines, but that question starts to bother me ;-) > >> > >You couls always do some testing ... > > > >In fact this is probably the fastest way to do it, for random keys and a > >file that will fit comfortably into memory. The dictionary implementation > >works hard to make sure that access time is roughly constant no matter > >what > >the size. > > > >Posters have in the past reported using dictionaries of 100,000 elements > >without problems, so your file has to grow some before you hit uncharted > >territory... > > > >regards > > Steve > >-- > >http://www.holdenweb.com/ > > > > I think that ZODB will allow you to have a dictionary bigger than your > memory. Is that so? Anyone tried it? Can't you accomplish this using the shelve module, more or less? From thomas at weholt.org Sun Nov 18 20:28:06 2001 From: thomas at weholt.org (Thomas Weholt) Date: Mon, 19 Nov 2001 02:28:06 +0100 Subject: egenix-mx-package error : copy_reg is not intended for use with classes Message-ID: Well, it's probably the pgdb module that comes with PostgreSQL 7.1.3 I've just installed but .... Anyway : I've installed PostgreSQL 7.1.3 with python enabled. Tried to use pgdb.py but it needed mxDateTime, so I installed http://www.lemburg.com/files/python/egenix-mx-base-2.0.2.tar.gz Now I get the following error : Python 2.1.1 (#1, Aug 30 2001, 17:36:05) [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.61mdk)] on linux-i386 Type "copyright", "credits" or "license" for more information. >>> import pgdb Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.1/site-packages/pgdb.py", line 64, in ? try: from mx import DateTime File "mx/DateTime/__init__.py", line 40, in ? class modinit: File "mx/DateTime/__init__.py", line 50, in modinit _DT) File "/usr/lib/python2.1/copy_reg.py", line 16, in pickle raise TypeError("copy_reg is not intended for use with classes") TypeError: copy_reg is not intended for use with classes >>> This is on a Mandrake 8.1-box. Any clues ?? Thomas From jakub.silar at volny.cz Sat Nov 10 06:02:50 2001 From: jakub.silar at volny.cz (Jakub S) Date: 10 Nov 2001 03:02:50 -0800 Subject: VB parsing - not that offtopic Message-ID: Hi, in near future I will have to check coding style of some VB code. (Yes, I should have persuaded them to use the right language...) I am considering writing a tool in Python for that purpose. Is there one of the following in the big world out there? 1/ A Python library/application do do the job or it's substantial part. 2/ (the offtopic part) any other non-python solution kind of adjustable VB - lint. 3/ Good advice for the case I have to start from scratch? Mr. Google does not seem to answer my questions on point 1/ which is the one I would prefer. Thanks for any advice from this friendly newsgroup. Jakub From deltapigz at telocity.com Fri Nov 9 18:20:47 2001 From: deltapigz at telocity.com (Adonis Vargas) Date: Fri, 9 Nov 2001 18:20:47 -0500 Subject: String Search. Message-ID: i posted a thread before asking help on how to find a specific string within a line of string, i unfortunately did not get too specific on what i was asking for. how can i do a search within a string using wildcards? i.e.: (pseudocode) if "*something*is*" in "something is written here": return true ive looked into the re module and have been to the how-to pages, but i cant seem to understand it. any help would greatly be appreciated. Adonis From ajs at ix.netcom.com Wed Nov 7 08:12:11 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Wed, 7 Nov 2001 08:12:11 -0500 Subject: Teaching python (programming) to children Message-ID: <000001c1678e$7ce9d240$a9e1fea9@carol> Cliff writes - >One of Python's strengths is that almost every >line of code is related to solving the programmer's >goal rather than telling the compiler how to >compile the code. Which has been my experience, and why I think I was more successful with Python than with other languages I false-started with before I came to it. In effect, my interest was not in learning programming, but in accomplishing some things for which an understanding of programming happens to have been an essential. In the educational setting, I think it is much more important to focus, in the end, on what an understanding of programming fundamentals brings to the table generally - rather than viewing it as an isolated educational goal. Invest in giving students that understanding because it will allow for enhanced curriculum in subjects X,Y, and Z. Math and science being the obvious. Looked at in this way, Python - in my view - particularly well fits the setting. Art From corrada at ciirsrv.cs.umass.edu Thu Nov 29 13:12:14 2001 From: corrada at ciirsrv.cs.umass.edu (Andres Corrada-Emmanuel) Date: Thu, 29 Nov 2001 13:12:14 -0500 (EST) Subject: list.sort() fails under Solaris 5.8 for Python 2.1 Message-ID: Hello, I'm having problems with list.sort() on a Solaris 5.8 machine. My program reads a file that consisting of three columns that it then sorts using list.sort(). If the input file is small enough (~400 lines), the right output is obtained. If the file is large (~40K lines), the sort silently fails and the list is returned unsorted as originally found in the file. Has anyone else seen this? Andres Corrada-Emmanuel Senior Research Fellow Center for Intelligent Information Retrieval University of Massachusetts, Amherst From headroom02 at gmx.de Sat Nov 17 13:21:06 2001 From: headroom02 at gmx.de (Gernot) Date: Sat, 17 Nov 2001 19:21:06 +0100 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> Message-ID: <9t69v4$muf$01$1@news.t-online.com> "Paul Sidorsky" schrieb im Newsbeitrag news:mailman.1005795261.24480.python-list at python.org... > Gernot wrote: > [deleted] > Assuming this is for a CS problem, I don't know what the instructor has in > mind, of course, but I expect he/she would consider the above approach (if it > had worked) as missing the point. It's more likely the instructor wants (or > would be more impressed by) a generic solution that would work in any language, > especially if this is for a "fundamentals of programming" course. Yes, it is for CS, and this is a course called "Praktische Informatik 1" (practical cs 1). It is no programming course in its sense, we have to learn general concepts of programming, and to learn it, we use the languages Python and Haskell. > > The way I would approach this problem (as I understand it) is to convert each > ASCII character of the strings to a number using ord() and then use > mathematical and relational operators (+, -, <, >, ==, etc.), assuming they're > allowed. (I would think they would have to be.) The conversion is easy with > list comprehensions (Python 2.0 and up): > > xlist = [ord(i) for i in x] > ylist = [ord(i) for i in y] > > This will give you two lists of numbers, the elements of which you can then use > the other operators on to mimic the logical operators. Exactly how to do that > I won't say because I expect that's what the instructor really wants you to > figure out. > > I hope that's a push in the right direction. But of course I don't know > exactly what the goal and specific restrictions are here so I may be way off > base. Thank you for your tip, it has interesting contents, but It is not really defined what the input for x and y can be, and it is necessary to find out the expression is true or not. Therefore I am sure this would be really hard to implement, if it is possible. greets Gernot From python at heidenreichs.de Tue Nov 13 20:31:58 2001 From: python at heidenreichs.de (Th. Heidenreich) Date: 13 Nov 2001 17:31:58 -0800 Subject: Need call by Name or any other solution...!?! Message-ID: <263c4e12.0111131731.3a7b49f2@posting.google.com> Hi, I?ve got the following problem: I want to assign a number of variables (which are not constant) a value by an entry box. Better look at the code: def confirm(self): print self.right def __init__(self, nof_entries, categories): self.right = [] for i in range(nof_entries): list_label = Label(text = categories[i], relief="flat") list_label.grid( row = i+2 , column = 0) self.right.append(chr(65+i)) # just to have something in there right_label.append(Entry( relief = "sunken", bd = 2, textvariable = self.right[i])) # **** THATS THE THING THAT DOSN?T WORK **** right_label[i].grid(row = i+2 , column = 1) b_confirm = Button(text = "Confirm", command = self.confirm) b_confirm.grid(row = laenge+3, column = 0, columnspan = 2) ... self.right[0] for example refers to a variable named "A" - but it should refer to a variable CONTAINING "A", so how can I assign a textvariable to an entry of an array?? Or has anyone another idea how to do this??? Hope anyone can help, the skript has to be finished by Friday :(( thanks Thomas ps: If possible please answer cc: python at thomas-heidenreich.net From prabhu at aero.iitm.ernet.in Tue Nov 6 12:30:57 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 23:00:57 +0530 Subject: newbie: selecting text by script in Tkinter fails In-Reply-To: References: Message-ID: <15336.7761.598395.240129@monster.linux.in> >>>>> "JdB" == Johnny deBris writes: JdB> part of a search-option I would like to add. For people who JdB> think they're suffering from deja-vu or something: I have JdB> posted a question quite similar to this one a few days ago, JdB> but no-one seemed to be able to or want to answer. (maybe a JdB> classical case of RTFM? If so, please tell me where to find JdB> that FM!! :) I guess its hard for people to follow what your exact problem is without a small script that illustrates the problem. Maybe you can write a 10 line piece of code that illustrates what you tried and mail that? prabhu From huaiyu at gauss.almadan.ibm.com Wed Nov 28 21:04:07 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Thu, 29 Nov 2001 02:04:07 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C045C07.BA7B3FE6@engcorp.com> Message-ID: On Tue, 27 Nov 2001 22:37:43 -0500, Peter Hansen wrote: >Huaiyu Zhu wrote: >> >> So let me repeat it once and for all: >> >> Question: What should tab be default to in terms of other charactors, or >> screen positions, or editor actions, or anything else that is not the tab >> charactor? >> >> Answer: It shouldn't. > >Phew! I'm glad you finally settled that question... The whole quoted paragraph was meant to be a quote instead of a statement. But this thread is full of _interesting_ interpretations anyway. Huaiyu From sholden at holdenweb.com Thu Nov 15 07:34:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 15 Nov 2001 07:34:53 -0500 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <3BF2C715.7050400@bigfoot.com> <97ae44ee.0111150043.4382fe2f@posting.google.com> Message-ID: "Stephen" wrote ... > Thanks for the help, Cezary > > > >>But when NUMTHREADS = 20, half the threads die with this error : > > >>Unhandled exception in thread: > > >>Traceback (most recent call last): > > >> File "", line 6, in send_request > > >> File "", line 1, in connect > > >>socket.error: (10061, 'Connection refused') > > > > If you are has clients and a server on the same machine, it is possible, > > that server it does not have enough time to accept connections on a > > listen socket. > > If I understand you correctly, then the server receives a > request, creates a thread to deal with it. But the server > is so busy creating threads to deal with incoming requests, > that some other requests are ignored. > > > By default only 5 connections can wait to be accepted - > > if more appears, they are refused by your operating system. You can > > raise this number, but there are limits on some OS-es. > > > > So, for really testing server you should launch clients from another > > machine(s). > > Sorry, you've lost me here. If the server can't generate > threads quick enough to deal with the incoming connections, > how will moving the clients to another machine give the > server more time (except perhaps in introducing a network > delay) ? > Well, for a start it will ensure that the server gets more of the CPU time, and reduce the strain on the transport layer at the server. > > > For building high-performance server check: > > http://www.nightmare.com/medusa/ > > > > Medusa combines asyncore with threads for optimal performance. > > I had found the asyncore/asynchat method a little strange > but just downloaded the medusa package and there's a lot of > good documentation in the source. The included chat_server > example looks like a good starting point. Will try that. > > Sam also provides a great page of reference material. Excellent. > Yes, asyncore/asynchat are heroes of the Python networking world. regards Steve -- http://www.holdenweb.com/ From daniel.dittmar at sap.com Mon Nov 12 06:08:17 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 12 Nov 2001 12:08:17 +0100 Subject: IsPython really O-O? References: Message-ID: <9soaj3$mev$1@news1.wdf.sap-ag.de> > But, Smalltalk is not Object Oriented, is **Object Based!** sometime ago, in a > smalltalk workshop, a line was drawed: Actually, the term 'object based' was used for languages like Ada when they had encapsulation, but not inheritance. trainspottingly yours Daniel From paul at prescod.net Tue Nov 13 16:21:09 2001 From: paul at prescod.net (Paul Prescod) Date: Tue, 13 Nov 2001 13:21:09 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> Message-ID: <3BF18EC5.51226C4@prescod.net> Adam Spitz wrote: > >... > > > def MyClass_newMethod(self): > print "new method" > MyClass.newMethod = MyClass_newMethod > > I smiled just now when I realized that the Python version is actually > fewer lines of code. :) But I still don't think it feels right. In > Smalltalk and Ruby, I'm just using the standard mechanism for adding > methods to a class. In Python, it feels like I'm sneakily hacking an > extra method into a class against its will. (Does that make any sense? > Maybe I'm being too touchy-feely. :) You are doing something sneaky in *any* language because if anyone else defines newMethod in any other module anywhere in the system you'll overwrite each other. Classes are more or less global variables and so are their methods. Python would probably not have first-class syntax to do this until there were a way to do it that scaled well to large programs written by people who do not necessarily communicate with each other. Paul Prescod From logiplexsoftware at earthlink.net Fri Nov 16 19:08:37 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 16 Nov 2001 16:08:37 -0800 Subject: MultiThread Socket on NT In-Reply-To: References: Message-ID: <01111616083701.03405@logiplex1.logiplex.net> On Friday 16 November 2001 14:26, David Bolen wrote: > Cliff Wells writes: > > Be sure you are using at least SP5. NT 4 had serious threading issues > > prior to that. > > Do you have any pointers or references to what the problem was? I've > been using multi-threaded applications (although not a high density > connection server) under NT4 SP4 without any observable problems. It's been around three or four years since I encountered that, so the details are pretty vague now.... I was writing an instant messaging server that spawned a thread for every incoming connection (not the best way, but it was my first attempt at network programming, multithreading and my first Python program to boot =). I was stress-testing my server and I had an adjustable parameter limiting the number of threads allowed at any one time. If I set this higher than, say 20 (highly questionable if that's the number), NT would flake out (I think to the point of BSOD, but I can't recall). Anyway, without changing any code, applying SP5 fixed it, and I seem to recall that threading was one of the issues addressed in SP5. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From bill-bell at bill-bell.hamilton.on.ca Fri Nov 30 07:30:02 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 30 Nov 2001 07:30:02 -0500 Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: <1007084325.890.69394.m11@yahoogroups.com> Message-ID: <3C07357A.2935.24FC2A4@localhost> Jonathan Gardner wrote, in part: > [Python] really *is* easier, it really *is* useful, and it really > *is* debuggable, so why would you want to use C++ when you have > Python? Amen! > They'd have to be [young]. I can't seem to find a place to get paid to work in > Python yet. I can't imagine a guy with 3 kids trying to make a living > by programming python unless he is the rare guy that has a job in it. AHEM! I may be a statistical anomaly but I'm almost 55. I now have two paying Python projects on the go. True, one is funded by a university. However, the other one is for a purely commercial play. The president of the company, like me, is a some breed of anarchist. I plan to use Python to introduce some of the students in the one and only MBA course that I do to concepts like threads and sockets this winter. (The code is a lot easier to understand than equivalents in most other languages.) And I believe I've influenced at least one guy aged around 20 to take up this fantastic language. (He might even be reading this when he is supposed to be doing his schoolwork.) It's amazing what one can do when one sits in front of a screen and rests one's canes against a bookcase. :o) Peace and bliss, eh. Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From dgallion1 at yahoo.com Wed Nov 14 22:10:13 2001 From: dgallion1 at yahoo.com (Darrell) Date: 14 Nov 2001 19:10:13 -0800 Subject: regex difficulty ? References: <20011114.112834.189124975.7396@localhost.localdomain> Message-ID: Search this group for "[ #456742 ] Failing test case for .*?" I think these are related. "Robert Nikander" wrote in message news:<20011114.112834.189124975.7396 at localhost.localdomain>... > How the heck is the [\w\s*] class matching the chars { } and " From jdadson at ix.netcom.com Wed Nov 7 18:58:15 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 07 Nov 2001 23:58:15 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s2rob$5p8$1@bugstomper.ihug.com.au> <3be5d7b5.186523676@news.tesco.net> Message-ID: <3BE9CA6D.E191C8DF@ix.netcom.com> seb wrote: > > Milligan was brill. My fave: > > Dr O'Dell fell down a well > And broke his collar bone > But doctors should attend the sick > And leave the well alone > > seb I remember hearing this when I was quite young, as one of the verses of a childrens' song called "It Ain't Gonna Rain No More". I'm 54 now. A quick web search found it attributed (in addition to Milligan) to "traditional", "anon", and to someone named Holly Sunley. I don't know who Holly Sunley is, but the look of the web page where I found it makes me suspect she is contemporary, and therefore the attribution is wrong. Jive From montanaro at tttech.com Fri Nov 9 10:55:30 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Fri, 09 Nov 2001 16:55:30 +0100 Subject: gtk, clist & python In-Reply-To: <3BE4EBD9.1719C3D4@freesbee.fr> References: <3BE4EBD9.1719C3D4@freesbee.fr> Message-ID: jm> how can i do the mapping between rows of a "clist" and a python's jm> vector? jm> how can i know the number of rows in a "clist"? These are questions probably better asked on the pygtk mailing list, but I'll take a stab at it (I've never used this particular widget). I don't see any obvious "length" method, so I think you'll just have to keep track of the size as you call the append() and insert() methods to add rows to the widget. Both return the offset of the row just added as the script below demonstrates. (I use the Gtk 2.0 API, so you may have to fiddle the script to make it work with the older API.) #!/usr/bin/env python import gtk win = gtk.Window() win.connect("destroy", gtk.mainquit) vb = gtk.VBox() win.add(vb) cl = gtk.CList(1) items = "foo bar baz".split() for item in items: print "row:", cl.append([item]) vb.pack_start_defaults(cl) b = gtk.Button("quit") b.connect("clicked", gtk.mainquit) vb.pack_start(b) win.show_all() gtk.mainloop() -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From sholden at holdenweb.com Thu Nov 8 07:39:56 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Nov 2001 07:39:56 -0500 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111080405.77c024a2@posting.google.com> Message-ID: "pawn" wrote in message news:4b4c5d99.0111080405.77c024a2 at posting.google.com... > My CGI scripts save information submitted by users in files, and later > display this information inside HTML templates. > > It seems to me that either I find a way to let these scripts run with > my UID, or, in order to let them read / write files in the data > directory, I have to make it world-writable which means malicious > users on the same system can delete files, as well as create files > which were not processed by the CGI's policies. > > Is there something I'm missing here? *Can* I get by without setuid? Had you considered mailing the form to a Python program on some other machine? Or using an FTP client to provide an authenticated connection to your server filestore? Both solutions are gash, but this is the kind of thing you end up doing when you don't have full access to your server environment. regards Steve -- http://www.holdenweb.com/ From slinkp23 at yahoo.com Tue Nov 6 12:15:07 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 06 Nov 2001 17:15:07 GMT Subject: RE Module Question. References: Message-ID: On Tue, 06 Nov 2001 15:25:11 GMT, Grant Edwards wrote: >In article , Corrado Gioannini wrote: >> On Tue, Nov 06, 2001 at 05:49:38AM +0000, Paul Winkler wrote: >> [snip] >>> You can do it like so: >>> >>> test = "this is spam" >>> if test.find("spam"): print "found it" >> >> this would fail if the sub-string to be found is at the beginning of the >> string (find returning 0). > >It also fails if the string is not present, since find() >returns a -1 in that case. Whoops. Very sorry for the incorrect advice. Should've checked before posting... --PW From mind.tech at verizon.net Sun Nov 25 15:42:42 2001 From: mind.tech at verizon.net (Power-Tech) Date: Sun, 25 Nov 2001 20:42:42 GMT Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> <3c015433.778200@news> Message-ID: <3C015854.E13B862F@verizon.net> Hi FF, Thanks for the reply....I am trying to play around with Active Phyton...since you're a beginner as well, we could exchange our troubles and solutions....let me know how sucessful you have been at running a .py file after you save it....does it open a DOS window? Anyway, feel free to write me either here or at my personal e-mail, I think it's much more fun to learn when we have people to share with... Take care Willie Fred Flintsone wrote: > On Sun, 25 Nov 2001 20:19:46 GMT, Power-Tech > >knows about a good tutorial online for someone in my situation? > >Is this group too advanced for me? > >I appreciate your attention > >Willie > Hey, Willie...I hope this group isn't too advanced for you, because I > just joined an hour ago and I'm as green as they come. I first did > the 2.1.1 version, but uninstalled and went for the Active version. I > noticed right away that the work screen is Windows-oriented rather > than the DOS-type screen I had with 2.1.1 > > I just bought the "Learning Python" O'Reilly book and it recommended > the www.python.org page for all kinds of reference materials. Someone > in this group also recommended to me > http://diveintopython.org/ > but the subtitle "For Experienced Programmers" has me trembling. > > Hope I helped. > FF > Please post any responses to this to this newsgroup. From wolf359_ at gmx.net Fri Nov 2 08:36:42 2001 From: wolf359_ at gmx.net (Thomas Weidner) Date: Fri, 02 Nov 2001 14:36:42 +0100 Subject: references ??? References: <9rtpsc$13j2@newton.cc.rl.ac.uk> Message-ID: In <9rtpsc$13j2 at newton.cc.rl.ac.uk>, Richard Brodie wrote: > "Thomas Weidner" wrote in message > news:pan.2001.11.01.17.30.27.280.2271 at gmx.net... > > >> I think anybody here knows what references,like in java,c++ or perl, >> are. How can i use references in python ? > > Implicitly. Consider the following: > >>>> a = [1,2,3] >>>> b = a >>>> b[1] = 20 >>>> print a > [1, 20, 3] Interesting.... Is this also possible for single values like ints ? How do i make clear if i want a copy of a or a reference to it ? From phd at phd.pp.ru Sat Nov 3 06:08:42 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sat, 3 Nov 2001 14:08:42 +0300 Subject: Freeware Python editor In-Reply-To: <3be33e4e.31678681@127.0.0.1>; from root@127.0.0.1 on Sat, Nov 03, 2001 at 12:44:13AM +0000 References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <3be33e4e.31678681@127.0.0.1> Message-ID: <20011103140842.A24226@phd.pp.ru> On Sat, Nov 03, 2001 at 12:44:13AM +0000, Fish wrote: > Oleg, kindly go away. You do *nothing* to improve this newsgroup when you Boy, you are attacking me for the second time. And you are doing this hiding your identity under the name "Fish" and email "root at 127.0.0.1", no signature. You are doing like a coward. When challenging people - do it with open face. Otherwise shut up and go away. I am witing for you to open your identity or your apologies. > rant about free speech versus free beer. In fact, you *HURT* the group. There are situations - and free speech is the first one of them - when improving a newsgroup is not the mail task. > Go away. I refuse to do it, of course. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From frederic.giacometti at arakne.com Tue Nov 6 09:58:09 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Tue, 06 Nov 2001 14:58:09 GMT Subject: _nr and callbacks Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: <5USF7.3918$Sx.1552470@news1.elcjn1.sdca.home.com> "Michael Hudson" wrote in message news:uady09pkm.fsf at python.net... > Martin von Loewis writes: > > [schnipp] > > * Are the _nr versions functionally completely backwards-compatible? > > If not, why? If yes, why is the original version preserved? > > I think the originals are just around because the implementation of > the _nr variants was tricky and Chris needed something to test > against. Not sure, though. >From what I understand in the stackless mechanism, the _nr functions are used in the Python VM, but cannot be used in C extension callbacks. In effect, in C extensions (or when embeding Python), Python must return to the C code after executing the callback. So, distinct hybrid functions, different from those used by the VM, are still needed. It's true that stackless introduces an additional level of complexity, and that its implementation could be lifted up. These can be the actual reasons why this has not been merged... FG From paul at boddie.net Tue Nov 6 06:25:21 2001 From: paul at boddie.net (Paul Boddie) Date: 6 Nov 2001 03:25:21 -0800 Subject: Python packages - problems, pitfalls. References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: <23891c90.0111060325.4c2ec924@posting.google.com> Prabhu Ramachandran wrote in message news:... > > I have an application that is shipped as part of a package. I'd like > the application to run right off the main directory or when the > package is installed. Also lets add to the problem by saying that the > project is under CVS and its a pain putting everything into another > directory. Something like this: > > pkg_root/ > __init__.py > app.py > # app is the application that is not part of the package There's something about this which intrigues me, too, but more on that below. > common_module.py > setup.py > common/ > __init__.py > foo.py # more common stuff > sub/ > __init__.py > submodule.py > a.py > sub1/ > __init__.py > b.py > > pkg_root might either be installed as Package (in site-packages) or > someone may decide to run app.py from within pkg_root. > > Also, irrespective of whether people have run into such problems or > not, don't you think it makes sense for modules to be searched the way > I had suggested earlier?? Or is there some serious issue with this. I've been reorganising some package structures recently, and I found a number of issues which may be of interest to you. Firstly, that remark I made above: let's say we run app.py from outside pkg_root... python pkg_root/app.py What would you expect to happen if app.py contained the line given below? import pkg_root.common_module What seems to happen is that unless the current directory (the parent of pkg_root) resides on your PYTHONPATH, this will not work - it's as if app.py is part of the package and should be using... import common_module I found this slightly confusing, but it is related to what you want to do in your example, because I agree that it can make some sense to include the test, demonstration or main application program within the package directory, even though it isn't strictly part of the package - it's a user of the package. Of course, in Java one uses an explicit package keyword to exclude or include "modules" from/in packages, whereas in Python it's implicit. This is really an aside, though, because your main issue is with the way importing of "super-package" members is done. What happens if there's a package called common somewhere else on your system outside (and unconnected with) this package, and then in a.py you do use the following statement? import common.foo In the scheme you propose, access to the external common module is likely to be restricted in some way by the presence of the common subpackage of the new package. With the existing mechanisms, however, this ambiguity is avoided entirely in this case - you have to do the following: import pkg_root.common.foo Of course, you can argue that you might want to use the new package's common subpackage without acknowledging that it is part of pkg_root, but then you should ask yourself whether the common subpackage wouldn't be better off outside pkg_root if it is to be used independently of it. You might need to rename the newly independent common package, though. I do see your point, though. In one of my works, I use packages to maintain a sort-of logical structure as follows: XMLForms __init__.py Accessor.py ... DOM __init__.py DOMAccessor.py # Yes, I could have called this Accessor, # but I did say that I just reorganised # the package! ... DOMElementTypes __init__.py BaseTypes.py ElementTypes __init__.py BaseTypes.py test.py # This just uses the package - it isn't # supposed to be part of the services # offered by the package, even though it # logically belongs inside the package. Now, DOMElementTypes is related to ElementTypes through their "nature" - they perform similar activities. However, I have chosen to group define subpackages according to implementation technology. As a result, I would have to do the following kind of import from within XMLForms.DOM.DOMElementTypes.BaseTypes: import XMLForms.ElementTypes.BaseTypes You might want to know why I can't do this: import ElementTypes.BaseTypes Well, I don't really see the need to do that unless I consider ElementTypes to be independent of XMLForms. Moreover, if I decided to give in and rename DOMElementTypes to ElementTypes, because it lives in a separate namespace to the other ElementTypes, then I would still be compelled to do a "full" import under any import scheme which isn't "really clever". import DOM.ElementTypes.BaseTypes import ElementTypes.BaseTypes # What does this import? One could insist that the first statement always be used to access the DOM version, and that the second statement always accesses the higher-level version, but how is the import mechanism supposed to know what you mean? So, to summarise, perhaps there's no simple way of introducing what you want without introducing some of the consequences outlined here. Explicit package specifiers might help in certain cases (the app.py or test.py cases), but they could promote a package structure which isn't obvious from browsing the filesystem. Unions of packages (which could be done using either explicit specifiers or import magic) could potentially introduce side-effects as modules start to co-exist with modules they were never meant to co-exist with. Paul From use-net at schabi.de Tue Nov 20 16:13:58 2001 From: use-net at schabi.de (Markus Schaber) Date: Tue, 20 Nov 2001 22:13:58 +0100 Subject: Still on python GUI toolkit References: Message-ID: <20011120221358.3e520125.use-net@schabi.de> Hi, Am 20 Nov 2001 18:20:50 GMT schrieb Laurent Pointal: > For our futur projects (I work at on beamlines at LURE, Orsay-France), > we may go to the following architecture (still to be tested and > evaluated): > > > GUI in Java > | > CORBA ORB for Java (OpenORB or other) > | > | > | > CORBA ORB for Python (omniORBpy) > | > scripting and > processing in Python Did you thing about using Jython? You could click the gui objects together using your favourite RAD tool, and then use this gui out of a Jython program. Gru?, Markus -- You don't have to be Microsoft to suck... but it helps. (Tim Hammerquist in comp.lang.python) From apost at cbmi.upmc.edu Wed Nov 14 21:00:33 2001 From: apost at cbmi.upmc.edu (Andrew Post) Date: Wed, 14 Nov 2001 21:00:33 -0500 Subject: CGIHTTPServer and Win2k Message-ID: Hello, I'm the T/A for a programming class at the University of Pittsburgh, and we're using Python. We're trying to get the students to use CGIHTTPServer that's packaged with Python 2.1, but many of our students running Windows 2000 can't get the server to run CGI scripts. I'm having the same problem, unfortunately. The code we gave them to run the server follows: from BaseHTTPServer import HTTPServer from CGIHTTPServer import CGIHTTPRequestHandler import os print "Starting Python Web Server..." port = 80 os.chdir('C:/Documents and Settings/apost/Desktop/Python Web Server') servr = HTTPServer(('', port), CGIHTTPRequestHandler) servr.serve_forever() The server output follows: APOST2 - - [14/Nov/2001 20:55:42] "GET /ccl.html HTTP/1.1" 200 - APOST2 - - [14/Nov/2001 20:55:49] "GET /cgi-bin/creat_calc.py?age=70&weight=70&s Cr=1.7 HTTP/1.1" 200 - APOST2 - - [14/Nov/2001 20:55:49] command: C:\Python21\python.exe C:\Documents a nd Settings\apost\Desktop\Python Web Server\cgi-bin\creat_calc.py APOST2 - - [14/Nov/2001 20:55:49] CGI script exit status 0x2 IE 5.5 returns a blank page. Netscape 4.7 reports "The document contained no data". The code we gave them runs perfectly on WinNT. Some students are also getting a CGI script exit status 0x1, but I haven't been able to reproduce that one. Changing the form to use POST instead of GET generates the same error. Thanks in advance for your help, Andrew From skip at pobox.com Sat Nov 3 05:45:03 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 3 Nov 2001 04:45:03 -0600 Subject: Getting started In-Reply-To: <3BE361DE.89B01B1C@ix.netcom.com> References: <3BE34358.8819E585@ix.netcom.com> <9rvhf4$vjrgr$1@ID-11957.news.dfncis.de> <3BE361DE.89B01B1C@ix.netcom.com> Message-ID: <15331.51887.283949.462592@beluga.mojam.com> Jive> But isn't there a way to change directories (cd) from the Python Jive> command line? Yes, you can execute os.chdir: >>> import os >>> os.getcwd() '/home/skip/tmp' >>> os.chdir("/tmp") >>> os.getcwd() '/tmp' -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From hzhu at mars.localdomain Sat Nov 24 06:12:50 2001 From: hzhu at mars.localdomain (Huaiyu Zhu) Date: Sat, 24 Nov 2001 11:12:50 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: On Fri, 23 Nov 2001 17:31:51 +0000 (UTC), Marcin 'Qrczak' Kowalczyk wrote: >Wed, 21 Nov 2001 23:00:35 -0500, Dave Cinege pisze: > >> Not so. It's completely logical. A single byte, per indented block >> instead of some variable, arbitary number. > >This would be a bad idea: >- using tab width of any other size than 8 is evil, >- 8 is too much for indentation in programming; 2 to 4 is good. There are really two issues involved: If everything can be redesigned from scratch, what would be the best indentation method for languages like Python's? There is a strong argument for one tab character per indent level. When indentation is encoded as the number of tab charactors, code can be exchanged between different programmers completely unaffected by the display style. The editor might even display it as charactor like this: | `-> In this situation, what's the best distance between tab stops? If tabs were used to help reducing key strokes while typing a table on a typewriter, 8 makes most sense, because 8x8=64. When tab is used to indent programs, the most active range of indentation would be before the first 16 charactors, so a tab stop of 4 is more economical in terms of key strokes. However, whichever size set in any editor will not mess up the code in any other setting. The second question is whether it is wise to set tab to a size other than 8 in a world where many utilities expect it to be 8? I've been setting tab=4 in emacs for several years (before using Python) and there is no adverse effect, as long as certain precautions are taken: - set tab size in editor (emacs), pager (less) and formatter (enscript). - Do not forget tabify the code when space is suspected to have sneaked in. The only problemd I encountered came code from others which mixes tab with space. It rarely happens in my own code, because having different tab size between emacs and python means such code rarely goes unnoticed. As to the problem wiht copy-and-paste - one charactor per indent level is great. When the indent level changes, you just insert or remove a certain number of tabs to the whole block. Huaiyu From keyton at weissinger.org Tue Nov 27 22:08:41 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Tue, 27 Nov 2001 22:08:41 -0500 Subject: Finding a Specific Class's Instance in a List In-Reply-To: Message-ID: Howdy Gang. I have a list of several objects of various classes. I would like to most quickly find the first instance of a given class and am still new to Python. Is this the fastest way: class Class1: def __init__(self, pName): self.wvName = pName class Class2: def __init__(self, pName): self.wvName = pName class Class3: def __init__(self, pName): self.wvName = pName class Class4: def __init__(self, pName): self.wvName = pName if __name__ == "__main__": myList = [] myClass1A = Class1("Class1A") myClass1B = Class1("Class1B") myClass2 = Class2("Class2") myClass3 = Class3("Class3") myClass4 = Class4("Class4") myList.append(myClass1A) myList.append(myClass1B) myList.append(myClass2) myList.append(myClass3) myList.append(myClass4) print "My List:", myList i=0 for obj in myList: if obj.__class__ == Class2: print "Found it at", i i += 1 Thank you in advance... Keyton From mbonnifait at wanadoo.fr Wed Nov 14 12:08:10 2001 From: mbonnifait at wanadoo.fr (Michel Bonnifait) Date: Wed, 14 Nov 2001 18:08:10 +0100 Subject: help for beginner ! References: <9sr9g4$gik$1@wanadoo.fr> Message-ID: <9su8ed$1t6$1@wanadoo.fr> thanks for your answer. when i say "print' i mean to a printer and "copying etc;" i mean exactly what you understood "Cliff Wells" a ?crit dans le message de news: mailman.1005678515.14007.python-list at python.org... > On Tuesday 13 November 2001 06:07, Michel Bonnifait wrote: > > i want to directly print the list or the result of my program > > i'm working with idle and i don't know how to do it without copying in one > > printable document > > I'm sorry, I don't know exactly what you are trying to do. When you say > "print", do you mean to the screen or to an actual printer? By "copying in > one printable document" do you mean copying the output of your program into a > text editor that you can then print from? > > Are you running Windows or some variation of Unix/Linux? > > -- > Cliff Wells > Software Engineer > Logiplex Corporation (www.logiplex.net) > (503) 978-6726 x308 > (800) 735-0555 x308 > From greg at cosc.canterbury.ac.nz Wed Nov 28 18:33:33 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 29 Nov 2001 12:33:33 +1300 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C046EB4.55B36D9D@cosc.canterbury.ac.nz> <3C0502B0.1F73497C@sympatico.ca> Message-ID: <3C05744D.D52CBBF0@cosc.canterbury.ac.nz> "Colin J. Williams" wrote: > > What parsing problems would be created by: > > for 0 < i < 10, 3 > > to give 3, 6, 9? Probably it would be parsed as for 0 < i < (10, 3): Besides, it's getting away from the self-evident nature of my original suggestion, which is the only thing it really had going for it. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From davebutlerREMOVE at hotmail.com Mon Nov 12 14:08:19 2001 From: davebutlerREMOVE at hotmail.com (Dave Butler) Date: Mon, 12 Nov 2001 19:08:19 GMT Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> <3bf01850.1296461609@news1.on.sympatico.ca> Message-ID: Bob, Thank you very much. Dave "Robert Roy" wrote in message news:3bf01850.1296461609 at news1.on.sympatico.ca... > PythonWin and Tkinter do not play nicely together. > > See: > > http://www.python.org/topics/tkinter/trouble.html > > under windows gotchas > > Bob > > On Mon, 12 Nov 2001 17:38:08 GMT, "Dave Butler" > wrote: > > >I recently began exploring Tkinter programming. I built the following > >program based on similar code in a book: > > > >from Tkinter import * > > > >top = Tk() > > > >quit = Button(top, text='Quit', command=top.quit) > >quit.pack() > > > >mainloop() > > > > > >This simple "app" opens fine and closes when run from a command prompt > >(under Win2000). However, when run from PythonWin (win32all build 140) the > >app does not close and a few clicks later PythonWin crashes with a MS Visual > >C++ runtime error ("abnormal program termination"). > > > >Any explanations? Is PythonWin a stable platform for using Tkinter? > > > >Thanks, > > > >Dave > > > > > From sabren at manifestation.com Sun Nov 25 05:24:24 2001 From: sabren at manifestation.com (Michal Wallace) Date: Sun, 25 Nov 2001 05:24:24 -0500 (EST) Subject: Returning HTTP POST body from CGI module In-Reply-To: <97ae44ee.0111241108.f40c23a@posting.google.com> Message-ID: On 24 Nov 2001, Stephen wrote: > I have a Python CGI script receiving XML data via HTTP POST from > another company. Unfortunately, that company doesn't seem to > have implemented the HTTP protocol correctly. This is completely valid HTTP. They probably ought to have Content-Type header in there, but it's no big deal. > If I understand correctly, the body of a HTTP POST should be > URL-encoded, right ? Since they are sending XML data in the > HTTP body, and it is not URL-encoded, it's not really > compatible with the CGI module which will be looking for > variable/value pairs. Is it possible to access the raw > HTTP header and body from the CGI module instead ? > Or will I really have to write a socket handler to deal with > this ? CGI request content comes in on stdin. The cgi lib just parses it. The headers tend to show up in the environment, but I'm not sure any old header you send shows up there... The following program should give you access to the data though: #!/usr/bin/python import sys, os length = os.environ["CONTENT_LENGTH"] print sys.stdin.read(length) Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From phillip_david at xontech.com Mon Nov 26 18:48:26 2001 From: phillip_david at xontech.com (Phillip David) Date: Mon, 26 Nov 2001 15:48:26 -0800 Subject: (off-topic humor) While browsing google for python and turtle References: Message-ID: <3C02D4CA.2E02DA28@xontech.com> Cliff Wells wrote: > > On Friday 23 November 2001 09:39, Syver Enstad wrote: > > > With the Python, one can easily drain and refill over 150 gallons in > > less than an hour without lugging a bucket or sucking on a hose. > > Just one more advantage of Python over Java =) Yes, but Python doesn't have caffeine. :( From grante at visi.com Tue Nov 6 10:25:11 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 06 Nov 2001 15:25:11 GMT Subject: RE Module Question. References: Message-ID: In article , Corrado Gioannini wrote: > On Tue, Nov 06, 2001 at 05:49:38AM +0000, Paul Winkler wrote: > [snip] >> You can do it like so: >> >> test = "this is spam" >> if test.find("spam"): print "found it" > > this would fail if the sub-string to be found is at the beginning of the > string (find returning 0). It also fails if the string is not present, since find() returns a -1 in that case. -1 is true. -- Grant Edwards grante Yow! Can you MAIL a BEAN at CAKE? visi.com From adamspitz at bigfoot.com Wed Nov 14 15:13:08 2001 From: adamspitz at bigfoot.com (Adam Spitz) Date: 14 Nov 2001 12:13:08 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> Message-ID: <87f44f44.0111141213.4778982c@posting.google.com> Paul Prescod wrote: > Adam Spitz wrote: > > > > def MyClass_newMethod(self): > > print "new method" > > MyClass.newMethod = MyClass_newMethod > > > > I smiled just now when I realized that the Python version is actually > > fewer lines of code. :) But I still don't think it feels right. In > > Smalltalk and Ruby, I'm just using the standard mechanism for adding > > methods to a class. In Python, it feels like I'm sneakily hacking an > > extra method into a class against its will. (Does that make any sense? > > Maybe I'm being too touchy-feely. :) > > You are doing something sneaky in *any* language because if anyone else > defines newMethod in any other module anywhere in the system you'll > overwrite each other. Um... sort of. It's really not as sneaky as you think. It's part of the culture. We *expect* people to do things like that. We encourage it. You're right, though, that the potential consequences are just as bad in Ruby or Smalltalk. We just think that the advantages are worth it, that's all. Sometimes I'll be programming and I'll have a need for a certain method on the Array class, but it's not there. Or I'll write a string-manipulation method as part of another class, but then decide that it really ought to live in the String class. In most other languages, I feel a little twinge of annoyance. In Ruby or Smalltalk, I just go add the method. The biggest advantage by far, though, is that it encourages evolution. When you've got lots and lots of programmers out there thinking up new library methods and adding them and playing with them and tweaking them, the best ones are going to get proposed as additions to the standard library, and the standard library is going to get really good. (Ever hear a Smalltalker brag about how the Smalltalk class library is so amazing? Guess how it got that way.) Anyway, because this *is* a cultural issue, adding this feature isn't necessarily a good idea for Python. Your priorities are different, and I wouldn't be surprised if you decided that the risks are too high. (Maybe someone here could come up with a clever Python-ish way to get the same effect with less risk.) But this is the sort of thing that prevents me from embracing Python whole-heartedly. Adam Spitz From peter at engcorp.com Fri Nov 30 07:59:21 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 30 Nov 2001 07:59:21 -0500 Subject: New updates needed for an old computer language humor piece References: <3c070c3f$1_1@news.iprimus.com.au> Message-ID: <3C0782A9.C48A0FF1@engcorp.com> Skeleton Man wrote: > > You post this to a perl group and yet don't have one for perl ? *L*.. shame > on you... > > I would write one myself, but I'm much to busy doing useless things like > writing JAPH signatures that scroll Merry Christmas across the screen.. (see > below).. *L* > > ---- -Begin Xmas Signature------ Ohhh, you set yourself up for this one! TASK: Shoot yourself in the foot. Perl: > *__=*Time::HiRes::usleep=>my at m=map{$_+=$_%2?-1:+1}map ord, > split//=>'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////'. > 'Ldssx!Bishrul`r!`oe!`!I`qqx!Odv!Xd`s/////////'; > unshift @m=>(32)x at m;require Time::HiRes;for(0.. at m){ > print map(chr, at m[0..(@m/2-1)])=>"\b"x(@m/2);push at m=> > shift at m=>__(0170*0xA**3);} 'Nuff said? :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From LLoeffler at home.com Tue Nov 27 21:19:01 2001 From: LLoeffler at home.com (Luke) Date: Tue, 27 Nov 2001 20:19:01 -0600 Subject: Unhandled exception warning Message-ID: <3C044995.3010809@home.com> Having used Java for so long, I am used to being told during compilation that foo() throws an exception and that I need to catch it or throw it upward. In Python you obviously don't get such reminders until it's too late. Is there some script or IDE or something that can tell you that certain code may produce exceptions? I'm sure this isn't an issue for those that know the modules inside and out, but when you're getting started it can be quite frustrating for your program to die suddenly and then be told, oh, by the way, spam() is capable of producing such and such exceptions. L From brueckd at tbye.com Tue Nov 27 09:22:00 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Tue, 27 Nov 2001 06:22:00 -0800 (PST) Subject: poll() on a linux box always returns POLLIN In-Reply-To: <3C039E35.DD35CC02@spkypc.demon.co.uk> Message-ID: On Tue, 27 Nov 2001, ab wrote: > Just trying out some asynchronous socket operations in python, > simple client server test code. > > Anyway so I get a queue of threads going waiting to be passed sockets. > When they get a socket, I am using poll to implement timeouts. However > poll() always seems to return data ready POLLIN, even when client has > disconnected and finished. when reading the socket, 0 bytes of data is > returned, as you would expect with the peer disconnected ??? > any thoughts ??? When recv returns an empty string, it means that the connection is done, there's no more data, so it's time to quit. For example, the code to read all data from a socket synchronously looks like this: while 1: data = sock.recv(4096) if not data: break # do something with the data With asynch sockets it's about the same; your code that handles POLLIN should call recv and, if the string returned is empty, do whatever you need to do to handle the end of the connection (most likely remove your socket from the poller and close it). -Dave From lars at larsshack.org Sun Nov 11 01:28:09 2001 From: lars at larsshack.org (Lars Kellogg-Stedman) Date: Sun, 11 Nov 2001 06:28:09 GMT Subject: Splitting on a regex w/o consuming delimiter Message-ID: Howdy folks, Given a string such as: sample = 'one two @three @four five @six' I want to split it on the '@' character, but I want the '@' character to be retained in each sequence. That is, I'd like the above string split into: one two @three @four five @six I thought maybe this would work: sre.compile('(?=@)').split(sample) Since, according to the python documentation, '(?=pattern)' matches pattern without consuming anything. While it seemed like a good idea at the time, it doesn't work. Other than manually splitting the string, is there a more graceful solution? Thanks, -- Lars -- Lars Kellogg-Stedman --> http://www.larsshack.org/ From mal at lemburg.com Mon Nov 26 11:06:55 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 26 Nov 2001 17:06:55 +0100 Subject: Python on AIX References: Message-ID: <3C02689F.E749DC89@lemburg.com> marco wrote: > > Hi all, > > We just recently compiled Python 2.2b2 under AIX 4.3.3 > using gcc 2.8.1. I'll just post our experience in case > anybody finds it helpful. The original configure command > was: > > ./configure \ > --prefix=/usr/local/python-2.2b2 > > This uses cc_r (v. 5), and while this more or less worked, > there were many of the following warnings: > > cc_r: 1501-210 command option t contains an incorrect subargument > > Later there were other problems but these were not > really compiler-related (I did not know this at the time, > though). Furthermore cc_r did not seem to have the threads > problem I later encountered with gcc (and which are documented > in the README). So, in summary, cc_r would have probably worked -- > perhaps better than with gcc -- but we didn't go down > that road. Instead, we used the following: > > ./configure \ > --prefix=/usr/local/python-2.2b2 \ > --with-gcc > > and when trying to "make" got the following error: > > In file included from /usr/include/sys/thread.h:45, > from /usr/include/sys/ptrace.h:28, > from /usr/include/sys/proc.h:48, > from /usr/include/sys/pri.h:29, > from /usr/include/sys/sched.h:38, > from /usr/include/sched.h:52, > from /usr/include/pthread.h:43, > from Python/thread_pthread.h:6, > from Python/thread.c:117: > /usr/include/sys/var.h:116: parse error before `__cptr64' > . > [snip a lot] > . > Python/thread_pthread.h:135: warning: implicit declaration of function `pthread_init' > make: 1254-004 The error code from the last command is 1. > > As I mentioned above, this is documented in the README. We > got around it by using: > > ./configure \ > --prefix=/usr/local/python-2.2b2 \ > --with-gcc \ > --with-threads=no > > The "make" then died with the following error: > > ./Modules/makexp_aix Modules/python.exp "" libpython2.2.a; -Wl,-bE:Modules/python.exp -lld -o python Modules/python.o libpython2.2.a -ldl -lm > /bin/sh: -Wl,-bE:Modules/python.exp: not found. > make: 1254-004 The error code from the last command is 127. > > Notice the space after the ";". Indeed, looking at the results > from the configure script we see: > > checking LINKCC... ./configure[1417]: LINKCC: not found > $(srcdir)/Modules/makexp_aix Modules/python.exp "" $(LIBRARY); > > Lines 1415 to 1417 of "configure" are as follows: > > case $ac_sys_system in > AIX*) > LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $(LINKCC)";; > > The problem turned out to be extra parenthesis around $(LINKCC). It should > read: > > AIX*) > LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; > > The lines after that read: > > dgux*) > LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; > Monterey64*) > LINKCC="$(LINKCC) -L/usr/lib/ia64l64";; > esac > > Presumably these too have extra ()s. > > Once that was fixed there were further complaints along the following > lines: > > WARNING: building of extension "fcntl" failed: command '/usr/local/python-2.2a4/lib/python2.2/ld_so_aix' failed with exit status 1 > > There seemed to be some confusion between the source directory > and the installation directory (which was set with --prefix to be > /usr/local/python-2.2b2). The file it was looking for was in fact > under the "Modules" subdirectory within the Python source tree. > The simplest workaround was to copy the files it wanted to the > appropriate location. These were: > > ld_so_aix > makexp_aix > python.exp > > Once copied into /usr/local/python-2.2a4/lib/python2.2/ we > re-ran the configure ; make ; make install. The following failed: > > /usr/local/src2/marco/Python-2.2b2/Modules/socketmodule.c: In function `PyH_Err': > /usr/local/src2/marco/Python-2.2b2/Modules/socketmodule.c:432: warning: implicit declaration of function `hstrerror' > WARNING: building of extension "_socket" failed: command 'gcc' failed with exit status 1 > > /usr/local/src2/marco/Python-2.2b2/Modules/_cursesmodule.c:2348: too few arguments to function `tparm' > WARNING: building of extension "_curses" failed: command 'gcc' failed with exit status 1 > > /usr/local/src2/marco/Python-2.2b2/Modules/_curses_panel.c:17: panel.h: No such file or directory > WARNING: building of extension "_curses_panel" failed: command 'gcc' failed with exit status 1 > > However, we can live for now without the socket and curses modules. Other > than that Python seems to be OK. Note that precompiled Python binaries (in > RPM form) are available for AIX at: > http://www-1.ibm.com/servers/aix/products/aixos/linux/download.html > > We haven't tried those, though. Still, we hope this is helpful for > people trying to perform the compilation on their own, and to the > Python developers by letting them know about the glitches we encountered. Some tips: * Make sure that you always use GNU make on AIX -- the one shipped with AIX is braindead. * AIX is a mixed 32-bit/64-bit platform -- this results in a whole bunch of problems; one thing to make sure is that you always use the same bit-length for the interpreter, the extensions and the libs you link against. Tip: use the same compiler, make and optimization options for all parts of the product build process. * Try to compile Python using ./configure --without-gcc make CC=cc_r OPT="-O2 -qmaxmem=4000" install Please upload your findings to the Python bug tracker; the socket module should definitely build on AIX, not sure about fcntl and curses. BTW, does anyone know how well Python runs on the new AIX 5L ? -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From chrishbarker at home.net Fri Nov 16 15:56:17 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 16 Nov 2001 12:56:17 -0800 Subject: python vs ecmascript References: Message-ID: <3BF57D71.F903C64D@home.net> I know nothing about ECMAscript, but I have a couple of comments about your supposed Python limitations: Peoter Veili wrote: > I am also a bit annoyed at some things like having to wrap objects in a str() > before printing, I don't see why this can't be automatic. HUH? it is automatic. print x works for any object that has defined a __str__ method, which includes the built in types, and indeed, works for any object that str(x) works for. > This thing about only having > two scopes, local and global, That's not quite true. nested scopes are being introduced, and Python has forever had a very flexible module namespace system. Each module had it's own namespace. "Global" refers to the module, so you really can have any number of "global" namespaces. IN fact, there is no truely global namespace at all. As another poster suggested, any new language will seem to be missing important features if you expect it to behave the same as another language. If you try to think about how to solve your problem in Python, rather than how to use python to solve it the same way you would in another language, you will find that Python is very powerful language for a very wide variety of tasks. Note also that while Python is an excellent language for programming for the web, it is designed to be general purpose, and in dome ways may not be as perfectly suited to any particular problem domain as a language that was designed just for that domain. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From prabhu at aero.iitm.ernet.in Wed Nov 14 23:02:24 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Thu, 15 Nov 2001 09:32:24 +0530 Subject: Problem with .pth files under linux In-Reply-To: References: Message-ID: <15347.15952.220589.431874@monster.linux.in> >>>>> "FP" == fperez writes: [snip] FP> So the point is, your .pth files have to be in your normal FP> site-packages hierarchy. But my problem is that my python is FP> installed in /usr, but I also have a FP> /usr/local/lib/python2.1/site-packages directory where I put FP> things I get off the web. I like it that way because when I FP> upgrade linux, I can just let the installer wipe /usr and all FP> the things I have in /usr/local remain. FP> Since the searcher will only expand on sys.prefix and FP> sys.exec_prefix (and it's a *bad* idea changing these to FP> anything that's not your real python directory), things that FP> are not under that will not be easily found (as .pth files). Hmm. This is the reason why Debian as a Linux distro rocks. Debian modifies site.py so that it also searches in /usr/local/lib/pythonX.Y/site-packages !! It does this by modifying site.py slightly like so: Original site.py: prefixes = [sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(sys.exec_prefix) Debian's version: prefixes = [os.path.join(sys.prefix, "local"), sys.prefix] if sys.exec_prefix != sys.prefix: prefixes.append(os.path.join(sys.exec_prefix, "local")) prefixes.append(sys.exec_prefix) Obviously very thoughtful, correct and convenient. :) Another work around in your case would be to stick your Numeric.pth alone (with an absolute path) inside /usr/lib/pythonX.Y/site-packages. Nnumeric.pth: /usr/local/lib/pythonX.Y/site-packages/Numeric prabhu From daves_spam_dodging_account at yahoo.com Tue Nov 20 19:20:48 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Tue, 20 Nov 2001 16:20:48 -0800 (PST) Subject: DDE Client? Message-ID: <20011121002048.53604.qmail@web21109.mail.yahoo.com> Hi all, Recently I asked how Python could be used to perform DDE, and the answer I got was something like "check out win32all", which I have done. I am now at wit's end. I have an application running that has a DDE server in it. I know the name of server, the topic, and the item I want to retrieve from it. I imagine from reading ActiveState's documentation that if I have a PyDDEConv object handy, I can call its Connect(server,topic) method to get the topic, from which I can get an item, from which I can make requests. So, the question of the hour is, how in the heck do I get a PyDDEConv object in the first place? Thanks, -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From peter at engcorp.com Wed Nov 14 08:13:09 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 14 Nov 2001 08:13:09 -0500 Subject: Stopping exception unwinding at exit References: Message-ID: <3BF26DE5.80C3D4B9@engcorp.com> Michael Hudson wrote: > > "Sean 'Shaleh' Perry" writes: > > > On a related note, is there a way to tell python to NEVER drop a trace? [...] > Of course, if you can hit ^C *really* quickly, you can do it before > you can do either of these things. Isn't the first line of site.py the very first code to be executed? Or is there something else that comes before? It should be possible to hook something soon enough that you *can't* hit ^C too soon. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From mwh at python.net Fri Nov 23 05:16:37 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 23 Nov 2001 10:16:37 GMT Subject: assigning to nested variables References: Message-ID: John Thingstad writes: > I tried to create the followin callback function in Python 2.1 > > from __future__ import nested_scopes > > def ask(self, pattern): > """Ask > Ask if query sentence is true; return 0 otherwise 1.""" > cPattern = self.convertClause(pattern) > > found = 0 > def match(bindings): global found; found = 1; return 1 > self.backChainEach(cPattern, match) > return found > > The ide was to assign 1 to found if the match callback function was > called. > However, found = 1 creates a new local variable found and ask's > found variable remains zero. I don't think that's what's going on actually. There are three scopes at play: ,-----------------------------, | global scope | | ,-------------------------, | | | ask's local scope | | | | ,---------------------, | | | | | match's local scope | | | | | `---------------------' | | | `-------------------------' | `-----------------------------' There are two variables called "found"; one is in the global scope, one is in ask's local scope. The assignment in match affects the one in global scope. If there was no "global found" statement in match, then there would still be too variables called "found", one in ask's local scope and one in match's, and the assignment would affect the latter. > Is there a way to assign 1 to ask's found? Not from match's scope, no. Here's one workaround: class Finder: def __init__(self): self.found = 0 def match(self, bindings): self.found = 1 [...] def ask(self, pattern): cPattern = self.convertClause(pattern) finder = Finder() self.backChainEach(cPattern, finder.match) return finder.found but it looks like you've provided yourself a pretty inconvenient interface to work with. > I read the documantation but found no refrerence to this. It's implied but not spelled out in: http://python.sourceforge.net/devel-docs/ref/definitions.html Cheers, M. -- Unfortunately, nigh the whole world is now duped into thinking that silly fill-in forms on web pages is the way to do user interfaces. -- Erik Naggum, comp.lang.lisp From d_blade8 at hotmail.com Mon Nov 12 17:15:57 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 12 Nov 2001 14:15:57 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> Message-ID: <7396d2b2.0111121415.3c6f18ed@posting.google.com> Thanks for the input, I guess I should clarify a little too. I started learning Python on the recommendation of a friend, for a problem closely related to the one here. I started writing this program when I was reading "Learning Python" so the version I'm posting has me doing a lot of things "the hard way." To create an Excel file, for example, I just save to an .xls file (as opposed to using Dispatch from the win32all package, which I didn't know how to use when I started). The problem now, is that I'm still learning the whole Win32 thing and interfacing with COM. I am working my way through it/around it but I still am trying to learn for next time. Thanks. Here is some of the code (any imported functions I left out and will just give comments on to save space): if __name__ == "__main__": fin = open(r"accessionlist.txt", 'r') #open a file with the info we want to search and read it orig = fin.readlines() fin.close() fout = open(r"accessionnolinks.xls", 'w') #open a file to write to, xls makes it an excel file under windows fout.write("Accession Number\tUnigene Link\n") # write to file, tabs move between cells for file in orig: # for each piece of info seperated by a newline file = getsetnums(file) #get correct format of number (drop spaces, etc.) if file != 'X': # A control, if the info fits special parameters, I know it is invalid and change it to X so I don't deal with it later fout.write(makewebpage(file)+ '\n') # create the link using the accession number and the NCBI cgi Query, returns a hyperlink fout.close() What ends up happening is everything works correctly, but I get http:\\Mylinkishere.com but it isn't an actual link until you go into the cell and hit enter manually. I've thought about just making a macro to do just that, but that won't teach me how to do it with python, if you know what I mean. Thanks and I hope that is enough info for you. Peter Hansen wrote in message news:<3BEF67B0.31ED5766 at engcorp.com>... > Lemniscate wrote: > > > > I made a program that takes input from a file (text file with \n > > splits). I search a public database and find more links (using the > > urllib.urlopen function). I want to plug these links into Excel and > > have them as functional links, but all I get is text (a Unicode > > translation thing, I assume). > > You don't say how you are getting the links into Excel? Are > you using the win32com package and using the Excel Object Model > directly from Python? If that's the case, you need to look > up the relevant information in the Excel docs. I found this tidbit: > > """ > Use the Add method to create a hyperlink and add it to the Hyperlinks collection. The following example creates > a new hyperlink for cell E5. > > With Worksheets(1) > .Hyperlinks.Add .Range("E5"), "http://www.gohere.com" > End With > """ > > > Is there a way to modify the output so > > that they will show up as links in Excel? I can send my code to > > anybody who wants to see it (it is big and hairy so I don't want to > > waste the space here). > > Big and hairy isn't good, but can't you summarize the relevant portions > and post them? It takes a little work, but ensures the quality > of the answers is higher... From astrand at lysator.liu.se Mon Nov 12 17:14:39 2001 From: astrand at lysator.liu.se (=?iso-8859-1?Q?Peter_=C5strand?=) Date: Mon, 12 Nov 2001 23:14:39 +0100 (CET) Subject: Linux/Alpha memory leaks Message-ID: I have some problems with memory leaks in a web application, written in Python. It works good on Sparc/Solaris and Linux/i386 (uses < 10 MB on these platforms), but in Linux/Alpha the application consumes > 50 MB in less than 24 hours. Since the Python application works good on two other platforms, I assume the problem is either Python or glibc. More details: The application is "WebKOM" (available from http://www.lysator.liu.se/lyskom/klienter/webkom/). It's an threaded FastCGI-application. The Alpha system, which leaks memory, is a RedHat 7.1 with latest upgrades. I've also tried RedHat 6.2. I've tried Python 2.1.1 and 2.2b1+, compiled with gcc 3.0.2. The app uses the following modules: cgi codeop cStringIO dircache errno fcgi Formtools gettext HTMLcolors HTMLgen HTMLutil os os.path popen2 pwd random re readline select socket stat string sys sz_fcgi thread time traceback types Any ideas or hints on how I can debug this problem? -- /Peter ?strand From phr-n2001d at nightsong.com Fri Nov 2 23:08:08 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 20:08:08 -0800 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> <7xn1257h0d.fsf@ruckus.brouhaha.com> Message-ID: <7xhescmr87.fsf@ruckus.brouhaha.com> "Leo Lipelis" writes: > Ok looking at above it's not possible. But how about here: > > ---begin script--- > def foo(frob): > x = frob.mumble() > > foo("String") # let's assume that string class has mumble method > foo(5) > foo(gdbm.open("bar", "rf")) > ---end script--- > > At some point you do know the type. You just have to infer it. I agree > that makes it more difficult than in Java. In real Python code the way people write it, I don't think you can infer types that way often enough to be useful. Try another language, like ML. From vze2q3xh at verizon.net Thu Nov 15 22:05:27 2001 From: vze2q3xh at verizon.net (Tech) Date: Fri, 16 Nov 2001 03:05:27 GMT Subject: PIL Installation on windows98 - from newbie Message-ID: Hello all, I would love to try to write an imaging app using the PIL, but I can even get it installed. I try reading all the documentation I could find on the subject, but nothing helped. Would some please help me. Thanks for your time, Tech. From mwh at python.net Thu Nov 8 11:15:58 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 8 Nov 2001 16:15:58 GMT Subject: variable function call References: <9se9i2$972fn$1@hades.rz.uni-sb.de> Message-ID: Uwe Schmitt writes: > Hi, > > I'd like to write a wrapper-function which takes a function and a > variable parameter-list like this: > > > def wrapper(fun, *args): > > ... do some checks ... > > fun(args) fun(*args) HTH. Python 2 or better (or was it 1.6?). Cheers, M. -- If you have too much free time and can't think of a better way to spend it than reading Slashdot, you need a hobby, a job, or both. -- http://www.cs.washington.edu/homes/klee/misc/slashdot.html#faq From tatebll at aol.com Wed Nov 14 09:01:31 2001 From: tatebll at aol.com (Bill Tate) Date: 14 Nov 2001 06:01:31 -0800 Subject: Request for Validation of Python as Development Language References: Message-ID: "A. Keyton Weissinger" wrote in message news:... > Does anyone have a more recent list of commercial products out there that > use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima > Online. I'd like more. > > The information in the books and the python.org site is a bit dated. Journyx Webware for python. In my last job, python is at the core of an internet-based ASP service and an intranet version of the ASP service that is sold as a product to post-production houses. NDA applies here, but safe to say there was nothing toy-like or trivial about our use of python. I don't know how many "shrink-wrap" solutions that are based entirely on python. I think your more likely to find Python is used as part of a multi-language code base for custom-built applications. In my case, most of my work has involved using Python to build a suite of integrated tools to support GIS and environmental modeling investigations that I was part of. Using COM objects for GIS, I've built front-ends in Python that access these COM objects and which hand off a lot of the visualization, data-laundering, and reporting stuff to standard python modules and extensions. While some "core" services were provided by COM objects, there was a substantial amount of python code that supported all the steps in between such as data laundering, storing/extracting the data from an RDBMS, restructuring data for input to various models (often written in fortran), reporting, data visualization, etc., etc. For these situations, I'll take Python anyday. It may not be sexy but the reality is often that not everything is nice and tidy. From danielk at aracnet.com Sun Nov 18 10:40:32 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 18 Nov 2001 07:40:32 -0800 Subject: Python IDE Opinion Request References: <2a6e94ef.0111170759.5fe7027a@posting.google.com> Message-ID: I was disappointed with the Python mode of VSE. The one thing that turned me off was the 'View > Function Headings"; it doesn't show the 'class' lines, so if there are 10 classes in a module, each with an '__init__' method, you will see all the '__init__' methods but won't know which class they belong to. Likewise for any other method that appears in more than one class. I've submitted this as a 'bug' to MicroEdge, they've acknowledged it and said it would be fixed in a future release, but I'm dubious that this will recieve a very high priority. Sorry, I can't provide advise on other IDE's as I have only used IDLE and Komodo to date. Daniel Klein On Sat, 17 Nov 2001 23:26:00 -0500, "A. Keyton Weissinger" wrote: >Hello All, > >I am a recent inductee into the Pythonista Cult. I use MicroEdge's Visual >SlickEdit (mostly so I can go back and forth with Python and Java, and Perl >and Java, and HTML and Java, etc). > >However, I've played with a few of the Python IDEs out there. Some are nice, >some are cute. None soom the "obvious" choice. > >Questions: >0) This question must have been asked before. Can someone point me in the >direction of the last set of answers? >[If not:] >1) Do you use a code editor (SlickEdit, emacs, etc) or an IDE (IDLE, etc)? >Why? >2) Are there any IDEs out there that allow me to do UIs easily (ala VB)? I >don't want a big code generator, but being able to drag and drop some simple >forms would be nice... >3) Does anyone out there use SlickEdit for Python? Any tips and tricks for >that combo? > >Thank you all. I know I'm telling you nothing you don't already know, but >Python rocks! > >Why is it not out there more???? > >Regards, > >Keyton > From kragen at canonical.org Sat Nov 24 01:40:53 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 24 Nov 2001 01:40:53 -0500 Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: <83itc0vfgq.fsf@panacea.canonical.org> "MANUEL FERNANDEZ PEREZ" writes: > Hello, > I'm looking for an editor for Python.I' m interested it works on Windows.Can > anybody help me? I used XEmacs last time I was doing this. It runs on Windows (as well as anything else, so you won't get left behind when Windows dies), is good at handling hundreds of open files totalling gigabytes open in multiple windows, does syntax-highlighting of Python (and C, and Fortran, and Perl, and SQL, and Tcl, and 16 other languages, out of the box), is reasonably fast, has automatic name completion with alt-/, auto-saves your files once a minute or so (to a special auto-save file, not on top of the original) so your machine crashing doesn't lose you any work, and has more good programmers using it than any other editor. I've also used Vim on Windows. Many of the same things can be said about it. Editors are rather a religious issue. From ngps at madcap.dyndns.org Mon Nov 26 10:39:57 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 26 Nov 2001 15:39:57 GMT Subject: HOWTO: Programming S/MIME in Python with M2Crypto References: Message-ID: <9ttnod$kvc$1@clematis.singnet.com.sg> According to Graeme Longman : > I've been trying to attach digital signatures to mime strings using the > M2Crypto package by using the examples in the HOWTO at : > > http://www.post1.com/home/ngps/m2/howto.smime.html > > Does anyone know if this is because I am using Outlook to receive the mail > or if this is because there has been an error in the mime string ? I've never used Outlook, so I've never tested M2Crypto.SMIME with it. I'm interested in doing so, though. Do you have pointers on how to set up Outlook with certs, keys and such? I use FreeBSD and I have no idea how to do this with Outlook. -- Ng Pheng Siong * http://www.post1.com/home/ngps From fredrik at pythonware.com Tue Nov 6 19:51:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 00:51:13 GMT Subject: How much is set in stone? References: <3BE8724E.7482C881@ix.netcom.com> Message-ID: <5A%F7.4682$R43.747319@newsb.telia.net> Jive Dadson wrote: > I expected better from this group. well, I expected better from you. From James_Althoff at i2.com Fri Nov 2 12:34:00 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 2 Nov 2001 09:34:00 -0800 Subject: Exception handling wart in Python Message-ID: "Leo Lipelis" wrote: > Leo "__who_doesnt_like_underscores_and_many_selves_at_all__" Lipelis > > P.S.: The double leading underscore is the ugliest thing I've ever > seen in language syntax. But to be fair, you have to admit it's only *half* as ugly as the double leading underscore plus double *trailing* underscore convention (I know, it's *suppose* to be ugly -- and it succeeds admirably in this regard! ;-) (Assuming here, for simplicity, that ugliness is linear). Jim From grey at despair.dmiyu.org Fri Nov 30 18:29:36 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 30 Nov 2001 23:29:36 -0000 Subject: Indenting with tabs vs spaces References: Message-ID: On Sat, 24 Nov 2001 19:54:34 -0500, Dave Cinege wrote: > A tab has a byte value of '9'. How it's is displayed is completely arbitary, > subjective, and the job of your editor. The fact the file will look > different between editors is a good thing. The idea all source files should > not be able to be displayed any otherway then how the author first created > them is: _Smart_ This is because, as Python has shown, formatting does mean something. That is why indention is important to the language and not just there for the programmers as in other languages. It is a visual representation of the meaning of code. Furthermore there are times, even in Python, where something is better displayed visually even though it is not required by the language. For example: some_dict = {'Jane':{'Age':'21', 'Dept':'0001', 'Ext':'1234'}, 'John':{'Age':'22', 'Dept':'0010', 'Ext':'5678'}, 'Jeff':{'Age':'23', 'Dept':'0100', 'Ext':'9009'}, 'Jody':{'Age':'24', 'Dept':'1000', 'Ext':'8765'}, 'Jeny':{'Age':'25', 'Dept':'0110', 'Ext':'4321'} } Yeah, yeah, we'll most likely be reading from a database for things of this nature and it is an overly simplistic example, however, it points out a valid point. My intent, as the original author, is better read in the format that I have presented. Tabs undermine this formatting. What if I use 4 and you use 8? some_dict = {'Jane':{'Age':'21', 'Dept':'0001', 'Ext':'1234'}, 'John':{'Age':'22', 'Dept':'0010', 'Ext':'5678'}, 'Jeff':{'Age':'23', 'Dept':'0100', 'Ext':'9009'}, 'Jody':{'Age':'24', 'Dept':'1000', 'Ext':'8765'}, 'Jeny':{'Age':'25', 'Dept':'0110', 'Ext':'4321'} } The other way around? some_dict = {'Jane':{'Age':'21', 'Dept':'0001', 'Ext':'1234'}, 'John':{'Age':'22', 'Dept':'0010', 'Ext':'5678'}, 'Jeff':{'Age':'23', 'Dept':'0100', 'Ext':'9009'}, 'Jody':{'Age':'24', 'Dept':'1000', 'Ext':'8765'}, 'Jeny':{'Age':'25', 'Dept':'0110', 'Ext':'4321'} } Are you prepared to say that either of those is far more readable than the first example? And yes, we can say "Well what if the person uses crappy formatting." Then they used crappy formatting and nothing will help that but reformatting. However, the tools we use should not undermine our intent and meaning when we use formatting to increase readability. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From jeff at ccvcorp.com Fri Nov 23 18:56:33 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 23 Nov 2001 15:56:33 -0800 Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> <3BFEC93C.78DB7D98@ccvcorp.com> <29AL7.2768$nK1.269290698@newssvr14.news.prodigy.com> Message-ID: <3BFEE231.26CABB58@ccvcorp.com> Keith Farmer wrote: > "Jeff Shannon" wrote in message > news:3BFEC93C.78DB7D98 at ccvcorp.com... > > you're doing repeated runs of the same script, you can run DOSkey and then > > you can repeat the command with up-arrow. > > Actually (at least under Win2k, I think under Win98), DOS already supports > up-arrow history. Almost--cmd.exe is the standard console for Win2k and WinNT (and presumably WinXP), and supports command history; command.com is the standard console for Win95/98/ME, and doesn't support history without the use of DOSkey. Actually, from what I've heard/read, command.com is a pretty weak excuse for a shell, in general, but cmd.exe is fairly decent... but my familiarity with the NT flavors is almost nil. Jeff Shannon Technician/Programmer Credit International From zope at thewebsons.com Sun Nov 18 17:08:05 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sun, 18 Nov 2001 14:08:05 -0800 Subject: No, not THAT Python, THIS Python! Message-ID: <5.1.0.14.0.20011118140515.00a0fec0@thewebsons.com> Hi; My server has 2 installations of python: 1.5 and 2.1.1. Now that Zope uses 2+, I've switched everything over. I'd like to install Tkinter, but when I try to install the rpm for 2.1.1 I get an error instructing me that I need Python 2.1.1 in order to proceed. How do I inform Linux (RH 7.1) that I do indeed have python2-2.1.1? TIA, BenO From qrczak at knm.org.pl Fri Nov 9 12:11:45 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 9 Nov 2001 17:11:45 +0000 (UTC) Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: Fri, 9 Nov 2001 10:48:19 -0500 (EST), Steven D. Majewski pisze: >> So under the proposed scenario, if one looks at 10 and asks "if >> 10 were to return an iterator, what would that iterator iterate >> over?", then it seems that range(10) would be a more *useful* >> answer than a sequence of one element 10. > > I wouldn't be against 'iter(10)' returning an iterator but having > 10 BE an iterator is too much of a surprise. The 'for' loop doesn't need an iterator. It needs something such that iter(something) is an iterator. There is no need to make 10 an iterator if we want 'for i in 10'. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From loewis at informatik.hu-berlin.de Mon Nov 26 04:46:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Nov 2001 10:46:21 +0100 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> <9tsfls$7q2$1@news8.svr.pol.co.uk> Message-ID: "Duncan Smith" writes: > Thanks for the reply. Basically I have an XML file containing data > that I need as various Python objects (strings, lists, arrays etc.). > I don't need to make changes to XML files, although I might want to > write data to new XML files of the same type (same DTD). I see. In that case, I recommend to use plain print statements to generate the XML (or other means of string processing, like collecting pieces of the document in a list). This is easier than generating a DOM or SAX in-memory representation, and then serializing it. > (I don't really want to have to learn about XSL, XSLT, X-path, SAX, > DOM, Pyxie etc. unless I know it's going to be useful.) Depending on the exact processing job, XSLT may be indeed useful. If you know that the output only depends on the input, then writing a style sheet that does the transformation, without writing a line of Python, might be possible. > Learning all that lot would be a lot of effort to achieve what I > need. So if you (or anyone) could give me advice along the lines of > "DOM would be appropriate but you'll have to know... as well", then > I'd be grateful. DOM alone will allow you to get all information from the document, in a moderatly convenient way. If you find to that you write algorithms of the kind Starting from the root, go to the first child element "foo", then to the last child element "bar", and take its "foobar" attribute value than XPath would help to tighten your code. > Martin, you were bang on with the 'invalid XML' thing. Cheers. That's a phrase (to be bang on) that is beyond my English understanding. I take it to mean something good, in absence of a clear understanding :-) Regards, Martin From emile at fenx.com Thu Nov 1 16:31:51 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Nov 2001 13:31:51 -0800 Subject: open vs. open References: Message-ID: <9rsf9l$ufi0q$1@ID-11957.news.dfncis.de> "Armin Steinhoff" wrote in message news:ddc19db7.0111011314.14bb657 at posting.google.com... > Hi all, > > I'm surely not the first one who was trapping into the > '__builtin__.open vs. os.open' problem. > > Question: is it possible to rename the __builtin__.open call to > __builtin__.fopen because it does really a fopen library call?? Yes. > > Or does it break something ?? > Probably. It sounds like you're doing from os import open. Why not import os, then refer to os.open? Emile van Sebille emile at fenx.com From timo.savola at iki.fi Sat Nov 17 14:05:31 2001 From: timo.savola at iki.fi (Timo Savola) Date: 17 Nov 2001 21:05:31 +0200 Subject: Boost.Python, callbacks and inheritance In-Reply-To: References: Message-ID: <1006023931.505.2.camel@misato> On Fri, 2001-11-09 at 13:45, Michael Hudson wrote: > Timo Savola writes: > > > Now I'm doing an extension module, or rather a system that I want to > > control via Python. I have a C++ class hierarchy that I want to be > > accessible from Python. > > Have you looked at Boost::Python? I haven't, but I've heard it's good > for this sort of thing. I've now converted my code to use Boost.Python and quite happy with it. But I do have one major problem. I have a C++ class (Color) with only pure virtual methods. All other classes with methods that have Color as the type of their argument obviously always get an instance of a class derived from Color. One of these other classes (ColorStream) also has only pure virtual methods, and is meant to be implemented with Python. class Color { virtual float red() = 0; virtual float green() = 0; virtual float blue() = 0; } class_builder color(module, "Color"); color.def(&Color::red, "red"); color.def(&Color::green, "green"); color.def(&Color::blue, "blue"); class ColorStream { virtual void put(Color &) = 0; } struct ColorStreamCallback : ColorStream { ColorStreamCallback(PyObject *s) { self = s; } void put(Color &color) { callback::call_method(self, "put", color); } private: PyObject *self; } class_builder color_stream(module, "ColorStream"); color_stream.def(constructor<>()); The problem surfaces in the put function of ColorStreamCallback. The call_method function of callback doesn't accept the reference to the non-concrete Color. I tried playing around with auto_ptr, but just ended up with incomprehensible errors with template unrolling. I'm more or less clueless. Timo From karthikg at aztec.soft.net Mon Nov 19 08:11:04 2001 From: karthikg at aztec.soft.net (karthik Guru) Date: Mon, 19 Nov 2001 18:41:04 +0530 Subject: Newbie question abt __getitem__ and __iter__ In-Reply-To: Message-ID: hi all, what other languages support treating a class as a collection of objects and allowing indexed access to it's constituents? I also liked the iter() concept and the way it works. I saw C# adopting both these things. But which language supported it first? thanks, karthik. From fredrik at pythonware.com Thu Nov 22 18:13:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Nov 2001 23:13:13 GMT Subject: PLEASE OH PLEASE UNSUBSCRIBE ME! References: <3BF95C82.A5688F06@nrc.ca> <3BFA9EEF.61CFBC43@nrc.ca> Message-ID: Alain D?silets wrote: > NO, I can't unsubsrcribe through the web or mail interface because I don't > know my stupid password. It doesn't seem to be any of the ones I typically > use. go to this page: http://mail.python.org/mailman/listinfo/python-list click on the "visit subscriber list" button find the mail address you're subscribed under (the address you used to send this mail doesn't appear in that list), click on that address, and then click on the "email my password to me". wait until the mail arrives, paste the password into the password field, and click "unsubscribe" From achim.domma at syynx.de Tue Nov 6 11:05:32 2001 From: achim.domma at syynx.de (Achim Domma) Date: Tue, 6 Nov 2001 17:05:32 +0100 Subject: count in 'for ... in ...' References: <9s90mr$osk$00$1@news.t-online.com> <9s91c3$94mgs$1@hades.rz.uni-sb.de> Message-ID: <9s91je$2o0$01$1@news.t-online.com> "Uwe Schmitt" wrote in message news:9s91c3$94mgs$1 at hades.rz.uni-sb.de... > | for i in range(len(my_list)): > | print i,". ",my_list[i] > What about the following ? > > idx=0 > for s in my_list: > print idx,".",s > idx+=1 two more lines ... not better, isn't it ? ;-) Achim From loewis at informatik.hu-berlin.de Fri Nov 9 08:05:49 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Nov 2001 14:05:49 +0100 Subject: GC question References: <20011108111846.A12007@glacier.arctrix.com> Message-ID: Kerim Borchaev writes: > I'm trying to control memory leakage in my code. > I need to know which objects wasn't deallocated in proper moment. Then using DEBUG_LEAK is the right approach. I still don't know what "problem" you've encountered. When you write def fun(): class C: def m(self): g = C() fun() you *will* create an unreferenced cycle. You should know that the implementation of nested scopes creates "cell" objects, which are holders for variables in nested scopes. Since "C" is a name used in a nested scope, a cell object is introduced for C. That gives you the cycle cellobject -> class C -> C.__dict__ -> C.m -> C.m.co_freevars -> cellobject HTH, Martin From chrishbarker at home.net Thu Nov 29 16:58:53 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 13:58:53 -0800 Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Message-ID: <3C06AF9D.E6DEB295@home.net> Dan Allen wrote: > Say I have > > mylist = ['one','two','three'] > > which I presume is a "tuple" as I have been scanning the manual. Now, Actually, no. It is a "list". It would be a tuple if you had built it like this: mylist = ('one','two','three') Parentheses rather than square brackets. The difference is that lists are mutable (can be changed in place) and tuples care not. > is there a way to run the php-like function in_array() on this. Are you looking for "in" >>> s = 'four' >>> if s in mylist: ... print s, " is in the list" ... else: ... print s, " is not in the list" ... four is not in the list > d = {} > for value in mylist > d[value] = 1 > try: > if d['four']: > print "your value was found" > except: > print "your value was not found" well, it's not very Pythonic in a number of ways: People do use dictionaries to simulate sets, but building it just for this is kind of overkill. If you are using a dict as a set, you can use the d.haskey() function, rather than your try:except. if you do use a try: except, in general, it is better to catch just the exception you are looking for: >>> try: ... d['four'] ... except KeyError: ... print "your value was not found" Also, you don't need the if d['four']: in fact, I think is is a syntax error, as there is no block inside the if..: If "in" didn't exist the obvious (to me) way to do it would be: >>> for i in mylist: ... if i == 'four': ... print "four is in the list" ... break ... else: ... print "four is not in the list" The for...else... is a little wierd at first, but handy for this kind of thing. By the way, you might want to get on the Python tutor mailing list. We're pretty helpful here, but a list designed for beginners may be more useful: http://mail.python.org/mailman/listinfo/tutor -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From ol1 at v10a.com Fri Nov 16 08:29:40 2001 From: ol1 at v10a.com (op) Date: Fri, 16 Nov 2001 14:29:40 +0100 Subject: Sparse matrix module that works Message-ID: <200111161329.fAGDTiv17156@smtp.wineasy.se> I'll be doing some stuff that involves sparse matrices. So far I've found three contenders for this task, two modules and a cookbook recipe. Sparsepy from Travis Oliphant http://pylab.sourceforge.net/ ASPN cookbook entry by Alexander Pletzer http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52275 Neil Schemenauers sparse matrix module http://www.enme.ucalgary.ca/~nascheme/ Maybe you could save a days work by telling me which module works best for really large (100K * 100K) matrices. op -- It may or may not be worthwhile, but it still has to be done. From phd at phd.pp.ru Fri Nov 23 12:36:10 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 23 Nov 2001 20:36:10 +0300 Subject: PHP vs. Python/comp.lang.php? In-Reply-To: ; from philh@comuno.freeserve.co.uk on Fri, Nov 23, 2001 at 04:41:55PM +0000 References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> Message-ID: <20011123203610.A5737@phd.pp.ru> On Fri, Nov 23, 2001 at 04:41:55PM +0000, phil hunt wrote: > PHP is also ugly. As an example, compare: > > PHP: $object->$member > Python: object.member Unfortunately, latest versions of Python have its own gotchas. "; ".join([a.id for a in listIds() if a.b > x]) looks worse than PHP, it looks almost like perl :( Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From lac at strakt.com Sun Nov 11 06:36:11 2001 From: lac at strakt.com (Laura Creighton) Date: Sun, 11 Nov 2001 12:36:11 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Sheila King of "Sun, 11 Nov 2001 08:47:46 GMT." Message-ID: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> I think we are speaking mostly at cross purposes, but I want to correct one misunderstanding. It is not that I have a low opinion of teachers, as that I have a really, really, high opinion of the difficulty of teaching. I think that it is more difficult to be an excellent teacher than it is to be an excellent physicist, or an excellent psychiatrist, or an excellent playwright. I am not sure that I think there is _anything_ it is harder to be than an excellent teacher. This produces an unsurrmountable structural problem. We need lots of teachers, so we have to accept those that we wouldn't if there was an infinite supply of excellent teachers we could draw upon. This means that an educational policy has to be crafted so that the bottom members of the profession can use it effectively to educate. I'd prefer to certify teachers every few years, in the same way you certify commercial pilots, and other professions, but I want other teachers, not random administrators and some education minister with some very odd ideas doing the certifying. I don't think that it is realistic to expect this any time soon, however. We might have better luck just seeing that teachers get continuing education. But then we have just moved the problem. Who decides what we should educate the teachers with? In the meantime, I think that letting teachers cut and paste whatever academic educational theories and texts they like reduces teaching to a hobby, and diminishes it as a profession. Many people appear to want this. They speak of the 'vocation' of teaching, and the 'calling'. David Ritchie and I both teach programming, as a hobby, and we have independently come up with the principle that it works better if you have the students code adventure stories. So we do this. If it turns out we are misguided idiots, are students can always leave and do something else. It is quite possible that we have only demonstrated that you should teach students that have joined a club where you code adventure stories, by teaching them to code adventure stories. This is a problem with a self selected set. David Ritchie was teaching people to program in Perl. I don't approve of that, and am pleased that he is now using python. But I think that it was an _unfortunate_ choice. But if David Ritchie was a professional middle school teacher, I would have a much stronger choice of words to describe what I think of the acceptability of Perl as a first programming language. I expect more from you and every professional teacher of programming to high school students. (Which perhaps you aren't doing any more.) But unless I misremember, you said that you were teaching C++ as a first programming language. And I think that this is worse than foolish, this is evil. You should not have been allowed to do this, even if you wanted to, a responsible educational policy should have a list of acceptable first programming languages, and C++ should not be on the list. But I don't think that you actually _wanted_ to teach C++ as a first programming language to high school students, but it was part of the the educational policy that you were given. So it is not a matter of a lack of policy, which would be bad enough, but a greater evil. The _policy_ itself is evil. What other evils do you have, and how do you get them, and why can't responsible teachers such as yourself get rid of evil damaging policies? If that is not worth getting angry about, I don't know what is. Laura Creighton lac at strakt.com (in Sweden) From bokr at accessone.com Wed Nov 21 04:13:05 2001 From: bokr at accessone.com (Bengt Richter) Date: Wed, 21 Nov 2001 09:13:05 GMT Subject: Pulling out References: Message-ID: <3bfb6c61.6364882@wa.news.verio.net> On Sun, 18 Nov 2001 20:45:44 -0800, Brett Cannon wrote: >You could just read each page and use a regex to fetch it: > >title_value=re.search(r'(?P<title>.*?)',re.I) >title_value.group('title') > Hm. What happens with the following page? Official new title ...whatever... >On Sun, 18 Nov 2001, David A McInnis wrote: > >> I am writing a script to catalog about 30,000 html pages on my site and need >> to pull out the value of . >> >> I guess this is possible with htmllib, but I cannot figure it out. >> >> Thanks, >> David >> >> >> > From tim at vegeta.ath.cx Tue Nov 27 20:01:20 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 28 Nov 2001 01:01:20 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3c029caa.260513688@news.laplaza.org> <3C03CFAC.6A29863@earthlink.net> Message-ID: Hans Nowak graced us by uttering: > Max wrote: > > Tim Hammerquist wrote: > > > There need not be 50 conflicting opinions. One only needs two editors: > > > - Vim > > > - Emacs > > > =) > > > > Why two editors? Will not one or the other do? > > Yes, but which one that is has been an age-old dispute. :-) Ding, ding, ding!! And _that's_ exactly why I didn't choose just one. > (Hint: I use the one that has the same name as a Dutch > cleaning solution. :-) I'm not familiar with Dutch, but mine's the one that can be stored as a C char[] in only 4 bytes. ;) Cheers! Tim Hammerquist -- Things need not have happened to be true. Tales and dreams are the shadow truths that will endure when mere facts are dust and ashes, and forgot. -- Morpheus, The Sandman From phd at phd.pp.ru Thu Nov 1 10:02:04 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 18:02:04 +0300 Subject: Monty Python (was: Freeware Python editor) In-Reply-To: ; from mikael@isy.liu.se on Thu, Nov 01, 2001 at 03:59:56PM +0100 References: Message-ID: <20011101180204.D675@phd.pp.ru> On Thu, Nov 01, 2001 at 03:59:56PM +0100, Mikael Olofsson wrote: > > and blod everywhere). But then there are the others (for instance the > ^^^^ > Make that "blood". And now it is time for something completely different - spelling wars :( Man, there was no spelling war in c.l.py, never. Why starting it now? Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From emile at fenx.com Thu Nov 8 12:17:01 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 09:17:01 -0800 Subject: How to get two modules loaded into the same namespace? References: Message-ID: <9seevi$1253gr$1@ID-11957.news.dfncis.de> ----- Original Message ----- From: Newsgroups: comp.lang.python Sent: Thursday, November 08, 2001 8:06 AM Subject: How to get two modules loaded into the same namespace? > I am trying to build a rule engine. I have two Python modules: > RuleEngine.py and utilities.py. > > I want to keep the engine and the utility functions separated for > reasons of maintainiability and cleannes. > > I am running into a few problems: > > 1) In RuleEngine.py I have defined a global, DEBUG_PRINT_LEVEL, which > allows me to steer the amount of debug info I get at runtime > (curently somewhere between 'nothing' and 'an awful lot'). > > When I try the following in RuleEngine.py: > > global DEBUG_PRINT_LEVEL > DEBUG_PRINT_LEVEL = 0 > from utilities import * > > class RuleEngine: > someUtilityFuncThatReferencesDEBUG_PRINT_LEVEL() > > I get a NameError on DEBUG_PRINT_LEVEL (see stack trace below): > > File "D:\Dev\PyCharGen\utilities.py", line 120, in calcLevel > if DEBUG_PRINT_LEVEL >= 4: > NameError: global name 'DEBUG_PRINT_LEVEL' is not defined > Process terminated with exit code 0 > The issue here is that 'DEBUG_PRINT_LEVEL' is not available to calcLevel in D:\Dev\PyCharGen\utilities.py. global applies to the module space, calcLevel lives in a different module, ie, your import * hasn't moved the function, simply imported a refernce to it into RuleEngine.py's globals. You may consider setting up a parameters module or dict that both refer to when testing DEBUG_PRINT_LEVEL. > As far as I understand the > docs, the 'from x import *' syntax should import stuff into the > current namespace, but apparently this does not hold for globals. > > 2) Several functions in utilities.py refer back to functions in > RuleEngine.py. They also return a NameError (see stacktrace below > from an actual debug log) > > File "D:\Dev\PyCharGen\utilities.py", line 157, in calcSpells > statLevel = find(stat, 'base') + find(stat, 'bonus') > NameError: global name 'find' is not defined > Process terminated with exit code 0 > > Again, it seems that the two modules are not in the same namespace. > That's right. > Both python 2.1.1 and 2.2beta show this behavior. > > Does anyone know a solution (other than putting the utility functions > in RuleEngine.py) to this problem? I must admit that I got lost at > the Python namespace rules before... > Stop doing from module import *. Do import module, then refer to the objects as module.obj using qualified names. The errors should stop. HTH, Emile van Sebille emile at fenx.com --------- From peter at engcorp.com Thu Nov 22 19:18:10 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 22 Nov 2001 19:18:10 -0500 Subject: python on handhelds References: <9tjsvr$90i$2@moonstone.imsb.nrc.ca> Message-ID: <3BFD95C2.666AA188@engcorp.com> ognen at bioinfo.pbi.nrc.ca wrote: > > I have inherited a 180,000 line VC++ project that I received a > green-light to rewrite/redesign. I come from a Unix background and would > very much like to go ahead and do it in Python however one of the > requirements is that a part of the app runs on a Palm. I have heard of > pippy (the python port for palmos) - but have no experience with it. My > manager is leaning towards Java. Does anyone have any experiences to > share as to the usability of the python port to palmos? Ease of > development? Any comparisons with Java for palms? Is there a strong requirement that the same language be used for both the PC side and the Palm side? Pippy is not mature. I don't know the status of the Palm Java support, but it must be much further along by now since it has been around for about two years and has had far, far more investment compared to Pippy. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From cfelling at iae.nl Mon Nov 26 22:54:40 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 27 Nov 2001 04:54:40 +0100 Subject: Perl to Python References: Message-ID: <9tv2q0$9rf$1@animus.fel.iae.nl> Paul Malinowski wrote: > Howdy, > #!/usr/bin/perl #!/usr/bin/python this first line is so simple that even I can cope with it, other lines I've to second guess Perl's semantics. from os import environ as env use env as shorthand for os.environ, done here solely to resemble Perl. > #Setting some environment variables. > $ENV{UDBCINI}="~openlinksw/bin/udbc.ini"; > $ENV{ODBCINI}="~openlinksw/bin/odbc.ini"; > $ENV{ODBCINSTINI}="~openlinksw/bin/odbcinst.ini"; env["UDBCINI"] = "~openlinksw/bin/udbc.ini" env["ODBCINI"] = "~openlinksw/bin/odbc.ini" env["ODBCINSTINI"] = "~openlinksw/bin/odbcinst.ini" see, the environment is just a dict inside python, and statements don't need no trailing semi-collin > $ENV{LD_LIBRARY_PATH}="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib"; > $ENV{SHLIB_PATH}="$ENV{SHLIB_PATH}:~openlinksw/lib"; > $ENV{PATH}="$ENV{PATH}:~openlinksw/bin:~openlinksw/samples/ODBC"; env["LD_LIBRARY_PATH"] = env["LD_LIBRARY_PATH"] + "~openlinksw/lib" env["SHLIB_PATH"] = env["SHLIB_PATH"] + ":~openlinksw/lib"; here we have to retrieve some info from the environment in the right hand side and concatenate it to get the new value. env["PATH"] = "%s:~openlinksw/bin:~openlinksw/samples/ODBC" % env["PATH"] but we could as well use %-string substitution. We could even use some fancy environment wrapper class that would allow us to substitute special values in case the environment variable was undefined, somthing Perlers seem very fond of. > #SQL query that runs qryModelSNforWeb in the warranty Access database. never used sql myself, so here I start talking double dutch:) > $sql = "echo \"select * from ;\" | > odbctest DSN="; sql = 'echo "select * from %s;" | odbctest DSN=%s' % (query, link) [[I take it this should be one long string, no return embedded.]] Python has two kind of string quotes, simply use the one most convenient. Here ' allows us to use " unbackslased inside the string. I took the freedom to suggest using the %-string substitution operator here to fill in the actual query and database link. > if (!open(SQL,"$sql |")) { > print "Unable to open connect to database
"; > exit 0; > } > > if (open(SQL, "$sql |")) { > chomp(@rawdata = ); > } I'm confused, twice the same query? Anyway, python is more verbose here, we'll have to be more explicit here. import commands, sys status, result = commands.getstatusoutput(sql) if status: print "Unable to open connect to database
" sys.exit(status) else: output = output.split('\n') [[guessing that the chomp works on an array of lines.]] getstatusoutput already strips any trailing linefeed, so we have to deal with embedded newlines only. Simply splitting on newline suffices. I think it's better to pass the status info on with sys.exit instead of using the misleading zero wich implies all's swell were it isn't. -- groetjes, carel From db3l at fitlinxx.com Mon Nov 5 19:27:57 2001 From: db3l at fitlinxx.com (David Bolen) Date: 05 Nov 2001 19:27:57 -0500 Subject: How would I write this perl script in python? References: Message-ID: Aaron Ginn writes: > I'm not sure how to isolate the different parts of the regexp in > Python as I have done in Perl by using parentheses and then referring > to the parts as $1, $2, $3, etc. I've used Python's re module many > times, but mostly only for searching. It seems I always revert to > Perl when I have a complicated (or not so complicated) search and > replace task to perform. Within the regex itself you identify groups just as in Perl (with parentheses). However, match results are not set to predefined variables (e.g., $2) but rather are available through the resulting match object returned by the regex comparison. To match up with the other behavior, you'd have to identify the line read from the file explicitly rather than depending on Perl to work on the current line. Also, you might want to consider compiling your pattern for performance. The most literal translation of your script could be: import re, fileinput for line in fileinput.input(): match = re.search(r'^(\w+\s+)(\-*\d+\.\d+)(\s+)(\-*\d+\.\d+)$',line) if match: val = match.group(2) - 0.775 print "%s%s%s%s" % (match.group(1),val, match.group(3),match.group(4)) else: print Note the use of a raw string for the regex pattern to avoid needing to quote the backslashes. I don't believe you use anything in the pattern that behaves differently between Perl and the Python re module. Note also that the Perl code can silently run through lines that don't actually match the pattern fully, and may produce empty values for $n (which may in turn, make your val be -0.775 if group 2 didn't match). The above Python code will generate exceptions in such cases, so if you are depending on Perl's silent behavior in that case you'd either need to do some more error checking in the Python code, or enclose the code within the "if match" block in a try/except clause to deal with any match group errors, even if only to skip past them. The fileinput module will handle taking input from command line filenames or stdin if no filenames are given. It's not necessarily the highest performing option (until most recent Python releases), but it's the closest match to Perl's null filehandle (<>). You could also use re.match rather than a "^" at the start of your pattern since match only matches at the beginning of the string. If you combined that with compiling the pattern for performance, you'd have: import re, fileinput re_pat = re.compile(r'(\w+\s+)(\-*\d+\.\d+)(\s+)(\-*\d+\.\d+)$') for line in fileinput.input(): match = re_pat.match(line) if match: val = match.group(2) - 0.775 print "%s%s%s%s" % (match.group(1),val, match.group(3),match.group(4)) else: print -- -- 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 lac at strakt.com Wed Nov 21 13:03:28 2001 From: lac at strakt.com (Laura Creighton) Date: Wed, 21 Nov 2001 19:03:28 +0100 Subject: dictionary-question In-Reply-To: Message from wl of "Wed, 21 Nov 2001 17:14:03 +0100." <3BFBD2CB.6070100@flexis.de> References: <3BFBD2CB.6070100@flexis.de> Message-ID: <200111211803.fALI3Sua029186@ratthing-b246.strakt.com> > Hello, > > Bas van Gils wrote: > > Now, can someone please explain why the > > > > foo.get("bar",0) += 1 > > > > won't work ... and what might be a better sollution then my current > > workaround? Aside from the problem of assigning to a function, you appear to want foo.get("bar",0) to assign foo["bar"] to 0. It doesn't work that way. It is just return this argument if you can't do the lookup, not return this argument and make the assignment in the dictionary. lac at ratthing-b246:~/Mail/boyd/pers$ python Python 2.1 (#3, May 26 2001, 17:43:53) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> foo={'a': 1} >>> foo.get("bar", 300) 300 >>> print foo {'a': 1} >>> Laura From wtanksle at dolphin.openprojects.net Thu Nov 15 20:58:04 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 16 Nov 2001 01:58:04 GMT Subject: Returning values from a lambda References: Message-ID: On Fri, 16 Nov 2001 01:56:50 GMT, William Tanksley wrote: >With the function I've defined, things should work. Just to clarify, I should mention that I didn't declare globals -- you almost certainly want them in this case. -- -William "Billy" Tanksley From achim.domma at syynx.de Thu Nov 8 10:22:04 2001 From: achim.domma at syynx.de (Achim Domma) Date: Thu, 8 Nov 2001 16:22:04 +0100 Subject: Newbie with Tkinter problems References: <3bea8c8a$1@netnews.web.de> Message-ID: <9se7pq$e5s$04$1@news.t-online.com> "Kerstin Dressler" wrote in message news:3bea8c8a$1 at netnews.web.de... > Also I've got problems with opening the files (the gif as well as the file I > need for the Listbox). > -> logo = PhotoImage(file="./Power at work_transparent_8farben.gif") > -> liste = open('./envliste', 'r') > In both cases I get the error message: IOError: [Errno 2] No such file or > directory: './envliste'. > But both files are in the same directory as the py-script? > What could be wrong there? If both files could not be opened I would guess that the path is wrong or you are not in the folder you think. I don't know excactly how python handles filenames, but it could be possible that you have to use \ instead of / on Windows 95. If that's not your problem try to show the current working dir with os.getcwd(). hope that helps Achim From ajs at ix.netcom.com Sat Nov 10 21:14:52 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 10 Nov 2001 21:14:52 -0500 Subject: Teaching python (programming) to children Message-ID: <000701c16a56$b587eb80$a9e1fea9@carol> >If you feel you have a good point about curriculum and/or teaching >methods, put your point out there and be vocal about it. Give the >teachers access to your ideas, and the reasons why you promote it. Then >allow them to decide whether to adopt it or not. As an outgrowth of work I have done with Python for geometry study, primarily as a project of self-education, I have recently had the opportunity to address the math faculty of an engineering college, and demonstrate some of the possibilities of using Python and related tools to advance their work as educators. I think it was well received. So my rantings here are not the extent of my involvement, by any means. Art From astrand at lysator.liu.se Tue Nov 13 04:15:52 2001 From: astrand at lysator.liu.se (=?iso-8859-1?Q?Peter_=C5strand?=) Date: Tue, 13 Nov 2001 10:15:52 +0100 (CET) Subject: Linux/Alpha memory leaks In-Reply-To: <3BF08B51.8B706BD1@metaslash.com> Message-ID: > > I have some problems with memory leaks in a web application, written in > > Python. It works good on Sparc/Solaris and Linux/i386 (uses < 10 MB on > > these platforms), but in Linux/Alpha the application consumes > 50 MB in > > less than 24 hours. Since the Python application works good on two other > Check out this patch which has been applied (9-Nov): > > http://sourceforge.net/tracker/index.php?func=detail&aid=478006&group_id=5470&atid=105470 > > That may address your problem. Specifically, it closes a leak in 2.2b1+. > I don't know if it affects 2.1.1. Now I have also tried the CVS version, with this patch applied. It still leaks. Maybe I should try with GNU pth threading libraries, instead of LinuxThreads? -- /Peter ?strand From jgardn at alumni.washington.edu Thu Nov 29 08:17:22 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 29 Nov 2001 22:17:22 +0900 Subject: The Editor Poll results are in! In-Reply-To: References: <3bfd7f87@news.airtel.net> <9u4cbu$2ts$1@news.xmission.com> Message-ID: <200111291320.fATDKiT10449@my.knctv.co.kr> On Thursday 29 November 2001 02:14 pm, Paul Winkler wrote: > > That's what you get for drinking that crap! I'm currently using > granola with soymilk. It's much more visually disgusting, which helps > enhance the comic experience, but it doesn't corrode things nearly as > badly. It's still a bitch to clean up. > Sounds like my fav-O-rite editor! Great for getting the system moving, if you know what I mean. ;-) ;-) Jonathan From robin at jessikat.fsnet.co.uk Sun Nov 11 11:52:59 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 11 Nov 2001 16:52:59 +0000 Subject: update forms 2.0 TextBox Message-ID: Anyone out there know how to force a repaint of a Forms 2.0 Text box using win32com. I have an embedded TextBox in an excel spreadsheet. My python is controlling setting values and recalculating the spreadsheet and I would like to write a simultaneous log in the textbox. In a former version this all happened automatically, but after being forced to convert to office 2000 I find that the text only updates when the macro has stopped running which is a bit pointless if useful information is present. I have tried various things (eg tb.Repaint, tb.Refresh) which appear to be referred to in the copious and confusing documentation, but nothing seems to work. -- Robin Becker From gh_pythonlist at gmx.de Mon Nov 12 09:26:35 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Mon, 12 Nov 2001 15:26:35 +0100 Subject: IsPython really O-O? - Think different ! In-Reply-To: <9snugr$bbc$06$1@news.t-online.com> References: <9smovs$cbu$02$1@news.t-online.com> <9snugr$bbc$06$1@news.t-online.com> Message-ID: <20011112152633.A912@lilith.hqd-internal> On Mon, Nov 12, 2001 at 08:43:25AM +0100, Guido Stepken wrote: > VisualPython is a windows port of the unix python from G.v.Rossum, done > with cygnus (now redhat) GNUPRO suite. [...] > regards, Guido Stepken You've got that wrong! Trust me. My description is the correct one :-) Go read the ActiveState page for the description: http://www.activestate.com/Products/Visual_Python/ """Visual Python is the full-featured Python plug-in for Visual Studio .NET, providing a rich development environment for programmers who wish to use Python within Visual Studio .NET. Unlike other Python IDEs and editors, Visual Python was written specifically for Visual Studio .NET, allowing programmers to fully leverage the features of Microsoft's powerful development tool suite.""" A quick google check reveals that a win32 port of Python exists at least since Python *1.2*. Gerhard > >Gerhard Haering wrote: > ... > > A minor correction: VisualPython is an ActiveState product. Microsoft has > > AFAIK nothin to do with it except that they provide VisualStudio 7 with a > > plug-in API for other languages, debuggers, etc. > > > > Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From barry at zope.com Fri Nov 9 17:48:58 2001 From: barry at zope.com (Barry A. Warsaw) Date: Fri, 9 Nov 2001 17:48:58 -0500 Subject: RELEASE Mailman 2.0.7 Message-ID: <15340.23898.112445.771939@anthem.wooz.org> I've just released version 2.0.7 of Mailman, the GNU Mailing List Manager. Mailman is released under the GNU General Public License (GPL). Version 2.0.7 closes two potential security / denial-of-service problems in the Mailman 2.0.x series, and includes a few other minor bug fixes. - If you are running Python 1.5.2, it is possible for someone to carefully craft some cookie data, and then trick Mailman into accepting that data, that will crash your Python interpreter. If you are not running Python 1.5.2, you should be invulnerable to the crash, however it is still possible for someone to even more carefully craft some cookie data that could cause arbitrary class constructors to be executed on the server. Mailman 2.0.7 closes this hole by disabling the Cookie.py module's default unpickling of cookie data. - It is possible that Mailman's bounce handler could receive a bounce message that looked like a DSN report, but was incorrectly formatted. Under Mailman 2.0.6's bounce detector, you would get a traceback for a message that would never be removed from the queue, thus potentially wedging your qrunner until the offending message was manually deleted. Mailman 2.0.7 fixes the DSN.py bounce detector. There are a few other useful bug fixes in this release, described in the NEWS excerpt below. I recommend anybody running a version of Mailman up to, and including 2.0.6 to upgrade to 2.0.7. GNU Mailman is software to help manage electronic mail discussion lists. Mailman gives each mailing list a unique web page and allows users to subscribe, unsubscribe, and change their account options over the web. Even the list manager can administer his or her list entirely via the web. Mailman has most of the features that people want in a mailing list management system, including built-in archiving, mail-to-news gateways, spam filters, bounce detection, digest delivery, and so on. Mailman is compatible with most web servers, web browsers, and mail servers. It runs on GNU/Linux and should run on any other Unix-like operating system. Mailman 2.0.7 requires Python 1.5.2 or newer. To install Mailman from source, you will need a C compiler. For more information on Mailman, including links to file downloads, please see the Mailman WWW page: http://www.gnu.org/software/mailman And its mirrors at: http://mailman.sourceforge.net http://www.list.org (Note: not all of the mirrors are updated yet.) Downloads are available at http://sourceforge.net/project/showfiles.php?group_id=103&release_id=60758 There are email lists (managed by Mailman, of course!) for both Mailman users and developers. See the web sites above for details. Cheers, -Barry -------------------- snip snip -------------------- 2.0.7 (09-Nov-2001) Security fixes: - Closed a hole in cookie management whereby some carefully crafted untrusted cookie data could crash Mailman if used with Python 1.5.2, or cause some unintended class constructors to be run on the server. - In the DSN.py bounce handler, a message that was DSN-like, but which was missing a "report-type" parameter could cause a non-deletable bounce message to crash Mailman forever, requiring manual intervention. Bug fixes: - Stray % signs in headers and footers could cause crashes. Now they'll just cause an [INVALID HEADER] or [INVALID FOOTER] string to be added. - The mail->news gateway has been made more robust in the face of duplicate headers, and reserved headers that some news servers reject. If the message is still rejected, it is saved in $prefix/nntp instead of discarded. - Hand-crafted invalid chunk number in membership management display could cause a traceback. From jason at jcrowedesign.com Sun Nov 18 08:35:41 2001 From: jason at jcrowedesign.com (jcrowe) Date: Sun, 18 Nov 2001 07:35:41 -0600 Subject: drawing functionality References: Message-ID: Chris Liechti wrote: > well you don't say much about how you would exchange data between client > and server. > do you want to write a custom app or should the clients simply use a > webbrowser? > > i would prefer the second as it limits the programming to the server side > and a wide variety of clients can connect. > you can either setup a webserver and use python scripts for CGI or write > even the server in python (realy simple to do). > > for graphical data there are e.g.: > - pdf: http://www.reportlab.com/ > - jpg, png, ...: http://www.pythonware.com/downloads/index.htm#pil > > with both you can create data on the fly and embed it in dynamic webpages. > > chris > I am planning on a custom app for this project. I don't think i was very clear when I asked my question. I am wanting to give the users the ability to draw a small schetch when they add information to the database. Thanks, Jason From d_blade8 at hotmail.com Tue Nov 13 16:45:54 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 13 Nov 2001 13:45:54 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111122102.2058f188@posting.google.com> Message-ID: <7396d2b2.0111131345.22483e62@posting.google.com> Actually, here is the code I am working on now. Like I said, I am tring to learn COM and am, basically, adding methods to the EasyExcel example given in the Excel chapter of Programming Python on Win32. Here is what the code I am using now. It uses the same functions and methods as the previous code, but uses the proper COM methods to create a Excel file and enter data. The problem I have now, as I said, is that I cannot insert hyperlinks. I believe I posted my interactive attempts based on the Excel help files (they should be up soon so you can see what I mean). Anyways, here is my new code (quick note: I was working around the problem by creating html files with the links I wanted and inserting them into an Excel sheet. It worked/works but is, like you said, not a python thing, plus it makes things a whole lot messier. I am also in the middle of adding a Tkinter GUI interface, as well as converting over to win32com.client.Dispatch methods, so the code is really messy). Thanks: if __name__ == "__main__": opening = Tk() OFrame = Frame(opening) OFrame.pack() Label(opening, text = "This program automates the process of searching public databases for information on particular genes.\nIt uses accession numbers to complete this goal.").pack(side = TOP) Label(opening, text = "Please select the file containing accession numbers ").pack(side = TOP) Quitter(opening).pack(side = RIGHT) fileOpener = Opener(opening) fileOpener.pack(side = BOTTOM) opening.title("Open A Text File") opening.mainloop() opening.destroy() file2read = fileOpener.file2open fin = open(file2read, 'r') orig = fin.readlines() fin.close() print "\nYour request is being processed..." timetocom = len(orig) * 9.0 print "\nEstimated time of completion: %s" % time.ctime(time.time() + timetocom) print "\nPlease wait while your command is completed...\n" StartTime = time.time() #fout = open(r"UnigeneLinks.html", 'w') #App = Dispatch("Excel.Application") #tout = open(r"accessnums.xls", 'w') #LLout = open(r"mLocusLinks.html", 'w') #HLLout = open(r"hLocusLinks.html", 'w') #Pout = open(r"Proteome.html", 'w') #OMIMout = open(r'OMIMLinks.html', 'w') #GenCdsout = open(r'GeneCards.html', 'w') #tout.write("Accession Number\tUnigene Link\tmLocusLink Link\tHuman Locus Link\tProteome Link\tOMIM Link\tGeneCards Link\n") XL = EasyExcel.EasyExcel() XL.SetCell(1,1,"Accession Number") XL.SetCell(1,2,"Unigene Link") XL.SetCell(1,3,"mLocusLink") XL.SetCell(1,4,"hLocusLink") XL.SetCell(1,5,"Proteome Link") XL.SetCell(1,6,"OMIM Link") XL.SetCell(1,1,"GeneCards Link") xCol = 1 xRow = 2 global filelen filelen = 0 for file in orig: file = getsetnums(file) if file[0] != '&': filelen += 1 #tout.write(file) XL.SetCell(xRow,xCol, file) xCol +=1 UnigenePage = PrintUnigenePage(file) #fout.write(makeUnigenePage(file)) XL.SetCell(xRow,xCol, "Unigene Link") XL.SetComment(xRow, xCol, StringLoc.UnigeneLink(UnigenePage)) xCol +=1 LLstr = makeLocusLinkPage(UnigenePage) #LLout.write(LLstr) XL.SetCell(xRow,xCol, LLstr) xCol += 1 HLLstr = GenericLinkGen.FindThehLL(LLstr, r"./LocRpt.cgi?l=") #HLLout.write(HLLstr) XL.SetCell(xRow,xCol, HLLstr) xCol += 1 Pstr = GenericLinkGen.FindTheURL(HLLstr, r"http://www.proteome.com/databases/HumanPD/reports/") #Pout.write(Pstr) XL.SetCell(xRow,xCol, Pstr) xCol += 1 OMIMstr = GenericLinkGen.FindTheURL(HLLstr, r"http://www.ncbi.nlm.nih.gov/entrez/dispomim.cgi?id=") #OMIMout.write(OMIMstr) XL.SetCell(xRow,xCol, OMIMstr) xCol += 1 GenCdstr = GenericLinkGen.FindTheURL(HLLstr, r"http://bioinformatics.weizmann.ac.il/cards-bin/carddisp?") #GenCdsout.write(GenCdstr) XL.SetCell(xRow,xCol, GenCdstr) xCol = 1 xRow += 1 EndTime = time.time() ElapsedMin = int(math.floor((EndTime - StartTime)/60)) ElapsedSec = int(math.floor((EndTime - StartTime) % 60)) secperfile = (EndTime - StartTime)/filelen ElapsedStr = "Number of accession numbers processed: %s\nProcessing Time: %s minutes %s seconds\nEfficiency: %02.1f seconds\\file" % (filelen, ElapsedMin, ElapsedSec, secperfile) #tout.write(ElapsedStr) xRow += 2 XL.SetCell(xRow,xCol, ElapsedStr) xRow += 1 #tout.write("The program that produced this output is copyrighted\n***** Copyright ? 2001 by DeltaGen, Inc. Program Design//Implementation: DeltaXpress *****") XL.SetCell(xRow,xCol, "The program that produced this output is copyrighted") xRow += 1 XL.save("AccessNums.xls") #tout.close() XL.close() From tim.one at home.com Sat Nov 3 22:17:07 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 22:17:07 -0500 Subject: dictionaries and 'in' in 2.1 In-Reply-To: Message-ID: [John J. Lee] > The Python 2.1.1 manual, section 2.1.6, says: > > k in a 1 if a has a key k, else 0 > k not in a 0 if a has a key k, else 1 These are new-in-2.2 features. They got documented "early" by mistake. The 2.1.2 docs will repair this. Use a.has_key() before 2.2. From phd at phd.pp.ru Tue Nov 27 11:30:38 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 27 Nov 2001 19:30:38 +0300 Subject: ScanMail Message: To Recipient virus found and action taken. In-Reply-To: <200111271625.fARGPdQ31629@tesla.solutioninc.com>; from joakley@solutioninc.com on Tue, Nov 27, 2001 at 12:25:48PM -0400 References: <02f901c1775e$21c62730$0e0fbb82@corp.es.com> <200111271625.fARGPdQ31629@tesla.solutioninc.com> Message-ID: <20011127193038.U25831@phd.pp.ru> On Tue, Nov 27, 2001 at 12:25:48PM -0400, James Oakley wrote: > On November 27, 2001 12:11 pm, Administrator wrote: > > ScanMail for Microsoft Exchange has detected virus-infected attachment(s). > > ...snip... > > As annoying as getting Windows viruses is, getting multiple copies of this is > worse. Imagine if 200 people on the list were running this stupid Exchange > thing... Yikes. Just another example of the same old wisdom: avoid, if possible, non-free software (it is dangerous and stupid); and avoid at all cost M$ "software". Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From just at letterror.com Fri Nov 16 14:05:43 2001 From: just at letterror.com (Just van Rossum) Date: Fri, 16 Nov 2001 20:05:43 +0100 Subject: Does smtplib lookup MX records? References: Message-ID: <3BF56916.8834B8D7@letterror.com> Dale Strickland-Clark wrote: > I've been trying to send emails with smtplib and had a large number of > failures. Investigation seems to reveal the the smtplib module does a > simple connect passing the hostname to socket.connect without trying > to resolve the MX record. > > In some cases this works where the mail server happens to have an > A-type DNS record anyway but otherwise it fails with a connection > error. > > Is this really the case? > > If it is, what do I need to do to lookup the MX record myself? > > (This is rather urgent now as this program was hastily written to help > a client out who's mail server has died.) Are you sure you're using smtplib correctly? I *think* it's mostly meant to talk to a local relay host (eg. smtp.my-isp.com). The smtp server will take care of the rest. If you insist on delivering yourself, then yeah, you'd have to look up the mx record for each recipient, but I wouldn't consider that typical usage of smtplib. Am I missing something? Just From clpy at snakefarm.org Thu Nov 8 09:47:14 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Thu, 08 Nov 2001 15:47:14 +0100 Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> <3BEA8B0F.E594BE84@snakefarm.org> Message-ID: <3BEA9AF2.CCC68665@snakefarm.org> Michael Hudson wrote: > > or should the > > implementation raise an exception because it violates the docs? I'd > > prefer the latter. > > That what the patch I just submitted to sf does :) I was just about to submit my bug report when I read this. Seems I'm getting slow. :-) cg. From wavy_gravy at worldnet.att.net Sat Nov 10 11:49:18 2001 From: wavy_gravy at worldnet.att.net (AT&T News) Date: Sat, 10 Nov 2001 16:49:18 GMT Subject: string manipulation question Message-ID: Greetings, I am looking for a more resaonable way to do the following, instead of ugly "if", "elif" constructs. Here goes: I have a string (line) that might contain, for example *any* *one* of the patterns or words "whale" , "cat". How do I elegantly set a variable say "animal" depending upon what word is there. I.e I want animal = "MAMMAL" if line contains the word "whale" or animal = "FELINE" if line contains the word "cat". is there a elegant way to code the above construct, I have 10 of these patterns/keywords that can be found in a line. I thought of using a dictionary for the keyword patterns, but the pattern/keyword does not have any known context in the line. TIA MO From shriek at gmx.co.uk Mon Nov 12 20:35:55 2001 From: shriek at gmx.co.uk (Stephen) Date: 12 Nov 2001 17:35:55 -0800 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> Message-ID: <97ae44ee.0111121735.ebbca1@posting.google.com> > Why not save yourself a little coding and just use netstrings? > > more info: http://itamarst.org/multiplex > advogato copy: http://www.advogato.org/article/212.html > python code: http://itamarst.org/downloads/multiplex-0.2.tgz > description: http://cr.yp.to/proto/netstrings.txt Just read Dan Bernstein's description. Interesting note about security considerations using CRLF, which follows on from an earlier post in this thread. 4. Security considerations The famous Finger security hole may be blamed on Finger's use of the CRLF encoding. In that encoding, each string is simply terminated by CRLF. This encoding has several problems. Most importantly, it does not declare the string size in advance. This means that a correct CRLF parser must be prepared to ask for more and more memory as it is reading the string. In the case of Finger, a lazy implementor found this to be too much trouble; instead he simply declared a fixed-size buffer and used C's gets() function. The rest is history. In contrast, as the above sample code shows, it is very easy to handle netstrings without risking buffer overflow. Thus widespread use of netstrings may improve network security. Stephen From ngps at madcap.dyndns.org Sat Nov 17 23:45:39 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 18 Nov 2001 04:45:39 GMT Subject: ssl error References: Message-ID: <9t7edj$pqd$1@violet.singnet.com.sg> According to Reid Nichol : > sslerror: SSL_connect error > > The error in my logs on my server if I try to connect to port 22: > Bad protocol version identification '\M^@\M^@\^A\^C\^A' from 192.168.0.2 Port 22 is where SSH normally lives. It looks like you're trying to talk the SSL protocol to an SSH server. SSH != SSL. There is a module to control OpenSSH binaries; look around on Parnassus. -- Ng Pheng Siong * http://www.post1.com/home/ngps From phr-n2001d at nightsong.com Fri Nov 16 17:42:21 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 16 Nov 2001 14:42:21 -0800 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> <7x8zddnroj.fsf@ruckus.brouhaha.com> <9sq94c$lim$1@slb1.atl.mindspring.net> Message-ID: <7xsnbenxrm.fsf@ruckus.brouhaha.com> barry at zope.com (Barry A. Warsaw) writes: > Anyway, I think we've addressed things as best we can for Python 2.2. > Please take a look at the new documentation and let me know if you > have any corrections or other suggestions. Barry, I can't find the new documentation. Can you say where to look? Thanks. From export at sendme.cz Sat Nov 24 11:48:52 2001 From: export at sendme.cz (Lad) Date: 24 Nov 2001 08:48:52 -0800 Subject: HTTPLIB - Problem retrieving a page References: Message-ID: <52ac9479.0111240848.d9f55bd@posting.google.com> Oleg Broytmann wrote in message news:... > On Fri, Nov 23, 2001 at 07:46:46PM +0000, Colin Meeks wrote: > > I am running the following code to retrieve pages and strip out some > > details, > > however I have noticed that some sites do not work, even though the correct > > URL is given. I can verify it works by testing it in my browser. The below > > code gives a 404 error. > > > > import urlparse, httplib, urllib > > UseURL='http://www.meeks.ca/index.htm' > > I tested the site a bit and found that it responds Error404 to HTTP/0.9 > requests (I tested it with netcat). HTTP/1.0 and HTTP/1.1 requests are ok. > So the reason is (or at least may be) that your version of Python library > does not send HTTP version with request. Try to verify this (that is, look > into headers that httplib sends; use debugging proxy or fake http server > for testing - there are a number of pure python tools for this task). > > Oleg. You must use HTTP/1.1 Here is a working sample import httplib,urlparse UseURL='http://www.meeks.ca/index.htm' (scheme, server, path, param,query,fragment) = urlparse.urlparse(UseURL) h = httplib.HTTPConnection(server)#start HTTP/1.1 h.putrequest('GET', path) h.putheader('Accept', 'text/html') h.putheader('Accept', 'text/plain') h.endheaders() r = h.getresponse() data = r.read() # Get the raw HTML print data Ladislav From peter at engcorp.com Mon Nov 12 20:05:13 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 12 Nov 2001 20:05:13 -0500 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111121415.3c6f18ed@posting.google.com> Message-ID: <3BF071C9.9EAF5B6C@engcorp.com> Lemniscate wrote: > > To create an > Excel file, for example, I just save to an .xls file (as opposed to > using Dispatch from the win32all package, which I didn't know how to > use when I started). > fout = open(r"accessionnolinks.xls", 'w') # open a file to write > to, xls makes it an excel file under windows This doesn't "make it an Excel file", it just gives it a file extension of .XLS. If Excel is happy reading the file in, it's because it knows enough to examine the file and understand that it's actually a CSV (comma-separated) or maybe tab-separated ASCII text file containing some kind of spreadsheet-like information. Put another way, this is in no way a Python problem, and purely an Excel one, and possibly one that has no solution. Why not try writing out a spreadsheet which *does* have a link in it, as both an XLS files and a CSV file? Examine them and figure out what Excel does to save the links. Read the CSV file back in (after renaming to XLS maybe) and see if the link survives the trip. If it does, you should be able to figure it out from that, or go on the web and find some docs on Excel's file formats... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From huaiyu at gauss.almadan.ibm.com Thu Nov 15 13:59:59 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Thu, 15 Nov 2001 18:59:59 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: On Wed, 14 Nov 2001 12:33:32 -0500, Steve Holden wrote: >> >Once you create a class where instances are not equal to themselves then >common sense goes out of the window, and readability is no longer your major >problem. If two lists contain items that compare unequal, then surely by >definition the lists are unequal, and so *not* short-circuiting the >comparison gives correct behavior. > It is true that once objects can be unequal to themselves a list of such objects can be uneqal to itself too. So my question really is this: Is there any major practical use for an object to be unequal to itself? Would it be better to just define (a==b) to take a shortcut of (a is b), always? Yes, I know NaN is a special case. But I do not really see any practical use of (NaN==NaN)==0, because it violates (a!=b) == not (a==b) anyway. A case for (NaN==NaN) == (NaN!=NaN) == NaN might be more reasonable. In any case this should not be a major concern, as currently the treatment of NaN is severely crippled anyway. To remove a fundamental semantic constraint (a is b implies a==b) due to such an ad hoc convention has quite dubious merit, to say the least. I'm also troubled by the loss of well-orderedness of the new rich comparison scheme. I think cmp should be applicable to any objects, and sort should be applicable to any list. This should not be affected by the fact that there is no "natural" well-order on some sets, such as complex numbers. Python can do cmp(1,"1"). Why can't it do cmp(1, 1j)? Overall I think most of these problems stem from the misguided belief that there should be either one "natural" order on a set, or there is not order. This belief orginates from observation on the set of real numbers but it is not valid on much of anything else. Huaiyu From garys at ihug.com.au Sun Nov 4 00:05:42 2001 From: garys at ihug.com.au (Gary Stephenson) Date: Sun, 4 Nov 2001 16:05:42 +1100 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: Message-ID: <9s2hl0$u6o$1@bugstomper.ihug.com.au> Gidday all! > You're missing one important link that is well represented in the > python-list archives: The Goon Show -- with Spike Milligan and > Peter Sellars. The Goon Show was a BBC radio show that was the > inspiration for Monty Python. > > Spike Milligan beat out John Cleese for 1st place in the BBC's > millenium poll of the top 10 funniest people: > The patriot (scoundrel??) in me wishes to point out that Spike was / is an Australian - though I imagine many Brits would be somewhat upset to learn this . He was also I believe the author of the immortal limerick: "There was a young man from Wooloomooloo (*) Whose limericks always finished on line two." cheers, gary (* - or somewhere ending in "oo" - can't remember now) From graz at mindless.com Sun Nov 4 15:55:04 2001 From: graz at mindless.com (Graham Ashton) Date: Sun, 04 Nov 2001 20:55:04 GMT Subject: python-gtk documentation References: <9rvbch$4l1$1@antares.worldonline.fr> Message-ID: In article <9rvbch$4l1$1 at antares.worldonline.fr>, "Jerome" wrote: > Where can I find a gtk-python documentation ?? I need widget and > function descriptions ... Try this too, it explains the mapping from C functions to pygtk classes: http://laguna.fmedic.unam.mx/~daniel/pygtutorial/pygtutorial/x324.html#AEN373 -- Graham From tim.one at home.com Sun Nov 11 03:02:51 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Nov 2001 03:02:51 -0500 Subject: Splitting on a regex w/o consuming delimiter In-Reply-To: Message-ID: [Lars Kellogg-Stedman] > I knew I should have said it the first time: this is a contrived > example; what if the delimiter regex was something like '\s(!|@)\s'? > Given: > > foo ! bar @ baz @ xyzzy ! mumble > > You'd end up with: > > [ 'foo', 'bar', 'baz', 'xyzzy', 'mumble' ] > > With no way of recovering the delimeter. > > Really, I just want to be able to split on (?=pattern), or some other > method of splitting a string without consuming the delimiter. You cannot: if split actually split on a zero-width match, the result would be an infinite loop (think about it ). Besides, it's ambiguous whether you want the separator to be attached "to the left" or "to the right". The best you can do is write code to force your idea of what the right answer is. First use a *single* capturing group around the entire delimiter regexp, so that the delimeters are included in the result list: p = re.compile(r''' ( # capture the delimiter \s (?: # do not capture anything else !|@ ) \s )''', re.VERBOSE) [note: in this specific example, [!@] would be better than (?:!|@)] Then the result is >>> p.split('foo ! bar @ baz @ xyzzy ! mumble') ['foo', ' ! ', 'bar', ' @ ', 'baz', ' @ ', 'xyzzy', ' ! ', 'mumble'] You have to paste that together again, programming your own answers for which delimiter goes with which non-delimiter, and what to do if a delimiter was found at the start and/or end of the string. From bit_bucket5 at hotmail.com Sat Nov 17 16:16:32 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Sat, 17 Nov 2001 21:16:32 GMT Subject: The Wayback machine - an interesting poke into the past References: <1006021175.16175.0.nnrp-01.c2de2503@news.demon.co.uk> Message-ID: On Sat, 17 Nov 2001 18:04:40 -0000, "Paul Brian" wrote: >Dear all, > >For no particular reason I thought people might be interested in this. > >The same people who brought us Alexa and WAIS, have been archiving as much >of the web as they could spider for years. Now they have set up a web farm >to let us all browse our pre-history. > >For example, the python.org home page from january 1997. >http://web.archive.org/web/19970414030137/http://python.via.ecp.fr/ > >The logo has not changed a bit :-) >Amazingly enough most of the links work too. I found an article by Frank >Williamson with some funny quotes just a click away. > >Actually there are some interesting debates being brought up by this, from >defamation postings suddenly being resurrected, to people trying to forget >embarrassing statements, that come back to haunt. > >but really its just for fun... > >---------- >Paul Brian > > Very cool! Thanks for the link. From achim.domma at syynx.de Tue Nov 6 10:50:17 2001 From: achim.domma at syynx.de (Achim Domma) Date: Tue, 6 Nov 2001 16:50:17 +0100 Subject: count in 'for ... in ...' Message-ID: <9s90mr$osk$00$1@news.t-online.com> Hi, if I have a list of strings and want to display with a count in front of it I usualy do something like: for i in range(len(my_list)): print i,". ",my_list[i] but I think the for s in my_list: print ... Syntax is much cleaner, because it clearly says what I'm doing. So I asked myself : is there a way to get the internal count in 'for ...in' ? Of course it would be the same as the first version, but in my opinion it would fit perfectly in the 'python-way' to say what one is doing. greetings Achim From garth_grimm at hp.com Fri Nov 30 15:26:10 2001 From: garth_grimm at hp.com (Garth Grimm) Date: Fri, 30 Nov 2001 12:26:10 -0800 Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> <3C06AA26.6020906@hp.com> Message-ID: <3C07EB62.1010200@hp.com> Paul Winkler wrote: >>>mylist = ['one','two','three'] >>> >>>which I presume is a "tuple" as I have been scanning the manual. >>> >> >>That's a list, not a tuple. A tuple would be like >> myTuple = { 'one', 'two', 'three' ) >> > oops, you mean: ( 'one', 'two', 'three' ) > > Garth, I assume that was a simple typo. > just trying to make sure we don't confuse the newbies... > > --PW > DOH! thanks Paul. Even after you pointed it out, it still took me about 30 seconds to identify what was wrong. Time to move to a different font! Garth From tim.one at home.com Fri Nov 9 17:00:47 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 9 Nov 2001 17:00:47 -0500 Subject: iters on ints? (reducing the need for range/xrange) In-Reply-To: Message-ID: [James_Althoff at i2.com] > ... > What if (in post-2.2) Python the tp_iter slot in the int type was > defined to return an xrange-like iterator such that one could do the > following: > > for i in 10: > doSomething(i) > > or, more realistically, > > for rowIndex in table.getRowCount(): > doSomething(rowIndex) > > instead of having to do the range(table.getRowCount()) thingie (or > xrange, if one prefers)? This isn't even half as disgusting as most people will say it is . I rather like it! Write a PEP. The usual rap against giving meaning to previously exceptional conditions is that it harms error-detection (what if the user made a mistake, and didn't have the new meaning in mind? for example, introducing negative array indices was a mixed blessing that way, often great but sometimes helping obscure indexing bugs go undetected). However, most times I've seen an exception due to using an int "instead of a sequence", I do believe stuffing range() around the int was the cure: it wasn't so much a logic error as a spelling error. Common newbie example: for i in len(list): print list[i] OTOH, what they really want is for x in list: print x so I'm not sure it's a Good Thing to let their first mistake "work". It would also be way cool that x = 1 sets x to 1 but x, = 1 sets x to 0 . postfix-comma-considered-prefix-decrement-ly y'rs - tim From m.faassen at vet.uu.nl Fri Nov 9 10:09:22 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 9 Nov 2001 15:09:22 GMT Subject: Gratuitous post References: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> Message-ID: <9sgrj2$aqq$1@newshost.accu.uu.nl> Steve Holden wrote: > Free software. Doing your service for the PSU, hm? I'm not sure if From bernhard at intevation.de Fri Nov 30 11:20:04 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 30 Nov 2001 16:20:04 GMT Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <9u8bjk$6tdp0$2@ID-89274.news.dfncis.de> http://subversion.tigris.org/ still in development, but looks promissing. In article , Laura Creighton writes: > Does anybody have any favourite alternatives to CVS? I'm constantly > looking for something which is not file oriented, or which is better > able to handle multiple people editing the same file on the same day. > Just a way to insist 'I just moved that class into its own file. > Nobody gets to reinsert their old hacked versions of this class _back_ > into this file -- if you are changing this class you now need _that file_' > would be incredibly useful. -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From rpb at soton.ac.uk Fri Nov 30 06:55:05 2001 From: rpb at soton.ac.uk (Richard Boardman) Date: Fri, 30 Nov 2001 11:55:05 -0000 Subject: Expat XML Parser References: <9u2t5e$kh4$1@aspen.sucs.soton.ac.uk> Message-ID: <9u7s30$amt$1@aspen.sucs.soton.ac.uk> Martin, Andrew, Garth and Carel: Thanks very much for your help; you've given me all sorts of new ideas to try out. I was just running round in circles before! I had wondered about using classes, but I wasn't sure how to go about their implementation. Martin: thanks for clarifying event-driven processing for me! Now I can get back to doing work instead of chasing my tail ;) Regards, Richard From cjensen at bioeng.ucsd.edu Wed Nov 28 11:57:25 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Wed, 28 Nov 2001 08:57:25 -0800 Subject: affects on extended modules Message-ID: <3C051775.A8D4FD66@bioeng.ucsd.edu> We have created a python interface to some core libraries of our own making. We also have a C interface to these same libraries. However, the the python interface seems to affect the speed of the extended libraries. ie. some library routines have their own benchmark code, and the time of exection from the start of the library routine to the end of the library routine (not including any python code execution), takes longer than it's C counterpart. Note, all data memory in Python is allocated using Numeric to allocate memory for arrays. All data memory in the C counterpart is allocated using basic array constructs using alloc. We are unsure of why there is a performance difference. We only have some speculation. Our best guess is that the memory allocated in Python is causing cache faults and thus incurring some overhead. If anyone else has any ideas, we would appreciate any input. Thanks. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From timr at probo.com Thu Nov 8 00:36:27 2001 From: timr at probo.com (Tim Roberts) Date: Wed, 07 Nov 2001 21:36:27 -0800 Subject: odbc: how to call a stored function in Oracle References: <25c120d1.0111071216.1947ca09@posting.google.com> Message-ID: tom.hines at usa.net (Tom Hines) wrote: > >Hi. I'm using ActivePython 2.1.212 and MS ODBC driver for Oracle. I >am able to call a stored procedure that returns a cursor, but I >haven't been able to figure out how to call a stored function or a >procedure that has an output parameter. I don't think ODBC supports stored procedures returning a value directly. Only as part of a cursor. I also don't know Oracle; it is possible for you to restate that as a SELECT statement with a constant, one-row result, as in: SELECT Call MYPKG.MYFUNC (?) AS result; -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From paul.malinowski at wulfsberg.com Mon Nov 26 18:45:17 2001 From: paul.malinowski at wulfsberg.com (Paul Malinowski) Date: 26 Nov 2001 15:45:17 -0800 Subject: Perl to Python Message-ID: Howdy, I am relatively new to programming and very new to Python. I have a number of Perl/CGI scripts on a Linux/Apache web server that run queries to MS Access databases through an Openlink service running on an NT server. Works great! I have been trying to do the same thing with Python and am not having much luck. Would it be to much to ask one of you Python guru's to help me translate this from Perl to Python? (I intentionally left out the paths in the Perl environment variables to the OpenLink installed client on my Linux system to hide user names and such...) Any help would be really appreciated! Paul Malinowski #!/usr/bin/perl #Setting some environment variables. $ENV{UDBCINI}="~openlinksw/bin/udbc.ini"; $ENV{ODBCINI}="~openlinksw/bin/odbc.ini"; $ENV{ODBCINSTINI}="~openlinksw/bin/odbcinst.ini"; $ENV{LD_LIBRARY_PATH}="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib"; $ENV{SHLIB_PATH}="$ENV{SHLIB_PATH}:~openlinksw/lib"; $ENV{PATH}="$ENV{PATH}:~openlinksw/bin:~openlinksw/samples/ODBC"; #SQL query that runs qryModelSNforWeb in the warranty Access database. $sql = "echo \"select * from ;\" | odbctest DSN="; if (!open(SQL,"$sql |")) { print "Unable to open connect to database
"; exit 0; } if (open(SQL, "$sql |")) { chomp(@rawdata = ); } From radix at twistedmatrix.com Sat Nov 10 23:09:29 2001 From: radix at twistedmatrix.com (radix) Date: Sat, 10 Nov 2001 23:09:29 -0500 Subject: doc generator References: Message-ID: Itamar Trauring and Jurgen Hermann (sorry Jurgen, no umlaut key) are working on a "competitor" of HappyDoc's called Teud. It uses XSLT and lookes much better (IMO) than HappyDoc. http://twistedmatrix.com/users/jh.twistd/python/moin.cgi/TeudProject On Sat, 10 Nov 2001 14:20:43 -0500, David B?langer wrote: > Looking for software to generate doc from source. Tried pythondoc 0.7 > but was unable to make it run on freeBSD. Looks that it was more made > for Windoz. > > Thanks, > David -- strange all my life i've hated object oriented programming when the problem was simply that i was using C++ -- Chris Armstrong <<< radix at twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/ From glauco.silva at iti.gov.br Tue Nov 6 12:12:30 2001 From: glauco.silva at iti.gov.br (Glauco Silva) Date: Tue, 6 Nov 2001 15:12:30 -0200 Subject: help - Create dll Message-ID: <004401c166e6$37aa3f60$107290c8@iti.gov.br> Hi , How can i create a dll file ( C dynamic library) from windows to be imported by python . Thank you Glauco -------------- next part -------------- An HTML attachment was scrubbed... URL: From shriek at gmx.co.uk Mon Nov 12 00:19:44 2001 From: shriek at gmx.co.uk (Stephen) Date: 11 Nov 2001 21:19:44 -0800 Subject: Sockets and messaging services Message-ID: <97ae44ee.0111112119.e8f42d2@posting.google.com> I have a CGI script which takes a HTTP request then sends a message to a custom server built on top of SocketServer.ThreadingTCPServer. Not that there is much chance of webserver CGI saturating the latter, but does Python have a messaging framework, similar to JMS for Java ? http://developer.java.sun.com/developer/technicalArticles/Networking/messaging/ Also in testing my socket server, I have noticed that if a process opens a socket (S) and the process is destroyed before closing the socket (S.close()), then the socket server gives an error "error: (10054, 'Connection reset by peer')". What happens with the server threads that were handling the sockets ? (I am using SocketServer.ThreadingTCPServer) Stephen From terabaap at yumpee.org Tue Nov 13 00:22:25 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Tue, 13 Nov 2001 05:22:25 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> Message-ID: <3BF0AE43.9050801@yumpee.org> Chris Tavares wrote: > "Manoj Plakal" wrote in message > news:3BF07BC8.3090405 at yumpee.org... > [... snip ...] > >> Basically, we need a portable, light-weight messaging >> protocol with a simple way of finding out how >> to connect to an application and calling some >> of the methods it exposes. Without having to >> do HTTP and XML and all that stuff that comes >> with XML-RPC and SOAP. >> >> > This is pretty much the goal of COM on Windows systems. It's potentially > very light weight - for simple addins, it's an inprocess function call. > > You might want to look at the Mozilla XPCOM stuff. I was going through some presentations by ActiveState on PyXPCOM and noticed a big bummer that basically rules out XPCOM: it can't be used for inter-process communication. All components that you talk to have to be loaded in the current application. Manoj From mind.tech at verizon.net Sun Nov 25 15:16:09 2001 From: mind.tech at verizon.net (Power-Tech) Date: Sun, 25 Nov 2001 20:16:09 GMT Subject: WINDOWS USERS???? Message-ID: <3C015216.9B4F2F8C@verizon.net> Hello, I've downloaded the regular Python and had some problems running the .py files, today I found that "ActivePython" should be the best download for windows users.... Can anyone throw some light on this? I am also a first time programmer (which means my only previous experience was with HTML, and some scripting language), does anybody knows about a good tutorial online for someone in my situation? Is this group too advanced for me? I appreciate your attention Willie From thomasNO at SPAM.obscure.dk Thu Nov 15 19:06:21 2001 From: thomasNO at SPAM.obscure.dk (Thomas Jensen) Date: Fri, 16 Nov 2001 00:06:21 GMT Subject: Threading References: Message-ID: David Bolen wrote in news:uy9l7y431.fsf at ctwd0143.fitlinxx.com: > I think this URL will get you to the thread (not sure if it can be > simplified) - it's all one line: > > http://groups.google.com/groups?hl=en&threadm=mailman.1003864103.32304.python-list%40python.org&rnum=1&prev=/groups%3Fq%3Dg:thl4080539814d%26hl%3Den%26selm%3Dmailman.1003864103.32304.python-list%2540python.org Thank you, this URL has been added to the Python section of my hotlist :-) -- Best Regards Thomas Jensen From joseph at arbitrary.org Fri Nov 30 16:52:33 2001 From: joseph at arbitrary.org (Joseph Santaniello) Date: Fri, 30 Nov 2001 13:52:33 -0800 Subject: pygettext examples? In-Reply-To: References: Message-ID: OK, so it works now (I had my directory structure incorrect) but the only way I have successfully changed languages on the fly is by using os.environ['LANG'] = 'no'. I haven't been able to figure out how to use gettext.translation() and install() to change the language. Is there any reason why I shouldn't just continue to use the os.environ method? Thanks everyone for the help. Joseph On 30 Nov 2001 at 12:32, Trond Eivind Glomsr?d wrote: > Joseph Santaniello writes: > > > Hi Martin, > > > > I've gotten my code marked up: (test.py) > > > > #!/usr/bin/python2 > > import gettext > > > > def _(msg): > > return gettext.dgettext("test", msg) > > > > def do_stuff() > > print _("I don't know.") > > > > if __name__ == '__main__': > > do_stuff() > > > import gettext > ## > ## I18N > ## > gettext.bindtextdomain(PROGNAME, "/usr/share/locale") > gettext.textdomain(PROGNAME) > _=gettext.gettext > > print _("Hello, world!") > > From loewis at informatik.hu-berlin.de Mon Nov 26 11:04:17 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Nov 2001 17:04:17 +0100 Subject: fork & exec a process? References: <87667x7o58.fsf@home.com> Message-ID: Jim Meier writes: > There must be a way to do this, what am I missing? I recommend to create a popen2.Popen3 instance, and then use its .wait() method (or .poll(), to check for completion). HTH, Martin From ballabio at mac.com Wed Nov 14 07:23:46 2001 From: ballabio at mac.com (Luigi Ballabio) Date: Wed, 14 Nov 2001 12:23:46 +0000 Subject: Infinite lists and generators In-Reply-To: <7xg07hsns8.fsf@ruckus.brouhaha.com> References: Message-ID: <5.1.0.14.0.20011114121906.00a695a0@mail.mac.com> At 01:29 AM 11/14/01 -0800, Paul Rubin wrote: >Luigi Ballabio writes: > > I've been reading a few back issues of the Perl Journal, and I > > came across an article on implementing infinite lists in Perl. Just > > for fun I went ahead and reimplemented it in Python---I know someone > > probably did already, but as I said, it was for fun. Also, I've > > written a test suite which showcases a few tricks such as building the > > list of all prime numbers, of the Hamming numbers, and the power > > series of exp, sin and cos. I'm including the file below. > > > > My question is: how does one go about pulling such stunts with > > generators instead? > >You might like to read the book Structure and Interpretation of >Computer Programs, by Abelson and Sussman. The entire text is online at: > > http://mitpress.mit.edu/sicp/sicp.html Paul, you might notice from the comments in the file that the power series tricks in the test suite were taken from SICP :) It was nice of you to post the link though, since a) I hadn't included it b) it should be mandatory reading for anyone who calls himself a programmer :) Bye, Luigi From ulbi at ivs.tu-berlin.de Thu Nov 29 09:45:12 2001 From: ulbi at ivs.tu-berlin.de (Andreas Ulbrich) Date: Thu, 29 Nov 2001 15:45:12 +0100 Subject: pyplets References: <655abd4a.0111290417.4b28a0f2@posting.google.com> Message-ID: <3C0649F8.4000509@ivs.tu-berlin.de> Or you may use jython, the Java implementation of Python. Write your applet (or pyplet :-) in Python and compile it with jythonc to a .class file. see: www.jython.org This is nothing new, we have it and it works. e toffi wrote: > i was thinking (which i dont do often), and came up with an idea > (which i *do* do often -- dont ask me how). the idea is pyplets -- the > analogue to java applets with a fittingly silly name. anyway the > premise is to define an api that lets programmers write small programs > that execute in a browser. > > whatdyathink? > From wl at flexis.de Wed Nov 21 11:14:03 2001 From: wl at flexis.de (wl) Date: Wed, 21 Nov 2001 17:14:03 +0100 Subject: dictionary-question References: Message-ID: <3BFBD2CB.6070100@flexis.de> Hello, Bas van Gils wrote: > My current "workaround" is this: > > >>> if foo.has_key("bar"): > ... foo["bar"] += 1 > ... else: > ... foo["bar"] = 1 > ... > >>> foo > {'bar': 1} > > (this is just an demonstration of the behavior I don't get ... I want to > use it in a bigger script). > > Now, can someone please explain why the > > foo.get("bar",0) += 1 > > won't work ... and what might be a better sollution then my current > workaround? Better sollution: foo["bar"] = foo.get("bar",0) +1 That works as expected. foo.get("bar",0) += 1 won't work because you try to assign something to a function. Thist is the same as foo.get("bar",0) = foo.get("bar",0) + 1 ( or same with __add__( ... ) ) The function is not evaluted, all is parsed from right to left. But if it goes the other way it makes no sense to add 1 to the integer value 0. ( foo.get("bar",0) returns 0 if bar is not present into foo, not foo["bar"] with value 0 ). bye by Wolfgang From montanaro at tttech.com Mon Nov 5 11:21:53 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Mon, 05 Nov 2001 17:21:53 +0100 Subject: MySQLdb Question In-Reply-To: References: Message-ID: David> Can anyone tell me why I need to connect twice in order to set David> cursorclass=MySQLdb.cursors.DictCursor? David> If I try to include this argument the first time, I get an error. David> The only way I can get it to work without the error is to David> recreate the connection object a second time like this. It works for me. Is it perhaps because you didn't import MySQLdb.cursors in your code before creating the connection (and that the first connection you created did that import for you)? Try this: import MySQLdb, MySQLdb.cursors db1 = MySQLdb.connect(user = config.user, passwd=config.passwd, host=config.host, db = "prweb", cursorclass=MySQLdb.cursors.DictCursor) -- Skip Montanaro (skip at pobox.com) From phr-n2001d at nightsong.com Wed Nov 7 04:37:15 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 07 Nov 2001 01:37:15 -0800 Subject: Teaching python (programming) to children References: <3BE82570.D76DCAE9@juno.com> <7xwv13kkko.fsf@ruckus.brouhaha.com> Message-ID: <7xsnbqdir8.fsf@ruckus.brouhaha.com> Paul Rubin writes: > Brian Elmegaard writes: > > I have to check out logo. > Oh wow, I hadn't seen this site before (The Logo Foundation): http://el.www.media.mit.edu/groups/logo-foundation/ From kfarmer at thuban.org Mon Nov 26 19:07:58 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Tue, 27 Nov 2001 00:07:58 GMT Subject: PythonWin event handling args? Message-ID: What are the contents of the params argument in a PythonWin event handler? Example: def on_size (self, params): lparam = params[3] w = win32api.LOWORD(lparam) h = win32api.HIWORD(lparam) self.GetDlgItem (win32ui.IDC_LIST1).MoveWindow((0,0,w,h)) lparam I recognize, but what are the other elements of params? ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From alain.desilets at nrc.ca Mon Nov 12 17:00:07 2001 From: alain.desilets at nrc.ca (Alain =?iso-8859-1?Q?D=E9silets?=) Date: Mon, 12 Nov 2001 16:00:07 -0600 Subject: Opening sockets on multiple ports Message-ID: <5463D867.7E5C3083@nrc.ca> I'm trying to implement a 2-way communication link between a client and a server. By 2-way, I mean that both the client and the server can initiate transactions. So in fact, the "client" is only a client in the sense that it is responsible for initiating the connection with the "server" during the hand-shaking part of the protocol. But after that, both sides can initiate transactions (this is done in separate threads obviously). My approach is to implement a non-blocking server using the SocketServer module. The client and server communicate through a pair of sockets, the TO_SERVER and FROM_SERVER sockets. Those are used for transactions that are initiated by the client and by the server respectively. Attached are two small pieces of code for the client and server parts. My problem is that I can't seem to be able to open two sockets on two different ports. For example, if I run those scripts in separate windows, I get: ****** in the client window ********* E:\VoiceCode\VCode.TCP_IP\Mediator>python socket_client_pylist.py -- ToServerThread: AF_INET=2, SOCK_STREAM=1, HOST=alaindes, TO_SERVER_PORT=50007 -- TO_SERVER Connection {'_sock': } opened -- FromServerThread: AF_INET=2, SOCK_STREAM=1, HOST=alaindes, FROM_SERVER_PORT=50008 Traceback (innermost last): File "socket_client_pylist.py", line 47, in ? fsChannel = FromServerThread() File "socket_client_pylist.py", line 32, in __init__ aSocket.connect(HOST, FROM_SERVER_PORT) File "", line 1, in connect socket.error: (10061, 'winsock error') ****** in the server window ********* E:\VoiceCode\VCode.TCP_IP\Mediator>python socket_server_pylist.py ... TO_SERVER Connection {'_sock': }: Starting handler In other words, the first connection (on the TO_SERVER port) opens correctly, but the second one (on the FROM_SERVER port) fails. Note that if I set both TO_SERVER_PORT and FROM_SERVER_PORT to the same port number (on both client and server sides), then I don't get this problem, i.e. I am able to open both connections. But then messages for client-initiated and server-initiated transactions get mixed together (not shown in this code, but I have tried it and that's what happens). Note also that everything happens in separate threads on both the client and server sides. On the client side, the two sockets are started by two separate threads. On the server side, the two SocketServers are running in separate threads. In addition, the handlers used to process a new connection are also spawned as separate threads (i.e. I use ThreadingTCPServer). Can anyone pull me out of the mud here? Thanks -- Alain D?silets Agent de recherche Conseil National de Recherches du Canada Research Officer National Research Council of Canad -------------- next part -------------- import SocketServer import threading # Port for transactions initiated by the client TO_SERVER_PORT = 50007 # Port for transactions initiated by the server FROM_SERVER_PORT = 50008 # # This handler is invoked when a new TO_SERVER socket is opened # class ToServerHandler(SocketServer.BaseRequestHandler): def handle(self): f = self.request.makefile() print '... TO_SERVER Connection %s: Starting handler' % self.request.__dict__ # # This handler is invoked when a new FROM_SERVER socket is opened # class FromServerHandler(SocketServer.BaseRequestHandler): def handle(self): f = self.request.makefile() print '... FROM_SERVER Connection %s: Starting handler' % self.id # # This thread listens for new connections on the TO_SERVER port # class ToServerServer(threading.Thread): def __init__(self): self.server = SocketServer.ThreadingTCPServer(("", TO_SERVER_PORT), ToServerHandler) def run(self): self.server.serve_forever() # # This thread listens for new connections on the FROM_SERVER port # class FromServerServer(threading.Thread): def __init__(self): self.server = SocketServer.ThreadingTCPServer(("", FROM_SERVER_PORT), FromServerHandler) def run(self): self.server.serve_forever() # # Start 2 threads, each listening for new connections on the TO_SERVER and # FROM_SERVER ports respectively # def serve_non_blocking(): # TO_SERVER thread tsServer = ToServerServer() tsServer.run() # FROM_SERVER thread fsServer = FromServerServer() fsServer.run() # # This third thread simulates a busy server # class DoStuffThread(threading.Thread): def run(self): """Simulate a very busy server""" while 1: x = 1 # print 'x=%s' % x if __name__ == '__main__': # Simulate busy server doer = DoStuffThread() doer.start() # Listen for connections on the TO_SERVER and FROM_SERVER ports serve_non_blocking() -------------- next part -------------- from socket import * import threading # Port for transactions initiated by client TO_SERVER_PORT = 50007 # Port for transactions initiated by server FROM_SERVER_PORT = 50008 HOST = gethostname() # # This thread opens a new connection on the server's TO_SERVER port # class ToServerThread(threading.Thread): def __init__(self): print '-- ToServerThread: AF_INET=%s, SOCK_STREAM=%s, HOST=%s, TO_SERVER_PORT=%s' % (AF_INET, SOCK_STREAM, HOST, TO_SERVER_PORT) aSocket = socket(AF_INET, SOCK_STREAM) aSocket.connect(HOST, TO_SERVER_PORT) print '-- TO_SERVER Connection %s opened' % repr(aSocket.__dict__) def run(self): pass class FromServerThread(threading.Thread): def __init__(self): print '-- FromServerThread: AF_INET=%s, SOCK_STREAM=%s, HOST=%s, FROM_SERVER_PORT=%s' % (AF_INET, SOCK_STREAM, HOST, FROM_SERVER_PORT) aSocket = socket(AF_INET, SOCK_STREAM) aSocket.connect(HOST, FROM_SERVER_PORT) print '-- FROM_SERVER connection %s opened' % repr(aSocket.__dict__) def run(self): pass if __name__ == "__main__": # # Initiate connection to the server # tsChannel = ToServerThread() tsChannel.run() fsChannel = FromServerThread() fsChannel.run() # # In the mean time, do some stuff in the main thread to simulate a busy # client. # ii = 0 while 1: # print "I'm a busy client: %s" % ii ii = ii + 1 From lac at strakt.com Wed Nov 28 09:40:04 2001 From: lac at strakt.com (Laura Creighton) Date: Wed, 28 Nov 2001 15:40:04 +0100 Subject: Is selecting from multiple list boxes in Tk possible? In-Reply-To: Message from Greg Ewing of "Wed, 28 Nov 2001 18:11:35 +1300." <3C047207.8243CFE7@cosc.canterbury.ac.nz> References: <3C047207.8243CFE7@cosc.canterbury.ac.nz> Message-ID: <200111281440.fASEe5ua006655@ratthing-b246.strakt.com> Make your listboxes with exportseletion = 0 ie lb = Listbox(exportselection=0) Laura Creighton From James_Althoff at i2.com Wed Nov 28 20:49:45 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 17:49:45 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: David Eppstein wrote: >I don't know how your set theory class defined the integers, but one >possible way is equivalence classes of ordered pairs (a,b) (representing >integers a-b) where a and b are naturals and (a,b) equiv (c,d) when >a+d=b+c. And then you have to worry about the set-theoretic definition of >ordered pairs Or, we could contemplate Russell's Paradox. Or, not. Jim From aaldv97 at student.remove-this-part.vxu.se Mon Nov 5 11:21:46 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Mon, 5 Nov 2001 17:21:46 +0100 Subject: Teaching python (programming) to children References: Message-ID: <9s6ecs$1u7$1@news.lth.se> Python is without doubt a very good language, but it's not good for the beginner because they will pick up bad practices, mostly because of the loose type paradigm. For teaching programming I strongly belive that Ada95 is by far the best, it teaches the students how to write good code; I do believe that at least in universities Python should be the language of choice beyond the first year studies, unless doing hardware or AI programming. From sholden at holdenweb.com Fri Nov 9 16:26:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Nov 2001 16:26:09 -0500 Subject: Dont Read - Retaliation for Spamming References: <9shbmr$avp$4161@plutonium.btinternet.com> Message-ID: wrote in message news:9shbmr$avp$4161 at plutonium.btinternet.com... > hostmaster at newbrummusic.com [ and so on, at tedious length] Well, since you asked me not to read it, I didn't. If I ask you not to use this newsgroup to retaliate against spammers, will you do that? Your message was, in fact, spam. regards Steve -- http://www.holdenweb.com/ Full headers as seen on newsgroup: Path: atlpnn01.usenetserver.com!cyclone-atl1!newsfeeds-atl1.usenetserver.com!cyclo ne2.usenetserver.com!usenetserver.com!newsfeed.ision.net!ision!news-fra1.dfn .de!news-kar1.dfn.de!news-han1.dfn.de!news-nue1.dfn.de!news-lei1.dfn.de!news feed00.sul.t-online.de!t-online.de!nntp-relay.ihug.net!ihug.co.nz!news-spur1 .maxwell.syr.edu!news.maxwell.syr.edu!btnet-peer1!btnet-feed5!btnet!mendelev ium.btinternet.com!not-for-mail From: hostmaster at newbrummusic.com Newsgroups: comp.lang.python Subject: Dont Read - Retaliation for Spamming Date: 9 Nov 2001 19:44:27 GMT Organization: BT Internet Lines: 102 Message-ID: <9shbmr$avp$4161 at plutonium.btinternet.com> NNTP-Posting-Host: host213-122-142-129.btinternet.com Xref: usenetserver.com comp.lang.python:133735 X-Received-Date: Fri, 09 Nov 2001 14:49:11 EST (atlpnn01.usenetserver.com) From gordon.scott at peregrine.com Tue Nov 27 16:55:52 2001 From: gordon.scott at peregrine.com (Gordon Scott) Date: Tue, 27 Nov 2001 13:55:52 -0800 Subject: newbie question - object from a string? Message-ID: Thanks that did the trick! -----Original Message----- From: Fernando P?rez [mailto:fperez528 at yahoo.com] Sent: Monday, November 26, 2001 3:59 AM To: python-list at python.org Subject: RE: newbie question - object from a string? Gordon Scott wrote: > Thanks for the reply. Didn't get this until this morning. > > I have a file named MyHandlers.py in which I have the class MyHandler. > > when I use > > __import__('MyHandlers', globals(), locals(), ['MyHandler']) or > . > . > . > eval('MyHandler()', globals(), locals()) or eval('MyHandlers.MyHandler()', > globals(), locals()) > > I get a NameError: name 'MyHandler' is not defined. Python is dynamic. Just generate the code: mod = 'MyHandlers' cls = 'MyHandler' exec 'from '+mod+' import '+cls That should work just fine. Cheers, f -- http://mail.python.org/mailman/listinfo/python-list From hfoffani at yahoo.com Thu Nov 15 07:07:01 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Thu, 15 Nov 2001 13:07:01 +0100 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <20011115070740.432$Dm@news.newsreader.com> "Michael 'Mickey' Lauer" escribi? en el mensaje news:3beedf26 at nntp.server.uni-frankfurt.de... > .... > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? > .... Nobody suggested it, so I will: A GUI "face" for an offline browser: Once you have a nice class that does the connection, grabs and parse the links (there are samples of this on the web) your project starts with the frontend. That class will have a clean interface so newbies don't need to mess with sockets, parsers, etc. And will show them how to design a GUI application separating presentation and "business" layers. The very first sample can be a window with a start (stop) button. Then you can add a progress bar, etc. And you can end with a multiple pane window with a tree widget showing the site structure, tabs panes with dialog boxes for setting parameters etc. And if you are brave enough you can finish with a multithreaded GUI application! hehehe... Hey! I love so much my idea that I will buy your book if you'll implement it! :-) note: There is no need to have a live internet connection for the samples to work as the offline browser can grab and parse the pages from the harddrive or the CD, for instance "grab" the Python Docs from the book's CD. (You are going to include a CD with the book full of python related thing, right? :-) Regards, -Hern?n From Nadavh at envision.co.il Sun Nov 11 04:06:41 2001 From: Nadavh at envision.co.il (Nadav Horesh) Date: Sun, 11 Nov 2001 11:06:41 +0200 Subject: Splitting on a regex w/o consuming delimiter Message-ID: <3BEE3FA1.9090804@envision.co.il> Whats about: >>> st = 'This @is a @modul@ ar trr' >>> re.split(".(?=@)", st) ['This', '@is a', '@modu', '@ ar trr'] Nadav. From sholden at holdenweb.com Wed Nov 14 17:34:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 17:34:02 -0500 Subject: does \1 in re work? References: Message-ID: <8gCI7.21757$vQ1.851579@atlpnn01.usenetserver.com> "Michael P. Soulier" wrote... > Hello. > > Looking at the documentation for python 1.5.2, the now aging version that > I'm using, in the re module it states that the standard \1, \2 keys that > reference that matched value in parenthesis in the pattern do in fact work, as > do \g<1>, \g<2>, etc. > > So, I tried this: > > new = re.sub("^(-?\d+)(\d{3})", '\1,\2', amount) > > new always ended up being '\001,\002'. Not what I wanted. > > So, I used the alternate... > > new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', amount) > > Which worked perfectly, giving me, for example, > > '100000,000' where amount was '100000000'. > > So, my question is, what was wrong with my first pattern? > The fact that you have neither used a raw string nor escaped the backslashes. Since \g isn't a recognised escape you get away with that! Try new = re.sub("^(-?\d+)(\d{3})", r'\1,\2', amount) and see what difference it makes. regards Steve -- http://www.holdenweb.com/ From nobody at nowhere Tue Nov 6 19:21:09 2001 From: nobody at nowhere (nobody at nowhere) Date: Wed, 07 Nov 2001 00:21:09 GMT Subject: Newbie Needs Help Message-ID: <9sagdn$u5n$1@slb2.atl.mindspring.net> x-no-archive: yes Can somebody recommend some good Python tutorials? From max at alcyone.com Tue Nov 20 13:28:16 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 20 Nov 2001 10:28:16 -0800 Subject: os.kill........ References: <9te2g4$sma$1@mail1.wg.waii.com> Message-ID: <3BFAA0C0.56460DFF@alcyone.com> Martin Franklin wrote: > I'm looking for a way of determining if a process is still running > (having > spawned it from a python app), I have come up with os.kill(PID, 0) > this will raise an exception if the process does not exist, and doe > nothing > if the process does exist. The sig of zero does not _seem_ to affect > it > (at least not on my linux box) This is fairly standard idiom under UNIX. Often more harmless calls are made, such as getpriority (of which I don't know if there's a Python equivalent). -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From fperez528 at yahoo.com Fri Nov 30 08:57:08 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 01 Dec 2001 13:25:08 +2328 Subject: Whatever happened to String Interpolation? References: <9u6dbn$nsj$1@peabody.colorado.edu> <9u6kft$5b$1@peabody.colorado.edu> Message-ID: <9ubecn$ped$1@peabody.colorado.edu> Andreas Kostyrka wrote: > What about "%%%(x)s%%" % locals() I'm looking for _clarity_ in the code. I've already written enough perl code in my life for things like that. > >> I am a big defender of not extending things unless truly needed, >> and with time I've learned to do things the 'python way', without >> saying at every corner 'but language_x has this feature!'. But >> string handling is the one that *constantly* feels kludgy in an >> otherwise stunningly clean and elegant language. > Nope it does not ;) > Adding magic handling of strings would make another wart in a clean > and elegant language. We already have magic strings: r'\....'. Since (char)'...' already means 'this string is special', pep215 just meant a new special mode in an already existing framework. We have raw, we'd have raw and interpolated. It doesn't introduce any new concept into the language, it only extends an existing one. >> I felt that pep215 had a clean argument, the extension is very >> orthogonal to the existing features, and can make a lot of code >> simply a lot cleaner. I feel those are strong arguments. > Not really. Python already has: > 1.) print >>f, data > 2.) "format" % data > > If you do not want exact formating the first one is quite > acceptable: >>>> import cStringIO >>>> x=cStringIO.StringIO() >>>> print >>x, "Hello World." >>>> x.getvalue() > 'Hello World.\n' This doesn't address the isssue o interpolating values with a clearer syntax, it's just a different way of doing the same we have today. >> Well, I can keep dreaming... > Try Ruby. It's got more perlish features. I don't want ruby (I've looked at it), I don't want perl (been there, done that, never again). I like python *a lot*, I just see an opportunity for a clean way of making it even more convenient in everyday programming than it already is. Cheers, f. From thomas.heller at ion-tof.com Thu Nov 8 06:10:35 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 8 Nov 2001 12:10:35 +0100 Subject: VHDL? Message-ID: <9sdp7b$12jom5$1@ID-59885.news.dfncis.de> Since I'm going to do a lot of electronics design in VHDL in the near future, I'd like to ask if anyone has done something to 'connect' VHDL and Python? Neither a google search nor Parnassus found anything... Thomas From logiplexsoftware at earthlink.net Tue Nov 13 14:01:19 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 13 Nov 2001 11:01:19 -0800 Subject: help for beginner ! In-Reply-To: <9sr9g4$gik$1@wanadoo.fr> References: <9sr9g4$gik$1@wanadoo.fr> Message-ID: <01111311011906.02982@logiplex1.logiplex.net> On Tuesday 13 November 2001 06:07, Michel Bonnifait wrote: > i want to directly print the list or the result of my program > i'm working with idle and i don't know how to do it without copying in one > printable document I'm sorry, I don't know exactly what you are trying to do. When you say "print", do you mean to the screen or to an actual printer? By "copying in one printable document" do you mean copying the output of your program into a text editor that you can then print from? Are you running Windows or some variation of Unix/Linux? -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From dale at riverhall.NOTHANKS.co.uk Wed Nov 21 06:08:41 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Wed, 21 Nov 2001 11:08:41 +0000 Subject: String formatting char References: <9tdde1$q6j$1@news1.wdf.sap-ag.de> Message-ID: <1h2nvt4gid8b1o9vv39ubqrmr7af05eb70@4ax.com> "Daniel Dittmar" wrote: >"Dale Strickland-Clark" wrote in message >> The string formatting operator, %, is a mighty powerful beastie when >> used in mapping mode if the map is an object of your own. >[...] >> Is there some way to alter the format escape character from % to >> something else? > >The %(varname)s formatting can be implemented using the re.sub method: > >class FancyLookup (UserDict): > def replace (self, match): > key = match.group (1) > return self [key] > >lookup = FancyLookup () >result = re.sub (r'%\(([^)]+)\)s', lookup.replace, input) > >You could add a 'sub' method to your FancyLookup class, thus having the >actual regular expression in only one place. > That's neat and gives you complete flexibility over the the substitution syntax - you could use !var!, for example but assumes a string substition. Also it would be much slower than the built-in function. -- Dale Strickland-Clark Riverhall Systems Ltd From tim at vegeta.ath.cx Tue Nov 13 21:44:14 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 14 Nov 2001 02:44:14 GMT Subject: Python Vim Module - works References: <3BF1B874.3060506@webone.com.au> Message-ID: simonb at webone.com.au graced us by uttering: [ snip ] > If you can get it to compile (just edit the Makefile to make it point to > the right place...) try this with Vim 6.0: > > $ gvim --servername TEST > $ python > > >>>import vim > >>>vim.list() > >>> > ['TEST'] > > >>>vim.send('TEST', 'iHello World!') > >>> > > You should see the string "Hello World!" neatly typed into the newly opened > vim window!!! [ snip ] Jonathan Gardner wrote: > Well this sounds interesting... > > i compiled vim60 with > CONF_OPT_PYTHON = --enable-pythoninterp > in the Makefile, > but "import vim" fails. > what next? > > Simon Burton It seems Simon didn't post the code to clpy, but only to vim-dev. Searching the vim-dev archives, the code is indeed there It is a python module (named vim.py) that may be loaded from outside of vim (or rather gvim, at the moment). The following worked perfectly on my box: $ gvim $ python Python 2.1 (#2, Oct 8 2001, 20:43:58) [GCC 2.95.3 19991030 (prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import vim, os >>> vim.list() ['GVIM'] >>> vim.send('GVIM', ':version') >>> vim.send('GVIM', '') >>> os.system('gvim') 0 >>> for i in vim.list(): ... vim.send(i, ':version') ... raw_input("Press to continue..."); ... vim.send(i, '') ... Press to continue... '' Press to continue... '' >>> vim.list() ['GVIM', 'GVIM2'] >>> vim.send('GVIM2', ':q!') >>> ^D (can't close 'GVIM'...it's got my post!) Congratulations, Simon! Tim Hammerquist -- If you had two people with a motive, and one of them was alive, who would you arrest? -- Inspector Boot, "Theater of Blood" From lfini at arcetri.astro.it Sat Nov 24 19:38:27 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Sun, 25 Nov 2001 01:38:27 +0100 Subject: File creation In-Reply-To: <1103_1006646455@t4q4p0> References: <1103_1006646455@t4q4p0> Message-ID: On Sun, 25 Nov 2001, Aaron Sterling wrote: > Hi, > > To create files, I am currently using: > > temp_file = os.open(file_name, O_CREAT) > temp_file.close() > open(file_name, 'w') > > Is this the cannonical way of doing it? If so, would it be usefull to have a function, create_file(file_name, mode, bufsize), linked to the interpreter, that > would create the file and return an associated file object? Is their a better way to do it, or is it something that shouldn't be done, and if so why? It is quite simpler than that: >>> fd=open('filename','w') >>> fd the open() function in write mode creates the file if it's not existing. Otherwise it truncates the existing file (i.e.: overrides the previous content) Cheers, l.f. -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From altis at semi-retired.com Wed Nov 21 03:33:13 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 21 Nov 2001 00:33:13 -0800 Subject: Still on python GUI toolkit References: Message-ID: "Prabhu Ramachandran" wrote in message news:mailman.1006265965.19059.python-list at python.org... > >>>>> "LF" == Luca Fini writes: > > LF> I'm trying to make a sound decision of which GUI toolkit to > LF> use for a new software project (it is the control and > [snip] > LF> After browsing through the various comparisons I could find > LF> around I stripped down the list to three of them: Tkinter, > LF> wxWindows, PyQt. > > One big advantage of Tkinter over almost any other toolkit is that you > can use/script an application written with it directly from the Python > interpreter on different platforms. This can be *very* powerful. To > do this with wxPython you have to do something like what scipy's > gui_thread does which is not a clean enough solution. I have no idea > about pyQt. You can create widgets and bind event methods to widgets using the shell with PythonCard as well. You can do this with any app. There is also a Property Editor for changing the widgets interactively at runtime, a Namespace Viewer and a Message Watcher. There are examples of runtime widget creation and event binding in the mail archives; it is very simple. http://pythoncard.sourceforge.net/ ka From root at rainerdeyke.com Tue Nov 13 19:38:19 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 14 Nov 2001 00:38:19 GMT Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: <%1jI7.131454$IR4.42373618@news1.denver1.co.home.com> "Ian Bicking" wrote in message news:359f85cd.0111131158.1520ea32 at posting.google.com... > Erik Max Francis wrote in message news:<3BEE09CD.FFC433CC at alcyone.com>... > Python is really sending, not calling. You don't (ever) know before > runtime what function definition is going to be invoked. If by "runtime" you mean at the actual time the function is called, you're wrong. def f(x): g = x.g print "I'm going to call %s." % g g() -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From bvdpoel at uniserve.com Mon Nov 12 11:36:34 2001 From: bvdpoel at uniserve.com (bvdpoel at uniserve.com) Date: Mon, 12 Nov 2001 09:36:34 -0700 Subject: agrep equivalent? References: <3BEEF857.D8F6438B@uniserve.com> Message-ID: <3BEFFA92.B87FCD25@uniserve.com> Matthew Dixon Cowles wrote: > > On Sun, 11 Nov 2001 15:14:47 -0700, bvdpoel at uniserve.com > wrote: > > >Is there an agrep or something similar module for python? Right now > >I'm calling this though the shell, but it be cleaner to do this > >natively... > > Agrep has been wrapped as a Python module. It's at: > > http://www.bio.cam.ac.uk/~mw263/pyagrep.html Thanks. I'll look at it later. > > I've used it though not lately and it seems to work fine. > > You may also want to have a look at difflib which is new in Python > 2.1's standard library. It takes a slightly different approach but > depending on what you're doing it may also be useful. I've not looked at this. Will do so before looking at the agrep stuff too much. Thanks again for the pointer. -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From emile at fenx.com Sat Nov 17 16:45:56 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 17 Nov 2001 13:45:56 -0800 Subject: Instantiating a class from its name References: Message-ID: <9t6m56$n4ld$1@ID-11957.news.dfncis.de> "Daniel Klein" wrote in message news:sgidvt8e5l5m7jmlk0grkqs9pm66beja8k at 4ax.com... > I need to create a class factory such that passing the 'name' of the class to the method will > produce an instance of that class. In Java, you do this with > > Class c = Class.forName("name_of_class"); > MyClass m = c.newInstance(); > > What is the Python equivalent? > >>> class A:pass ... >>> a = locals()['A']() >>> a <__main__.A instance at 007E5FE4> >>> class C: ... def __init__(self, val): ... self.val = val ... >>> c = locals()['C'](123) >>> c.val 123 >>> There's probably a better way, so by posting this I expect we'll find out. ;-) -- Emile van Sebille emile at fenx.com --------- From emile at fenx.com Thu Nov 15 18:41:32 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 15 Nov 2001 15:41:32 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <9t1kvg$166pi8$1@ID-11957.news.dfncis.de> "William Tanksley" wrote in message news:slrn9v8k4u.k8a.wtanksle at dolphin.openprojects.net... > I, however, am also starting to wonder about this... Aside from infinite > for loops, which DO seem very useful and not possible under the old > system, I've lost track of why we're arguing about this. Why should we > make any change here? What are we fixing? I don't know... ;-) ...but, if it ends up that for i in 10 becomes doable when we're done, that's all I'd like. I can deal fine with the other constructs as it is now and don't really see the need for any of this, but it'd nice to have. Along the lines of being able to drop the colons, which probably has as much chance of making it in as this does... ;-) -- Emile van Sebille emile at fenx.com --------- From emile at fenx.com Wed Nov 7 07:15:39 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 7 Nov 2001 04:15:39 -0800 Subject: Disk explorer from python with COM References: <3BE91448.5020809@ulb.ac.be> Message-ID: <9sb8u9$127p7o$2@ID-11957.news.dfncis.de> "Benoit Lagrange" wrote in message news:3BE91448.5020809 at ulb.ac.be... > Hi all > I am wondering wether it is possible to browse the disk from a python > application by using COM. > And if it is possible, how to use it? > Any help would be great. > Thanks > There are ways of browsing the disk using python. What more does using COM get you? -- Emile van Sebille emile at fenx.com --------- From kuran42 at yahoo.com Thu Nov 8 01:36:07 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Thu, 08 Nov 2001 01:36:07 -0500 Subject: Help Help Help References: <3be77f95@152.65.161.36> Message-ID: <3BEA27D7.9050405@yahoo.com> import sys def isInteger(x): """Checks if argument can be made to represent an int Returns 1 if so, 0 otherwise""" try: int(x) return 1 except: return 0 def isPrime(x): """Checks if argument is a prime number Returns 1 if so, 0 otherwise""" if x <= 1: return 0 else: for i in range(2, x / 2): if x % i == 0: return 0 return 1 def readInt(prompt = 'Enter an integer:'): """Read in and return an integer from standard input, printing prompt first and checking for valid input""" print prompt, while 1: x = sys.stdin.readline() if isInteger(x): return int(x) else: print 'That is not an integer, please try again:', if __name__ == '__main__': while 1: x = readInt('Enter a prime number:') if isPrime(x): for i in range(0, x): print i, sys.exit(0) else: print x, ' isn\'t a prime number.' Kojo Duncan wrote: > I'm taking a computer science course and I really need help understanding > python. If you know of any easy to follow tutorials, great emphasis on easy > to follow, please send me a reply on gyekye_7 at yahoo.com . > > Thanks. > > Here's a lil practice question for you python gurus out there. > > Write a program that lists all prime numbers less than a prime number a user > inputs. Post on site for all to see. > > > > > > From bedge at troikanetworks.com Tue Nov 20 13:39:24 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 10:39:24 -0800 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> Message-ID: In <3BFAA0FC.EB3CB91B at alcyone.com>, Erik Max Francis wrote: > Bruce Edge wrote: > >> I know about all the regex stuff, but I have the format string that >> was >> used to generate a string, which I'd like to use to decompose it back >> into it's source data: >> >> fmtstr = "%02d.%02d" >> >> str = fmtstr % ( x, y ) >> >> # Now get x any y back using only str and fmtstr: >> >> (x, y ) = ? > > x, y = map(int, str.split('.')) > OK, that works for this case, I was looking for something more generic. What about for this case: fmtstr = "x=%02d and y is %02d" currently I'm looking at converting the %02d into \d{:2} for use with the re module. -Bruce. From James_Althoff at i2.com Wed Nov 14 18:46:04 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 14 Nov 2001 15:46:04 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: David Eppstein wrote: >> [Tim Hochberg] >> >So you can use it in your own class if you want. In particular, one could >> >make >> > >> >int[1,3,...,53] act like range(1,53,2) if one wanted. > >I missed this the first time it came around, but here is another argument >why the current range syntax is not good: it confused Tim. >What you want is for int[1,3,...,53] to act like range(1,54,2) or >range(1,55,2) -- the final element of the range should be 53 not 51. I believe this brings up a key point, namely, any proposal for a new (Haskell-esque) syntax for specifying a sequence of integers is going to face the problem of open versus closed intervals. The difficulty is that a syntax that calls for both ends to be specified (as most such proposals do), as in for example "0 .. 5", will probably *look* like a closed interval. Unfortunately, the "most common case" of sequence indexing wants a half-open interval -- closed on the left and open on the right -- *not* a closed interval. In current Python, range and xrange yield the half-open interval that is ideal for sequence indexing. The "half-openness" is something that "just has to be learned". (But it is very convenient in the end.) Jim From kragen at canonical.org Sat Nov 24 02:11:02 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 24 Nov 2001 02:11:02 -0500 Subject: dynamic parameters References: <119c3c89.0111231417.5f060692@posting.google.com> Message-ID: <836680ve2h.fsf@panacea.canonical.org> (By the way, Lua is cool!) luiz at fabricadigital.com.br (Luiz Carlos Silveira) writes: > I already can call Lua functions from Python, but I have a > problem when calling Python functions from Lua. My problem is that > when I call a Python function, I don't know which function it is, so I > don't now how many parameters it will take. > My question is: how can I pass (dynamically) all the > parameters that the function should receive? > I'm using the Py_BuildValue function. As far as I could see, > this function only allows me to pass a determined number of > parameters. Well, you can't use Py_BuildValue. I think you can use PyTuple_New to create a tuple, then use PyTuple_SET_ITEM or PyTuple_SetItem to fill it in, then use PyObject_CallObject (as you're presumably doing). There's some sample code for some of this in the 'Reference Count Details' section of the Python/C API Reference Manual. From sasoft at gmx.de Wed Nov 28 20:17:10 2001 From: sasoft at gmx.de (cruciatuz) Date: Wed, 28 Nov 2001 20:17:10 -0500 Subject: 1st day newbie question. In-Reply-To: <29A97D00F387D411AC7900902770E14802BB131F@lcoeexc01.coelce.net>; from calves@coelce.com.br on Wed, Nov 28, 2001 at 05:06:10PM -0300 References: <29A97D00F387D411AC7900902770E14802BB131F@lcoeexc01.coelce.net> Message-ID: <20011128201710.A5267@blackscarab> On Wed, Nov 28, 2001 at 05:06:10PM -0300, Alves, Carlos Alberto - Coelce wrote: short hint: If you're under windows and you're not used to use the command prompt, you can put a raw_input() at the end of your script and you can start the text-file with a double-click if it has the *.py extension. try that if you want to avoid the command prompt at the beginning. -- Stefan Antoni ---------------------------- Mit Nov 28 20:12:31 EST 2001 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From root at rainerdeyke.com Mon Nov 26 12:29:34 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 26 Nov 2001 17:29:34 GMT Subject: question: metaclass and C - a new general style References: <3c02343d@netnews.web.de> Message-ID: <2_uM7.172373$IR4.63184952@news1.denver1.co.home.com> "Jens Gelhaar" wrote in message news:3c02343d at netnews.web.de... > When I compile a module with an class in it, I would like to call a special > function: __metainit__ after the class has been compiled. Don't do that. Names in the form '____' are reserved, and should not be used for your own "special" functions. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From usenet at minus1.de Fri Nov 23 15:04:27 2001 From: usenet at minus1.de (Konrad Anton) Date: Fri, 23 Nov 2001 21:04:27 +0100 Subject: Python + emacs/oo-browser ... pls help References: Message-ID: Mike Sowka schrieb: >I was wandering if anyone is using oo-browser under emacs21 (linux) and >if so... could you tell me how you build oo-browser... I'm ripping hair >out trying to figure this out. I've heard oo-browser is REALLY GOOD! >but... :( I used a readymade Debian package for oo-browser 4.07, which of course was rather painless to install, but I cannot recommend it for python work because it ignores modules. If you have a class Wouf in module Bla and another class Wouf in module Blubb, only one class Wouf is shown in the browser, and you don't even get to decide which. It looks nice, and browsing through lots of code can be very pleasant with the tool, but the class name problem has really disqualified oo-browser for me. HTHabit, Konrad. -- Konrad Anton gpg: 0x22954D8A Tel. +49-761-881-2122, Fax +49-721-151318943. Alice: Why (I shall have prizes)! From paul.moore at atosorigin.com Thu Nov 1 08:48:32 2001 From: paul.moore at atosorigin.com (Paul Moore) Date: Thu, 1 Nov 2001 14:48:32 +0100 Subject: win32wnet.WNetOpenEnum - passing NULL NETRESOURCE Message-ID: I'm trying to use win32wnet to enumerate net resources (it's actually to test some issues I'm having with a larger piece of software). The MSDN documentation says of the "resource" parameter, that it *must* be NULL if the scope parameter is not RESOURCE_GLOBALNET, and that it can be NULL if the scope parameter *is* RESOURCE_GLOBALNET. Also of relevance, it implies that to enumerate the full network, you should start the enumeration with a NULL resource, and walk the resulting tree from there. When I try to pass 0 as the resource parameter, though, I get an error - specifically, >>> w = WNetOpenEnum(2,0,0,0) Traceback (most recent call last): File "", line 1, in ? pywintypes.api_error: (0, 'WNetOpenEnum', 'failed converting NetResource Object') (Here, 2 is RESOURCE_GLOBALNET - it seems that this constant isn't exposed by win32wnet?) Is there something else I should use to pass a NULL value? Thanks, Paul. From loewis at informatik.hu-berlin.de Tue Nov 6 04:29:27 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 06 Nov 2001 10:29:27 +0100 Subject: gzip and file size References: <84a8bdbe.0111051534.501ea62e@posting.google.com> Message-ID: taw_usenet at yahoo.com (ToddW) writes: > It's simple to get the correct file size for a file. But if it is > gzipped, is there a simple way to snag the file size of the > uncompressed file? The last four bytes of the file contain the uncompressed size, unless the file is corrupted. If the compressed file was created by contatenating multiple compressed files, you can obtain the true uncompressed size only by uncompressing the entire file. Regards, Martin From eeide at cs.utah.edu Wed Nov 14 11:12:46 2001 From: eeide at cs.utah.edu (Eric Eide) Date: Wed, 14 Nov 2001 09:12:46 -0700 (MST) Subject: Parser Generators: which is best? References: <3BF297E2.4D900A75@divalsim.it> Message-ID: "Nicola" == Nicola Musatti writes: Nicola> While searching for parser generators in Python I came across Nicola> Aaron Watters's kw(j)Parsing and John Aycock's SPARK. Before I Nicola> make my choice I'd like to know about experiences with these or Nicola> other tools. Nicola> Nicola> Keep in mind that I'm (still!) a Python beginner and that I'm Nicola> more interested in ease of use than performance. Perhaps you would be interested in PLY: . >From the Web page: PLY is yet another implementation of lex and yacc for Python. [...] The original version of PLY was developed for an Introduction to Compilers course where students used it to build a compiler for a simple Pascal-like language. [...] Because of this, the current implementation has been extensively tested and debugged. In addition, most of the API and error checking facilities have been adapted to address common usability problems. Eric. -- ------------------------------------------------------------------------------- Eric Eide . University of Utah School of Computing http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX From george at cc.gatech.edu Sun Nov 18 17:20:13 2001 From: george at cc.gatech.edu (George Thomas) Date: Sun, 18 Nov 2001 17:20:13 -0500 (EST) Subject: SGMLParser error on HTML comment In-Reply-To: Message-ID: Hi, Well, to clear things up: I had a handler for the SGMLParseError. Thanks to Sean for directing me to the exact problem spot in the HTML file (which I should have spotted myself, had I not had other concerns). The problem I was grappling with was suppressing the error traceback after handling the error. Invoking the reset() method of the parser does this for me now. If time is on my side, I can venture into creating a more robust parser, instead of just rejecting bad HTML. On a mildly related note, is there a Python wrapper for libwww? rgds and thanks ----------------------------------------------------------------------- George Thomas 'wIjwI' Resident,Planet Earth,Third Rock from the Sun ----------------------------------------------------------------------- reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') ----------------------------------------------------------------------- From kragen at canonical.org Sat Nov 24 01:51:13 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 24 Nov 2001 01:51:13 -0500 Subject: test error after installation References: <20011123.130014.771151432.17893@jeroen.fw.belnet.be> Message-ID: <83bshsvezi.fsf@panacea.canonical.org> "Jeroen Valcke" writes: > I downloaded and installed Python 2.1.1 > after installation I did make install and got an error. > It seems to work fine when I start python. Should I be worried? > ... > test_zlib > Segmentation Fault - core dumped Yes, you should be worried. Does it segfault again if you do make install? The above indicates either flaky hardware or a serious bug, probably in Python. From phd at phd.pp.ru Thu Nov 29 12:27:13 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 20:27:13 +0300 Subject: __setattr__ recursion problem In-Reply-To: <3C066BF8.8D911FCB@olen.to>; from joonas@olen.to on Thu, Nov 29, 2001 at 07:10:16PM +0200 References: <3C066BF8.8D911FCB@olen.to> Message-ID: <20011129202713.K19701@phd.pp.ru> On Thu, Nov 29, 2001 at 07:10:16PM +0200, Joonas Paalasmaa wrote: > The code above causes an infinite loop. How can I set an attribute of > Class > without overloading the __setattr__ function? Or does someone have some > other > solution to make that script work? > > > > class Class2: > eggs = 1 > spam = 2 > > class Class: > base = Class2() > def __setattr__(s,attr, value): > if hasattr(s.base, attr): > setattr(s.base, attr, value) > else: > setattr(s, attr, value) To avoid recursion the last line must be s.__dict__[attr] = value > Class().foo = "eggs" Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From slinkp23 at yahoo.com Thu Nov 15 12:54:40 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 15 Nov 2001 17:54:40 GMT Subject: sending a function on the fly? References: <3bf2a06f$1@207.229.64.20> <3bf3942f$0$256$edfadb0f@dspool01.news.tele.dk> Message-ID: On Thu, 15 Nov 2001 11:08:50 +0100, Max M wrote: >"Peter Bismuti" wrote in message >news:3bf2a06f$1 at 207.229.64.20... > >> In ECMAscript you can send a function as an argument that is defined on >the >> fly such as: >> >> callMyFunction( new Function(){ blah blah }) >> >> Something like that. Here the function has not been named and was not >> defined outside of the call. Can this be done in Python? You can't put a def statement inside a function call. But you could use lambda. --PW From gmcm at hypernet.com Wed Nov 7 08:44:28 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 07 Nov 2001 13:44:28 GMT Subject: A smarter(?) package importer. References: Message-ID: Prabhu Ramachandran wrote: [import caching failures] > Does the performance boost occur mainly because each subsequent > failure would mean that sys.modules would have to scan through all of > its keys and then fail? Hmmm, but if you kept caching failure, you'd > increase the number of keys. If the package nesting is substantial > for every global module this would insert several new item into > sys.modules. But sys.modules is a dictionary. It's hashed, not scanned. If you *don't* cache failure, you get 3 (4 on Windows) attempted opens per directory that you could have avoided. - Gordon From geraldol at uai.com.br Sat Nov 10 13:00:39 2001 From: geraldol at uai.com.br (geraldol at uai.com.br) Date: Sat, 10 Nov 2001 18:00:39 -0000 Subject: Python in a hospital application please help Message-ID: <9sjq07+7dsl@eGroups.com> Hi, I want to write an application for the hospital I'm working to. I'm newbie in python, and I want to hear some opinios about what are the options I have.. The structure I have in mind is : At Server we will have an application that handles business rules, connects to databases, and send objects to the clients . At client we will have an wxPython application that will talk to the server application Some things this application must provide * Ability to change the database I think one way tho achieve this is via Object Relational mapper. Have anyone implemented a library like this in python ? * Pool of connections. In the application I have today all clients have their own connections to the database. Today I'm using Interbase (free one) but what if the hospital need a commercial database in the future ? With a pool of connection we can spent less money, and this is issue in a hospital in little city of Brazil. * The communication between the server and the client must be encrypted. Personal information of the patients can't run unencrypted over the wire. I know that this is difficult application to write, so I want to hear some design hints, what are the difficulties I'm going to face. What libraries I can use. Sorry my english and thanks in advance Geraldo Lopes de Souza From keyton at weissinger.org Wed Nov 21 23:01:10 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Wed, 21 Nov 2001 23:01:10 -0500 Subject: RogueLike Games in Python In-Reply-To: <20011121000734.48b85dde.sthiyaga@operamail.com> Message-ID: Anyone know of any written completely (i.e. not just partially) in Python? Thanks in advance... Keyton From montanaro at tttech.com Fri Nov 9 11:26:16 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Fri, 09 Nov 2001 17:26:16 +0100 Subject: gtk, clist & python In-Reply-To: References: <3BE4EBD9.1719C3D4@freesbee.fr> Message-ID: >> how can i know the number of rows in a "clist"? Sylvain> clist.rows Ahh... One of those pesky data attributes the Gtk people don't document in a very obvious fashion: struct GtkCList; This is the embodiment of the GtkCList widget. This structure contains only private data, and should be accessed only via the CList API. ;-) Skip From tim at vegeta.ath.cx Mon Nov 26 22:57:49 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Nov 2001 03:57:49 GMT Subject: Perl to Python References: Message-ID: Paul Malinowski graced us by uttering: > I am relatively new to programming and very new to Python. > I have a number of Perl/CGI scripts on a Linux/Apache web > server that run queries to > MS Access databases through an Openlink service running on > an NT server. Works great! I have been trying to do the > same thing with Python and am not having much luck. Would > it be to much to ask one of you Python guru's to help me > translate this from Perl to Python? (I intentionally left > out the paths in the Perl environment variables to the > OpenLink installed client on my Linux system to hide user > names and such...) > > Any help would be really appreciated! > > Paul Malinowski w/o writing the program for you: > #Setting some environment variables. > $ENV{UDBCINI}="~openlinksw/bin/udbc.ini"; > $ENV{ODBCINI}="~openlinksw/bin/odbc.ini"; > $ENV{ODBCINSTINI}="~openlinksw/bin/odbcinst.ini"; > $ENV{LD_LIBRARY_PATH}="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib"; > $ENV{SHLIB_PATH}="$ENV{SHLIB_PATH}:~openlinksw/lib"; > $ENV{PATH}="$ENV{PATH}:~openlinksw/bin:~openlinksw/samples/ODBC"; Environment vars can be set using the os.environ dictionary. eg: $ENV{DISPLAY} = ":0.0"; # perl os.environ['DISPLAY'] = ":0.0" # python > #SQL query that runs qryModelSNforWeb in the warranty Access database. > $sql = "echo \"select * from ;\" | > odbctest DSN="; > > if (!open(SQL,"$sql |")) { > print "Unable to open connect to database
"; > exit 0; > } > if (open(SQL, "$sql |")) { > chomp(@rawdata = ); > } Pipes can be opened using os.popen(). Pipes can be read/written by reading from/writing to the file object returned by os.popen(). Read from this as normal in Python, just as you're reading from the SQL filehandle in the perl code. # Perl open PIPE, "ls /etc" or die "can't read from pipe: $!\n"; print while ; close PIPE; # Python (roughly) pipe = os.popen('ls /etc') while 1: line = pipe.readline() if not line: break print line retval = pipe.close() BTW: many people here don't know Perl and many don't want to talk about Perl in a Python newsgroup. HTH, Tim Hammerquist -- Is that a 286 or are you just running Windows? From terabaap at yumpee.org Tue Nov 13 01:31:50 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Tue, 13 Nov 2001 06:31:50 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> <3BF07FA7.10807@yumpee.org> Message-ID: <3BF0BE8C.4010809@yumpee.org> Steve Holden wrote: > "Manoj Plakal" wrote in ... >> This might cover a lot of cases where you don't >> need RPC semantics (no return value expected) >> > > But some sort of response will usually be required, even if it's a simple > ACK. Sure, there will be situations where you want an ACK, in which case you want to do RPC. Or maybe you'd want an asynchronous response instead of waiting for it. But I believe there will be some cases where you just want to send a notification and not wait for anything. >> and you're sending simple data values (so no >> need of full-blown XML or other elaborate encoding). >> > > How simple is simple? ASCII strings of less than 256 characters you might > get away with...\ I was thinking about fixing a grammar and then having a parser for this grammar rather than having a general XML parser and giving it the DTD for the protocol. >> And you may not even need a reliable transport >> protocol (so no need of HTTP or even TCP). >> XML-RPC is cool but it seems like a really >> big and overweight hammer. >> > Oh, so you don't mind if Word prints file "xyy.doc" when you ask it to print > "xyz.doc"? By reliable, I meant stuff like acknowledgments and sequencing and all that. I assume that the data payload itself is protected from corruption. Doesn't UDP have checksums? > Can we say "UDP? Sure you can use UDP, but I don't want to use a separate application-level protocol on top of UDP for each app I write or talk to. I'm not trying to reinvent a new network protocol here. All I'm asking is if there's some kind of cross-platform ultra-lightweight COM/CORBA-kind of messaging system, built on top of some IPC mechanism (UDP or domain sockets or named pipes or something not too heavy). I did find a link to XPLC: xplc.sourceforge.net Manoj From usenet at thinkspot.net Sun Nov 11 03:47:46 2001 From: usenet at thinkspot.net (Sheila King) Date: Sun, 11 Nov 2001 08:47:46 GMT Subject: Teaching python (programming) to children References: Message-ID: <9skhr3.3vumrot.1@kserver.org> On Sat, 10 Nov 2001 22:41:06 +0100, Laura Creighton wrote in comp.lang.python in article : :> Sheila King :> Well, in my opinion, the problem is in the way the previous teachers :> have assessed the students, allowing them to get by with such a shallow :> understanding of the topic. Whether or not the graphing calculators is :> used in the course is really not the issue. The issue is: What type of :> test questions was the student required to answer. The best scenario, :> would be having the student take tests, at least half of the time, with :> no calculator permitted, and having them answer meaty questions on the :> topic. In other words: I'm not sure that the problem here is either :> curriculum or method, but assessment. : :This is crazy. The problem is that the students didn't learn. :Assessing the fact that they didn't learn may help educators, parents, :and the students themselves realize that there is a huge problem, but :the question remains: : : Is this a decent way to teach mathematics? I think you misunderstand my meaning. When I refer to "assessment", I mean the daily and weekly ongoing assessment of one's students, as practiced by the classroom practitioner. (Think: high school. High school instructors give much more frequent assignments and tests than their college counterparts.) For example, the teacher probably evaluates homework assignments in some manner (daily or weekly). How about questions and discussion in the classroom? Even during one's lecture or presentation, one can ask the students questions and see if they are following along or not. Put an example problem on the board, and tell everyone to try it RIGHT NOW. Walk around the room as they work on it and see if they are able to do the problem or not. This is immediate and daily assessment. Weekly quizzes and tests? A teacher should be continually assessing the students, determining if the desired material has been learned, and when/if to go back and reteach. Finding out that the students didn't learn yesterdays' lesson is not a crazy way to teach. I've been quite successful at teaching, because I've indicated to my students, that I was serious about what they were to learn, and that my tests would be designed to get at whether they had understood the concepts, and not merely learned how to work a certain set of problem types. Well, there were those students whom I could not motivate to learn. But I'm not sure that someone else would have done better with them. Maybe. But overall, the majority of the students wanted to do well in the course, and would rise to the level required by the assessments that I gave. So, I'm saying, that instructors should design types of assessment that students cannot succeed at, unless they have understood the concept at hand. I often found group activities and long projects to be good for this, although I more frequently did this type of thing on tests. :> You admit, earlier, that the number of students you've encountered who :> have this shallow understanding is small, and yet you say that you want :> to dictate what "high school teachers" should do. : :Yes. The students I have met who have been exposed to this method has :also been small, foreign students mostly. What I want to dictate to :all teachers is that what they do actually promotes learning whatever :subjects they are teaching. Assesment is good for this, as a way to :evaluate the teachers, and their courses. Assessment is a way to evaluate students, not teachers. IMHO. (Here I assume you mean by "assessment", instruments given to the students to see what they know.) Evaluating a teacher's teaching methods, curriculum and assessment instruments is a way to evaluate a teacher. : Let us say, for argument, :that a teacher who is using method A needs to spend 4 times as much :time individually coaching students and gettting involved with them :personally than a person using method B. Then only teachers who are :also willing to make the commitment to spend the 4 times as much :should be using method A. And if that is only, say 10% of the :population of teachers as a whole, then method A, whatever its virtues :when taught well, must be discouraged, unless we have a way to :restrict its use to the 10% who are capable and willing to use it :effectively. Its wholesale adoption means society as a whole suffers, :and, in the aggregate, statistically speaking, students as a whole are :being more poorly taught. : :This really stinks for the teachers in the 10%, and their students, :but the alternative really stinks for everybody else. I would agree with the above, merely because of efficiency's sake. I can't imagine any teacher knowingly wanting to spend extra time and energy of that magnitude for nearly equal results. But, I think it is too far fetched to be seriously related to the discussion at hand. :> In my experience, it doesn't matter what group you are dealing with, :> whether it is teachers, doctors or plumbers, there will always be a :> small part of that group that is "bad". And it really isn't reasonable :> to form the policies for an entire groups based on a few "bad" ones. : :Yes. My suggestion was for the bottom third, not the handful of worsts. :If somebody made me _God_ I think that I would ban the bottom half of :teachers from the profession, on the grounds of our children deserving :better. I'd do that every 10 years or so, and give teachers a huge :increase in salary so that it would attract the best minds, and :the best people in general in the profession, instead of what we have :now. Until this happens, we have to design educational platforms so :that the poorest third of our educators can educate with them. There :is nothing pleasant about this at all. But I don't see being made :God any day soon, so this is the harsh reality we are stuck with. I think that you have a very low opinion of teachers in general (below the college level). I would recommend, instead of getting rid of the bottom 1/3, to support and train these teachers so that they could learn to be more effective (and how you would replace them, even with increase in salaries, I can't imagine). I can agree with increasing in salaries to attract the best. I'm not sure what country you are in (although I imagine somewhere in Europe...UK, perhaps?), but at least here in the US, there is a lot of stuff that could be done to make the profession of elementary and secondary teachers more appealing, and it doesn't stop with increasing the salaries. :> In any case, here is what I really think: :[much snipped. I don't live in the United States. I have no idea :if any of the mentioned programs are effective. If they are, I like :them even if all the teachers hate them. If they aren't I hate them. Where you live isn't important. I'm sure that were I to mention these same programs to US teachers, the overwhelming majority would have as much knowledge of them as you do. That is why I included references about the programs. :What I hate worse is why you can't get rid of them already. This makes it :political, which I understand gets in the way of stopping doing bad :things because they are bad. Testing and assessing is only of use if :we can make some hard conclusions here and stop doing foolish things.] Agreed. ...... :What if its too late? How old are these students? If they are in :college then it is way too late for them. You have to start developing :a mathematical intuition in childhood, and really grow one through :adolescence. You can't graft one on later, no matter how much you :would like to. It is precisely the same sort of thing as a dietary :deficiency. You correct that when you find it, but you can't undo the :stunted growth that was supposed to happen and didn't. My current students are (mostly) first year college students. They are only about a year older than the students I used to teach PreCalculus to, and learning the same level of abstraction. It shouldn't be an impossible thing, like they are "soooo old". It would be easier if they had learned a bit of mathematical intuition and ability to grasp abstract concepts earlier in their life, but I respectfully disagree that it is "too late". It's like learning foreign language, really. Easier when one is younger, but not impossible if one is older. Some of the students in my class are just taking the course for General Education requirements. But there are some who think they are going to be engineers. Will they make it? I don't know. Personally, I'm amazed that people coming into an engineering major in college aren't starting out at a minimum of calculus. But, these people seem to want to try. And I think they should be given the chance. I didn't start working on my math degree until I was in my 30's. Granted, I was pretty good at problem solving and stuff when I was younger. But my brain grew several sizes in the abstraction department as a result of persuing this degree. :Why isn't this considered child abuse? Why can't we find the bad :policies at every level that cause this and stop them? Whoever in :the United States thinks that college level is the place to learn :abstraction is either a fool or a very evil person and in any :case I want him or her out of the education business. Now. : :angry as anything, though not at you, :Laura Creighton I don't think that anyone in the US thinks that college is the place to start learning abstraction. I think, that we have students who want to try, who (for whatever reason) didn't learn the stuff earlier, and someone is willing to let them try. Students have to be allowed to try, and allowed to fail. It should be noted, that the College Algebra course I'm teaching is considered by university standards in the US to be a high school level (i.e. remedial) course. As for angry: I did angry for many years a long time ago. You can only stay angry for so long. I don't do angry any more. (Well, I try to avoid it.) I just try to do what I can do each day with the group of students I'm working with. Celebrate the successes and realize that all students have a right to try and a right to fail. A large dose of realizing that the student is ultimately responsible for his own learning doesn't hurt, either. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From kragen at pobox.com Tue Nov 27 19:02:22 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 19:02:22 -0500 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> Message-ID: <837ksb69v5.fsf@panacea.canonical.org> cpr at emsoftware.com (Chris Ryland) writes: > I went back and forth with Paul a few times re: Lisp vs. Python, and > in the end the only really serious differences we could come up with > were > (a) Lisp's universal (i.e., non-) syntax makes it easy to write > little languages and to use macros, and > (b) Lisp compilers exist today > which produce quite a bit more efficient code than Python's > interpreter can do. [Forgive me, Paul, if I'm mis-remembering.] > > (a) could be tackled, if someone were seriously inclined, by getting > the Python folks to agree on an intermediate Lisp-like syntax (lists), We have ASTs and bytecode, and, in fact, there's already a working macro system in bytecodehacks. But I don't think it will have the same effect, even if the macro system is incorporated into Python so you don't have to invoke it explicitly. > (b) is only a matter of time & will. I emphatically disagree. Every feature that is added to Python that is not written in Python is a step backwards for alternative implementations. And Python seems to be adding new features at a blistering pace: __slots__, listcomps, augmented assignment operators, metaclasses, class methods, __get__ and __set__, generators, nested scopes, types being more like classes, iterators --- the list goes on and on. (b) will never happen if features continue accreting at this rate, no matter how much time and will we put into it; the Python compiler project will remain as experimental and useless as WINE. Implementing cool language features in a high-performance compiler is just inherently more difficult than implementing them in an interpreter. I wish there were a fast Python compiler, but I don't expect one. From jonathan.gilligan at vanderbilt.edu Tue Nov 13 15:25:41 2001 From: jonathan.gilligan at vanderbilt.edu (Jonathan M. Gilligan) Date: Tue, 13 Nov 2001 14:25:41 -0600 Subject: Tracking memory leaks Message-ID: <9srvk5$e8o$1@news.vanderbilt.edu> I have problems with an application that makes heavy use of Numeric and calldll. The problem is that it leaks memory like a seive (at each iteration of a loop in which large Numeric arrays are created and (I hope) destroyed, python's memory use skyrockets. I have invoked gc.set_debug and there are no unreachable objects, but the third-generation object store gets bigger and bigger each time through the loop. I am sure that the problem is with my code, not with the core of Python or Numpy, but I would really like to get to the bottom of this. Is there any good way for me to get python to dump a list of all the Python objects in existence? I have no way right now to tell what objects are taking up so much room on the heap and if I could get the garbage collector or something else to give me a snapshot of what types all the active objects are, it would be a tremendous help. If I could trace allocation and freeing to stderr, it would be even better! I am using Active State python 2.1.1 (#20, Jul 26 2001, 11:38:51) under Windows NT 4.0 SP 6a. Thanks for any help or pointers. Jonathan From mkelly2002 at earthlink.net Wed Nov 21 00:12:09 2001 From: mkelly2002 at earthlink.net (Michael Kelly) Date: Wed, 21 Nov 2001 00:12:09 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> <3BF3378B.8030205@altavista.com> <3BFB3569.C3044BD9@engcorp.com> Message-ID: On Wed, 21 Nov 2001 00:02:33 -0500, Peter Hansen wrote: >Maybe you have an editor >which saves files with tabs representing only four spaces >instead of the correct eight? I'm using PythonWin and the script I pasted from was one of the COM IConnectionPoint examples that came with the win32 com distribution. If this guy was experienced Pythoner then I dunno' why there was an issue. Anyway, I've found "tabnanny" and "whitespace" utilities on the web so I gotta' figure I'm not the only one who has run into it. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From thomas.heller at ion-tof.com Thu Nov 15 10:15:59 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 15 Nov 2001 16:15:59 +0100 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <87f44f44.0111141213.4778982c@posting.google.com> Message-ID: <9t0m7b$15hfom$1@ID-59885.news.dfncis.de> "Laura Creighton" wrote in message news:mailman.1005822025.13344.python-list at python.org... > (I've always wanted to ask this:) > > The Design Patterns Smalltalk Companion (p 214) discussing Proxy states: > > 'Since the problem lies in Proxy's subclass relation to > object, one way to solve it would be to dissolve this > relationship. How is this possible? Subclass Proxy off nil' > > Do people actually do this. Pardon this phrasing, but isn't it, ah, > 'evil'? I'm way to scared to use it, though of course I had to write > one just to see it. > Laura, wrong group, I'd say ;-) I remember having played with this (with great fun), but I didn't use it in production code. Firing up VSW311, I find (in the class browser which probably does not display all classes) these classes as subclasses of nil other than Object: SelfInitializingObject SelfInitializingObjectReference Smells like the proxy pattern... Thomas From peter at engcorp.com Sun Nov 25 21:31:52 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 25 Nov 2001 21:31:52 -0500 Subject: A newbie that needs some HELP References: Message-ID: <3C01A998.E21E1161@engcorp.com> The News wrote: > > monty = [] > number = input("How many Monty's are there?") > for x in range(1,number): > mln = input("Name a Monty?") > monty.append(aln) > print monty > > It gets through it but prints out some wierd stuff along with each listed > monty. Can someone tell me what I'm doing wrong? Also, when I try to get > it to repeat x at the end of "Name a Monty #", x it gives me an error. How > could I get around that? range() the way you have it will return one less than the number you probably want. Use range(0,number) or just range(number) instead. Use raw_input() instead of input(), which evaluates its input as an expression (returning a value, not a string, if possible). When you print the list that way, you get a printable representation of the data, which might be the source of the "weird stuff". Maybe you want something more like this instead: print ', '.join(monty) Finally, you can't use the comma-notation to join strings except with the print statement (which has some unique behaviour in Python). Use the format operator instead, as in raw_input("Name a Monty #%s" % x). -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jeff at ccvcorp.com Wed Nov 14 15:49:19 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 14 Nov 2001 12:49:19 -0800 Subject: Non-obvious name bindings References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> <3BF1BB43.6B4E667B@bgb.cc> <9ssf3h$dfh$1@peabody.colorado.edu> Message-ID: <3BF2D8CE.7CC12F87@ccvcorp.com> Fernando P?rez wrote: > Don Garrett wrote: > > >> > I mean this: > >> > > >> > >>> [e for e in ['exists']] > >> > ['exists'] > >> > >>> e > >> > 'exists' > >> > > >> > And I'm still confused - those "temporary" variables declaration > >> > looks so "innocent", and in most cases (in every case for list > >> > comprehensions I guess?) it's everyones intension not to use this > >> > variable somewhere outside the loop. > > This is a bug in Python 2.1, very recently fixed. .... If I'm reading the bug report right, then it *is* expected behavior that list comp variables are function-local variables, not true "temporary" variables. C++ (IIRC) treats loop indices as being limited to the scope of the loop only, and invalid once the loop ends. Python, however, has a much simpler scoping scheme, and doesn't use a separate scope for loops (and list comps are just syntax sugar for a for-loop). >>> def Example(mystring): ... spam = [char for char in mystring] ... print char ... >>> Example('spam and eggs') s >>> char Traceback (innermost last): File "", line 1, in ? NameError: There is no variable named 'char' >>> This is the expected behavior. There is nothing about list comprehensions that limits their variables to *only* within the list comp, just as with for-loops. The bug reported on SF would (I think) have made char a global variable, thus there would've been no NameError (I'm actually using 2.0 not 2.1 for this, so can't demonstrate the buggy behavior). Jeff Shannon Technician/Programmer Credit International From frederic.giacometti at arakne.com Sun Nov 4 21:13:00 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Mon, 05 Nov 2001 02:13:00 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: "Martin von Loewis" wrote in message news:j4zo6cixu2.fsf at informatik.hu-berlin.de... > "Bruce Dodson" writes: > > > Would Stackless have a better chance of making it into the core if its > > initial PEP talked only about increasing performance and removing limits on > > recursion? > > No. It is not the feature set that prevents its incorporation; it is > the implementation strategy chosen. The patch is too intrusive. 'intrusive'? This words seems to point out that the actual reason is not technical... This is definitely not a word from the realm of engineering, but more from someone sense of his core self being disturbed by an outsider. Am I right ? FG From phr-n2001d at nightsong.com Thu Nov 15 19:08:10 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 16:08:10 -0800 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> Message-ID: <7xhervy3v9.fsf@ruckus.brouhaha.com> "Daniel Lakeland" writes: > On a similar type of program I worked on in CMUCL it would run plenty fast > at home on my 233 MHz PII and then when I took it to work and ran it on a > 400 Mhz Sparq or something like that, it would be a dog. > > Turned out that consing was a big problem, and the x86 had a generational > collector, whereas the Sparq had a mark-sweep. CMUCL uses different GC's on different platforms? Or do you mean you were using CMUCL on one box and a different CL on the other? From kerstin.dressler at web.de Fri Nov 9 09:26:48 2001 From: kerstin.dressler at web.de (Kerstin) Date: 9 Nov 2001 06:26:48 -0800 Subject: Newbie with Tkinter problems References: <3bea8c8a$1@netnews.web.de> <9se7pq$e5s$04$1@news.t-online.com> Message-ID: "Achim Domma" wrote in message news:<9se7pq$e5s$04$1 at news.t-online.com>... > "Kerstin Dressler" wrote in message > news:3bea8c8a$1 at netnews.web.de... > > > Also I've got problems with opening the files (the gif as well as the file > I > > need for the Listbox). > > -> logo = PhotoImage(file="./Power at work_transparent_8farben.gif") > > -> liste = open('./envliste', 'r') > > In both cases I get the error message: IOError: [Errno 2] No such file or > > directory: './envliste'. > > But both files are in the same directory as the py-script? > > What could be wrong there? > > If both files could not be opened I would guess that the path is wrong or > you are not in the folder you think. I don't know excactly how python > handles filenames, but it could be possible that you have to use \ instead > of / on Windows 95. If that's not your problem try to show the current > working dir with os.getcwd(). > > hope that helps > > Achim Hi, the slashes aren't the problem. I'm now at another file with about the same problems. But this time I'm using full pathnames. I also tried the / and \ nothing seemed to change. The problem was indeed the directory. I looked up another directory as I thought I would. I put it right and it's working! Thanx, Kerstin From James_Althoff at i2.com Thu Nov 29 19:18:15 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 29 Nov 2001 16:18:15 -0800 Subject: Python evangelists unite! Message-ID: Peter Milliken wrote: >There is no real justification that works for these "features" of python - OTOH, there *are* plenty of good *reasons* for them. Consider "adding attributes to instances". Languages that don't support this feature directly require some kind of a workaround since this is something that one simply needs to do from time to time. A typical workaround is to define, as part of a class's definition, a catch-all property whose value is a hashtable. Clients add "instance-specific" attributes to a given instance "on the fly" by adding name-value pairs to the instance's hashtable. Java/Swing's JComponent (with its putClientProperty and getClientProperty methods) is a good example of this type of workaround. Jim From sabren at manifestation.com Mon Nov 19 16:07:29 2001 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 19 Nov 2001 16:07:29 -0500 (EST) Subject: General infrastructure/design question - long In-Reply-To: <20011119145702.3d23ad04.billw@witherspoon-design.com> Message-ID: On Mon, 19 Nov 2001, Bill Witherspoon wrote: > My fear is that everytime I change the db schema, I have > to run around and update all of the classes to insure that > the data maps correctly. Is there any way to easily have a > class that 'knows' how to create its own __init__ so that > the db fields always become appropriate properties? ZDC does this. http://sf.net/projects/zdc (not much in the way of docs yet, but look in the CVS browser for RecordObject) Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From Bill.Scherer at VerizonWireless.com Wed Nov 14 12:32:40 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Wed, 14 Nov 2001 12:32:40 -0500 (EST) Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) In-Reply-To: <97ae44ee.0111140921.281c4b7@posting.google.com> Message-ID: You've got a multithreaded client hitting a single threaded, synchronous server. You can do significantly better if you thread your server, or use asyncore (or a combination of the two). On 14 Nov 2001, Stephen wrote: > > >> IMHO the SMTP and POP protocols provide the same benefit (and there > > >> are Python modules for those protocols). > > > > shriek> Using a mailserver as a messaging platform for middleware ? > > > > It's not all that far-fetched. I know some people have experimented with > > XML-RPC over SMTP (which is no longer XML-RPC, but that's a nit). > > OK, let me show an example where I think we need some sort > of basic message queue ~ > > I've been trying to benchmark socket server and can't seem > to get it past serving 200 requests per second. > > Here's the test code ~ > > > # ----------------------------------------- > # SOCKET SERVER CODE - JUST SENDS A REPLY > # ----------------------------------------- > > #! /usr/bin/python > > import SocketServer, string, socket, time > > total_requests = 0 > > class RequestServer(SocketServer.ThreadingTCPServer): > allow_reuse_address = 1 > > class RequestHandler(SocketServer.StreamRequestHandler): > def handle(self): > global total_requests > # ACCEPT : > host, port = self.client_address > request = "" > while 1: > line = self.rfile.readline() > if line in (None, "\r\n", ""): > break > request = request + line > request = string.rstrip(request) > self.wfile.write("Received OK") > total_requests = total_requests + 1 > if total_requests % 100 == 0 : > print "%s - %s" % (total_requests, time.time()) > > def main(): > server = RequestServer(("127.0.0.1", 8888), RequestHandler) > print "Listening to socket [%s:%s]" % ("127.0.0.1", 8888) > server.serve_forever() > > > # ------------------------------------------- > # CLIENT CODE FOR TESTING > # ------------------------------------------- > > #!/usr/local/python > > test_msg = "This is just a test message" > > import socket, thread, time > > total_sent = 0 > > NUMTHREADS = 20 > > def send_request() : > start = time.time() > global total_sent > for i in range(0,100) : > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > s.connect(("127.0.0.1", 8888)) > s.send("%s\n\r\n" % test_msg) > s.recv(512) > s.close() > total_sent = total_sent + 1 > if total_sent % 100 == 0 : > print "total sent = %s" % total_sent > end = time.time() > print "exiting thread. duration %s" % (end - start) > > total_sent = 0 > for i in range(0,NUMTHREADS) : > thread.start_new_thread(send_request, ()) > > > Results ~ > > When NUMTHREADS = 2, 200 requests are handled in < 0.5 secs > When NUMTHREADS = 5, 500 requests are handled in 2.5 secs > > But when NUMTHREADS = 20, half the threads die with this error : > Unhandled exception in thread: > Traceback (most recent call last): > File "", line 6, in send_request > File "", line 1, in connect > socket.error: (10061, 'Connection refused') > > and it just gets worse when NUMTHREADS = 50. > > I'm guessing this means that the server is max'ed out and > can't handle any more. > > How should I handle this error ? Yes, with a "try/except" > but what should the "except" do, because if the server is > too busy, it's probably no point retrying immediately. > > So, you see, I was looking for something more immediate than > SMTP, that also takes care of the message queueing. Writing > code to manage the queue and buffering could be horrendous. > > Is there any way to get this up to say 1,000 requests/sec peak load ? > > In reality, I'm going to want to put some Database query > into the RequestHandler too so it'd be even slower. > Does this sound possible ? > > Am-I-asking-too-much-of-Python-ly-your's, > > Stephen > -- Bill.Scherer at Verizon Wireless RHCE 807101044903581 From dale at riverhall.NOTHANKS.co.uk Fri Nov 23 09:17:54 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Fri, 23 Nov 2001 14:17:54 +0000 Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: "MANUEL FERNANDEZ PEREZ" wrote: >Hello, >I'm looking for an editor for Python.I' m interested it works on Windows.Can >anybody help me? > >Thank you > >Manuel > PythonWin is pretty good and has pop-up help for class attributes. There also Edit Plus 2 (http://www.editplus.com/)which can be configured to syntax high-light a bunch of stuff including Python. -- Dale Strickland-Clark Riverhall Systems Ltd From teyc at bigfoot.com Tue Nov 13 16:05:58 2001 From: teyc at bigfoot.com (Chui Tey) Date: Wed, 14 Nov 2001 07:05:58 +1000 Subject: Request for Validation of Python as Development Language References: Message-ID: <9st60l$dlf$1@bunyip.cc.uq.edu.au> You have to be fairly certain your shop *needs* python: 1. Do your apps need to be deployed on non-MS Operating Systems? If not, you are better off sticking to the standard fare from MS, since their development environment for .net is without peer - changing code in place, re-stepping through code, blah ... 2. Do you need certain libraries that are available in python and not available in MS languages? 3. Do you need to perform introspection beyond what MS languages offer? For me personally, I found Python useful to prototype and test ideas. Once I get a working algorithm, I just port it back to VB. Python has lists and dictionaries and the language supports these types well. I find typing a={'key':'value'} a lot easier than set a= new dictionary: a("key") =" Value". Similarly, the Collections class in VB is very limited compared to the python list. A. Keyton Weissinger wrote in message news:mailman.1005625157.24434.python-list at python.org... > Does anyone have a more recent list of commercial products out there that > use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima > Online. I'd like more. > > The information in the books and the python.org site is a bit dated. > > I'm pretty new to the language and I'd like to use it for more stuff at > work. I'm beginning to feel some of the stigma of it being a "scripting > language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for > those who care) and I'd like to introduce Python into the mix. But I say > "scripting language" and people head to the hills yelling "PERL!" which is a > bit disconcerting (especially since I like Perl too, though not as much as > Python). They need to hear "object oriented application development > language" or I need to buck up and realize I'm barking up the wrong tree. > > Thank you! > > Keyton > > From emile at fenx.com Thu Nov 22 08:25:12 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 22 Nov 2001 05:25:12 -0800 Subject: writnig my first programm References: <9tfrf5$27hfr$1@ID-79019.news.dfncis.de> <83zo5fvpk8.fsf@panacea.canonical.org> <9tid61$2ptdl$1@ID-79019.news.dfncis.de> Message-ID: <9tiuld$2qbh0$1@ID-11957.news.dfncis.de> "Felix Seeger" wrote in message news:9tid61$2ptdl$1 at ID-79019.news.dfncis.de... > > Ok, but my Problem is: How can I transfer the commands from the > Webinterface to the Server? > > About ssh or with my own server <--> client. > I don't know, can I talk about ssh without entering a passwort and saving > it in my python scripts ? > I could scp a script to the server, and then ssh to run is, delete it. > > rsync? -- Emile van Sebille emile at fenx.com From chrishbarker at home.net Thu Nov 15 13:08:44 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 15 Nov 2001 10:08:44 -0800 Subject: GUI toolkit References: Message-ID: <3BF404AC.3B8B734F@home.net> Cary Coulter wrote: > I have looked at the demos for wxPython. Have to say I like what I > see, but I haven't tried to develop anything yet. wxPython is very nice. Also, be sure to check out wxDesigner, it costs about a $100, but it can make building GUIs a whole lot easier, particularly if you wnat to use all sizers, which is a good idea if you are writing cross platform code. > Platforms would be Linux (primary), Windows, and AIX (didn't see any > prebuilt code for wxPython). I'd post a message on wxPython users, and see if anyone is using it on AIX. There's no reason it souldn't work, but you may be in for a bit of work if you are the first to try to compile it all there. Good luck, -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From root at rainerdeyke.com Fri Nov 23 01:34:49 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 23 Nov 2001 06:34:49 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <5C0L7.159189$IR4.55612315@news1.denver1.co.home.com> Message-ID: "Dave Cinege" wrote in message news:mailman.1006474065.23010.python-list at python.org... > On Thursday 22 November 2001 1:06, you wrote: > > Tabs should not be displayed as spaces at all. I'm inclined to say that > > any editor that does display them as spaces is broken. > > Here on earth, tabs are typically represented by 8 * space width. > A good editor allows to set the mutiple to anything you desire. If your editor does not show the difference between tabs and spaces, your editor is lying to you. > A very bad editor will display a tab as a symbol, in raw form, or not at > all. Maybe you use one of these? Actually, I just press '/' a lot, which causes tabs on VIM to light up. There is a "proper" way to change the appearance of tabs, but I'm too lazy (for now) to use it. > If what you mean is, you press the tab key and the editor > inserts X * spaces then yes this is the most evil form of blasphamy. If you press at all (not counting alt-tab to switch contexts and such), you are spreading a disease that must be wiped off the earth. Only when the last of your miserable breed has drowned in his own vomit will I be able to sleep peacefully. Death to the users! Death to the users! -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From fraxos4h2208 at Flashmail.com Mon Nov 19 06:16:03 2001 From: fraxos4h2208 at Flashmail.com (fraxos4h2208 at Flashmail.com) Date: Mon, 19 Nov 2001 06:16:03 Subject: leads reaching your internet clients 1617PT Message-ID: <200111201952.fAKJqiE32353@rox.geoscience.org.za> Do you need new leads for your business ? Do you need increased Internet Exposure ? Thousands join the Internet daily.... ever since 1995 Have you reached the thousands of new internet users? Search Engines: work IF you're in the TOP 20 among thousands Classifieds: work IF your ad is near the top among thousands Banner Ads: work IF you use top engines for a lot of money ALL 3 require prospects TO FIND YOU FIRST among thousands. Did you know that there is a method of marketing that costs pennies but have the same effect as direct postal mail? AND THEY DONT HAVE TO FIND YOU ... bring it straigt on ... You can now compete with the big boys, with exposure in mass numbers, without expensive investments such as those associated with TV, radio, direct postal mail, or telemarketing. THE SOLUTION ... E-mail Marketing E-mail Marketing is a proven method to reach a global market with a small investment. It is more advantageous than conventional marketing. The prospects are millions and can be reached for much less than conventional methods. Send your ad to millions nationwide, by state, country or worldwide. ACT NOW and reach your untapped internet market ! Call : 6 2 6 8 2 1 3 1 5 0 Mention your 1) name 2) tel 3) service needed ACT NOW and reach your untapped internet market ! From sdm7g at Virginia.EDU Wed Nov 14 11:27:32 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Wed, 14 Nov 2001 11:27:32 -0500 (EST) Subject: Can Prophecy be Changed? In-Reply-To: Message-ID: If you were a regular reader of this list, you would know that Guido has a time machine, so we really have no need of your services. "Prophecy" -- HA! -- how quaint! On Wed, 14 Nov 2001 list at icmerlin.com wrote: > Greetings, > > We found you on the Internet at http://www.fnorb.org/contact.html > > Prophecy -- what does it mean to you? Does it mean the prediction of > momentous events, even dire events like catastrophic earthquakes and > murderous acts of terrorism? Does it also mean the alternative > predictions of a brilliant new golden age of peace, astounding > innovation and high culture? > > On Tuesday, November 20, 2001 from 7 - 9 p.m. (CST) you can hear and > participate in a free interactive worldwide internet broadcast called: > PROPHECY FOR THE 21ST CENTURY: TURNING TERROR INTO TRIUMPH. > > This talk -- unlike any you have probably heard before -- covers all > these aspects of prophecy for our times and many more. For example, > in this address you will hear a review of the dramatic prophecies of > Nostradamus, Edgar Cayce, Saint Germain, Mother Mary and others > explained and compared. Far from a doomsday message, this address > will cover the key idea of how to mitigate and transform dire > predictions into positive new eras of history. > > To learn more about this event and how you can hear the FREE > interactive Internet broadcast, visit http://www.icmerlin.com/prophecy > > ___________________ > > * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * > [To be removed from this list, please hit reply and type REMOVE. Please to not reply to this email with a message. > To send a message: email prophecy at icmerlin.com.] > > -- > http://mail.python.org/mailman/listinfo/python-list > From dokken at inc.com Wed Nov 21 14:22:41 2001 From: dokken at inc.com (don dokken) Date: Wed, 21 Nov 2001 11:22:41 -0800 Subject: drawing functionality References: Message-ID: "jcrowe" wrote in message news:ouAJ7.1872$tg4.89012 at eagle.america.net... > I am concidering creating an app that would basicly be a database frontend. > But I would like to have the ability to make small (300 X 300 dpi) > drawings. This would be used to create a rough floorplan drawing for each > entry (real estate) in the database. I am planing on running this on a > linux server that is being accessed by window 98/95 client machines. > > Thanks for any URL's or insites that you can provide. > > Jason Crowe > maybe tk? From tdelaney at avaya.com Thu Nov 1 19:51:07 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 2 Nov 2001 11:51:07 +1100 Subject: Freeware Python editor Message-ID: > FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS The PSU failed! A post about the PSU escaped to the world in its entirety! We are fre From Gareth.McCaughan at pobox.com Fri Nov 30 17:24:01 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 30 Nov 2001 22:24:01 +0000 Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: Message-ID: The timbot wrote: [Michael Abbott wrote:] > > Of course, if you are sorting a list of arbitrary datatypes using random > > datatypes as the key then you're in a state of sin. If we're worrying about states of sin then it's time to remove the "random" module, of course. > More like potential sin : many applications for sorting couldn't care > less about a total ordering, they merely want to make "equal" elements > adjacent, to simplify "the next" step Which is, I have always assumed, why it's called "sorting". Sorting is a mechanism that puts things of the same "sort" together. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From kragen at canonical.org Sun Nov 25 21:29:10 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 21:29:10 -0500 Subject: Does Anybody Know How To Get Tkinter Working?? References: Message-ID: <83k7wetgcp.fsf@panacea.canonical.org> Ben Ocean writes: > This is my third request for help and I'm hoping someone will respond this > time :) I responded last time. Did that not count? From robin at jessikat.fsnet.co.uk Thu Nov 22 15:45:26 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 22 Nov 2001 20:45:26 +0000 Subject: Win32 _PyOS_GetOpt Message-ID: I'm trying to dynamically attach to Python21.dll and find the following oddness. I can't map the symbol _PyOS_GetOpt (from getopt.c) and related variables _PyOS_opterr, _PyOS_optind, _PyOS_optarg. Wouldn't it be better to ensure that all of these were explicitly exported so I can use the built in code rather than faking my own? Many other semi private functions are exported eg _PyImport_FindExtension etc etc -- Robin Becker From slinkp23 at yahoo.com Fri Nov 30 13:12:27 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Fri, 30 Nov 2001 18:12:27 GMT Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> <3C06AA26.6020906@hp.com> Message-ID: On Thu, 29 Nov 2001 13:35:34 -0800, Garth Grimm wrote: >Dan Allen wrote: > >> Say I have >> >> mylist = ['one','two','three'] >> >> which I presume is a "tuple" as I have been scanning the manual. > > >That's a list, not a tuple. A tuple would be like > myTuple = { 'one', 'two', 'three' ) oops, you mean: ( 'one', 'two', 'three' ) Garth, I assume that was a simple typo. just trying to make sure we don't confuse the newbies... --PW From tor at tor.to Wed Nov 7 01:19:45 2001 From: tor at tor.to (Tor Gunston) Date: Wed, 07 Nov 2001 06:19:45 GMT Subject: count in 'for ... in ...' References: <9s90mr$osk$00$1@news.t-online.com> <9s9204$a73$1@news1.wdf.sap-ag.de> Message-ID: <20011107.010357.76065818.2391@tor.to> In article <9s9204$a73$1 at news1.wdf.sap-ag.de>, "Daniel Dittmar" wrote: > I'm generally using something like: [cool stuff snipped] This is cool. Thank you. Also thank you to Achim Domma for asking that, as it had been on my mind as well. -- Random Bible Quote: And unto him at damascus and went with all full of the vagabond in cornelius thy fathers so soon as a man be broken and he and his fathers skirt of the priest shall be fulfilled which is the sons and the danites out of the king. From andreas at mtg.co.at Mon Nov 5 09:40:19 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Mon, 5 Nov 2001 15:40:19 +0100 Subject: no setuid for CGI scripts? In-Reply-To: <4b4c5d99.0111050348.6d7c9406@posting.google.com> References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: <200111051440.fA5EeOE20924@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Montag, 5. November 2001 12:48 schrieb pawn: > I'm trying to convert a few simple CGI scripts from Perl to Python, > and was shocked to learn that the Python interpreter silently ignores > the setuid bit. Thats not a problem of python, it's a general problem with setuid scripts. Perl supports this by having a special version that does all the setuid stuff itself. It's the OS that forbids setuid/setgid operation of scripts, as it is basically unsafe. How perl solves the inherent race condition I'm not sure. Actually, SuSE at least leaves the suid bit off by default on /usr/bin/suidperl. So I'm not the only paranoid on this planet. ;) > I really don't know how to get around this. Since the server is hosted > remotely I can't recompile python to allow setuid, and I can't make my > files world read/writable - I need my python CGIs to run with MY uid. Well, then your hosting provider is setup in a wrongway: They should setup suexec ;) > > I read somewhere about using a wrapper C program but it seems really > convoluted, as well as requiring a different wrapper for each CGI. Not necessarily: It could process the argv[0] argument, check it against a list of "allowed" scripts and execute the right one. Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE75qTWHJdudm4KnO0RAlNZAKCVRI3hBCsfehUg/EGbHOx3KVt6ZgCgijI0 a02pj3PEUBG5rs4IJwzrh0E= =/vyE -----END PGP SIGNATURE----- From volucris at hotmail.com Fri Nov 9 22:34:05 2001 From: volucris at hotmail.com (Greg Krohn) Date: Fri, 9 Nov 2001 21:34:05 -0600 Subject: Tkinter menu commands activate when menu is built References: <3bec7f09$1_6@goliath.newsgroups.com> Message-ID: <3bec9efd$0$79562$6e49188b@news.goldengate.net> 'command' needs to be a assigned a function, not the value returned from the function (in this case None). Here lambda is you friend. try this instead: connectmenu.add_command(label="Example 1", command=lambda n=1: do_stuff(n)) connectmenu.add_command(label="Example 2", command=lambda n=2: do_stuff(n)) connectmenu.add_command(label="Example 3", command=lambda n=3: do_stuff(n)) connectmenu.add_command(label="Example 4", command=lambda n=4: do_stuff(n)) or even: for num in range(1, 5): connectmenu.add_command(label="Example %d" % num, command=lambda n=num: do_stuff(n)) greg From sdm7g at Virginia.EDU Wed Nov 14 11:55:23 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Wed, 14 Nov 2001 11:55:23 -0500 (EST) Subject: Infinite lists and generators In-Reply-To: Message-ID: On Wed, 14 Nov 2001, Terry Reedy wrote: > Two easy examples (untested, but pretty sure correct): > > def integersFrom(n): > "Infinite stream of integers starting from n" > > return Stream(n,lambda n=n:integersFrom(n+1)) > while 1: > yield n > n += 1 > > >def filter(f,s): > > """returns the stream of the elements x of the > > input stream s which satisfy the predicate f""" > > while s and not f(s.head()): > > s = s.tail() > > if not s: > > return None > > else: > > return Stream(s.head(), > > lambda f=f,s=s: filter(f,s.tail())) > > The problem with filtering an infinite stream is that if there are > only N items that pass, the filter will never halt looking for the > N+1st. You just do 'lazy' filtering -- in fact you try to avoid forcing evaluation of the whole stream until the very end, and then you stop when you get a sufficient number, or reach the end of the stream. ( And if possible, you may not have to force full evaluation at all if you can do your output one item at a time. You should avoid list comprehensions though, which force evaluation -- kind of like Icon's 'every' ) Filter is just: def filter( f, stream ): for item in stream: if f(item): yield item > def iterate(f,x): > "returns the stream of x, f(x), f(f(x)), f(f(f(x))), ..." > > return Stream(x, > > lambda f=f,x=x: iterate(f,f(x))) > while 1: > yield x > x = f(x) > From johnroth at ameritech.net Mon Nov 12 11:57:04 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 12 Nov 2001 08:57:04 -0800 Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> <3BED54C2.1010608@sci.kun.nl> <3BEFD59B.9000709@sci.kun.nl> Message-ID: "husam" wrote in message news:3BEFD59B.9000709 at sci.kun.nl... > John Roth wrote: > > > "husam" wrote in message > > news:3BED54C2.1010608 at sci.kun.nl... > > > > > >>yes, i understand the general defenition of data bases and of data > >>structures. i should in fact put the question like this: > >>is a given dictionary or list of a set of data, a data base? > >> > >> > > > > In some respect, it depends on your point of view. All of the > > data structures quoted in the previous articles in the thread > > are in fact collections with different access policies. Data bases > > are also collections with different access policies (SQL being > > by far the most popular one). > > > > I normally think of a data structure as an abstract description > > of a way to organize a collection, a collection as a concrete > > example of a data structure with specific data that is in > > memory, and a data base as something that is managed > > by an external piece of software, called a 'data base > > manager.' > > > > John Roth > > > > > > > > ok, the thing that i can make up from this discussion is that the > difference between data base and data structures (list, dicts and > tuples) lies in the usage policy. i mean data access and data > manipulation methods differe, but they might resemble each other by the > way data is organized. to be more specific, i have builed a small > application to manage my audio cds. i made two programs in the first one > i stored the cds and programs in lists. the length of main_list > represent cd numbers, and each cd number is a list of the names of the > audio tracks in that cd. in this program i can manipulate the items in > any way i desire. in the second program i organized the cds and the > audio tracks in dictionaries. to go back to the subject and according to > what i understood i can now call my application is a data base program, > or my cds are organized in a data base! right? Since there're out there on a permanent file, that's technically correct. The formal notion of a data base requires that other programs be able to get at the data with 'relative' ease, which is why most people don't really regard a flat file as a data base. John Roth > > From emile at fenx.com Mon Nov 12 12:30:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 12 Nov 2001 09:30:54 -0800 Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: <9sp1a7$14k4bc$1@ID-11957.news.dfncis.de> "Paul Winkler" wrote in message news:slrn9v00d0.1ms.slinkp23 at roaddog.armsnet... > On Mon, 12 Nov 2001 17:02:38 +0100, Laura Creighton wrote: > (snip) > >I have a new problem. I've just lost a major amount of precision in my > >language usage. What is the collective noun for 'attributes that aren't > >methods (you can't call them)'? > > Good question! Makes me realize that I have no specific word in my > mind for that. > > Data attributes? > Non-callables? > Yuck. Must be something better. > Property? -- Emile van Sebille emile at fenx.com --------- From richard at NOstarfighterSPAM.freeuk.com Thu Nov 15 17:26:18 2001 From: richard at NOstarfighterSPAM.freeuk.com (Richard Townsend) Date: Thu, 15 Nov 2001 22:26:18 -0000 Subject: Pmw.ScrolledListbox References: <6749bb94.0111140719.15db2737@posting.google.com> <9t04c2$53ra$1@mail1.wg.waii.com> <6749bb94.0111150929.73df59df@posting.google.com> Message-ID: <1005863128.24183.1@demeter.clara.net> > Making some tests now, it seems that the problem is connected to the > functions > withdraw(), activate(). I have no idea why. > I suspect the Pmw activate() method is setting the keyboard focus using the focus_set() method. If you do this on a Tkinter.Listbox it also shows the wretched underline behaviour... e.g. from Tkinter import * root = Tk() lb = Listbox(root) for item in ["one", "two", "three", "four"]: lb.insert(END, item) lb.pack() lb.focus_set() root.mainloop() Even calling tk_strictMotif(TRUE) doesn't stop this non-motif behaviour :-( From gmcm at hypernet.com Tue Nov 6 14:02:11 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 06 Nov 2001 19:02:11 GMT Subject: C callbacks ? Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: Frederic Giacometti wrote: > > "Gordon McMillan" wrote in message [snip] >> But making Python *truly* stackless means getting rid of all recursions, >> and that is an enormous task. If you don't do that, you've got a >> language feature that doesn't work in some apparently random set of >> circumstances. > > But how do you process callbacks to Python from C code (extensions or > embeded python)? > > One has to return to C after executing the Python code, and than C has to > return to Python after executing the remainer of its code... All depends on what you mean by "return" . Try thinking of "callbacks" and the "return" from callbacks as events. In Stackless, the Python stack and the C stack are completely separate. In the case where C code needs to call Python and then do something with the result (that is, where tail recursion doesn't apply), Christian used the trick of manufacturing a Python-style frame object that represents the C code. As far as (Stackless) Python is concerned, it gets dispatched like any other frame (Stackless' Python "stack" is really a tree). > I see maintaining hybrid behavior (iterative / recursive calls to the > interpreter, and 'recursion tolerance') as a requirement... True. And Stackless (as a 3rd party product) can get away with saying "Oops, I can't do that". The bar is higher for a core language feature, though. Which is a shame, because this turns out to be more of a theoretical problem than a real one. - Gordon From jeff at ccvcorp.com Tue Nov 27 17:33:49 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 27 Nov 2001 14:33:49 -0800 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> <3C014329.7B828AE8@alcyone.com> <3c014926.1812080@news> Message-ID: <3C0414CD.4557D69E@ccvcorp.com> Fred Flintsone wrote: > I did download the 2.1.1 but noticed afterwards a suggestion for me to > d/l "ActiveState," which is a larger d/l, so I'm assuming it has > important goodies bundled in it. Before I get going here, should I > uninstall 2.1.1 and go for the ActiveState d/l? (This message refers > to Gillou's post above.) You can do that, but it's not necessary--the add-ons are also available as a win32all package, which you should also be able to find at ActiveState's website. If you install win32all on top of your PythonLabs distribution, the result is *almost* identical to having installed the ActiveState distribution to begin with, and is probably a lot simpler than unistalling the one and reinstalling the other. ;) I do highly recommend using the Windows extensions, though. Having the indexed, searchable .chm help files is *very* nice, and (IMHO) PythonWin is a much more usable IDE than IDLE is (IDLE being the default IDE that is bundled in the base distribution). Of course, the IDLE-fork project may be changing this... but that's not standard, yet. Jeff Shannon Technician/Programmer Credit International From woodm at equire.com Wed Nov 21 02:13:33 2001 From: woodm at equire.com (Matthew D. Wood) Date: 20 Nov 2001 23:13:33 -0800 Subject: urllib.urlencode has 2 parameters?? References: Message-ID: <32cedc66.0111202313.1480ee99@posting.google.com> I understand that there is documentation for the vast majority of the python modules. In point of fact, I stated that I had been looking at the documentation for urlencode in my original post. I don't understand what the documentation is trying to say. "If any values in the query arg are sequences..." Isn't query supposed to be a sequence to begin with? (I know that it can also be a dict.) I even tried it with a list of tuples, which is a sequence of sequences, nothing changed when I changed the parameter from 1 to 0. I don't get it. My hope was that someone else had struggled through what I had, and that everyone (myself especailly) could benefit from their time. In short, I know that I should always RTFM, I just don't understand what TFM is saying. > On 20-Nov-2001 Matthew D. Wood wrote: > > I've been staring at the documentation page for urllib for about 15 > > minutes, and experimenting around on the python-command-line trying to > > figure out what the second parameter for urllib.urlencode does. > > def urlencode(query, doseq=0): > If any values in the query arg are sequences and doseq is true, each > sequence element is converted to a separate parameter. > > That is from urllib.urlencode.__doc__. Also, most of python's modules are in > python so you can just read the urllib.py file and it is explained there in > comments and code. > > > > -- > > http://mail.python.org/mailman/listinfo/python-list From mikael at isy.liu.se Thu Nov 15 02:35:23 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 15 Nov 2001 08:35:23 +0100 (MET) Subject: IsPython really O-O? In-Reply-To: <9sukag$9mc$1@slb7.atl.mindspring.net> Message-ID: On 14-Nov-2001 Matt Gerrans wrote: > In any case, a 1-dimensional graph is not adequate, but most of us will > probably struggle to visualize the several hundred (or so) -dimensional > graph to accurately describe the differences between the three... I thought we were talking about distances here. It should be enough with a two-dimensional subspace of that multi-dimensional space, namely the plane on which the three points (languages) are. Everything else is orthogonal to that plane... Now back to business! /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 15-Nov-2001 Time: 08:28:38 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From mwh at python.net Wed Nov 7 05:01:40 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 7 Nov 2001 10:01:40 GMT Subject: Newbie Needs Help References: <9sagdn$u5n$1@slb2.atl.mindspring.net> Message-ID: nobody at nowhere writes: > Can somebody recommend some good Python tutorials? http://www.google.com/search?client=googlet&q=python%20tutorials HTH, M. -- : Giant screaming pieces of excrement, they are. I have a feeling that some of the people in here have a MUCH more exciting time relieving themselves than I do. -- Mike Sphar & Dave Brown, asr From jdhunter at nitace.bsd.uchicago.edu Mon Nov 5 18:13:44 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: Mon, 05 Nov 2001 17:13:44 -0600 Subject: Tkinter bind single key Message-ID: I am reading 'An Introduction to Tkinter' by Fredrik Lundh and my read of Chapter 7 'Events and Bindings' is that this syntax self.__canvas.bind('+', self.zoomin) should bind the '+' key to the member function zoomin (but it doesn't work). I know the function and everything else is ok, because when I do self.__canvas.bind('', self.zoomin) Everything works as expected (mouse-1 causes a zoom event). Is there something I am missing about binding regular keys? Thanks, John Hunter From peter at engcorp.com Fri Nov 30 08:40:56 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 30 Nov 2001 08:40:56 -0500 Subject: Library os.path.isfile(filename) - long filenames error. References: <1b9aff84.0111300205.60095d6d@posting.google.com> Message-ID: <3C078C68.65C3C3A4@engcorp.com> Clayton Brown - Emmie Osawa wrote: > > The python os.path.isfile() function gets a system error: > "Filename or extension is too long." when tested on this file.. > > "c:\path\path\path\kddf-slgjsfdljgklsj+=lkjdlfks > jdlfkjsdk_lfjsdklfj+=ljk sjflksdj fklsdjf.ext" There's no reason that filename shouldn't work, although as written you might be implying it has an embedded newline (between the two lines? or is that just a space) and in addition you might want to use one of the following instead of what you wrote: "c:\\path\\path\\path\\kddf- ..... r"c:\path\path\path\kddf- ... "c:/path/path/path/kddf- ... (because without those, in some cases, the backslash before the character will turn it into a special code, such as if you had c:\test\test which has embedded tabs). os.path.isfile() returned true on my machine (Win 98) for that filename. Best answer if you can't figure it out: type it in the interactive prompt and then cut and paste the resulting error message (and what you typed!) into the newsreader window and post that. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From eppstein at ics.uci.edu Thu Nov 15 17:23:45 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 15 Nov 2001 14:23:45 -0800 Subject: PEP 276 Simple Iterator for ints References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> <9t0jko$14b$1@thorium.cix.co.uk> <3BF43EA3.42A5A4B6@ccvcorp.com> Message-ID: In article <3BF43EA3.42A5A4B6 at ccvcorp.com>, Jeff Shannon wrote: > > >>> for i in int[2:10:2]: print i, > > 2 4 6 8 > > > > This doesn't look too bad to me. I'd go for it. Why is int[2:10:2] an improvement over range(2,10,2)? They have the same number of words and the same argument values with the same amount of punctuation, the only difference to me is that int[2:10:2] is in a much less familiar syntax. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From follower at iname.com Tue Nov 13 12:25:19 2001 From: follower at iname.com (Follower) Date: 13 Nov 2001 09:25:19 -0800 Subject: Help extending BaseHandler from urllib2 References: Message-ID: Hi, > I'm trying to extend the BaseHandler class from urllib2 to handle 302 > redirects in a different way. I need to grab the cookies from the page > and send them after being redirected. Just today I was trying to do a similar thing, using a slightly different approach but with no success. Instead of subclassing the 'BaseHandler' class I subclassed the 'urllib2.HTTPRedirectHandler' class with the intention of overriding the 'http_error_302' method. The code looked a little like this: class MyHTTPRedirectHandler(urllib2.HTTPRedirectHandler): def http_error_302(self, req, fp, code, msg, headers): print headers urllib2.HTTPRedirectHandler.http_error_302(self, req, fp, code, msg, headers) It got called okay (i.e. it prints out the headers) but then the call to the parent class's 'http_error_302' method generates an 'HTTPError' exception (HTTPError: HTTP Error 302: Found) with the following trace: Traceback (most recent call last): [Snipped local details...] File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 135, in urlopen return _opener.open(url, data) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 318, in open '_open', req) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 297, in _call_chain result = func(*args) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 824, in http_open return self.do_open(httplib.HTTP, req) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 818, in do_open return self.parent.error('http', req, fp, code, msg, hdrs) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 344, in error return self._call_chain(*args) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 297, in _call_chain result = func(*args) File "E:\LANGUAGES\PYTHON21\lib\urllib2.py", line 425, in http_error_default raise HTTPError(req.get_full_url(), code, msg, hdrs, fp) HTTPError: HTTP Error 302: Found I worked around this (sort of) by copying the 'HTTPRedirectHandler' class code from urllib2.py and making additions to that--so it no longer generates the exception but it's not an ideal solution. I readily admit I may have made a mistake completely unrelated to the task at hand but thought you might want to consider this alternative approach. There is one thought that's been nagging me which might apply to both our situations: The documentation for build_opener states: "Instances of the following classes will be in the front of the handlers, unless the handlers contain them, instances of them or subclasses of them: ProxyHandler, UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler" This makes me wonder if, in your case, because you're subclassing 'BaseHandler' and not 'HTTPRedirectHandler' your 302 specific code doesn't get called because the redirect is still being handled by the default 'HTTPRedirecthandler' because it is before it in the queue. Just a thought. In my case, I'm wondering if this means I can't actually call the parent classes's 'http_error_302' method, but my knowledge of Python's class handling is mediocre at best, and besides, it's too late/early... As for my application, I'm (re)-implementing a script to archive email from a web mail account (at mail.com -- don't use them, they suck and lost two years worth of my email!). It appears they also keep track of the current value of the 'Host' header. I thought I needed to grab the cookies from the initial redirect but it turns out it's the destination page which contains the cookies but the the value of the 'Host' header needs to change on the redirect (otherwise the redirect won't succeed) and I couldn't find an easy way to do that with urllib2 either. In the interim I'm using a raw httplib solution. Hope this is of some use. Phil. From mwh at python.net Wed Nov 7 13:24:17 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 7 Nov 2001 18:24:17 GMT Subject: Creating a list of files in a directory References: Message-ID: "Jeff Klassen" writes: > Thanks to Alex at the 'HelpDesk', this solves it Duh, I was halfway through a thoroughly confusing reply to you when I realized I was talking nonsense, but one bit of advice I'll keep: investigate the standard library module glob. Cheers, M. -- 93. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From frederic.giacometti at arakne.com Thu Nov 8 00:41:16 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Thu, 08 Nov 2001 05:41:16 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <7x8zditn72.fsf@ruckus.brouhaha.com> Message-ID: <0WoG7.4487$Sx.2071563@news1.elcjn1.sdca.home.com> "Paul Rubin" wrote in message news:7x8zditn72.fsf at ruckus.brouhaha.com... > Yes, it's a standard idiom of continuations to implement coroutines > with them. > > One virtue of using kernel threads is in principle the kernel threads > can take advantage of multiple hardware CPU's. Python's global > interpreter lock stops that from happening, but I thought there was > some hope the lock might go away someday. Here are more details of a possible design of the stackeless OS thread model: [Preamble: In a single thread build, all this collapses into one thread] The Python VM thread (this thread that python at <>, without interruption) is associated to two pools of OS threads. The thread in the first pool runs arbitrary reentrant C functions. The threads in the second pool are each associated to a non-reentrant C API's (one thread per independent sets of API; to be initialized upon loading the extension module); e.g. OpenGL, Metaphase... Each thread schedules its own queue of continuations (micro-threads) for execution. The C threads can post new continuations to the Python thread, and vice-versa. In total, three main types of continuations are used: - continuations from the Python thread, scheduled in the Python thread - continuations from C function threads, scheduled in the Python thread - continuations from the Python thread, scheduled in the C threads This model seems generic; it has no interpreter lock, and can simply distribute C calls across multiple OS threads. Multithreaded C/Python programming would be simplified too. [As an exemple, with this model, in JPE, the Java threads would be mapped to python continuations; and this would work without regard whether the JVM uses native or green threads. In contrast, without stackless, JPE requires that the JVM runs with native thread, and has to bear the constant thread switching/Python lock overhead of the present implementation...]. Furthermore, non-blocking versions of some of the Python C functions can be provided. For instance, the functions py_decref() and py_decref_non_blocking() could be provided.... Finally, the concept can be pushed as far as dedicating a third thread to python de-referencing and memory de-allocation, that would run in parallel to the python thread; thus releasing the later from the load of de-referencement. FG From michaell.taylor at reis.com Mon Nov 19 14:47:40 2001 From: michaell.taylor at reis.com (Michaell Taylor) Date: Mon, 19 Nov 2001 14:47:40 -0500 Subject: conversing with the shell Message-ID: I am looking to build a VERY simple load balance app for batch job submission on several linux machines. The basic structure that I have in mind is. For M in list_of_machines: fm = 'rsh '+M+' "cat /proc/meminfo"' fcpu = 'rsh '+M+' uptime' freemem = SOMECOMMAND(fm) freecpu = SOMECOMMAND(fcpu) . . parse output of freemem and freecpu . . . select machine submit job using rsh BUT... Problem is of course the SOMECOMMAND lines. I need to query the shell for input and then read that input in as a variable. I could use the shell commands to redirect the output to a file and then read the file with python, but this seems like a waste. FYI, there are only 6-8 machines and fairly low frequency usage, so larger load balancing seems like overkill. Thanks in advance Michaell From ykingma at accessforall.nl Sat Nov 17 05:04:31 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Sat, 17 Nov 2001 11:04:31 +0100 Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> Message-ID: <3BF63625.33330E2A@accessforall.nl> Stuart & repliers, There is a python to java byte code compiler that does something quite similar for local namespaces: it maps some known locals to the iloadN/istoreN instructions of the java virtual machine. I don't know/understand the details, so in case you want more information it is probably best to post at jython-dev via www.jython.org. Have fun, Ype (email at xs4all.nl) From bedge at troikanetworks.com Tue Nov 20 12:17:21 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 09:17:21 -0800 Subject: sscanf ? Message-ID: Is there an equivalent function in python? I know about all the regex stuff, but I have the format string that was used to generate a string, which I'd like to use to decompose it back into it's source data: fmtstr = "%02d.%02d" str = fmtstr % ( x, y ) # Now get x any y back using only str and fmtstr: (x, y ) = ? I suppose I could write something to convert printf style format strings into regexp format, but it seems like there's gotta be an easier way. TIA, Bruce. From jdadson at ix.netcom.com Sun Nov 4 21:04:56 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 02:04:56 GMT Subject: PEP "option explicit" [Re: How much is set in stone?] References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> Message-ID: <3BE5F3A2.1B4FEBCE@ix.netcom.com> Replying to my own message. I should have changed the subject line on the message I'm replying to. Make it, 'PEP "option explicit" [Re: How much is set in stone?]' From erno-news at erno.iki.fi Wed Nov 7 22:44:36 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 08 Nov 2001 05:44:36 +0200 Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <7x8zditn72.fsf@ruckus.brouhaha.com> Message-ID: In article <7x8zditn72.fsf at ruckus.brouhaha.com>, Paul Rubin writes: | Yes, it's a standard idiom of continuations to implement coroutines | with them. | One virtue of using kernel threads is in principle the kernel threads | can take advantage of multiple hardware CPU's. Python's global | interpreter lock stops that from happening, but I thought there was | some hope the lock might go away someday. i don't think anyone has come up with a reasonably way of implementing "free threading" yet, since the last time it was tried it caused everything to slow down so much. probably for good performance reference counting would have to be dropped in exchange for a less predictable garbage collection system, and the python internals sprinkled with fragile locks. threads suck, use fork :) -- erno From horatio at qpsf.edu.au Tue Nov 13 18:19:06 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Wed, 14 Nov 2001 09:19:06 +1000 (EST) Subject: Scientific Libraries in Python In-Reply-To: <3BF17F43.6066667F@home.net> Message-ID: On Tue, 13 Nov 2001, Chris Barker wrote: > But Scientific Python already is exactly what you are advocating! It > isn't the least bit complete, but as far as I can tell, it's goals are > exactly what you want. Agreed. Um, this and the next sentence read together confuse me slightly: are you saying this of SciPy by Enthought, or Scientific Python by Konrad Hinsen? Not that it matters, the same sentiment can be applied to both projects. And probably a few others, which is the problem. Another poster on this thread has already observed that users would rather be busy solving their problem than hunting down and installing libraries. > The only question is why other folks are still doing their own little > projects, rather than contibuting to SciPy. This was, in fact, the question I was getting at. Although possibly not phrased with such certainty that SciPy is the One True Way. (: > One anser, with Scientific Pyhton at least, is that it waws around > long before the SciPy project got started. Also agreed. A minor aesthetic point: Konrad is sitting dead on top of the most Pythonic part of the namespace for this domain. When you type from Scientific import Foo you know what you're getting and where it's coming from, for much the same reasons that Numeric is named, well, Numeric instead of numpy. Two of the minor side benefits from merging Scientific Python into SciPy (note the order) would be that SciPy could finally use a decent top-level package name <0.3875 wink> and it could stop smooshing together the two words in its name. Doesn't Scientific.Compiler sound much better? (: It's a pity the issue isn't just aesthetics (which I could cheerfully ignore), but useability. The merge is worth doing because having a single Scientific Python library will give more and richer functionality, with less hassle, to scientists and engineers using Python. With the current state of affairs, I can't really make the case to my colleagues here (or anywhere) to use Python instead of Matlab or Mathematica. Such a merge would imply some serious manual labour on someone's part. While I'm willing, I'm not able for a few months, but I thought I'd get the idea up in front of the relevant community now. having-exhausted-his-quota-of-posting-for-2001-ly yours, AHD From oktay_safak at yahoo.com Thu Nov 22 04:46:25 2001 From: oktay_safak at yahoo.com (Oktay Safak) Date: Thu, 22 Nov 2001 01:46:25 -0800 (PST) Subject: python vs ecmascript In-Reply-To: <83g079u348.fsf@panacea.canonical.org> Message-ID: <20011122094625.18376.qmail@web14706.mail.yahoo.com> I dealt with Javascript for some time before I took a serious plunge into Mighty Python and here are my observations about the language: Javascript looks very appealing at first JUST because of its C (or Java) like syntax with weak typing and dynamism(and I think these are the ONLY things that make JS appealing at first sight). Considering the domain that you are supposed to use it you think "oh well, this is great". And I agree that it may well be more than enough for its intended purpose. But no matter how close it may compare to Python conceptually, actually they are not comparable. You admire JavaScript when you see at first but there is always a feeling that something is not just right with the implementation of these ideas. And only after studying Python you finally understand what is wrong: it is mostly a lack of coherence and good design. Compared to Python's coherence and good design JS looks like a *pile* of features arbitrarily brought together. Python on the other hand, has borrowed many ideas from other languages but their unification is truly unique (at least to me). Apart from the many extras of Python as a mature and general purpose programming language, its implementation of the ideas of good syntax, dynamic typing and code dynamism (which is the result of being an interpreted language) is much better. C-like syntax looks appealing at first if you have that background but it promotes highly cryptic coding and it is no easy task to figure out what a sufficiently advanced JS script that some other guy has written is meant to do. On the contrary, Python syntax is very unorthodox and may seem odd at first but when you eat your prejudices and get it, you begin to wonder how you have done without it and how you'll ever be able to code in other languages again. Even advanced Python code (like the ones in the standard library) are highly readable and fairly easy to understand. For typing, Python has taught me some good lessons too: after VBA and JS I thought that weak typing was nice, but after studying Python I understood that it is not *weak* typing that is nice, but it is *dynamic* typing. Other posters also wrote on this typing issue so that's enough for now I think. Apart from these similarities, Python has much much more to offer as a language which others in this thread have mentioned. But what is especially important to me (second to its great community:) is its ability to lend itself to the development of (very) large and complex programs which I used to think would only be possible with something like C++. Especially after 2.2, Python has become quite "slick". Javascript aside, even the giants have a serious thrill now. The only disadvantage of Python against them is that it's not as fast due to its interpreted nature, but that is what it is. Since Python's origins predates JS, it is quite possible that JS script inventors knew and were influenced by Python. That may or may not be the case, but Python is what JS guys have missed, I think. and-there-is-no-Tim-Peters-for-Javascript-ly yours, Oktay Safak c.l.p resident lurker __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From morten at thingamy.net Tue Nov 20 15:20:53 2001 From: morten at thingamy.net (Morten W. Petersen) Date: Tue, 20 Nov 2001 21:20:53 +0100 Subject: Python execution speed In-Reply-To: <3bfab7ae_3@mk-nntp-1.news.uk.worldonline.com> References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> <3BF9D791.BEA22D61@engcorp.com> <3bfab7ae_3@mk-nntp-1.news.uk.worldonline.com> Message-ID: On Tue, 20 Nov 2001, Sandy Norton wrote: > "Morten W. Petersen" wrote in message > news:Pine.LNX.4.21.0111201815190.6229-100000 at bcryachts.atsat.com... > > > One of Python's advantages is a consistent (simple) design, (not counting > > small quirks like 'def function(): return 1' and 'function = > > lambda: 1'. Consistent design says 'less complexity' in my ears, along > > the same lines of the simpleness (ease of maintenance, readability, > > portability) of a python application if it can always be coded in Python. > > Excuse my curiosity but what's quirky about 'def function(): return 1' and > 'function = > lambda: 1'? (I'm posting to the newsgroup as well, didn't notice you posted to both the newsgroup and me.) Curiosity is good. :-) In Lisp, functions can be built this way: cl-user(3): (defun multiply (argument) (* argument argument)) multiply cl-user(4): (multiply 3) 9 cl-user(5): Where the last evaluated value is returned. In Python, there is: def multiply(argument): return argument * argument Or (using anonymous functions): multiply = lambda argument: argument * argument Where the lambda has the implicit return-of-last-expression (no return needed), while functions do not. Helpful? Regards, Morten From nospam at bigfoot.com Fri Nov 9 14:20:02 2001 From: nospam at bigfoot.com (Gillou) Date: Fri, 9 Nov 2001 20:20:02 +0100 Subject: Open a windows database file with a path name? References: Message-ID: <9sh9t0$1fia$1@norfair.nerim.net> You can use Access from Python (with win32all extensions) as a COM object, if you want to play with your Access database. But, IMHO, if all you need to do can be done using SQL statements only, you'd better play with your database with ODBC/DSN : - more portable (other OS, other database) - less memory overhead - more stable API (what if M$ changes the Access COM API/object model in the future) --Gillou "Nomad" a ?crit dans le message news: qnonuto5ao5iu4c0fa1ttletlje3s9sfck at 4ax.com... > Hi, > > Is there anyway that I can open a database (MSAccess in this case) > using the path and file name rather than a DSN? I can't seem to get > it to work. > > TIA > > -- > Nomad > > Wondering of the vast emptyness of the 'net > in search of something cool. From bokr at accessone.com Thu Nov 22 05:18:21 2001 From: bokr at accessone.com (Bengt Richter) Date: Thu, 22 Nov 2001 10:18:21 GMT Subject: Pulling out References: <3bfb6c61.6364882@wa.news.verio.net> Message-ID: <3bfccaeb.96102738@wa.news.verio.net> On Wed, 21 Nov 2001 23:42:51 -0800, Brett Cannon wrote: >Could use negative lookahead and lookbehinds. Another solution is to just >strip out all comments from the HTML. Probably wouldn't hurt, anyway, >since it will probably increase performance slightly be cutting down on >the amount of tags to deal with. It's probably useful to not that there must be one legal in an html doc, and it must be in the / section. Once you've found it, you're done. But the real question is what the operational requirement is. Seems like he is making a command line tool to generate an index (to put in DB? to put into a monolithic HTML page indexing and inliking to all the pages? to put in a hierarchical frame-wrapped version of that? etc?) of HTML pages (all in a single directory? specified by a list of glob expressions?). Or he might want a cron job and keep track of file mod dates to avoid reprocessing? (Hm, wonder about using make cleverly)... You never know what people are up to ;-) > >But it is also illegal syntax, I believe, to embed tags within a comment. > Nope. It's ok. I think the standard will move to the XML definition of a comment, even though you probably will want to handle the illegal but widely accepted error of including more than one '-' in a row between the '' (the '--' is illegal in XML for compatibility with SGML). >From the CML spec: -- 2.5 Comments Comments may appear anywhere in a document outside other markup;in addition, they may appear within the document type declaration at places allowed by the grammar. They are not part of the document's character data; an XML processor may, but need not, make it possible for an application to retrieve the text of comments. For compatibility, the string "--" (double-hyphen) must not occur within comments. Comments [15] Comment ::= '' An example of a comment: -- The example show's it's ok to embed tags in comments. From thomas.heller at ion-tof.com Tue Nov 13 15:51:53 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 13 Nov 2001 21:51:53 +0100 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com><87f44f44.0111131022.5ab1b6f@posting.google.com><9srqem$vt2$1@slb0.atl.mindspring.net> Message-ID: <9ss15a$14snvc$2@ID-59885.news.dfncis.de> > "AD" == Andrew Dalke writes: AD> but I've never really needed it. Better I think would be if AD> Python's IDE's offered a reload() which was closer to AD> Smalltalks's, where a modified class definition propagates AD> even to existing instances of that class. So someone could AD> edit a module and manipulate things interactively without AD> having to reload and rerun everything. Here's a script I'm sometimes working on which does this. It's not bulletproof, but it kindof works. It runs a thread in the background (once started), which checks the timestamp of all modules loaded from the filesystem. It it's out of date, is is reloaded automatically. Classes and functions in the reloaded module are updated automatically to the new version. Hopefully sometime I will complete it and post it to the Python Cookbook. Thomas ---- autoreload.py ---- # # autoreload.py - automatically reload changed source # code into a running program # # You may want to place the following two lines # into your sitecustomize.py: # # import autoreload # autoreload.run() # # Created: Thomas Heller, 2000-04-17 # # $Id: autoreload.py,v 1.8 2001/11/13 20:44:51 thomas Exp $ # # $Log: autoreload.py,v $ # Revision 1.8 2001/11/13 20:44:51 thomas # Clean up a little... # # Revision 1.7 2001/10/05 16:38:35 thomas # Assure a clean shutdown of the thread with atexit # # Revision 1.6 2001/10/04 19:21:46 thomas # Only some comments added and a typo fixed. # # Revision 1.3 2001/10/04 18:37:54 thomas # Stores now old objects with (modulename, objectname) as keys. # # Revision 1.1 2001/10/04 16:54:04 thomas # Discovered this old module on my machine, it didn't work too well, # but seems worth to continue with it... # Checked in as a first step. version = "$Revision: 1.8 $".split()[1] # ToDo: # # Cannot reload __main__ - explain why this cannot work # # Optimize - the number of watches objects (in old_objects) # grows without limits. Think if this is really necessary... import time, os, threading, sys, types, imp def _get_compiled_ext(): for ext, mode, typ in imp.get_suffixes(): if typ == imp.PY_COMPILED: return ext PY_COMPILED_EXT = _get_compiled_ext() class ModuleWatcher: running = 0 def __init__(self): # If we don't do this, there may be tracebacks # when shutting down python. import atexit atexit.register(self.stop) def run(self): if self.running: print "# autoreload already running" return self.running = 1 self.thread = threading.Thread(target=self._check_modules) self.thread.setDaemon(1) self.thread.start() def stop(self): if not self.running: print "# autoreload not running" return self.running = 0 self.thread.join() ## print "# autoreload stopped" def _check_modules(self): ## print "# autoreload running" while self.running: time.sleep(0.01) for m in sys.modules.values(): if not hasattr(m, '__file__'): continue if m.__name__ == '__main__': # we cannot reload(__main__) First I thought we # could use mod = imp.load_module() and then # reload(mod) to simulate reload(main), but this # would execute the code in __main__ a second # time. continue file = m.__file__ dirname = os.path.dirname(file) path, ext = os.path.splitext(file) if ext.lower() == '.py': ext = PY_COMPILED_EXT file = os.path.join(dirname, path + PY_COMPILED_EXT) if ext != PY_COMPILED_EXT: continue try: if os.stat(file[:-1])[8] <= os.stat(file)[8]: continue except OSError: continue try: superreload(m) except: import traceback traceback.print_exc(0) def superreload(module, reload=reload, _old_objects={}): """superreload (module) -> module Enhanced version of the builtin reload function. superreload replaces the class dictionary of every top-level class in the module with the new one automatically, as well as every function's code object. """ start = time.clock() # retrieve the attributes from the module before the reload, # and remember them in _old_objects. for name, object in module.__dict__.items(): key = (module.__name__, name) _old_objects[key] = _old_objects.get(key, []) + [object] module = reload(module) # iterate over all objects and update them count = 0 # XXX We should optimize here: # It may be that no references to the objects are present # except those from our _old_objects dictionary. # We should remove those. I have to learn about weak-refs! for name, new_obj in module.__dict__.items(): key = (module.__name__, name) if _old_objects.has_key(key): for old_obj in _old_objects[key]: ## if sys.getrefcount(old_obj) == 3: ## _old_objects[key].remove(old_obj) ## continue if type(new_obj) == types.ClassType: old_obj.__dict__ = new_obj.__dict__.copy() count += 1 print sys.getrefcount(old_obj), name elif type(new_obj) == types.FunctionType: old_obj.func_code = new_obj.func_code count += 1 print sys.getrefcount(old_obj), name stop = time.clock() print "# updated %d objects from %s" % (count, module) print "# This took %.3f seconds" % (stop - start) print return module _watcher = ModuleWatcher() run = _watcher.run stop = _watcher.stop ---- EOF ---- From skip at pobox.com Tue Nov 20 06:24:06 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 20 Nov 2001 05:24:06 -0600 Subject: Steering novices in the right direction In-Reply-To: <3BF9D800.E4A88559@engcorp.com> References: <3BF9D800.E4A88559@engcorp.com> Message-ID: <15354.15702.45793.736531@beluga.mojam.com> >> Are there any good, free PIL web tutorials or any other source I can >> find info on the lib? Peter> Did http://www.google.com/search?q=Python+Imaging+Library+tutorial Peter> not produce the results you needed? I've lately been thinking since the correct response to many "where can I find ...?" questions is, "have you tried google?" or at least "have you searched yet?" that perhaps the footer added to the end of all python-list at python.org mailings should include a line like Ask here first: http://www.python.org/search/ or Before asking where something is, check Google: http://www.google.com/ Even better would be if Mailman could pick a random line out of a file to use as the footer. That way you could have all sorts of interesting subliminal messages. Any thoughts on the general idea of embellishing the footer? -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From mdlch at altavista.net Fri Nov 23 12:59:19 2001 From: mdlch at altavista.net (marco) Date: 23 Nov 2001 12:59:19 -0500 Subject: Python on AIX References: Message-ID: marco writes: > Once copied into /usr/local/python-2.2a4/lib/python2.2/ we > re-ran the configure ; make ; make install. The following failed: Sorry, that should have read: /usr/local/python-2.2b2/lib/python2.2/ instead of /usr/local/python-2.2a4/lib/python2.2/. Cheers, -- mdlch at altavista.net Gunnm: Broken Angel http://reimeika.ca/ From a-steinhoff at web.de Thu Nov 1 16:14:23 2001 From: a-steinhoff at web.de (Armin Steinhoff) Date: 1 Nov 2001 13:14:23 -0800 Subject: open vs. open Message-ID: Hi all, I'm surely not the first one who was trapping into the '__builtin__.open vs. os.open' problem. Question: is it possible to rename the __builtin__.open call to __builtin__.fopen because it does really a fopen library call?? Or does it break something ?? Regards Armin From python at commandprompt.com Mon Nov 26 17:15:59 2001 From: python at commandprompt.com (python at commandprompt.com) Date: Mon, 26 Nov 2001 14:15:59 -0800 (PST) Subject: [OT] PostgreSQL Book In-Reply-To: Message-ID: Hello, Just letting all you snaker tamers out there that use PostgreSQL that the book Practical PostgreSQL from OReilly and Command Prompt is now in production. It will be shipping December 15th. You can view the book online at: http://www.postgresql.info/ Sincerely, J From stephen.boulet at motorola.com Fri Nov 30 14:50:01 2001 From: stephen.boulet at motorola.com (Stephen Boulet) Date: Fri, 30 Nov 2001 13:50:01 -0600 Subject: Converting an integer to base 2 References: <3C07CFED.C7F7CA38@motorola.com> <3C07D793.4CCE9954@alex2.labs.agilent.com> Message-ID: <3C07E2E9.A1F0B6DC@motorola.com> Ah, that explains why int() fails. Thanks. Meanwhile, I found this recipe on ActiveState's site: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/65212 and I adapted it for my situation. def decimalToN(num,n=2): """Change a decimal to a base-n number. Up to base-36 is supported without special notation.""" new_num_string='' current=num while current!=0: remainder=current%n if remainder>=36: remainder_string='('+str(remainder)+')' else: remainder_string=str(remainder) new_num_string=remainder_string+new_num_string current=current/n while len(new_num_string) < 8: # want 8 bits, so pad with zeros new_num_string = '0' + new_num_string return new_num_string "David R. Smith" wrote: > > int(string, 2) converts the string to the internal representation. You > told it that the string was base-2, e.g., '101'. '5' is not a valid > digit in binary. > > Stephen Boulet wrote: > > > > I'm trying to convert integers to base 2. Can someone tell me why this > > doesn't work? > > > > >>> int('5', 2) > > Traceback (most recent call last): > > File "", line 1, in ? > > int('5', 2) > > ValueError: invalid literal for int(): 5 > > > > Thanks. > > > > -- Stephen From peter at engcorp.com Wed Nov 28 00:30:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 00:30:50 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> Message-ID: <3C04768A.CFDC1CE8@engcorp.com> Rainer Deyke wrote: > > "Peter Hansen" wrote: > > Greg Ewing wrote: > > > > > > While trying to think of a range syntax that looks > > > unambiguously half-open without clashing with list > > > or tuple constructors, the following blindingly > > > obvious solution occurred to me: > > > > > > for 0 <= i < 5: > > > ... > > > > -1 for being ambiguous to newbies. > > The same could be said for 'for i in range(5)', since 'i in range(5)' is an > expression that is roughly equivalent to '0 <= i < 5'. But range() can be looked up. You can type range(5) at the interactive prompt (where a newbie would live) and see [0, 1, 2, 3, 4] and infer immediately that you are stepping through the items one at a time. Typing 0 <= i < 5 at the prompt gives you either 0 or 1, or NameError: name 'i' is not defined. Not helpful for a newbie. (Note: I'm not exactly interested in dumbing a language down to the point where anyone can understand it without learning something from a tutorial or the reference. I am uninterested, however, in adding line noise and moving closer to Perl just because it "looks" nicer to some. range() is clean. > Having written several programs where the vast majority of 'for' loops were > in the form 'for something in range(something_else)', I would appreciate the > syntax sugar of 'for i in 5'. All the other suggestions strike me as worse > than 'range'. Definitely an improvement over the above, and almost elegant in its simplicity. The fact it means 5 does different things depending on where you type it is a little concerning. My argument about the newbie at the prompt above still applies. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From logiplexsoftware at earthlink.net Mon Nov 12 14:25:12 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 12 Nov 2001 11:25:12 -0800 Subject: Module for reading CSV data In-Reply-To: References: Message-ID: <01111211251200.01611@logiplex1.logiplex.net> On Saturday 10 November 2001 01:03, Ian Parker wrote: > The ASV module by Laurence Tratt handles csv files very well. IIRC it > doesn't fall apart on quoted strings containing commas. As long as everyone else is plugging CSV modules, I may as well point you to a module I wrote a few months ago for importing CSV files: https://sourceforge.net/projects/python-dsv/ It is poorly documented and full of re.ugliness, but it does some things that I haven't seen in any other csv importer: - Not limited to using commas as delimiters - It can guess the delimiter - It can guess the text qualifier (single or double quotes) - It can guess whether the first row is a header - It handles quoted delimiters - It handles quoted newlines - It can handle inconsistent quoting (Excel, for instance, only quotes data that requires it, i.e. data containing delimiters or newlines, whereas some other programs quote everything). - It has an optional dialog (using wxPython) for previewing the data prior to import (ala MS Excel) and allowing the user to change the guessed parameters. - It's reasonably fast, considering the amount of data analysis it does. The heuristics analyze the smallest portion of the file they can get away with, so increasing the file size won't usually increase the time spent in the guessing steps (although it will obviously affect the overall time to import). The guessing steps seem to be reliable, but can be skipped and set programmatically. Caveats: - I had some problems when Python 2.0 first came out with the sre module that somehow broke my regular expressions. I believe this was fixed, but can't recall what the condition was that caused the error, so can't be sure. My recent tests seem to indicate everything is working properly. - The code for the wxDialog is ugly (I was planning on creating a wizard-like series of dialogs, but never got around to it). What is there is usable though. - The code for the guessing heuristics is poorly documented and fairly dense. On the other hand, this code was used in a production environment without a hitch. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From sasoft at gmx.de Mon Nov 19 12:13:01 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Mon, 19 Nov 2001 12:13:01 -0500 Subject: newbie in threading In-Reply-To: <9t93vi$6gi$1@slb7.atl.mindspring.net>; from dalke@dalkescientific.com on Sun, Nov 18, 2001 at 01:00:15PM -0700 References: <9t93vi$6gi$1@slb7.atl.mindspring.net> Message-ID: <20011119121301.A7665@cruciatuz.de> i am a total newbie in threading. i got some questions to verify if i understood some aspects of threads. 1. threads will never terminate in python, the'll live on during the whole runtime, but i can modify them to be inactive using an "threading.Event" if i doesn't have any work for this thread further on(?) some code which does that from another listmember 1-2 days before: ### [code ### import threading import time def mythread(killevent): # checkt ob Event.isSet == true und f?hrt sollange # print und sleep aus. wenn isSet == true wird der # thread "inaktiv" (terminieren kann man einen thread # nie ganz) while not killevent.isSet(): print "thread running" time.sleep(2) killevent = threading.Event() # das event f?r den thread erstellen thread = threading.Thread(None, mythread, "", (killevent,)) # thread erstellen und event reingeben thread.start() time.sleep(6) killevent.set() # das killevent setzen damit der thread beeinflusst wird thread.join() # thread synchronisieren(?) zum sauberen beenden ### code] ### 2. what does thread.join exactly? 3. is a bunch of inactive threads able to slow down my program, or will the gc clean them up for me? should i do a "del myThread" for saving memory? are there any other ways to terminate a thread? -- thx in advance, stefan antoni /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ From grzegorz at trisoft.com.pl Thu Nov 29 09:27:44 2001 From: grzegorz at trisoft.com.pl (Grzegorz Makarewicz) Date: Thu, 29 Nov 2001 15:27:44 +0100 Subject: M2Crypto, LDAP and python In-Reply-To: References: Message-ID: <01112915274400.02801@makpc.local1> > Could anyone give examples of types of useful applications that they've > made using M2Crypto? http://www.sourceforge.net/projects/pyssh1 PYSSH (Secure Shell) is a implementation of SSH1 protocol in Python. It provides strong authentication and secure communications over insecure networks. mak From tim at vegeta.ath.cx Mon Nov 26 23:29:38 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Nov 2001 04:29:38 GMT Subject: Perl to Python References: Message-ID: Paul Malinowski graced us by uttering: > I am relatively new to programming and very new to Python. > I have a number of Perl/CGI scripts on a Linux/Apache web > server that run queries to > MS Access databases through an Openlink service running on > an NT server. Works great! I have been trying to do the > same thing with Python and am not having much luck. Would > it be to much to ask one of you Python guru's to help me > translate this from Perl to Python? (I intentionally left > out the paths in the Perl environment variables to the > OpenLink installed client on my Linux system to hide user > names and such...) > > Any help would be really appreciated! I gave some Python tips in another thread, but I feel obligated to point out a problem in the Perl: [ snip ] > if (!open(SQL,"$sql |")) { > print "Unable to open connect to database
"; > exit 0; > } > > if (open(SQL, "$sql |")) { > chomp(@rawdata = ); > } Another poster was correct. You're opening a pipe from $sql _twice_. Why?! Connecting to a database is an expensive process, and you're not even protecting yourself against the event you're (apparently) trying to avoid. Try: unless (open SQL, "$sql |") { # you might also want to output _why_ it failed print "Unable to connect to database
"; exit 0; } else { chomp(@rawdata = ); } And as any perler would tell you, you should be running with 'use strict;' unless you have a specific reason not to. Perl's autovivification does not inherently have the safeguards that Python does. Tim Hammerquist -- We are Pentium of Borg. Division is futile. You will be approximated. -- seen in someone's .signature From vze2q3xh at verizon.net Fri Nov 16 06:41:49 2001 From: vze2q3xh at verizon.net (Tech) Date: Fri, 16 Nov 2001 11:41:49 GMT Subject: PIL Installation on windows98 - from newbie References: Message-ID: I downloaded the file for my version of python and ran the setup executable that I downloaded. Next, I tried to test the installation by running some of the test scripts that came with PIL. Each time I tried I got the following error... Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> Traceback (most recent call last): File "C:\py21\Samples\viewer.py", line 7, in ? import Image, ImageTk ImportError: No module named Image I had hope that all I had to do was run the "py21-pil-1.1.2-20010910.exe" file and it would do everything and I could just start using PIL. However, this does not seem to be the case. I look for a Setup.py script in directory created by the executable, but I found nothing. Do I have to copy the files to a different directory? I'm new to python; I have a C++ Builder 4.0 background. Am I doing anything wrong? Does this answer you question? Thanks you your reply, Tech vze2q3xh at verizon.net On Fri, 16 Nov 2001 09:04:43 GMT, "Fredrik Lundh" wrote: >"Tech" wrote: >> Hello all, I would love to try to write an imaging app using the PIL, >> but I can even get it installed. I try reading all the documentation >> I could find on the subject, but nothing helped. Would some please >> help me. > >so, what did you do, and what didn't work. > > > From robin at jessikat.fsnet.co.uk Mon Nov 5 12:15:02 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 5 Nov 2001 17:15:02 +0000 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: <84xuJgAWks57EwZD@jessikat.demon.co.uk> In article , Toby Dickenson writes >(posted and cc'ed to robin) > >Robin Becker wrote: > >I dont think thats safe > >'system' uses many environment variables that could be used to change >the behavior of this program to be something other that what you >expected. I certainly agree that this will break easily enough when run from the command line. If the web server is already compromised there's little point in worrying about what LD_LIBRARY_PATH etc it's supplying. I suspect that getting python to run with a different LIBRARY_PATH would not be as hard as getting the compromised shared libraries/binaries onto the system in the first place. -- Robin Becker From nospam!jklassen at biblesociety.ca Wed Nov 7 13:18:57 2001 From: nospam!jklassen at biblesociety.ca (Jeff Klassen) Date: Wed, 7 Nov 2001 13:18:57 -0500 Subject: Creating a list of files in a directory References: Message-ID: Thanks to Alex at the 'HelpDesk', this solves it >The match method of RE's returns None when there is no match. So, just guard the append statement with a test: if matchedfile is not None: for allfiles in workingdir: matchedfile=filespec.search(allfiles) if matchedfile > 0: filestoprocess.append(matchedfile.group()) "Jeff Klassen" wrote in message news:FpeG7.3375$pR5.112872545 at radon.golden.net... > Hello, > > I am new to Python. As a non-programmer I am encouraged by the level of > 'success' I feel I have had, relative to similar learning attempts in other > languages. > > I would like to simply do the following: > - read all of files of a particular form (e.g. *.cev) from a particular > directory > - manipulate them with a series of re.sub expressions > - write each file to its own output file with a certain form (e.g. *.out). > > I have been able to create the re stuff, and process individual files. > However, I cannot get a for loop to do everything in a directory. > > Here is the code I came up with. (I am wanting to create a list of all files > that conform to *.cev) > > ---------------------------- > import dircache > import re > > workingdir=dircache.listdir('/jobs/python/learning/') > filespec = re.compile(r'.*?\.cev') > filestoprocess = [] > > for allfiles in workingdir: > matchedfile=filespec.match(allfiles) > filestoprocess.append(matchedfile.group()) > > print filestoprocess > ---------------------------- > > When I run this script I am returned: > AttributeError: 'None' object has no attribute 'group' > > When I issue these commands in the Python Shell, substituting an actual > value for allfiles such as 'mat.cev', everything works OK. I can execute > filestoprocess.append(matchedfile.group()) and then print filestoprocess, > and I am returned ['mat.cev']. Why does this fail to work inside of the > loop? > > Thanks very much for any help. > > Jeff > > From tim at vegeta.ath.cx Sun Nov 25 19:09:38 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 26 Nov 2001 00:09:38 GMT Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> Message-ID: Hans Nowak graced us by uttering: > Howdy y'all, > > I'm currently developing a program (in Python, obviously) and plan to > publish it. Before I do so, though, I would like to have some opinions > on the following: > > - should I use a license / copyright notice? > - if so, which one would you recommend? > > I know of the GPL, Python license, BSD license etc, and opensource.org > has a long list of them, but I absolutely hate legalese, and reading > all of this and pondering the possible consequences of picking one > over the other makes me cringe. Does someone have a pointer to a > page with some concise explanations of these licenses? The following page has a long list of licenses and their explanations. The list seems somewhat biased towards the GPL, since it's hosted on gnu.org, but is fair in its facts. Python has had several licenses in recent times; this page mentions the brief GPL-incompatible license and the current GPL-compatible one, so you can make sure you get the right one. http://www.gnu.org/licenses/license-list.html In my case, my perl modules are released under the Artistic License (like Perl) for consistency, while most other software I write comes under the GPL or whichever GPL-compatible license is most appropriate. HTH Tim Hammerquist -- The court finds everyone to be in contempt (including himself :-), and orders everyone sentenced to five years hard labor. (Working on Perl, of course.) -- Larry Wall in <199807211548.IAA26184 at wall.org> From sholden at holdenweb.com Fri Nov 16 09:42:42 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 09:42:42 -0500 Subject: PIL Installation on windows98 - from newbie References: Message-ID: "Tech" wrote ... [ eff-bot asks how loaded, what errors were seen ...] > I downloaded the file for my version of python and ran the setup > executable that I downloaded. Next, I tried to test the installation > by running some of the test scripts that came with PIL. Each time I > tried I got the following error... > > > > Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on > win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> > Traceback (most recent call last): > File "C:\py21\Samples\viewer.py", line 7, in ? > import Image, ImageTk > ImportError: No module named Image > Aha! Have you tried import PIL.Image > > I had hope that all I had to do was run the > "py21-pil-1.1.2-20010910.exe" file and it would do everything and I > could just start using PIL. However, this does not seem to be the > case. I look for a Setup.py script in directory created by the > executable, but I found nothing. Do I have to copy the files to a > different directory? I'm new to python; I have a C++ Builder 4.0 > background. Am I doing anything wrong? Does this answer you > question? > PIL is, I believe, built for Windows using the distutils, the end result of which is a Windows installer. Did you notice where it installed PIL? Does this look like the right place? regards Steve -- http://www.holdenweb.com/ From datalim at email.com Fri Nov 2 03:46:18 2001 From: datalim at email.com (Data) Date: 2 Nov 2001 00:46:18 -0800 Subject: win32 - create/access file properties on NTFS Message-ID: <446d315.0111020046.2fc5c1d1@posting.google.com> How do I create/access the extra information while we right click a file on NTFS at the "Summary" tab? I checked ActivePython documentation but the win32file.CreateFile seems doesn't provide such feature. Any hint? Data. From sholden at holdenweb.com Wed Nov 7 10:11:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Nov 2001 10:11:19 -0500 Subject: win32print.Enumjobs References: <3BE7A509.A03DD6C9@nchc.gov.tw> Message-ID: <87cG7.3909$U07.207789@atlpnn01.usenetserver.com> "Wolfgang Strobl" wrote ... > "T. C. Huang" schrieb: > > >Hi, > > > > How to use win32print.EnumJobs() function? The documention has too > >little information to > >be useful. > > Hu? > > I've never used this function, but it took me only a few seconds to > figure this out from the win32print docs. > > >>> zps=win32print.OpenPrinter("\\\\pricos\\zps") > >>> win32print.EnumJobs(zps, 0, 1,win32print.JOB_INFO_1)[0]['pPrinterName'] > 'zps' Neither have I, and it was but the work of a second to discover I don't HAVE the function. I assume you are running with something more recent than 2.0? >>> pr=win32print.OpenPrinter("\\\\ltree1\\epson") >>> win32print.EnumJobs(pr, 0, 1,win32print.JOB_INFO_1)[0]['pPrinterName'] Traceback (innermost last): File "", line 1, in ? AttributeError: EnumJobs out-of-date-ly y'rs - steve -- http://www.holdenweb.com/ From fperez528 at yahoo.com Sun Nov 25 19:02:19 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 26 Nov 2001 23:30:19 +2328 Subject: Regular expression References: <6039af6a.0111262123.54806bb7@posting.google.com> <3C032B29.A77DE30@earthlink.net> Message-ID: <9tvbv4$2uo$1@peabody.colorado.edu> > Sang DeSibtis wrote: >> >> >> Questions: how do I make a global replacements in the 'line' that >> read from the file object (buffer in memory? ). The key thing to understand is that in Python, strings are immutable, so you can never do *anything* in place to a string. All string operations return a new string, which if you want to work 'in place' you can just reassign to your original string: string = do_whatever(string) Even string methods don't work in-place: In [1]: s='abc' In [2]: s.replace('a','A') Out[2]= 'Abc' In [3]: s Out[3]= 'abc' Cheers, f From sholden at holdenweb.com Thu Nov 8 18:42:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Nov 2001 18:42:48 -0500 Subject: python path - pdflib References: Message-ID: "steve" wrote ... > I am trying to set a program to use a path in python. I see that I > can set my environment variable PYTHONPATH or set the sys.path in > python to the dir I want. I am having problems getting python to find > the files I want in this path. > > I am using the pdflib to create a pdf file. I need things that are in > the fonts directory. If I do a sym-link in the dir I am running my > script from, everything works fine. When I don't try to open up a > file from a different directory, the fonts are loading correctly. > When I open a file, then set the font type, it can't find the font, > unless it is in the directory the script is being run from, even > though I do a print sys.path and the directory is the first path > listed. > > Has anyone seen this problem or know a fix for it? I'm somewhat > stumped. It seems to me that it is a python/sys problem, because why > would the sys module be affected by another module? Maybe I'm wrong > on this assumption. As a note, I was using python 2.0 as this is what > pdflib wants to use, but I have tried with 2.1. You are mistaken in believeing that the Python path (effectively, sys.path) affects how the system finds data files. The path mechanism is used only for locating modules to be imported. You will therefore need to either locate the data files in a known directory or programmatically try the directories on the path until you find it. Probably a good compromise is having a default location hard-wired into the program, but allowing an environment variable (found in the os.environ dictionary) to override the default if/when set. regards Steve -- http://www.holdenweb.com/ From tjreedy at home.com Sat Nov 3 22:38:55 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 04 Nov 2001 03:38:55 GMT Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> Message-ID: "Fred" wrote in message news:3BE41CBE.94AED22 at nospamco.com... ... > Is there a better way to count the > individual values than dictionaries? Given that you want the number of different values with repeats not counted, no (Ie, not that I can think or or imagine thinking of). ... > nacc[ivacno]=None > ntra[idno]=None > nstk[stkno]=None ... > print "Number of acc: " + `len(nacc.keys())` > print "Number of tra: " + `len(ntra.keys())` > print "Number of stk: " + `len(nstk.keys())` > sys.exit() Terry J. Reedy From lac at strakt.com Mon Nov 12 11:02:38 2001 From: lac at strakt.com (Laura Creighton) Date: Mon, 12 Nov 2001 17:02:38 +0100 Subject: Is this considered black magic? In-Reply-To: Your message of "Mon, 12 Nov 2001 11:30:03 GMT." References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: <200111121602.fACG2cua014004@ratthing-b246.strakt.com> I supplied the original version, and for my first trick I wanted to silently skip objects that don't have a method whether or not they have an attribute-that-is-not-a-method by the same name. Sort of 'If you can do this, do it, if you can't, no problem ...' This sentence reveals why I went out and made that sinful ugly hack in the first place . In the internal dictionary I keep in my head, an 'attribute' is not callable. Up until yesterday, I didn't realise that the Python Usage is for methods to also be called attributes. So now I have to rearrange the contents of my skull again. It's a good thing that I enjoy this... I have a new problem. I've just lost a major amount of precision in my language usage. What is the collective noun for 'attributes that aren't methods (you can't call them)'? Laura Creighton From akuchlin at mems-exchange.org Fri Nov 16 22:31:07 2001 From: akuchlin at mems-exchange.org (Andrew Kuchling) Date: 16 Nov 2001 22:31:07 -0500 Subject: what happened to Python Cryptography Toolkit? References: Message-ID: <3dzo5m6pl0.fsf@mozart.cnri.reston.va.us> Peter Wang writes: > i find quite a few references to Andrew Kuchling's Python Cryptography > Toolkit on the web, but all the links to actual sources/distributions > are broken. also, there doesn't seem to be any mention of it past See http://www.amk.ca/python/code/crypto.html . Note that it hasn't been actively developed in some years (but see below). > has it been supplanted by something else? all i want is to easily do > RSA, preferrably in a platform-independent manner. (if platform > dependence is unavoidable, unix is preferable.) No one has written anything which has completely killed off my old code. However, the public-key support is definitely the weak point; it works, but it's non-standard and won't interoperate with anything else. If you want SSL, use M2Crypto; if And this is as good as time as any to say that I'm hoping to revive development of the code (but then, I said that a few months ago). See http://www.sf.net/projects/pycrypto/ for pointers to the CVS tree and the pycrypto-checkins mailing list. Send me your SourceForge ID if you want check-in privileges. Discussion should take place on the python-crypto list at http://listserv.surfnet.nl/archives/python-crypto.html, which is hosted outside of the US. (Who knows what will happen to cryptography in the post 9-11 world?) --amk From huaiyu at gauss.almadan.ibm.com Tue Nov 27 18:53:28 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Tue, 27 Nov 2001 23:53:28 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> Message-ID: On Tue, 27 Nov 2001 00:40:46 -0500, Peter Hansen wrote: >Huaiyu Zhu wrote: >> >> On Sat, 24 Nov 2001 21:25:22 -0500, Peter Hansen wrote: > >I didn't miss those points. I agree with the latter. The >former is also true, provided you are talking strictly about TAB==X spaces, >which is *never* something I said. By the way, the phrase "tab size" >was outlawed by David a few messages back, I believe. Remember, >tabs don't have sizes, or so we were told. See below. Just to clear up possible misunderstanding: no one is arguing with you about tab "size" vs tab "position" - this is a minor issue. If you think that's the argument, you are missing the point. The argument is whether the display of tab (be it size, position, shape, color, sound, smell, whatever) should have ANY default at all. Now that is clear, maybe you can reread the previous articles in a different light. >This would of course not cause any trouble provided those who used >it, used it consistently. That is, they *never* used anything spaces >for indentation. Problem is, they don't follow that rule, and >don't seem to understand that, with Python having mandated a convention, >any mixed use of spaces and tabs set to other than every 8 columns will >confuse Python. Have it ever occured to you, that it might be possible, however unlikely at first glance, that the rule itsself is the source of inconsistency? Maybe, just maybe, that ANY setting of equivalence between tab and space would be inconsistent? Maybe, just maybe, that if a language identifies m with rn it would cause similar amount of headache? Just give it a thought. You have to admit that it is a possibility. Yeah, yeah, Python did not invent the rule. That does not change whether the rule is consistent. > >> If you get around the notion that tab can ever be translated into spaces in >> a _universal_ way, you'll find that all the problems dissappear. >> >> For example, got a problem with mixing tab and space? Well, just don't do >> it. They are two different characters. It's the same as mixing w with vv >> or mixing m with rn. If this is enforced with the same strictness there >> would be no more problem with mixing tab and space than mixing w and vv. > >Obviously. Isn't this the whole point? Didn't I say that >mixing tabs and spaces was going to cause trouble? Thought I did. Not if your argument is consistent. In your ideal world that everyone interprets tab as 8 spaces there would be no problem mixing them. If you accept that mixing them is inconsistent whatever the equivalence is defined, why would you insist on tab=8? Wouldn't it be just as wrong as tab=42? So my understanding of your point is that tab=8 is prefered to tab=other, not about whether tab=anything is allowed. I hope you do agree that they are two different questions. > Therefore, to at least set a convention, >if not completely solve the problem, the Python standard is to >define TAB as representing indentation to the next multiple of >eight spaces. End of story... beginning of some people's problem. It is in fact the beginning of everybody's problem. > Why don't *you* >define an easy way to describe the "size" -- no wait, I mean >"tabstop" -- no wait, I can't say that either -- the indescribable >characteristic of the TAB character which when represented >onscreen as a shift in cursor position can be considered to >represent a particular *number* of columns.... Why don't *I* define that? Because, as you might have figure out by now, I don't think it is possible. It does not matter who defines it. Any definition would be inconsistent. Why don't *you* define whether m equals rn or nn? > I've been told >I can't use "tab size" for that, nor "tabstop", nor probably >tab width, spacing, or any other term ever used by an editor. >If we not only can't agree on a term for it, and you won't >even let me define my own term clearly and attempt to use >it for rational discussion, I guess we're done... Of course you can use these terms to describe the proper editor actions or screen positions and so on. But have you realized that you need an argument before associating these terms with tab the character? > I am only concerned about them wasting time >when they mistakingly think they will be able to type Python >code with a mix of TABs and SPACEs when their TABs are not >set to 8. You are concerned if they make the mistake when their tab is set to 4, or 2, or 7 or 9, or whatever, except that you are not concerned when they make exactly the same mistake when it is set to 8? What is so special about this magic number 8? If I were to care about this, I would be concerned about this mistake even if their tab is set to ANY size, or position, or shape, or sound, ... If a mistake is not allowed in any special cases, it is much less likely to be made in all cases at all. > >> Where is the inconsistency you are complaining about? > >When they mix it with spaces. Which is where I started about >when I mentioned "ambiguity", but we seem to have agreed about the >inadvisability of that, so there's no argument. If the inconsistency is mixing tabs with spaces, then setting a default equivalence between them actually contribute to it instead of prevent it. > >> I think his point is quite clear. The reason you do not see it that way is >> because, IMHO, you have not seriously considered the possibility that people >> might be arguing for the position that tabs can be used consistently without >> a defined equivalence as spaces. > >If you think I was suggesting TABs should be treated as X spaces, >you missed everything I said. By the way, is that phrase you used -- >"the position of tabs" -- the permitted way of describing what I >inappropriately (so it seems) termed tab "size", and "width", and >when my wrist was slapped tried "tabstop" as a temporary substitute? >Maybe if we all talk about "position of tabs" we can get somewhere. >Problem is, that's the first time in this discussion *that* >particular way of describing it has come up > >Sigh. All that typing, and still you two seem to insist >that I was saying things I did not intend, because you seem >to believe I don't understand about TAB *characters* just >because I used a different term for "width/size/stop/position" >than you did. I think I'll quit while I'm way behind on this one. We understand your point perfectly clear. I think you refuse to believe that it could be possible that people are arguing against ANY default display property of tab altogether. Therefore you continue to interpret them as trivial arguments about HOW the default should be defined. So let me repeat it once and for all: Question: What should tab be default to in terms of other charactors, or screen positions, or editor actions, or anything else that is not the tab charactor? Answer: It shouldn't. Huaiyu From sholden at holdenweb.com Thu Nov 29 15:05:42 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 15:05:42 -0500 Subject: Copy operator (was list.remove for Noivces) References: <3C06846E.DA673080@ccvcorp.com> Message-ID: <0vwN7.109399$vQ1.5236264@atlpnn01.usenetserver.com> "Jeff Shannon" wrote ... > [...] > > Just as a minor point, the quoted section above was written by Art Siegel, not > by me. I don't think any confusion has resulted, and I'm not really worried > about being misattributed, just wanted to clarify this for the record. :) > I though misattribution could make you go blind. Or did my parents lie? most-of-my-spelling-mistakes-are-typos-ly y'rs - steve -- http://www.holdenweb.com/ From ursus_horibilis at hotmail.com Tue Nov 27 12:30:59 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Tue, 27 Nov 2001 12:30:59 -0500 Subject: Integer Overflow Message-ID: Is there a way to force the Python run time system to ignore integer overflows? I was trying to write a 32-bit Linear Congruential Pseudo Random Number Generator and got clobbered the first time an integer product or sum went over the 32-bit limit. From kfarmer at thuban.org Mon Nov 26 22:40:40 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Tue, 27 Nov 2001 03:40:40 GMT Subject: AppBars in Win32 -- DEMO Message-ID: I've posted the code for a project-in-progress, demonstrating how to do AppBars using the win32 extensions. The current demo creates a wxPython frame, snags the handle to create a PythonWin object to deal with some more sophisticated message handling. It doesn't quite work the way it's supposed to -- there's an incompatibility with the taskbar, should its status change from non-hidden to auto-hide and the like, which should just be a matter of properly dealing with messages. (Speaking of which, I wouldn't mind clues on the params argument for PythonWin message handlers). The code provides for feedback messages if executed from a command window. Left-click to exit, right-click to change edges, or use the drop-down menu. See http://www.thuban.org/projects ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From skip at pobox.com Thu Nov 1 01:09:53 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 00:09:53 -0600 Subject: Underscore data hiding (was python development practices?) In-Reply-To: References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> Message-ID: <15328.59185.615816.939496@beluga.mojam.com> Peter> On Wed, 31 Oct 2001 18:42:03 -0600, Skip Montanaro Peter> wrote: >> Smiley or not, you seem to be trying a bit too hard to compare Python >> with C++. They serve dramatically different audiences. Peter> what are these dramatically different audiences? Perhaps I should have phrased that "designed for dramatically different audiences". Stroustrup designed C++ with the high-performance applications of his employer in mind (e.g. telephone switching). He also had C compatibility in mind. Guido (or Tim channeling Guido) will likely correct me if I'm wrong, but I don't think Guido necessarily had high performance or C compatibility in mind when he designed Python. He was creating a scripting language for the Amoeba distributed operating system. The fact that Python is "fast enough" for many things you might apply C++ to is in large part because: * the types of applications to which it is applied (frequently interactive applications where the user is the slowest part of the system, "glue" applications (Paul Rubin's recent comments on horses not withstanding) where it provides an integration layer over libraries written in C or C++, * processor performance has increased "a lot" in the decade since Python's first release, * productivity gains outweigh (relative) performance loss (programmers are relatively expensive, CPU performance relatively cheap) C++ is also roughly ten years older than Python. The change in the computing landscape in that ten-year period (and in the ensuing ten years) was pretty significant. The two languages were simply designed in quite different environments. Skip From slinkp23 at yahoo.com Thu Nov 1 20:01:31 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Fri, 02 Nov 2001 01:01:31 GMT Subject: List transpose method References: <20011101205127.A4219@ibook.distro.conectiva> Message-ID: On Thu, 1 Nov 2001 22:45:05 +0100, Gerhard H?ring wrote: >On Thu, Nov 01, 2001 at 08:51:27PM -0200, Gustavo Niemeyer wrote: >> > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru >> > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can >> > only come up with an ugly multiliner. >> >> >>> zip((1,2),(3,4),(5,6)) >> [(1, 3, 5), (2, 4, 6)] > >Hmm. How would I apply zip if I have a variable already, like > >l = ((1,2),(3,4),(5,6)) Easy questions are answered faster by the python prompt than by usenet. Hint: Try the most obvious thing that comes to mind. --PW From eppstein at ics.uci.edu Tue Nov 13 17:22:50 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 13 Nov 2001 14:22:50 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: As a possibly-related side note to this debate: I have been moving towards using Python-like pseudocode in my algorithms classes in place of the C/C++/Java-like pseudocode I was previously using; that is, using colons and indentation to mark blocks of code instead of curly braces, etc. As well as conciseness, Python offers some other advantages e.g. in the ability to write code with list comprehensions. The single biggest barrier for me to write actual working Python code is the range/xrange syntax: I just don't feel comfortable writing code like for i in range(n-1,-1,-1): for j in range(i+1,n+1): ...do something... because I don't expect my students (who are not required to learn Python) to understand from that syntax that the outer loop runs backwards from n-1 to 0 and that the inner loop runs from i+1 to n. Instead I have to make up some non-Python syntax which is less formal but immediately clear: for i in [n-1, n-2, ... 0]: for j in [i+1, i+2, ... n]: ...do something... (actual example from ). As far as I can see, the PEP under discussion (which simply replaces the word "range" by "iter", creates an iterator instead of a list, and perhaps only allows the single-argument version of range) doesn't help me at all in my desire to have lecture notes which are both intuitively understandable and runnable. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jdgorman at ieee.org Thu Nov 15 01:28:31 2001 From: jdgorman at ieee.org (John D. Gorman) Date: Thu, 15 Nov 2001 06:28:31 GMT Subject: GUI toolkit References: Message-ID: <3BF35DED.63DDD6C4@ieee.org> Cary, If you've tinkered with wxPython, you should definitely check out the bundled demo as well as some of the developer tools. Things to look at: - Cameron Laird's collection of links: http://starbase.neosoft.com/~claird/comp.lang.python/python_GUI.html wxPython related tools: - Boa Constructor: http://boa-constructor.sourceforge.net/ - wxDesigner http://www.roebling.de/ For simple tasks, I'm kinda partial to Boa Constructor & wxPython. I was able to get an analytical chemist with no prior programming experience up and building usable GUIs in a matter of hours. (Of course, I had to supply the callback routines, but what do you want for nothing ;^). The resulting codes run fine on both RedHat7.2 & Win2K. Moreover, they look mighty impressive to customers used to dealing with shrink- wrapped software. Cheers, John Gorman Cary Coulter wrote: > While I've learned a lot of Python in the last year, all my scripts > have run from the command line or as CGI programs. I'm very happy > with it all. > > I am interested in developing gui wrappers for a couple of my command > line scripts to make them easier to use, especially under Windows. I > don't have any experience with the gui toolkits yet. I'm looking for > some hints on the pros/cons to help make a good choice. I'm really > looking at just learning one of them. > > I have looked at the demos for wxPython. Have to say I like what I > see, but I haven't tried to develop anything yet. > > Platforms would be Linux (primary), Windows, and AIX (didn't see any > prebuilt code for wxPython). > > Your help/ideas are greatly appreciated. > > TIA > Cary From fredrik at pythonware.com Wed Nov 7 17:41:43 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 22:41:43 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: David Andreas Alderud wrote > I see big demand for Ada programmers here in Sweden, not as big as Java and > C++, but indeed much more so than Python :) Says who? If you're judging the demand by studying job ads, you should be aware that light-weight tools like Python and Perl are often hidden under labels like "various scripting languages" or "rapid development tools" or "script programming". Most companies don't mention them at all, even if they use them a lot. Why would they? Any programmer worth hiring can pick up a light-weight language in a day or two. From skip at pobox.com Mon Nov 19 19:03:00 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 19 Nov 2001 18:03:00 -0600 Subject: Free Python Server In-Reply-To: References: Message-ID: <15353.40372.784126.72589@beluga.mojam.com> Stephen> Hey, does anyone know of any free web hosting solutions that Stephen> offer Python, and no banners or pop-up ads? I hate to play the devil's advocate here, but if they don't charge for their web hosting and don't put up ads, how are they supposed to make the money necessary to keep offering their services to you? Oh, right, they take your personal info and sell it to direct marketing folks. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From clpy at snakefarm.org Fri Nov 30 11:45:23 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 30 Nov 2001 17:45:23 +0100 Subject: xmlrpc tutorial? References: <3C063569.8230ADD0@snakefarm.org> <3C07961D.9A7970FA@snakefarm.org> Message-ID: <3C07B7A3.2A6443C9@snakefarm.org> talon at www.tempestnetworks.net wrote: > > On Fri, 30 Nov 2001 15:22:21 +0100, Carsten Gaebler wrote: > > >However, there seems to be a problem with restarting the server. I > >have to wait a minute or so to avoid an 'address is already in use' > >error. > > Use the setsockopt function on the socket objet, pass it the value > SO_REUSEADDR (defined in the socket module). Nope, doesn't help. My code is: server = SocketServer.TCPServer(('', 8000), TestRequestHandler) server.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) server.serve_forever() cg. -- 'In iteger arithetric divsion is no the oposite of multiplication.' -- scenes from comp.lang.python From sigma at safepassage.ca Sat Nov 17 14:40:22 2001 From: sigma at safepassage.ca (Reid Nichol) Date: Sat, 17 Nov 2001 13:40:22 -0600 Subject: ssl error Message-ID: I got a client/server app that I am triing to build and am having problems. I created the key and cert with openssl as per 'man ssl'. The socket seems to load it all find and think that the what's in the files are good. I can connect without ssl fine and dandy but when I goto use socket.ssl it blows up. The error: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", line 1285, in __call__ return apply(self.func, args) File "main.py", line 57, in logon self.conn = self.connection.connect()# = connect() File "connect.py", line 18, in connect self.incoming = socket.ssl(self.clear_in, "ssl/dsakey.pem", "ssl/dsacert.pem") sslerror: SSL_connect error The error in my logs on my server if I try to connect to port 22: Bad protocol version identification '\M^@\M^@\^A\^C\^A' from 192.168.0.2 I'm not really understanding what is going on here, ie where to start, which files to look at. I've looked on the net and haven't found any examples of ssl under python (at least the built in module). My relevant code for the client: import socket class connect: def __init__(self): self.HOST = '' self.IN_PORT = 10006 self.OUT_PORT = 10007 self.clear_in = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def connect(self): self.clear_in.connect (('host', 22,)) self.incoming = socket.ssl(self.clear_in, "ssl/dsakey.pem", "ssl/dsacert.pem") And the server: import socket HOST = '' IN_PORT = 10006 in_in = socket.socket(socket.AF_INET, socket.SOCK_STREAM) in_in.bind((HOST, IN_PORT)) in_in.listen(1) try: conn, addr = in_in.accept() incoming = socket.ssl(conn, "ssl/dsakey.pem", "ssl/dsacert.pem") except socket.sslerror, msg: print 'ssler => ', socket.sslerror print 'sockr => ', socket.error print 'error => ', msg print 'connected by => ', addr conn.close() ----- If you truly love the memory, you must set it free()! From ws-news at gmx.at Mon Nov 26 04:56:16 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 26 Nov 2001 10:56:16 +0100 Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: <3c021287@brateggebdc5.br-automation.co.at> Hi, > > I've decided to do what I should have from the beginning: always use > string.join. I didn't want to because it seemed silly to import a whole > module for one function, and as long as I'm using Official String Methods for > everything else I should use them for joins too. I think this is no big deal, since the string module maps most of its actions including join to the string methods. Of course, this will slightly reduce the performance, but the module itself is pretty light-weight. Moreover, I think readable code is more important than performance. regards Werner From hfoffani at yahoo.com Thu Nov 1 10:00:24 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Thu, 1 Nov 2001 16:00:24 +0100 Subject: accessing a web search engine References: <9rq340$1hfc@r02n01.cac.psu.edu> Message-ID: <20011101100106.786$WB@news.newsreader.com> "Rajarshi Guha" escribi? en el mensaje news:9rq340$1hfc at r02n01.cac.psu.edu... > Hi, > I'm trying to use Python to send queries to a webpage and analyse the > results. However the search engine does'nt use cgi scripts - it uses a > Javascript function. How can I access a JScript function. I realize that > this is not really a Python question, but since I am using it I thought I'd > ask here. I know that I have to use the urllib module but what string do I > send to the server? Did you try to access that site with a browser with javascript disabled? It may default to a standard form/submit page... -Hernan From goodger at users.sourceforge.net Sun Nov 11 17:45:09 2001 From: goodger at users.sourceforge.net (David Goodger) Date: Sun, 11 Nov 2001 22:45:09 GMT Subject: Tim Peters on speed! References: Message-ID: > not-responsible-for-insane-user-methods-ly y'rs - tim Insane user or insane methods? -- David Goodger goodger at users.sourceforge.net Open-source projects: - Python Docstring Processing System: http://docstring.sourceforge.net - reStructuredText: http://structuredtext.sourceforge.net - The Go Tools Project: http://gotools.sourceforge.net From gtalvola at nameconnector.com Fri Nov 9 14:36:51 2001 From: gtalvola at nameconnector.com (Geoff Talvola) Date: Fri, 09 Nov 2001 14:36:51 -0500 Subject: python1.5.2 + nt services + COM In-Reply-To: Message-ID: <5.1.0.14.0.20011109142948.0360ac60@infratest1.nameconnector.com> At 12:44 PM 11/9/01 -0500, Steven Scott wrote: ... >I'm not specifically using threads, although I am subclassing >win32serviceutil.ServiceFramework as per the ntservice example that comes >with win32all...I don't know if it does something with threads, but I'm led >to believe that it's so. ... That's probably the reason it doesn't work. See Appendix D of Python Programming on Win32 for a good explanation of threading issues with COM. Or if you don't have the book, the short version is, try calling: pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED) at the beginning of the DoRun method (or if you'd prefer apartment-threading instead of free-threading, call pythoncom.CoInitialize() instead). Also, you should call pythoncom.CoUninitialize() at the end of the DoRun method. The difference between apartment and free threading is covered pretty well in Python Programming on Win32. -- - Geoff Talvola gtalvola at NameConnector.com From lfini at arcetri.astro.it Mon Nov 5 08:40:54 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Mon, 5 Nov 2001 14:40:54 +0100 Subject: Problems compiling PyQt Message-ID: I'm trying to compile PyQt on RedHat Linux 7.1 (gcc version 2.96 20000731) as usually I do: ./configure make And I always get the following errors: qtcmodule.cpp: In function `PyObject *registerClasses (PyObject *, PyObject *)': qtcmodule.cpp:9159: `Rounded' is not a member of type `QTabWidget' qtcmodule.cpp:9160: `Triangular' is not a member of type `QTabWidget' qtcmodule.cpp:10361: `TSCII' is not a member of type `QFont' qtcmodule.cpp:10625: `AccelOverride' is not a member of type `QEvent' qtcmodule.cpp:11251: `WGroupLeader' is not a member of type `Qt' This happens for various versions pf PyQt(2.3,2.4,2.5). Am I doing something wrong? -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From slinkp23 at yahoo.com Fri Nov 30 14:30:28 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Fri, 30 Nov 2001 19:30:28 GMT Subject: New updates needed for an old computer language humor piece References: Message-ID: On Fri, 30 Nov 2001 13:28:08 GMT, Nick Mathewson wrote: >Python (Time Machine version). > You try to shoot yourself in the foot, only to realize that > there's no need, since Guido thoughtfully shot you in the foot > years ago. Bingo! From dalke at dalkescientific.com Tue Nov 27 15:21:00 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 27 Nov 2001 13:21:00 -0700 Subject: Perl to Python References: Message-ID: <9u0si9$hc1$1@slb7.atl.mindspring.net> Tim Hammerquist: >Pipes can be opened using os.popen(). Pipes can be read/written by >reading from/writing to the file object returned by os.popen(). Read >from this as normal in Python, just as you're reading from the SQL >filehandle in the perl code. > > # Perl > open PIPE, "ls /etc" or die "can't read from pipe: $!\n"; > print while ; > close PIPE; > > # Python (roughly) > pipe = os.popen('ls /etc') > while 1: > line = pipe.readline() > if not line: > break > print line > retval = pipe.close() The Python isn't quite equivalent to the Perl since 'print' adds the newline after printing. You'll either need to chomp off the final newline or use sys.stdout.write(line). Assuming Python 2.2 iterators, this can be written pipe = os.popen('ls /etc') for line in pipe: sys.stdout.write(line) retval = pipe.close() Andrew dalke at dalkescientific.com From peter at engcorp.com Tue Nov 13 20:49:18 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 13 Nov 2001 20:49:18 -0500 Subject: dynamically generating a module References: <8ef9bea6.0111131459.38f96699@posting.google.com> Message-ID: <3BF1CD9E.A9C9712B@engcorp.com> Hung Jung Lu wrote: > > Here is one more challenge: is it possible to create a module on the > fly? > > Suppose I have the ASCII Python source code of a module-to-be, or even > better, suppose that I have the compiled byte code of a module-to-be, > stored in a Python string. Is there a simple way (meaning not tweaking > at C++ level) of making the module-to-be into a real module, without > hitting the harddrive? You can use new.module() to get a "raw" module to play with. Example of one way to use it at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82234 -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aa at bb.cc Mon Nov 5 04:51:19 2001 From: aa at bb.cc (Károly Ladvánszky) Date: Mon, 5 Nov 2001 10:51:19 +0100 Subject: Question: Error or misconcept Message-ID: <3be65da4$1_3@corp-goliath.newsgroups.com> I have run into the following problems. 1.) class c1: a1=[] def f1(self,a): self.a1.append(a) def test1(): o1=c1() o1.f1(99) def test2(): o1=c1() print o1.a1 Running test1(), test2(), in test2 I'd expect o1.a1 be []. This is not the case, test2() prints [99] ! My guess is self.a1.append(a) modifies the class object's a1 member, not the instance object's a1. When a1 is a number, everything goes as expected: class c1: a1=0 def f1(self,a): self.a1=(a) def test1(): o1=c1() o1.f1(99) def test2(): o1=c1() print o1.a1 Now test2() prints 0. 2.) I thought of writing a tiny funtion that'd present a report on an object given as parameter. Processing the object's __dict__ special attribute seemed to be a good choice. It works fine for the class: class c1: a1=0 def f1(self,a): self.a1=(a) c1.__dict__ ==> {'__doc__': None, '__module__': '__main__', 'f1': , 'a1': 0} Trying to use it for an object results in an empty dictionary: o1=c1() o1.__dict__ ==> {} Referring to an attribute of o1 through the dictionary seems to sortof refreshing the dictionary: o1.__dict__['a1']=2 o1.__dict__ ==> {'a1': 2} Is it a misconcept of mine about __dict__? If it is, what's the right way to enlist an arbitrary object's attributes, methods? I'm using ActivePython build 2.1.212 Thanks for any help. Cheers, K?roly ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net From nhodgson at bigpond.net.au Thu Nov 1 17:04:09 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 01 Nov 2001 22:04:09 GMT Subject: What about background? References: <8ba2utofr79esiih1ujqveuaea4a8df61p@4ax.com> Message-ID: Nomad: > AFAIK, the pythonwin editor is set up as a standard windows > 'View' window. So what you could do is go to "Control > Panel | Display | Appearance" and change the colour for the > 'Window' item to something more pleasing to your eyes. The default white background colour is currently hard-coded although there is a good argument for it to work as you say. However, if the user chooses a much different background colour, such as black, then all the foreground colours should change to still be visible - particularly black! The styles are defined in the PYTHON_STYLES variable in formatter.py with the third element in each item being the background colour but this setting is only applied to a new installation and is then stored in the registry to remember user changes. Neil From gmfawcett at operamail.com Wed Nov 7 13:31:37 2001 From: gmfawcett at operamail.com (Graham Fawcett) Date: Wed, 7 Nov 2001 13:31:37 -0500 Subject: Passing object as param to Python COM server Message-ID: <3BE97F56@operamail.com> Hi folks, I've got a COM server written in Python, and it's running great (thank you to EVERYONE who made this marvellous tech possible). But I've got a question about passing parameters in method calls on my server. I have a VB script in PowerPoint that creates an instance of my server. I'd like to pass a reference to the PowerPoint application to my server, for example: 'in the PowerPoint macro, sub PassExample(pptapp as Application) Set myserver = CreateObject("UWindsor.MyServer") myserver.QueryApp pttapp end sub # in the server, def QueryApp(self, app): #Name should be a valid attribute of a PowerPoint.Application print app.Name ... Running the VB macro incurs an AttributeError: Name when the QueryApp method is called. The object (app) passed to my server is a PyIDispatch object. What do I have to do to make my server recognize this as a PowerPoint.Application object so that I can access its attributes (and hopefully invoke its methods)? Apologies for my lack of what is probably basic COM knowledge. Thanks, everyone. -- Graham From tjreedy at home.com Wed Nov 14 11:32:28 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 14 Nov 2001 16:32:28 GMT Subject: Infinite lists and generators References: Message-ID: "Luigi Ballabio" wrote in message news:mailman.1005728119.32612.python-list at python.org... > > Hi all, > I've been reading a few back issues of the Perl Journal, and I came across > an article on implementing infinite lists in Perl. Just for fun I went > ahead and reimplemented it in Python---I know someone probably did already, > but as I said, it was for fun. Also, I've written a test suite which > showcases a few tricks such as building the list of all prime numbers, of > the Hamming numbers, and the power series of exp, sin and cos. I'm > including the file below. > > My question is: how does one go about pulling such stunts with generators > instead? Two easy examples (untested, but pretty sure correct): def integersFrom(n): "Infinite stream of integers starting from n" > return Stream(n,lambda n=n:integersFrom(n+1)) while 1: yield n n += 1 >def filter(f,s): > """returns the stream of the elements x of the > input stream s which satisfy the predicate f""" > while s and not f(s.head()): > s = s.tail() > if not s: > return None > else: > return Stream(s.head(), > lambda f=f,s=s: filter(f,s.tail())) The problem with filtering an infinite stream is that if there are only N items that pass, the filter will never halt looking for the N+1st. def iterate(f,x): "returns the stream of x, f(x), f(f(x)), f(f(f(x))), ..." > return Stream(x, > lambda f=f,x=x: iterate(f,f(x))) while 1: yield x x = f(x) Terry J. Reedy From mwh at python.net Wed Nov 7 06:09:29 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 7 Nov 2001 11:09:29 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: I've refreshed my memory somewhat, but this certainly shouldn't be taken as definitive. Martin von Loewis writes: > Michael Hudson writes: > > > > - it adds 17 new members to the frame object, doubling the number > > > of members. Usage of some of these members isn't obvious to me. > > > > See below about map & friends. > > If they are all just for the variables in map etc., a better solution > must be found - don't think it is desirable to have them in every > frame, if they are just used inside map. I thought this at the time I looked at the code. > However, from inspecting the patch, I doubt this is the case. Some of > them are general-purpose, but I couldn't easily figure out what, for > example, this first-instruction business is good for. Sorry, my memory had failed me somewhat. I've downloaded the code now. I think f_first_instr is there to transfer information between eval_code2_setup and eval_code2_loop. As such I don't think it's at all necessary; I think eval_code2_loop could just go _PyCode_GETCODEPTR(f->f_code, &first_instr); Another mystery, this time about core Python: why go to so much trouble to ensure that code_object->co_code is only a readable buffer? (a) I'm pretty sure it's always a string (b) I don't see any error checking, so if it's something more complicated than a string and bf_getreadbuffer fails, the interpreter is going to go "boom". Oh well, just another mystery about the buffer interface. Not sure what f_next_instr is for either; it seems to always satisfy unsigned char* first; _PyCode_GETCODEPTR(f->f_code, &first); f->f_next_instr == first + f->f_lasti It may be another optimization... I think f_stackpointer does what f_stacktop does in today's Python (it was introduced by the generator patch). f_statusflags records various hairy things about the frame. I certainly don't understand the details, but I don't think you can go without this. f_execute is usually eval_code2_loop, but can also be builtin_map_loop. This is fundamental. f_dealloc is used by the continuation module, as are f_node, f_co, f_coframes. I /really/ don't understand that module. f_depth seems to be used only by map(). Oh no, continuations too. f_age really does seem to be only used by map(). To store the length of the longest sequence being iterated over, it seems. Nice name. Same for f_reg3. So there definitely seems to be some room for cleanup here. I'd need to understand continuationmodule.c to see exactly how much. > > So when map wants to call the Python function, it needs to stuff all > > the local data it cares about into a frame object (see above), push > > this frame object onto the (Python) stack, *return* to the interpreter > > in such a way that the mapping function is called next and then every > > time(!) that returns have the interpreter call back into map again. > > Why couldn't map behave as if it was a plain Python function, > implemented as > > def map(fun,args): > res = [] > for a in args: > res.append(fun(a)) > > [I know that map is implemented in a more-involved way; it should > still be possible to find its Python equivalent, then think how > stackless would execute this equivalent] > > For the additions to frame_state, that would mean that map should > reserve a number of localsplus variables, instead of outright adding > to frame_state on the C level. I wasn't trying to justify the existing implementation, just explain it. I agree with you here. > > > - The code adds PREPARE macros into each branch of ceval. Why? > > > - It adds a long list of explicitly not-supported opcodes into > > > the ceval switch, instead of using 'default:'. No explanation > > > for that change is given, other than 'unused opcodes go here'. > > > Is it necessary to separately maintain them? Why? > > > > This was an optimization Chris used to try and get back some of the > > performance lost during the stackless changes. IIRC, he handles > > exceptions and return values as "pseudo-opcodes" rather than using the > > WHY_foo constants the current ceval.c uses. I never really understood > > this part. > > If it is an optimization, I think we should take a step back and first > try to understand what it tries to optimize, and how it does > that. Perhaps we find that it isn't needed at all, and that the > problem could be solved in a different way. If you don't understand > it, it can't go into Python. And here. > > I think integrating stackless into the core is a fairly huge amount of > > work. I'd like to think I could do it, given several months of > > full-time effort (which isn't going to happen). About the only likely > > way I see for it to get in is for it to become important to Zope > > Corp. for some reason, and them paying Tim or Guido (or Chris) to do > > it. > > I don't think these are the options. I don't volunteer to support this > code myself, either, but if somebody would step forward and claim that > she understands it all, and is willing to present it to Guido in a way > that he understands it also, and if all the hackish parts of it would > be replaced by understandable code, I think it could go into Python. > It just needs a determined volunteer to work on it. Yeesss, but does anyone have the time for this? I mean, I've just spent an hour or so I probably shouldn't have writing this article, and I've barely scratched the surface. I don't want to discourage anyone, but I thinking liking a challenge is a prerequisite. I might devote an evening or two to it and see where I get. Homological algebra beckons -- brain relief in this context! Cheers, M. -- LINTILLA: You could take some evening classes. ARTHUR: What, here? LINTILLA: Yes, I've got a bottle of them. Little pink ones. -- The Hitch-Hikers Guide to the Galaxy, Episode 12 From max at alcyone.com Thu Nov 1 12:44:34 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 01 Nov 2001 09:44:34 -0800 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> <3BE11391.BF044772@alcyone.com> Message-ID: <3BE18A02.76FE1AB@alcyone.com> Oleg Broytmann wrote: > On Thu, Nov 01, 2001 at 01:19:13AM -0800, Erik Max Francis wrote: > > > Oh, please. You don't have the "freedom" to dictate to other people > > what license to put on software that _they_ write. > > When and where was I dictating this? You're talking about people "restricting your freedoms," presumably by providing closed source licenses. What else did you mean? -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From wpmelcher at snet.net Sun Nov 25 10:02:17 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Sun, 25 Nov 2001 15:02:17 GMT Subject: Win98 PySol problem References: Message-ID: Hi Matt, What fun! After a few nanoseconds of thought, it occurred to me that what I should do is invoke the Windows Run window type: python Q:\pysol-4.72\src\pysol.py and click OK. Wow! A ton of messages in the DOS/python window followed by a popup message named "PySol installation error" that complains that "No cardsets were found !!!". OK, I can get the cardsets from the Russian site and try to figure out where to put them. Hung off src (AKA python Q:\pysol-4.72\src\) I would guess. However, the messages from the compile scroll away far to fast to read. Is there a way to save these for debugging purposes or just, at this point in my python education, out of curiosity. Also, where does the compiled PySol go? Our old friend src? Can I add an option to direct the compiled out put elsewhere? I notice that the original PySol src archive does not contain any .pyc files. This makes sense to me but the current directories do have .pyc files last modified 11/24/2001 8:15 AM and I have run the python command twice today. My problem is that I do not remember what I did to cause the compile yesterday and do not understand why the compiles I did today did not affect the time stamps in my on-disk src directory structure. More to the point: Where in the documentation do I find the syntax of the python command itself? Another topic is a file called ".gdbinit" which contains: file python set args -u -t pysol.py What the heck is this? Matt, I am sure the other guys who have responded mean well but they and, to a lesser extent, you do not appreciate the depth of my ignorance of those things that 'everybody' knows. The Python documentation goes into great detail about the language itself and how to program in it. However, the really fundamental mechanics of how to get stuff done (especially in Win98) and who's doing what to whom appears to be missing. Ah well, if I keep pestering you guys, sooner or later you will tell me what I need/want to know or just get tired of me and go on to other things. -- Cheers, Bill TANSTAAFL! PS: I cut my programming 'eye teeth' on the IBM 701, then onto the 704, 709x, 704x, Philco 2000, Univac 1108, Univac 494, then IBM 360, followed by IBM XT and the subsequent IBM AT and IBM PC clones. I think the most fun machine was the 494 and I had much more fun rewriting portions of Fortran II (once I snagged the source) than writing code in any higher level language. "Matthew Dixon Cowles" wrote in message news:zE_L7.19409$H7.3406936 at ruti.visi.com... > On Sat, 24 Nov 2001 22:52:56 GMT, Bill Melcher From jeff at ccvcorp.com Thu Nov 29 13:54:39 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 29 Nov 2001 10:54:39 -0800 Subject: Copy operator (was list.remove for Noivces) References: Message-ID: <3C06846E.DA673080@ccvcorp.com> "Delaney, Timothy" wrote: > > From: Arthur Siegel [mailto:ajs at ix.netcom.com] > > Jeff Shannon wrote: > > > > But if I could find some way to demonstrate (not saying that I > > necessarily could find a way to do so convincingly) that it would > > indeed make Python better equipped for beginners/learners - > > is there a shot it would find acceptance by the community? > > Probably not, since the only thing it would be doing would be introducing > syntactic sugar for something which Python already has. ..... Just as a minor point, the quoted section above was written by Art Siegel, not by me. I don't think any confusion has resulted, and I'm not really worried about being misattributed, just wanted to clarify this for the record. :) (Also for the record, I tend to agree with Tim Delaney on this point...) Jeff Shannon Technician/Programmer Credit International From peter at engcorp.com Wed Nov 28 22:33:27 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 22:33:27 -0500 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <3C05AC87.89B0FDC3@engcorp.com> James_Althoff at i2.com wrote: > > Peter Hansen wrote: > >What am I missing here? Is the above not just > >a far less sane way of writing the following? > > > >if index >= len(mylist): > > print 'index out of range' > > But "sane" is *such* a loaded term. ;-) Loaded in this case with connotations of adequate performance. ;) > index in range(len(mylist)) > > works both in a for-loop and an if-statement. I see it quite a lot in code > that I come across. YMMV. Except that when used with a list, it performs a brute-force search for index (for the 'if' case)! Surely that wouldn't be very sane. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sholden at holdenweb.com Thu Nov 1 07:39:31 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 1 Nov 2001 07:39:31 -0500 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> Message-ID: "Oleg Broytmann" wrote in message news:mailman.1004604242.30735.python-list at python.org... > On Wed, Oct 31, 2001 at 03:48:57PM -0500, Steve Holden wrote: > > "Oleg Broytmann" wrote in message > > news:mailman.1004551447.32304.python-list at python.org... > > > On Wed, Oct 31, 2001 at 09:45:25AM -0800, Erik Max Francis wrote: > > > > You said you didn't want to start another GNU flamewar. But what do you > > > > think you're doing? > > > > > > Trying to stop you arguing :) > > > > > I'm sorry, this is abuse. > > I have no problem abusing this in case people are trying to restrict my > freedom. [Makes note to remember that Oleg isn't a Monty Python viewer.] Wasn't trying to suggest you were abusing the group, Oleg. Just a corny joke I should have left alone! Now, can we *all* please stop beating this subject to death before three thousand group memebers die of boredom? regards Steve -- http://www.holdenweb.com/ From johnroth at ameritech.net Sun Nov 4 15:08:49 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 4 Nov 2001 12:08:49 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: "Tim Peters" wrote in message news:mailman.1004858117.20012.python-list at python.org... > > An odd thing is that, when this comes up, people complain that under > Python's current rules it's not necessarily the case that > > (-i)/j == -(i/j) > > Across decades of integer numeric programming, I can't recall any *use* for > that identity; but that i%j >= 0 whenever j>0 is endlessly useful, as is > your identity relating int-div and int-mod. Useful as it is, it makes division not be the inverse of multiplication, so it's mathematically incorrect, and hence astonishing to people who don't know the score. John Roth > > doing-a-right-thing-is-a-trial-ly y'rs - tim > > From sholden at holdenweb.com Wed Nov 21 08:52:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 21 Nov 2001 08:52:35 -0500 Subject: getting modules optionally References: <3BFC2647.D9692B49@gol.ge> Message-ID: "Giorgi Lekishvili" wrote in message news:3BFC2647.D9692B49 at gol.ge... > Dear all! > > I apologize for this nebye-like question. > > Suppose, we have a package with one __init__.py file, while the rest are > other modules (let's call them active modules), which do the essential > stuff. > > Apparently, I need to start like this: > > > from MyPackage import * > > I need to import only one active module. This can be done by hardcoding: > > from MyPackage.ThisModule import * > > What I can not do is to import the module, if I have its name as string. > > modname='ThisModule' > > Of course, the code below doesn't work: > > from MyPackage.modname import * > > The question: is there something like eval function, which could > transfer the string as the real module name? In other words, how have I > to treat the modname to make this code running? > > from MyPackage.modname import * > Take a look at the built-in __import__() function. regards Steve -- http://www.holdenweb.com/ From anthony at interlink.com.au Thu Nov 1 22:42:03 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 02 Nov 2001 14:42:03 +1100 Subject: Monty Python (was: Freeware Python editor) In-Reply-To: Message from quinn@retch.ugcs.caltech.edu (Quinn Dunkan) of "02 Nov 2001 03:27:26 GMT." Message-ID: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> >>> Quinn Dunkan wrote > I'd also like to see what they do to the opening credits in the Swedish > translation. obofftopic: I seem to recall that when Life of Brian was banned in Norway, it was advertised in Sweden with "This Film Is So Funny It Is Banned In Norway". Anthony From phr-n2001d at nightsong.com Fri Nov 2 02:45:38 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 01 Nov 2001 23:45:38 -0800 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> Message-ID: <7xn1257h0d.fsf@ruckus.brouhaha.com> "Leo Lipelis" writes: > >> Considering that in Python exceptions are matched by identity instead > >> of equivalence, it's possible to track all the exception flows, right? > > > > Of course not. Since you can execute arbitrary strings, you can create > > new exception classes at runtime and throw them. > > This is a non-argument. It's like saying, you can access anything with a > pointer in C, thus you shouldn't use any tools that can warn you about > possible segfaults. It's nonsense. Just because you can dynamically > execute dynamically created strings with unknown exceptions doesn't mean > it's good to do so. But it means you can't have the exception discipline Python that you can have in Java. The Python compiler can't generate code based on the idea that it knows every possible return path from the function. Apparently that wasn't what you cared about--I thought maybe it was. > In 99.99% of Python code, the exceptions that are thrown are well > known in advance. Even dynamically executed strings are really not > so dynamic, because, for example, they are often scripts that could > be exception-checked prior to execution. You said "track all the exception flows". In technical subjects like programming, "all" means 100%, not 99.99%. > > I don't understand the problem. The whole idea of an exception is it's > > something you don't have to know how to deal with. You catch the > > This is simply wrong. That's not the idea. The whole idea of exceptions > is that you will know 99.99% of the time which exceptions you should > handle, so that you can intelligently decide where to handle them, or > whether to handle them at all, and how to handle them. This decision is > impossible if you don't know what is being thrown at a certain point. I mean the idea of RAISING an exception is that it's a condition you don't know how to deal with. The caller then has to either deal with it if it knows how. If it doesn't know how, it should raise another exception. If it's the top level and gets an unexpected exception, that's an error condition. It's possible to write spaghetti code with exceptions, that's for sure. It's best to avoid doing that. Your modules should generally not have the possibility of raising a lot of different exceptions. Rather, they should catch exceptions from modules they call, and deal with them or re-raise them in a uniform way. Also, use the standard exception classes for things like system errors, attempting to raise the right kind of exception for the condition you encounter. Designing the exception system in a program is just like designing the class structure--it takes a certain amount of thought and tweaking but generally you can come up with something clean and well suited to your program. > In reality, there is no reason why you shouldn't know it. Well, as a matter of coding convention, that's possibly true, but in Python it can't really be enforced, as we've seen. > Then, you can deal with various exceptions differently. For some, you can > just log them and keep going. For others, you may request the user to try > again. For yet others you can attempt automatic recovery. All this is > impossible if you don't know what exceptions you're dealing with. I don't know, maybe I'm missing something. It's always seemed to me that having to declare every single exception that a function can raise (like Java requires) goes against the principle of modularity. Callers should not have to care about the internal intricacies of things they call. > > exceptions you can handle, and leave the rest for higher levels of the > > program. You can always catch all the exceptions, and then if you get > > something you can't deal with, re-raise it. > > This is also nonsense. Sure you can catch all exceptions and examine them. > But in order to code anything intelligent, you again have to know ahead of > time what these exceptions might be. At the very *LEAST* you need a list > of *all possible* exceptions in an entire Python code base, including > Python standard module library! But how much better would it be if you > could narrow the scope to the most likely exceptions. > except: # foo is not bound here... because I am catching ALL exceptions > if (not self.__canHandleException(foo)): # what is foo? > raise foo # and how can you re-raise it here? what is foo? Getting the exception object done in a kludgy way in Python, which I agree should be improved. You'd say except: foo = sys.exc_info[1] if not self.__canHandleException(foo): raise foo but normally you'd write something more like your other example: > except BlahType: > self.__handleBlahError() > except BuzType: > self.__handleBuzError() > except OtherType: > self.__handleOtherError() > > But, no matter how you write it, you *still have to know* what exceptions > you need to handle. You can't magically decide it at run time, nor do you > need to, nor should you. This doesn't seem like a worse situation to me than if you have a function that returns a tuple, and you're supposed to know what the elements of the tuple signify, and if it returns something other than what you expected, your program has a bug. > The dynamic nature of Python is absolutely not a reason for such a > lucklaster handling of exceptions in Python. Let's get this argument out > of the way, because I don't think it's even worth discussing further, > unless someone can demonstrate that in 99.99% of cases you really can't > possibly know what exceptions you should handle anyway. I don't think static analysis of the program can tell you what exceptions are possible, just because if you have def foo(frob): x = frob.mumble() you don't know what class frob belongs to, so you don't know what exceptions it can raise. Global dataflow analysis of the whole program can help only some of the time, or else optimizing compilers would work a lot differently than they do. It's different in java, where frob has to be declared in the function header. If you add some syntax (or a convention) declaring what frob is, e.g. def foo(frob): assert isinstance(frob, FrobClass) x = frob.mumble() then your chances are a lot better. But you really have to know the type of everything in the program that can raise an exception. > Again, just because it's possible to use the language in a twisted > way, doesn't mean that the other 99.99% of exceptions should be > penalized by not having a tool that automatically warns you about > unhandled exceptions. I agree that a tool like that can be useful in some situations. But knowing what something will do in the usual case (e.g. 99.99% of the time) is a lot different than being able to make rigorous inferences about it which require you to know what it will do 100% of the time. Java tries to provide the latter and I thought at first that that was what you wanted. > I say that without such a tool, exceptions in Python are pointless > at worst, and are very awkward to use at best. That seems like an extreme overstatement. There's no tool like that for now, and exceptions still currently work pretty well, both in Python and in millions of lines of Lisp code, though improvements are possible in both languages. Having such a tool is one of the possible improvements. From dwangeri at uci.edu Tue Nov 27 05:18:35 2001 From: dwangeri at uci.edu (David Wangerin) Date: 27 Nov 2001 02:18:35 -0800 Subject: Determining word wraps in Tkinter text widget Message-ID: <371b5d38.0111270218.4b92b810@posting.google.com> When the text widget is configured for wrapping text on words, is there an easy and/or elegant method for determining if a specific line of text has been wrapped? I've been developing an app with a text box and some widgets that float next to each text line, but when a line is too long and gets wrapped, my floating widgets get out of place. By using Text.dlineinfo(INSERT) I can get the width in pixels, but this is not too useful unless I do some conversions based on the font size (which I'd rather avoid doing). In addition, when my window is resized, the Text.cget('width') does not update to reflect the new size. I could set the wrap to none and add a horizontal scrollbar, but this really makes the application ugly and is a last resort. Anyone have any ideas? Thanks, David Wangerin... From marcoxa at cs.nyu.edu Sun Nov 18 13:18:08 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 18 Nov 2001 13:18:08 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: Message-ID: George Demmy writes: > I do a bunch of list-oriented programming with a bunch of one-off > programs. For a variety of reasons these lists tend to have a bit > of cruft associated with them (I don't write it -- just process > it!). So stuff like this shows up quite a bit: > > data = filter(lambda x: x, crufty_list) > > I did it so often, that stuff like this shows up: > > identity = lambda x: x # like this in practice (lazy) > > def identity(x): # Pythonic -- shows up in profiler, etc > return x > > data = filter(identity, crufty_list) > > There are, of course, other nifty things to do with identity, and I > find it used all the time -- far more often than many Python > built-ins. How prevalent is identity usage in the Python community? Is > there anyone that would rather suffer hellfire and damnation that do > something like this? > > Curiously, The function `identity' is part of the Common Lisp standard. It is defined extacly as you suspected. Within CL, it turns out that `identity' is useful in a number of cases, especially when dealing with sequence operators. E.g. the `sort' function is really defined as sort &key (key #'identity) So that you can write things like * (sort '(2 3 4 1) #'<) '(1 2 3 4) * (sort '((1 3) (3 0) (33 9) (19 5)) #'< :key #'second) ((3 0) (1 3) (19 5) (33 9)) All in all a good thing. Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From cliechti at gmx.net Sun Nov 18 19:11:47 2001 From: cliechti at gmx.net (Chris Liechti) Date: 19 Nov 2001 01:11:47 +0100 Subject: Pulling out References: Message-ID: [posted and mailed] "David A McInnis" wrote in news:mailman.1006125625.21231.python-list at python.org: > I am writing a script to catalog about 30,000 html pages on my site and > need to pull out the value of . > > I guess this is possible with htmllib, but I cannot figure it out.> > > Thanks, > David > this may help, but it is using the sgmllib for parsing HTML: http://diveintopython.org/dialect_divein.html -- Chris From senux at senux.com Wed Nov 28 03:19:29 2001 From: senux at senux.com (Brian Lee) Date: Wed, 28 Nov 2001 17:19:29 +0900 Subject: all process list on Linux? Message-ID: <20011128171929.A5335@jupiter.senux.com> I'm newbie at Python programming. How can I get all processes list on Linux OS? I need PID and process name (like the result of ps command). I found setproctitle have many usefull function but it is not supported on Linux. Any modules which return all process list on Linux? Thank you for your help. :) -- Brian Lee - http://www.senux.com/ From claird at starbase.neosoft.com Tue Nov 13 16:26:02 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Nov 2001 15:26:02 -0600 Subject: Request for Validation of Python as Development Language References: <9sqmug$efp$1@slb1.atl.mindspring.net> Message-ID: In article <9sqmug$efp$1 at slb1.atl.mindspring.net>, Matt Gerrans wrote: >You didn't mention Zope, which is a big Python project, if not commercial. . . . Zope's PLENTY commercial--it's just available under a license that doesn't charge. The Zope Corporation, though, is eminently commercial, as are many of its showcase installations. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From paulp at ActiveState.com Thu Nov 1 00:23:57 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 31 Oct 2001 21:23:57 -0800 Subject: Python.NET, MONO and Visual Studio etc. References: Message-ID: <3BE0DC6D.DC70F339@ActiveState.com> Xavier Defrang wrote: > >... > > This is almost off-topic but since you guys are talking about that .NET > thing, I'd like just to ask anyone in here : WHAT THE HELL IS .NET??? Microsoft, Oracle, Sun etc. sell to CIOs more than to individual developers. So they invent overarching marketing names for a variety of developments. .NET is the marketing name for most of Microsoft's developments in the year 2001. .NET has a variety of themes and components including the .NET framework which is a virtual machine runtime not unlike the JVM. You've probably also heard about the new .NET programming languages: C# and VB.NET. There are also tools for working with web services. And there are actual web services run by Microsoft. The IDE that allows you access to all of this stuff is Visual Studio.NET. Paul Prescod From pieroul at attglobal.net Sun Nov 4 13:02:46 2001 From: pieroul at attglobal.net (pieroul at attglobal.net) Date: Sun, 04 Nov 2001 13:02:46 -0500 Subject: Command shell access within Python Message-ID: <3BE582C6.7D8C450B@attglobal.net> I am new to Python and i want to execute several shell commands within a Python function. Is there an easy way to execute several shell command lines and get the return code of each of them using a Python library call? Things like os.execv(), os.system() and os.startfile() allow me to execute one command at a time, starting one process for every statement. I also played with the os.popen(), os.popen2(),... These allow to get a pipe to a command shell and issue commands and read the results via stdin, stdout and stderr. But there must be a better way so I can use Python to execute command line programs programmatically using Python the way you would use a command line script. I also need to get the return code (c exit()) of the program that ran. I do not want to start one command shell process for every single command line . Anyone knows how to do it? Thanks Pierre R. From dav-nospam-id at westco-nospam-ntrol.com Thu Nov 29 06:32:00 2001 From: dav-nospam-id at westco-nospam-ntrol.com (David Brown) Date: Thu, 29 Nov 2001 12:32:00 +0100 Subject: Printing and Tkinter Message-ID: <9u56pt$vag$1@news.netpower.no> Hi, I'm starting to use Python and Tkinter to make quick user interfaces for various programs. Making GUIs is working well, but there is one thing that seems to be missing - printing. Is there any sort of cross-platform printing API that I can use from Python? My main platform at the moment is Windows, but I want to make sure I support Linux too (that is one of my reasons for moving to Python+Tkinter). I know it is possible to generate postscript from a Canvas, but is there any other way? It does not necessarily need to be through Tkinter. Thanks, David Brown Norway From nas at python.ca Mon Nov 26 16:36:12 2001 From: nas at python.ca (Neil Schemenauer) Date: Mon, 26 Nov 2001 13:36:12 -0800 Subject: Become In-Reply-To: <3c028dfc$0$26362$7a628cd7@news.club-internet.fr>; from a11w@SoftHome.net on Mon, Nov 26, 2001 at 07:42:53PM -0500 References: <3c028dfc$0$26362$7a628cd7@news.club-internet.fr> Message-ID: <20011126133612.A26383@glacier.arctrix.com> Jiba wrote: > Become can replace (quite) all references to an object by a reference to > another object. It relies on gc.get_referents(). gc.get_referents() is not guaranteed to find all references to an object. It may also go away in a future Python release. Consider yourself warned. Neil From lfini at arcetri.astro.it Fri Nov 23 08:01:53 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Fri, 23 Nov 2001 14:01:53 +0100 Subject: Still on python GUI toolkit Message-ID: Dear friends, I started a discussion (yet another ...) on the right GUI development toolkit for an application few days ago. I received many useful replies and I'd like to say thank you to everybody and add a resume of the discussion which may be useful for other too. Problem: I've got to choose a GUI development toolkit for a software project (the software interface to control a pretty complex scientific instrument which is a component of a big telescope). We want to use Python as scriptimng language and the lower level stuff will be written in C. I'd like to have a GUI develpment tool which can be used in Python but also allows to code critical parts in C. The environment both for development and for the target system is Linux, but an MS Window compatible GUI could be useful. After some searching I got to four possible solutions: pygtk, PyQt, Tkinter, wxWindows. I also did some tests to verify the speed of the same program with the different implementation. The test is as follows: repeatedly painting a square area with small rectangles, all black and all white alternately: this emulates the real situation where you must display a graytone image by drawing each pixel as a small square. The implementation for PyQt, pygtk and wxWindows are very similar: I use the respective DrawRectangle function. I do not try to manage redrawing when the window comes in the foregraund and things like this. So I think the comparison is pretty fair. Tkinter has not (to my knowledge) a similar function, I define an array of Rectangles and I paint the big square by changing the color property to all the small Rectangles. Tkinter manages by default the repainting of the window when is comes to the foreground, I didn't find a way to avoiid this, so I believe it has to do more work to paint and for this reason the test is not fair with Tkinter. I didn't do very precise measurements because I only need a gross evaluation: speed is not the only important aspect. Here follows a resume of my findings (it includes pygtk together with what I've already posted): If I put Tkinter to 1, I get the following relative speed: Tkinter 1 PyQt 4 wxWindows 4 pygtk 15 Here follows a brief resume of the answers I've got (I've included only the ones on the topic and not a few branches regarding Java and CORBA) Boudewijn Rempt gave me many hints on how to get PyQt working. Then I discovered that my RedHat 7.2 system had it included (albeith not the very last release) Eddie Corns gave an overview of his experience and pointed me to a comprehensive analisys of GUI toolkits: http://www.atai.org/guitool (very valuable) Fran?ois Pina pointed me to gtk (which I didn't consider at the beginning), after his advice I repeated my tests with gtk, too. He also offered advice and more (even pieces of code: thanks again) on one weak point of pygtk: documentation. Laurent Pointal pointed me to a recent workshop on experiment control in the high energy physics field: http://www.esrf.fr/taco/workshop/ Very Interesting, I'll try hard to find the full text of papers from that. He also commnets on the fact that there is not yet a clear winner in the GUI toolkit war. Kevin Altis spent a word about PythonCard which is (if I understand it all) something like an implementation of Apple's HyperCrd for Python (see: http://pythoncard.sourceforge.net/) It looks interesting but I think it's outside the scope of my application. He also commentd on the use of Tkinter canvas for million points plots. Fredrik Lundh and Tyler Eaves commented on the right way to do tests and pointed to some interesting developments of Tkinter: Tkinter 3000 http://www.pythonware.com/products/tkinter/tkinter3000.htm Many thanks to everybody. l.f. -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From wolf359_ at gmx.net Thu Nov 1 11:30:27 2001 From: wolf359_ at gmx.net (Thomas Weidner) Date: Thu, 01 Nov 2001 17:30:27 +0100 Subject: references ??? Message-ID: Hi, I think anybody here knows what references,like in java,c++ or perl, are. How can i use references in python ? 2.Question: l=[1,2,3,4,5,6] for i in l:i=0 print l l is still [1,2,3,4,5,6]. How to make changes made to i also apply to l ? From sholden at holdenweb.com Wed Nov 7 08:13:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Nov 2001 08:13:53 -0500 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s43jo$bku$1@news8.svr.pol.co.uk> <9s538j$qo1$1@bugstomper.ihug.com.au> Message-ID: <%oaG7.3490$U07.169147@atlpnn01.usenetserver.com> "Fredrik Lundh" wrote in message news:F1YF7.5270$Z_1.857034 at newsc.telia.net... > Gary Stephenson wrote: > > We here downunder have just always claimed him as one of our own > > like ABBA? > Does this mean alt.bonzer.bozos.australia? regards Steve -- http://www.holdenweb.com/ From shriek at gmx.co.uk Wed Nov 14 12:21:46 2001 From: shriek at gmx.co.uk (Stephen) Date: 14 Nov 2001 09:21:46 -0800 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> Message-ID: <97ae44ee.0111140921.281c4b7@posting.google.com> > >> IMHO the SMTP and POP protocols provide the same benefit (and there > >> are Python modules for those protocols). > > shriek> Using a mailserver as a messaging platform for middleware ? > > It's not all that far-fetched. I know some people have experimented with > XML-RPC over SMTP (which is no longer XML-RPC, but that's a nit). OK, let me show an example where I think we need some sort of basic message queue ~ I've been trying to benchmark socket server and can't seem to get it past serving 200 requests per second. Here's the test code ~ # ----------------------------------------- # SOCKET SERVER CODE - JUST SENDS A REPLY # ----------------------------------------- #! /usr/bin/python import SocketServer, string, socket, time total_requests = 0 class RequestServer(SocketServer.ThreadingTCPServer): allow_reuse_address = 1 class RequestHandler(SocketServer.StreamRequestHandler): def handle(self): global total_requests # ACCEPT : host, port = self.client_address request = "" while 1: line = self.rfile.readline() if line in (None, "\r\n", ""): break request = request + line request = string.rstrip(request) self.wfile.write("Received OK") total_requests = total_requests + 1 if total_requests % 100 == 0 : print "%s - %s" % (total_requests, time.time()) def main(): server = RequestServer(("127.0.0.1", 8888), RequestHandler) print "Listening to socket [%s:%s]" % ("127.0.0.1", 8888) server.serve_forever() # ------------------------------------------- # CLIENT CODE FOR TESTING # ------------------------------------------- #!/usr/local/python test_msg = "This is just a test message" import socket, thread, time total_sent = 0 NUMTHREADS = 20 def send_request() : start = time.time() global total_sent for i in range(0,100) : s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("127.0.0.1", 8888)) s.send("%s\n\r\n" % test_msg) s.recv(512) s.close() total_sent = total_sent + 1 if total_sent % 100 == 0 : print "total sent = %s" % total_sent end = time.time() print "exiting thread. duration %s" % (end - start) total_sent = 0 for i in range(0,NUMTHREADS) : thread.start_new_thread(send_request, ()) Results ~ When NUMTHREADS = 2, 200 requests are handled in < 0.5 secs When NUMTHREADS = 5, 500 requests are handled in 2.5 secs But when NUMTHREADS = 20, half the threads die with this error : Unhandled exception in thread: Traceback (most recent call last): File "", line 6, in send_request File "", line 1, in connect socket.error: (10061, 'Connection refused') and it just gets worse when NUMTHREADS = 50. I'm guessing this means that the server is max'ed out and can't handle any more. How should I handle this error ? Yes, with a "try/except" but what should the "except" do, because if the server is too busy, it's probably no point retrying immediately. So, you see, I was looking for something more immediate than SMTP, that also takes care of the message queueing. Writing code to manage the queue and buffering could be horrendous. Is there any way to get this up to say 1,000 requests/sec peak load ? In reality, I'm going to want to put some Database query into the RequestHandler too so it'd be even slower. Does this sound possible ? Am-I-asking-too-much-of-Python-ly-your's, Stephen From david.abrahams at rcn.com Thu Nov 29 11:56:58 2001 From: david.abrahams at rcn.com (David Abrahams) Date: Thu, 29 Nov 2001 11:56:58 -0500 Subject: debugging under NTEmacs? Message-ID: <9u5q1g$so7$1@bob.news.rcn.net> Does anyone know how to get pdb debugging in gud mode under emacs for NT? Any help appreciated, especially if you send answers to me directly! ;-) Thanks Dave -- =================================================== David Abrahams, C++ library designer for hire resume: http://users.rcn.com/abrahams/resume.html C++ Booster (http://www.boost.org) email: david.abrahams at rcn.com =================================================== From skip at pobox.com Fri Nov 2 10:36:00 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 2 Nov 2001 09:36:00 -0600 Subject: ReXX Style translate() function for strings ? In-Reply-To: References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> <3BE20B6E.F9275CD0@cosc.canterbury.ac.nz> <9rt3co$rid$1@slb2.atl.mindspring.net> Message-ID: <15330.48480.305974.107512@beluga.mojam.com> Steve> input = "".join([chr(x) for x in range(256)]) Not that it's used all that often, but there is an input builtin, so in the interest of not hiding builtin functions, it's probably best to get into the habit of not using them as local variable names. have-we-flogged-this-horse-enough?-ly, y'rs, -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From jyrinxatmindspringdotcom Mon Nov 5 02:37:04 2001 From: jyrinxatmindspringdotcom (Jyrinx) Date: Sun, 4 Nov 2001 23:37:04 -0800 Subject: how to start Idle under Windows References: <3BE60B50.88B1E792@ix.netcom.com> Message-ID: <9s5fj2$ges$1@slb6.atl.mindspring.net> If the newbie might lead the newbie :-) ... I think there are two versions of the IDLE program file, one whose extension is "py" and the other which ends "pyw". Try opening the "pyw" one. Jyrinx jyrinx_list at mindspring dot com "Jive Dadson" wrote in message news:3BE60B50.88B1E792 at ix.netcom.com... > How do you start Idle when running Windows? I can get it to come up, > but I get two extraneous windows on the screen -- a console window and a > Python interactive window. > > Jive From jason at jcrowedesign.com Thu Nov 22 09:35:53 2001 From: jason at jcrowedesign.com (jcrowe) Date: Thu, 22 Nov 2001 08:35:53 -0600 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: I think it all depends what you are going to be using the language for. In my opinion PHP and Python are not really comparable. I see php as a step up from cgi. I would not even concider using python for web scripts, it's just doesn't make sense ( if you know php). But on the other hand I would not even concider using php to write a small app that is not web based. They are both great languages, but they should be used where they are strongest. If you want newsgroups checkout: alt.comp.lang.php alt.php alt.php.sql I will warn you that php is more like coding in c++, or perl. It may be confusing to learn php & python at the same time, but that will depend on you and your skills. Good luck. the Spinning Spider wrote: > I'm finding learning Java is quite a tough challenge, like wading through > a > swamp. So I'm exploring PHP and Python as possible alternatives. > > I notice there doesn't seem to be much mention about PHP by Python people > whenever they mention other languages, > e.g.,see http://www.python.org/doc/Comparisons.html. > > Or is it because PHP is incomparable against Python? > > Could it be the news servers I have access to, or is there no > comp.lang.php > newsgroup? Is PHP too insignificant? > > Will Python be too intellectually challenging, like Java? > > > From logiplexsoftware at earthlink.net Fri Nov 2 14:37:35 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 11:37:35 -0800 Subject: Underscore data hiding (was python development practices?) In-Reply-To: References: Message-ID: <01110211373501.09296@logiplex1.logiplex.net> On Friday 02 November 2001 11:05, Tim Peters wrote: > Guido didn't think so (and every complaint ever made about it was made at > at least once before it was implemented, so the odds of a compelling new > argument are approximately nil). My cat doesn't like it and refuses to switch from Perl until it's fixed (Perl's syntax is friendly to the fingerless - he can write a valid Perl script by simply walking across the keyboard). Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From steve at ferg.org Tue Nov 13 15:54:47 2001 From: steve at ferg.org (Stephen Ferg) Date: 13 Nov 2001 12:54:47 -0800 Subject: PEP proposal: enhanced string functions Message-ID: I have been thinking about two proposals for PEPs, and I would like to see what other folks think of them. They aren't anything major, just small enhancements that I think would be easy to do and useful. -- Steve Ferg (steve at ferg.org) ========================================================= PEP: XXX1 Title: Optional pad character for string justification functions Abstract This PEP proposes a minor enhancement to the ljust(), rjust(), and center() functions in the standard string module, and their corresponding methods for string objects. The proposal is to allow these functions and methods to take one optional argument in addition to the arguments that they now accept. The argument is called "pad", and it will default to a single space character. The pad argument may be over-ridden only by an argument that consists of a single character. If the pad argument is over-ridden, then the specified pad character, rather than the default space character, will be used in padding the string to the desired length. Rationale The rational for this PEP is that it will add some minor, but handy, ease- of-use functionality to the affected functions. It will not break any existing code, and it should be easy to implement. This functionality will make it easier to do some simple but useful string formatting tasks. - It can be used to create leaders. For example: import string budget_items = [("Cookies", "13.25"), ("Sodas", "8.50")] # print budget items with leaders for item, expenditure in budget_items: s1 = string.ljust(item, 15, ".") s2 = string.rjust(expenditure, 10, ".") print s1 + s2 produces: Cookies.............13.25 Sodas................8.50 - It can be used to create headings: s = "Chapter 2: Working with XML" print s.center(50, "-") produces ------------Chapter 2: Working with XML----------- ========================================================= PEP: XXX2 Title: Optional argument for string strip functions Abstract This PEP proposes a minor enhancement to the lstrip(), rstrip(), and strip() functions in the standard string module, and their corresponding methods for string objects. The proposal is to allow these functions and methods to take one optional argument in addition to the arguments that they now accept. The argument is called "stripchar". If the stripchar argument is unspecified or is specified as None, then these functions and methods will do exactly what they now do, and strip whitespace. If the stripchar argument is specified, and not specified as None, it must contain a single character. If the stripchar argument is specified, then rather than stripping out whitespace, the functions and methods will strip out the specified stripchar character. Rationale The rational for this PEP is that it will add some minor, but handy, ease- of-use functionality to the affected functions. It will not break any existing code, and it should be easy to implement. This functionality will make it easier to do some simple but useful string formatting tasks. - It can be used to strip out leaders. For example: s = "Chapter 1........................" print s.rstrip(".") produces: Chapter 1 - Its most frequent use will probably be be to assist in cleaning up files by cleaning out junk characters. For example: s = "?????????????Text that I want?????????" s = s.strip("?") produces a value for s of "Text that I want". From guuge at localhost.localhost Mon Nov 19 10:23:19 2001 From: guuge at localhost.localhost (guuge) Date: 19 Nov 2001 15:23:19 GMT Subject: something Evil happens when large hashes destroyed References: <9t8m1c019qd@enews1.newsguy.com> Message-ID: <9tb8572vqq@enews1.newsguy.com> On Sun, 18 Nov 2001 18:39:52 -0500, Tim Peters wrote: > [guuge] >> I was trying to sort about 100,000 items by splitting them into >> groups (using a python dictionary type) and then successively splitting >> these groups until they were small enough to use a brute force method. > > Try list.sort(). > >> My test program, which used only two or three keys to create the first >> split, worked fine. When I tried the real thing, using 256 keys, the >> program slowed to a crawl. The python interpreter took forever to >> destroy the dictionaries. >> >> Here's a little program ... > > I tried that w/ 2.2b2 under Win98SE, 866MHz, 256MB RAM, also with 100,000 > elements, and the number of bins didn't matter: for assorted values from 1 > through 100,000, creation time was 2 seconds and destruction time 0 > (time.time() only has 1-second resolution on Windows). > > So best guess is that you're fighting your platform C library's > malloc()/free(). Which OS? Which C compiler and library? Linux (2.4.2 kernel) libc-2.2.4 gcc 2.95.4 > If you build Python yourself, try rebuilding 2.2b2 --with-pymalloc, > and see whether that helps. The problem is fixed using "--with-pymalloc". Thank you! > It would be interesting to know one way or the other. From di1322 at ezlink-trade.com Fri Nov 2 07:32:54 2001 From: di1322 at ezlink-trade.com (Diadem & Hussar Corp., ) Date: Fri, 2 Nov 2001 20:32:54 +0800 Subject: Best Doilies, Tablecloths, Place Mats, Runners, Curtains, Sofa Backs, Tissue Bags etc. Message-ID: An HTML attachment was scrubbed... URL: From LLoeffler at home.com Mon Nov 26 15:16:29 2001 From: LLoeffler at home.com (Luke) Date: Mon, 26 Nov 2001 14:16:29 -0600 Subject: IDLE improvement? References: Message-ID: <3C02A31D.5020008@home.com> forgotten gentleman wrote: > Hi, in Dr. Scheme, you can use two windows for interactive > programming. One is a normal text area where code can sit, and the > other is the interactive prompt, just like IDLE's prompt. The way it > works is, when you press Ctrl-t or the big "execute" button: > > - The interactive prompt's memory is cleared and restarted > - The code in the text area is interpreted, and loaded > - Cursor is now in the interactive prompt, so you can play with what > you just loaded > > As I understand, in IDLE you have to close and open the window, and > then cut & paste your code back in. > > Is this true? If it is, maybe I can help rewrite IDLE if the code > isn't so complex. It probably shouldn't be. > > TIA. > Check out idle fork on sourceforge. They'd be the ones to chat with about new features. From zope at thewebsons.com Sat Nov 17 18:13:10 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sat, 17 Nov 2001 15:13:10 -0800 Subject: GetImageSize Message-ID: <5.1.0.14.0.20011117151154.00a768d0@thewebsons.com> Hi; In PHP there is a library function called getimagesize(). What is the equivalent in python? TIA, BenO From maxm at mxm.dk Fri Nov 9 12:11:01 2001 From: maxm at mxm.dk (maxm) Date: Fri, 9 Nov 2001 18:11:01 +0100 Subject: Trouble with cgi.FieldStorage() on iis/asp References: <3bebd556$0$25387$edfadb0f@dspool01.news.tele.dk> Message-ID: "DeepBlue" wrote in message news:tunvpsbktq0ac5 at corp.supernews.com... > This works flawlessly with me, and file is found with no problems. > Hope this helps. > DeepBlue Yes, but as far as I can tell, you are using the cgi module in a cgi script. I am trying to do the same thing under Active Server Pages on Microsoft IIS, and there I dont have the same enviroment variables available. So calling FieldStorage() without any argumants will not work there. Thats why I call FieldStorage with parameters. But apparantly it isn't working like i believed. Regards Max M From root at rainerdeyke.com Wed Nov 14 22:26:23 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 15 Nov 2001 03:26:23 GMT Subject: Non-obvious name bindings References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> <3BF1BB43.6B4E667B@bgb.cc> <9ssf3h$dfh$1@peabody.colorado.edu> <3BF2D8CE.7CC12F87@ccvcorp.com> Message-ID: "Ken Seehof" wrote in message news:mailman.1005788512.24883.python-list at python.org... > Actually, the index has the scope that contains the 'for' statement, so > it does persist after the loop. > > int main(int argc, char* argv[]) > { > for (int i=0; i<10; i++) > { > printf("%d ", i); > } > printf("\n\n i = %d", i); > } This will not compile on a conforming C++ compiler. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From sholden at holdenweb.com Tue Nov 27 14:03:36 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 27 Nov 2001 14:03:36 -0500 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: "Ursus Horibilis" wrote in ... > [...] > > At the moment, I'm working with 2.0. Is it legal to assign a > (long) to an (int) if the long contains a number that is bigger > than the (int) can store? > Only because you don't "assign a long to an int". You rebind a name formerly bound to an int to a long. Since all operations on longs will produce something at least as wide as a long, you will need to force coercion to integer by calling int() on your longs. regards Steve -- http://www.holdenweb.com/ From logiplexsoftware at earthlink.net Fri Nov 16 19:02:48 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 16 Nov 2001 16:02:48 -0800 Subject: python vs ecmascript In-Reply-To: References: <01111609593502.02629@logiplex1.logiplex.net> Message-ID: <01111616024800.03405@logiplex1.logiplex.net> On Friday 16 November 2001 14:03, Peoter Veliki wrote: > I'm using Python 2.0 at the moment (it is necessary as it is integrated > into another product), perhaps this limitation was removed in later > versions. If I try to do this: > > print "integer i = " + i > > it will barf on this and tell me that i is not a string, I must do this: > > print "integer i = " + str(i) That's because you're _adding_ an integer to a string (not because you're printing an integer). You can add two integers, or even two strings, but you can't mix and match. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From jgardn at alumni.washington.edu Wed Nov 28 10:05:03 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 29 Nov 2001 00:05:03 +0900 Subject: Editor for Python: A PLEA In-Reply-To: References: <3bfd7f87@news.airtel.net> Message-ID: <01112900050307.13207@linux> Tim Hammerquist wrote: > (PS: I don't have to learn Lisp to script Vim...I can use Python... > This was originally a python thread, wasn't it? =) > What, you can't use python in Emacs? This cannot be true... can it? *rubbing eyes* Jonathan From mickey at tm.informatik.uni-frankfurt.de Tue Nov 27 07:04:48 2001 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 27 Nov 2001 14:04:48 +0200 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> <0pKH7.859$Au5.304844@news.uswest.net> Message-ID: <3c038f70@nntp.server.uni-frankfurt.de> Kevin Altis wrote: > "Ron Stephens" wrote in message > news:3BEF0436.33D7F2A5 at earthlink.net... >> As someone else said, pleas einlcude anygui. Also, it woudl be nice if you > could >> include PythonCard, as an application frmaework on top of wxPython. > > While I would like to see PythonCard and anygui covered in a book, it > doesn't make sense for either project right now. The APIs are in flux and by > the time a book went to print the information would be completely wrong. > PythonCard is likely to change quite a bit between now and the end of the > year and anygui probably won't be usable for anything but the simplest > projects until early next year or later. Yes, that's true. An unstable API will render a whole chapter of my book useless, which is not quite a clever idea. I'm even considering to dump the discussion of pyGTK because of this. AFAIK GTK2 will be so much better than GTK1.x that almost everyone who can will switch as soon as possible. But for a discussion of (py)GTK2 there is too much change in the API yet. :M: From oliphant at ee.byu.edu Wed Nov 14 14:22:25 2001 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Wed, 14 Nov 2001 14:22:25 -0500 Subject: Matrix in Python . In-Reply-To: References: Message-ID: > On Fri, 09 Nov 2001 12:50:32 +0200, Amit Weisman > wrote: > >Is there a module for dealing with Matrix ? > > Assuming you mean matrix in the mathematical sense, instead of whatever the > film or video that others are joking about, then: > > There is the Numeric package. Search for either "numeric python" or "numpy" > on Google. I think it is numpy.sf.net > > If you want a more Matlab like syntax, I have a wrapper package MatPy around > NumPy, also on sourceforge. Haven't updated it for quite some time, though. The latest version of NumPy has an expanded Matrix Package that borrows from the ideas of Huaiyu's work. If you have NumPy installed, and import Matrix then Matrix.Matrix() generates a matrix where the * acts as matrix multiplication instead of element by element multiplication (to get that you have to get the array out and use it) There are attributes .T and .H to get the transpose and .A to get the array out Also Matrix.Matrix('[1,2,3;4,5,6;7,8,9]') Let's you use Matlab-style semicolon separation to separate the rows. -Travis From mark at laptop.local Wed Nov 14 11:29:08 2001 From: mark at laptop.local (mark at laptop.local) Date: 14 Nov 2001 11:29:08 -0500 Subject: How do you get persistent database connections with Python? References: <9sshgb$eh4$1@laptop.local> Message-ID: <9su64k$11q$1@laptop.local> In article , Gerhard =?iso-8859-1?Q?H=E4ring?= wrote: >On Tue, Nov 13, 2001 at 08:30:51PM -0500, mark at laptop.local wrote: >> How do you create persistent database connections with Apache, Python, >> and PostgreSQL? Any generic methods of creating persistent database connections >> would be helpful. >> >> I have been trying like crazy to find information on the topic, but I can't >> find any useful information. >> >> I am using mod_python and also PyGreSQL modules. I can switch to others >> if need be. > >The db module doesn't matter. What you probably need to check out is the >Python documenation (wrt. importing modules). Your mod_python handler >lives as long as the Apache process lives. > >So, you just have to instantiate a db connection in the handler's module >and store the connection object it in the module. That's all there is to >it. > >There are three alternatives to PyGreSQL: pyPgSQL, psycopg and PoPy (I'm >a developer in the pyPgSQL project). I'd recommend you check out the >alternatives, too if you're interested in a good db module 4 PG. Iff you >want to continue using PyGreSQL, I recommend you check out the latest >version from *PostgreSQL* CVS - it contains several bugfixes when >compared to the latest "released" version of PyGreSQL (3.2). Ah, thanks for the advice! I tried to create global variables, but they didn't persistent from session to session. Of course, I had the global variables in he scripts, perhaps I should try them in modules. I wonder what happnes to global variables in scripts? It seems like they don't stay global the next time th hanlder runs. I should try it with modules though. Mark > >Gerhard >-- >mail: gerhard bigfoot de registered Linux user #64239 >web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 >public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 >reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) > From vze2q3xh at verizon.net Mon Nov 19 22:22:05 2001 From: vze2q3xh at verizon.net (Tech) Date: Tue, 20 Nov 2001 03:22:05 GMT Subject: REQ: PIL web tutorials Message-ID: Are there any good, free PIL web tutorials or any other source I can find info on the lib? Tech From johnroth at ameritech.net Wed Nov 14 20:42:11 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 14 Nov 2001 17:42:11 -0800 Subject: PEP proposal: enhanced string functions References: Message-ID: "Stephen Ferg" wrote in message news:b16e4ef7.0111131254.1e33ec17 at posting.google.com... > I have been thinking about two proposals for PEPs, and I would like to see what > other folks think of them. They aren't anything major, just small enhancements > that I think would be easy to do and useful. > > -- Steve Ferg (steve at ferg.org) I've certainly found this functionality handy in the past, although infrequently enough that I can (almost) agree with Guido that it isn't worth the bother of supporting it in the interpreter. John Roth From nbecker at fred.net Mon Nov 5 11:49:28 2001 From: nbecker at fred.net (N Becker) Date: 5 Nov 2001 08:49:28 -0800 Subject: simple eval question References: <1f5252d4.0111021241.643efe1e@posting.google.com> <7xlmhoc2q6.fsf@ruckus.brouhaha.com> Message-ID: <1f5252d4.0111050849.78c7c217@posting.google.com> Paul Rubin wrote in message news:<7xlmhoc2q6.fsf at ruckus.brouhaha.com>... > nbecker at fred.net (N Becker) writes: > > What is wrong with this? > > > > eval ("print \"hello\"') > > Unbalanced quotes. You began the string with a double quote and ended > it with a single quote. Did you mean > eval ('print \"hello\"') > ? Yes, that doesn't work either. From mpryor at sprintmail.com Fri Nov 30 16:45:02 2001 From: mpryor at sprintmail.com (Mark_Pryor) Date: Fri, 30 Nov 2001 21:45:02 GMT Subject: PythonWin DDE Conversion error References: <3c07f946.27546641@news> Message-ID: Hi, On Fri, 30 Nov 2001 21:28:47 GMT, phony_address at yahoo.com (Phredd Phlintstone) wrote: >New here. This is my first programming experience. I d/l PythonWin >and when I open it from the Start > Programs etc. (Windows ME), I get >a delay and then an error message, "There was an error in the DDE >conversion with PythonWin." Then the program pops open. What's up >with this? When the program opens, is it fully functional in every >way? Is there a way to fix this? > >Is this the wrong place to post a message about PythonWin? I have the same trouble, but only when running Apache 1.3.20. If I stop Apache and launch PythonWin, then all goes well. Make sure that you don't have more than one instance of PythonWin running, too. good luck, Mark Pryor >Please post any responses to this to this newsgroup. From ny_r_marquez at yahoo.com Thu Nov 8 13:46:49 2001 From: ny_r_marquez at yahoo.com (R.Marquez) Date: 8 Nov 2001 10:46:49 -0800 Subject: Get file owner in Windows Message-ID: <8a27e309.0111081046.5bafb354@posting.google.com> Does anyone have a handy example of how to get the owner of a file in windows NT/2000? From sdelafond at vertical.net Mon Nov 19 15:18:33 2001 From: sdelafond at vertical.net (Sebastien Delafond) Date: 19 Nov 2001 12:18:33 -0800 Subject: CGI output References: <63343bfd.0111161819.14263d83@posting.google.com> Message-ID: <63343bfd.0111191218.6f95910c@posting.google.com> OK, thanks to all for your input. Here's my feedback now :) > Before coming up with a solution for displaying a progress indicator in some > fashion (which is a nasty idea, over the web), consider speeding up your > algorithm, or moving the slow parts to C code. Maybe you're doing something > wrong, and should never have to even think of doing a "wait screen" of some > type (if the task can actually be completed in, say, 15 seconds). > > Perhaps if you mentioned what you were doing, and what the slow parts of > your code are, we could help you with that. If you think theres /no way/ you > could make it this much faster, ask Guido: > http://python.org/doc/essays/list2str.html I understand one should always try to enhance its programs from an algorithmic approach, in order to make them faster, and eventually get rid of the unnecessary progress report. And yeah, I've already been reading on some of Guido's fine code enhancements to run faster... But unfortunately, the script I call from my python CGI script is a bash script that pull Java sources from the CVS, then builds and packages them; I'm sure you'll agree that there's not much I can do to speed up that Java compilation :> > This works with my Apache configuration. If it doesn't work as expected, it > might be a webserver configuration problem. For example, the following CGI > script is displayed line by line in my browser: [snip] > sys.stdout.flush() of course, this is what I was missing : the ouptut was buffered at the Python level, so there was no way for me to retrieve it on the web server side... There shouldn't be any work involved on the Apache (which I'm using) side, since one can read from the FAQ : < As of Apache 1.3, CGI scripts are essentially not buffered. Every time your < script does a "flush" to output data, that data gets relayed on to the < client. [snip] < Prior to 1.3, you needed to use "nph-" scripts to accomplish non-buffering. < Today, the only difference between nph scripts and normal scripts is that nph < scripts require the full HTTP headers to be sent Thanks to all, and especially to Gerhard :) --Seb From claird at starbase.neosoft.com Wed Nov 28 12:04:46 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Nov 2001 11:04:46 -0600 Subject: Database in a simple ascii file References: <3C04F826.CB408C9D@engcorp.com> Message-ID: In article <3C04F826.CB408C9D at engcorp.com>, Peter Hansen wrote: >Rafael Mentz Aquino wrote: >> >> How many lines can I have in a simple ascii file before >> I start to loose performance when I open this file and >> put all the lines in a dict, turning the first column into the key >> and the rest of the line into a list associated to that key. >> >> (my file has just 100 lines, but that question starts to bother me ;-) > >You will start to lose performance, relatively to no lines, >with even one line. If you start with ten lines, you will >begin losing performance after you switch to a file of 11 >lines... > >Why focus on performance when you have no idea how fast >you want your program to be? Recent advances in software >development are teaching programmers *never* to optimize >until the program works, and only when there is a clear >requirement for more performance. > >If you are really concerned about performance, you will >always be able to get more than a 10 times speedup by >switching to a compiled language over Python. Use of >Python should imply you are more interested in readability >and ease of use, and thus speed of *development*, over >speed of execution. > >(Shorter answer: don't grow any grey hairs over it.) . . . Peter and I agree on so many large conclusions, and differ on so many details. My own suspicion about the situation the original poster describes is that I/O time dominates, and that neither "switching to a compiled language" nor a fancier persistence method will help by even a factor of two (maybe not 10%) in comparison with judiciously straightforward Python coding. I know that's true for many things I do: it just takes a long time to read in data. Once it's in memory, Python manages it plenty swiftly. Peter's entirely correct in his general advice. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From peter at engcorp.com Tue Nov 27 00:45:32 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 27 Nov 2001 00:45:32 -0500 Subject: [OT] PostgreSQL Book References: Message-ID: <3C03287C.C3EED358@engcorp.com> python at commandprompt.com wrote: > > Basically we want to present a solid book. If we were going to produce a > python chapter, I would prefer (and we are talking about it) to have a > book that covered say, Python and Perl... for a total of about 500/600 > pages. Please don't do that. Do separate Python and Perl books. There is no reason to make all of us buy 300 pages wastefully, and they're so hard to tear out of the middle. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jeske at chat.net Tue Nov 6 23:18:38 2001 From: jeske at chat.net (David Jeske) Date: Tue, 6 Nov 2001 20:18:38 -0800 Subject: Yahoo Groups archive fixed Message-ID: <20011106201838.E16327@mozart.chat.net> For those who noticed the Yahoo! Groups Python List archive was confused recently, it is now fixed. It turns out there was a bug which caused the rest of the archive to be put aside somewhere else. There were in the midst of fixing it and when I pointed it out they quickly fixed the Python List archive for us. Thanks go to the Yahoo! Groups engineering team! ..back to regularly scheduled Python talk.. -- David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske at chat.net From fperez528 at yahoo.com Thu Nov 22 16:49:23 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 23 Nov 2001 21:17:23 +2328 Subject: Bug in sys.stdout.flush()? References: <9tn5qb$fr3$1@peabody.colorado.edu> Message-ID: <9tn728$goo$1@peabody.colorado.edu> Never mind... Please disregard the above. The 'bug' was some strange behavior being triggered by something else in my code. My fault... Cheers, f. From __x__ll at yahoo.com Sun Nov 25 13:51:00 2001 From: __x__ll at yahoo.com (Fred Flintsone) Date: Sun, 25 Nov 2001 18:51:00 GMT Subject: Which Version for Absolut Beginner? Message-ID: <3c013d0d.26717374@news> Hi. I went to the Python.org page to pick up a copy of Python, and was faced with a choice of which version I want to d/l. As a rank beginner, does it matter? I'll be working on a Windows ME machine. Between the O'Reilly book I just bought, and all those great looking tutorials, I'm anxious to dig in. Thanks. FF Please post any responses to this to this newsgroup. From loewis at informatik.hu-berlin.de Sat Nov 10 07:10:46 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 10 Nov 2001 13:10:46 +0100 Subject: Defining inheritance in C extensions References: Message-ID: Timo Savola writes: > If my types are be compatible with their base types, > PyArg_ParseTuple(args,"O!:abc",&basetype,&ptr) would do the checking > for me, or does it check for the *exact* type? I think it would require the exact type, in Python 2.2. > Also, I like player with powerful RTTI. :) There is no excuse for that :-) So please have a look at Python 2.2; I think you'll find what you are looking for. Regards, Martin From ursus_horibilis at hotmail.com Wed Nov 28 09:07:53 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Wed, 28 Nov 2001 09:07:53 -0500 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> <9u0m3l$447$2@peabody.colorado.edu> Message-ID: "Gareth McCaughan" wrote in message news:slrna084ef.1ra3.Gareth.McCaughan at g.local... > Yes, but the fact that you ask the question indicates that > your model of the universe isn't quite the same as Python's. > In Python, unlike C, *values* have types but *variables* > don't. There's no such thing as a variable that can only > hold "int"s in Python, for instance... Yes, you are correct; I did not understand that Python worked like that until someone emphasized that I needed to think in terms of "binding" rather than "assignment". Python is not the first language I have encountered with this property, and working with it is not a problem so long as I know what to expect. Either I took a lot for granted or the original documentation didn't really emphasize this (or both). In any case, thanks for your comments. From sdm7g at Virginia.EDU Tue Nov 6 14:01:31 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Tue, 6 Nov 2001 14:01:31 -0500 (EST) Subject: Having a builtin exit function in python interpreter In-Reply-To: <9s9ajr$qmg$1@slb4.atl.mindspring.net> Message-ID: You could also do something like: >>> class Quitter: ... def __repr__(self): ... ans = raw_input( 'Do you *REALLY* want to Quit? [Y/N]:' ) ... if ans[0] in ( 'Y', 'y' ) : raise SystemExit ... return 'type ^Z to quit' ... >>> __builtins__.quit = __builtins__.exit = __builtins__.q = Quitter() >>> del Quitter >>> >>> q Do you *REALLY* want to Quit? [Y/N]:n type ^Z to quit >>> exit Do you *REALLY* want to Quit? [Y/N]:n type ^Z to quit >>> quit Do you *REALLY* want to Quit? [Y/N]:y % From kragen at pobox.com Tue Nov 27 17:10:12 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 17:10:12 -0500 Subject: (no subject) References: Message-ID: <83itbv6f23.fsf@panacea.canonical.org> toffer_ji0 at subdimension.com writes: > is it possible to call or rather use an instantiated class using, say > a string (assuming unique).. Do you want to instantiate new classes at run-time, or do you want to be able to choose among a set of classes that already exist based on a string? The latter can be done with getattr or a dict or (*shudder*) eval. The former can be done in a variety of ways; the easiest is probably to have a class inside a function. Every time the function runs, it will produce a new class. From huaiyu at gauss.almadan.ibm.com Thu Nov 15 14:27:23 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Thu, 15 Nov 2001 19:27:23 +0000 (UTC) Subject: PEP 276 Simple Iterator for ints (fwd) References: <7xadxo27tr.fsf@ruckus.brouhaha.com> Message-ID: On 14 Nov 2001 16:31:28 -0800, Paul Rubin wrote: > >Sometimes you want to use the index in the loop. Maybe the loop syntax >should be extended somehow to easily let you do that. def items(x): return zip(range(len(x)), x) for i, x in items(sequence): ... If there were an xzip for iterators, and an int-generator xint, then we could have def xitems(x): return xzip(xint(), x) which would work for an iterator x without knowing its length beforehand. Huaiyu From johnroth at ameritech.net Mon Nov 19 19:48:15 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 19 Nov 2001 16:48:15 -0800 Subject: Two questions about Python.. References: <3BF99E55.2C300858@hotmail.com> Message-ID: "Ken" wrote in message news:3BF99E55.2C300858 at hotmail.com... > I'm looking into using Python for a project, and was wondering how does > Python rank up against other scripting languages for speed? > > I assume its not as fast as something like C, which isn't an option as I > need a scripting language. All the comparisons I've seen say there's not much difference between Python and Perl. > Second question is, does Python have a robust exception handling system? Same try, except construct as every other o-o language with structured exception handling. Exact syntax may vary. > Ie.. if a program loads a module and that module has a logic error in > it, can the program recover? Or will it crash? If you put a try/except block around it, yes. John Roth From mwh at python.net Fri Nov 9 06:58:32 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 9 Nov 2001 11:58:32 GMT Subject: Numerical Bug in Numpy V19.0 References: Message-ID: "Gordon Williams" writes: > Hi, > > I have just changed to Numpy V19 from V17. I get the following output in > V19: Unlikely to be the best place to report this; http://sourceforge.net/tracker/?group_id=1369&atid=101369 Is at least likely to be better, if indeed it hasn't already been reported there. Cheers, M. -- QNX... the OS that walks like a duck, quacks like a duck, but is, in fact, a platypus. ... the adventures of porting duck software to the platypus were avoidable this time. -- Chris Klein, alt.sysadmin.recovery From sholden at holdenweb.com Tue Nov 6 07:20:57 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 6 Nov 2001 07:20:57 -0500 Subject: Help Help Help References: <3be77f95@152.65.161.36> <7x3d3s8jo3.fsf@ruckus.brouhaha.com> Message-ID: "Paul Rubin" wrote in ... > "Kojo Duncan" writes: > > Write a program that lists all prime numbers less than a prime number a user > > inputs. Post on site for all to see. > > Do your own homework ;-) Especially since in this case the homework could be lifted with very few modifications from a Google search of recent postings on this list. What should the program do if its input isn't prime? just-thinking-of-test-cases-ly y'rs - steve -- http://www.holdenweb.com/ From mwh at python.net Tue Nov 6 05:11:52 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 6 Nov 2001 10:11:52 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Martin von Loewis writes: [schnipp] > It's been quite some time since I studied it last, so here's what I > found after a quick glance right now: Did you actually want answers to these questions? It's been sometime since I looked at it, but think I can remember the answer to some of them. Take a pinch of salt with most of what follows. > - it adds 17 new members to the frame object, doubling the number > of members. Usage of some of these members isn't obvious to me. See below about map & friends. > - It adds a field nesting_level to the thread state, without > ever checking its value (it just counts the nesting level) I imagine this was just for bragging with :) > - it adds a number of _nr variants of functions (non-recursive), > e.g. for map and eval. In __builtins__, the _nr versions are > available as "map" and "eval", while the original versions are > preserved as apply_orig and map_orig: > * Are the _nr versions functionally completely backwards-compatible? > If not, why? If yes, why is the original version preserved? I think the originals are just around because the implementation of the _nr variants was tricky and Chris needed something to test against. Not sure, though. > * Just to implement map, 150 lines of builtin_map had to be > rewritten into 350 lines (builtin_map, make_stub_code, > make_map_frame, builtin_map_nr, builtin_map_loop). The author > indicates that the same procedure still needs to be done for > apply and filter. Just what is the "same procedure"? Isn't there > some better way? This is where implementing stackless in C really, really hurts. To get continuations to work (the way stackless does it anyway, there are other tricks), you need to allocate your locals on the (C) heap (it is called stackless, after all). This is no problem for Python code (as Python has heap-allocated its locals forever). So when map wants to call the Python function, it needs to stuff all the local data it cares about into a frame object (see above), push this frame object onto the (Python) stack, *return* to the interpreter in such a way that the mapping function is called next and then every time(!) that returns have the interpreter call back into map again. So in the map case, I think builtin_map_nr is called first, which calls make_map_frame specifying that the interpreter should return into builtin_map_loop, shoves the resulting frame onto the stack, then returns. The interpreter than calls builtin_map_loop, which if the lists mapping over are exhausted, pops the "fake" frame off the stack and returns (which means the interpreter carries on with the code that called map), or just returns again. I don't remember what make_stub_code is for. Is this helping? Oh well... > - The code adds PREPARE macros into each branch of ceval. Why? > - It adds a long list of explicitly not-supported opcodes into > the ceval switch, instead of using 'default:'. No explanation > for that change is given, other than 'unused opcodes go here'. > Is it necessary to separately maintain them? Why? This was an optimization Chris used to try and get back some of the performance lost during the stackless changes. IIRC, he handles exceptions and return values as "pseudo-opcodes" rather than using the WHY_foo constants the current ceval.c uses. I never really understood this part. > It may be that some of these questions can be answered giving a good > reason for the change, but I doubt that this code can be incorporated > as-is, just saying "you need all of this for Stackless Python". I > don't believe you do, but I cannot work it out myself, either. I think integrating stackless into the core is a fairly huge amount of work. I'd like to think I could do it, given several months of full-time effort (which isn't going to happen). About the only likely way I see for it to get in is for it to become important to Zope Corp. for some reason, and them paying Tim or Guido (or Chris) to do it. Cheers, M. -- Never meddle in the affairs of NT. It is slow to boot and quick to crash. -- Stephen Harris -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From barry at zope.com Tue Nov 6 01:09:55 2001 From: barry at zope.com (Barry A. Warsaw) Date: 06 Nov 2001 01:09:55 -0500 Subject: bg and fg References: Message-ID: >>>>> "NF" == Nicholas FitzRoy-Dale writes: NF> On my system, "man 2 setsid" gives a useful, if terse, NF> definition of setsid(). This was useful to me six months ago NF> when I ran across exactly the same problem (wanted to write a NF> daemon) and didn't understand what setsid() did. :) Anybody who wants to write a proper Unix daemon should read Stevens, Advanced Programming in the UNIX Environment, Chapter 13. Actually, if you're doing any amount of sophisticated Unix programming, with Python or otherwise (yeah, right :), then the Stevens books are absolutely indispensible, IMHO. -Barry From pieroul at attglobal.net Sun Nov 4 18:46:25 2001 From: pieroul at attglobal.net (Pierre Rouleau) Date: Sun, 04 Nov 2001 18:46:25 -0500 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> <3BE5A1A7.75C7EC9C@attglobal.net> <9s4f79$8b3$1@nntp2-cm.news.eni.net> <87ady25fdf.fsf@lisboa.ifm.uni-kiel.de> Message-ID: <3BE5D350.6BD162FB@attglobal.net> Janko Hauser wrote: > > A better way is to use the commands module. It wraps os.popen and I'm > not sure if this also didn't open a shell beforehand. Do you know if the commands module is supported under Win32 (NT) by python 2.1? Or 2.2? I tried it and without changing the source of commands.py this is the result i get (under NT): >>> import commands >>> dir(commands) ['__all__', '__builtins__', '__doc__', '__file__', '__name__', 'getoutput', 'getstatus', 'getstatusoutput', 'mk2arg', 'mkarg'] >>> (exitstatus, outtext) = commands.getstatusoutput('ls') >>> exitstatus 1 >>> outtext 'The name specified is not recognized as an\ninternal or external command, operable program or batch file.' Now, I looked at the commands.py and getstatusoutput() is: def getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell.""" import os pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') pipe = os.popen(cmd + ' 2>&1', 'r') text = pipe.read() sts = pipe.close() if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text The {ls;} does not work in the native NT command shell. So if i modify the source to the following the problem is solved: def getstatusoutput(cmd): """Return (status, output) of executing cmd in a shell.""" import os if os.name in ['nt', 'dos', 'os2'] : # use Dos style command shell for NT, DOS and OS/2 pipe = os.popen(cmd + ' 2>&1', 'r') else : # use Unix style for all others pipe = os.popen('{ ' + cmd + '; } 2>&1', 'r') text = pipe.read() sts = pipe.close() if sts is None: sts = 0 if text[-1:] == '\n': text = text[:-1] return sts, text Now it works fine under NT: >>> reload(commands) >>> (stat, text) = commands.getstatusoutput('ls') >>> stat 0 >>> print text calc freeware mkssi mkssi.py mkssi.pyc si_localChekpoint.py testname.py testname.pyc testtk.py testtk.pyc >>> So, in the end, it looks like commands could be used under Win32 and DOS-like command shells. The docstring in commands.py states that it is for Unix only. Is it worthed to add Win32 compatibility so that modules using commands.py can run in Win32 as well? Pierre From db3l at fitlinxx.com Tue Nov 20 19:45:07 2001 From: db3l at fitlinxx.com (David Bolen) Date: 20 Nov 2001 19:45:07 -0500 Subject: Conversion from tuple to argument list? References: <3BFAE47F.C014585B@earthlink.net> Message-ID: Erik Johnson writes: > Chris Liechti wrote: > > > > > > > >>> args = range(3) > > > > newer python releases: > > >>> struct.pack("bbb", *args) > > '\x00\x01\x02' > > > > Hmm, I am new to Python. ORA's "Learning Python" & "Programming Python" > both document the use of '*' for variable argument lists in the function > definition, but this is the first time I have seen it used in the function > call. Does this sort of use have a name? Is this documented somewhere? Thus the preface about "newer python releases". This feature (and **kwargs for passing keyword arguments) mirrors the use of the similar syntax in function formal parameters for accepting normal unnamed and keyword arguments. It was added in Python 2.0. It's mentioned briefly in the What's New document for Python 2.0 (http://www.python.org/2.0/new-python.html). I'm not actually sure where it may be documented in the primary set of documentation. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From slinkp23 at yahoo.com Thu Nov 15 15:21:32 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 15 Nov 2001 20:21:32 GMT Subject: PIDDLE/SPING?? References: <7d38vt0br1abnvg30j9lettstbq6lh5k89@4ax.com> Message-ID: On Thu, 15 Nov 2001 18:56:49 GMT, Richard West wrote: > >I was looking into PIDDLE today and it seems the only web address I >could find is a little out dated: > >http://piddle.sourceforge.net/ > >Under the status section it reads, "with the 1.0 stable release coming >soon (4th quarter 2000 is the current best guess)". And the link to >the PIDDLE mailing list doesn't appear to work any longer. The list is still live, but egroups has been absorbed by yahoo. http://groups.yahoo.com/group/pythonpiddle >Is this a dead project? Are there any alternative competing projects? For document generation, I think more people are using reportlab now. (inlcuding me). But reportlab doesn't have nearly as much flexibility with kinds of output. >Does anyone know if this will work bug free under Python 2.1 or 2.2, >and the latest version of PIL? Or do I just not have the latest web >address? I can't say if it's "bug free", but it works with 2.1.1. PDF, PS, and SVG tests run fine here. I don't have PIL installed a.t.m. so I can't verify that, but it should be fine. --PW From phd at phd.pp.ru Fri Nov 16 14:22:26 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 16 Nov 2001 22:22:26 +0300 Subject: Xlib bindings for Python? In-Reply-To: ; from shalehperry@home.com on Fri, Nov 16, 2001 at 11:19:01AM -0800 References: <20011116213729.Q22329@phd.pp.ru> Message-ID: <20011116222226.V22329@phd.pp.ru> On Fri, Nov 16, 2001 at 11:19:01AM -0800, Sean 'Shaleh' Perry wrote: > >> Yes, I'm really looking for a set of bindings for Xlib, not a Xt or Xm > > > > http://sourceforge.net/projects/python-xlib > > This is *NOT* a binding, it is a new implementation in 100% python. There is no binding because noone needs it. You are the first - so it is you turn. Use SWIG to wrap Xlib, and publish the reuslts, please. Good luck! Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sholden at holdenweb.com Fri Nov 16 13:34:48 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 13:34:48 -0500 Subject: Does smtplib lookup MX records? References: Message-ID: "Dale Strickland-Clark" wrote ... > I've been trying to send emails with smtplib and had a large number of > failures. Investigation seems to reveal the the smtplib module does a > simple connect passing the hostname to socket.connect without trying > to resolve the MX record. > > In some cases this works where the mail server happens to have an > A-type DNS record anyway but otherwise it fails with a connection > error. > > Is this really the case? > > If it is, what do I need to do to lookup the MX record myself? > > (This is rather urgent now as this program was hastily written to help > a client out who's mail server has died.) > The intention with smtplib.sendmail() is that the host you send through should itself be a mail server, which will be prepared to look up the appropriate MX records. If you just take the domain from an email address and use that as the smtplib host you will usually see errors. In case you really do need to look up the appropriate MX hosts I am sending some code by email, rather than clutter up c.l.py with something so esoteric. regards Steve -- http://www.holdenweb.com/ From fperez528 at yahoo.com Tue Nov 20 13:09:52 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 21 Nov 2001 17:37:52 +2328 Subject: bug in emacs python mode with long documents? Message-ID: <9thhib$3kp$1@peabody.colorado.edu> Has anyone else noticed the following problem? I have a long class (about 1000 lines). When working on code towards the bottom, opening new lines, indenting or deindenting takes forever. Xemacs will go crazy backtracking up the code, and my cpu usage will go to 100% for up to 10 seconds, freezing emacs completely (800 Mhz PIII). I know it's a long class and in fact I need to reorganize it, but that's besides the point. I can't see an editor which is incapable of handling classes longer than 1000 lines! And certainly not 'the beast' Xemacs :) For reference, I'm using: [version 21.4; April 2001] on a Mandrake box. If anyone knows of a bugfix to the python mode, I'd greatly appreciate hearing about it. Cheers, f. From rossini at blindglobe.net Thu Nov 29 10:27:03 2001 From: rossini at blindglobe.net (A.J. Rossini) Date: 29 Nov 2001 15:27:03 GMT Subject: pyplets References: <655abd4a.0111290417.4b28a0f2@posting.google.com> Message-ID: <9u5k47$e7p$0@216.39.145.92> >>>>> "et" == e toffi writes: et> i was thinking (which i dont do often), and came up with an et> idea (which i *do* do often -- dont ask me how). the idea is et> pyplets -- the analogue to java applets with a fittingly silly et> name. anyway the premise is to define an api that lets et> programmers write small programs that execute in a browser. et> whatdyathink? I thought they had support for them in Grail eons ago. best, -tony -- A.J. Rossini Rsrch. Asst. Prof. of Biostatistics U. of Washington Biostatistics rossini at u.washington.edu FHCRC/SCHARP/HIV Vaccine Trials Net rossini at scharp.org -------------- http://software.biostat.washington.edu/ -------------- FHCRC: M-W: 206-667-7025 (fax=4812)|Voicemail is pretty sketchy/use Email UW: T-Th: 206-543-1044 (fax=3286)|Change last 4 digits of phone to FAX Rosen: (Mullins' Lab) Fridays, and I'm unreachable except by email. From dalke at dalkescientific.com Mon Nov 12 23:38:51 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Mon, 12 Nov 2001 21:38:51 -0700 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: <9sq85t$8tu$1@slb6.atl.mindspring.net> David Andreas Alderud: >Python's biggest strength from my point of view is the fact that it is >master tool for fast prototyping, but you can't really take full advantage >of that feature in a project until you have a lot of experience with low >level languages. I don't know how to do generic programming in assembly or C, and barely understand how to do it in C++, but it's trivial in Python. Regarding Ada, I know Stepanov original worked on generics in Ada but switch to C++ and templates as they fit better what he wanted to do. Don't know any more details though. That was also pre-Ada95. >The fact that Ada is the only language that truly was designed, people who >have used Ada have no problem to pick up other langauges other than fully >functional languages such as LISP. Huh? Part of the history of Python is that it was based off the ideas learned in ABC, which was a language that not only was designed but underwent modifications based on user testing of beginning programmers. So how is Ada "the only language"? >I see big demand for Ada programmers here in Sweden, not as big as Java and >C++, but indeed much more so than Python :) One of my clients is on G?teborg, using Python. I know several people doing Python in Sweden. I don't know anyone using Java in Sweden. But then, I'm biased :) >I must say I'm anti-GNU, i.e. anti-GPL/LGPL, but I found this which was an >interesting quote from a GPL'ed project: >"Using GtkAda and GNAT, we can decrease time to market by a factor of two to >four over any other language/compiler." >-- http://libre.act-europe.fr/gvd/ Everyone says their language can decrease time to market by about that much. I've heard the same statements from Eiffel, Lisp, Smalltalk, Java, OCaml, Perl, and yes, even Python developers. Therefore, logic dictates that it takes no time to get a product to market. Andrew dalke at dalkescientific.com From peter at engcorp.com Sat Nov 24 09:21:47 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 24 Nov 2001 09:21:47 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: <3BFFACFB.36AF1DB2@engcorp.com> Huaiyu Zhu wrote: > > Marcin 'Qrczak' Kowalczyk wrote: > >This would be a bad idea: > >- using tab width of any other size than 8 is evil, > >- 8 is too much for indentation in programming; 2 to 4 is good. > > There are really two issues involved: > > If everything can be redesigned from scratch, what would be the best > indentation method for languages like Python's? There is a strong argument > for one tab character per indent level. When indentation is encoded as the > number of tab charactors, code can be exchanged between different > programmers completely unaffected by the display style. The editor might > even display it as charactor like this: There's a stronger (IMHO) argument that using *only spaces* would be a more appropriate redesign. But since that would cause too much trauma for many people who perhaps can't adjust, it would be more pragmatic to open it up to people who "need" to use tabs. Unfortunately, since the definition of a tab is ambiguous and inconsistent, one would have to suggest a *preferred* definition, such as the one *most commonly used* throughout the world of computing, which would be a tabstop of 8. Unfortunately, some people insist on using tabs with tabstop sizes other than 8, so one would perhaps open up the language to those people by allowing them to use their atypical tabsize, provided they were to do it consistently. In the end, if people mixed tabs which were not the typical size with spaces, there would not be much one could do except repeatedly recommend in newsgroup postings that they change their editors to use spaces instead of inserting TAB characters, or that they stick with a tabstop of 8 as the standard. Deciding how much of a redesign of Python this new specification would require is left as an exercise for the reader.... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From phr-n2001d at nightsong.com Thu Nov 15 19:14:11 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 16:14:11 -0800 Subject: PEP 276 Simple Iterator for ints References: <3BF40F8A.378CC6F8@ccvcorp.com> Message-ID: <7xd72jy3l8.fsf@ruckus.brouhaha.com> David Eppstein writes: > - Functional programming e.g. "def factorial(n): > reduce(multiply,range(1,n+1))" vs "reduce(multiply,[1,2,...n])". A closed > interval would be more natural. Well, non-Pythoners already are terrified of how Python uses indentation instead of curly braces or begin/end to express program structure. Why not drive them COMPLETELY crazy? factorial = reduce(multiply[1,2...n]) # closed interval for i in [0,1,...n): # half-open interval , I think ;-) From kragen at pobox.com Wed Nov 28 18:06:21 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 28 Nov 2001 18:06:21 -0500 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> Message-ID: <838zcqv6ky.fsf@panacea.canonical.org> joost_jacob at hotmail.com (J.Jacob) writes: > List comprehension in the later Python versions is fun but i need to > get this piece of code to run as quickly as possible on Python version > 1.5.2 and no NumPy available (not allowed to install extra things on > the computers here alas). "install"? What exactly aren't you allowed to do? Put things in /usr/local? Use up a lot of disk space? Leave stuff in the filesystem overnight? Write things to the filesystem at all? I wonder if you could write a C module to do the job; it would probably run a lot quicker, and it would probably be about a page of simple code. You could run it from your local directory, just like you run a Python module. > This is the code as it is now, it works allright but the profiler says > we spend a lot of time here: > for j in range(self.nh): > sum = 0.0 > for i in range(self.ni): > sum = sum + self.ai[i] * self.wi[i][j] > > the .nh and .ni values are correct What are their relative magnitudes? From michael at stroeder.com Fri Nov 30 03:30:17 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 30 Nov 2001 09:30:17 +0100 Subject: HOWTO: Programming S/MIME in Python with M2Crypto References: <200111292132.fATLWw368380@bigboy.bizarsoftware.com.au> Message-ID: <3C074399.17CA2613@stroeder.com> Richard Jones wrote: > > Netscape 6+ aka Mozilla aka "nobody uses S/MIME, it's not important, > so we won't bother implementing it" aka *grrr* ... Currently there is work done on S/MIME in the Mozilla project. > You need to revert to a _useful_ email package, like the one with > Netscape 4.7 or Outlook (the only two mail packages that I know of that > support S/MIME in a graphical environment.) Note that Netscape 4.x has interoperability problems with e.g. wrapped header lines which affects e.g. S/MIME e-mails sent by Outlook... Ciao, Michael. From fperez528 at yahoo.com Fri Nov 9 21:42:12 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 11 Nov 2001 02:10:12 +2328 Subject: Bug in list comprehensions in Pyhton 2.1.1? References: Message-ID: <9slfbl$p9c$1@peabody.colorado.edu> Tim Peters wrote: >> def flatten_bug(seq): >> # a *global* variable x is left over after calling this function, >> # with the value of the last element in the return list >> return [x for subseq in seq for x in subseq] > > See > > > > This was a bug, and was fixed last month (for 2.2; perhaps also for 2.1.2). Thanks for the info! I'll update to 2.2 when it comes out. In the meantime there's an easy workaround (as my original post indicated). Well, at least it's a nano-ego trip to have found a bug in Python after having only recently started to use the language :-) Cheers, f. From dgrisby at uk.research.att.com Thu Nov 8 11:45:50 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 8 Nov 2001 16:45:50 GMT Subject: CORBA client & server with Python References: <01c16873$ddd02ce0$06d1178b@mvn40020> Message-ID: <9secru$63g$1@pea.uk.research.att.com> In article <01c16873$ddd02ce0$06d1178b at mvn40020>, Murat Demir wrote: >with this example, I compiled the .idl file, there is no problem with it, >I run the server program, it' OK as well, >but when I try to run client side program, the message is: > >bash-2.03$ python client.py >Traceback (most recent call last): > File "client.py", line 9, in ? > ior = sys.argv[1] >IndexError: list index out of range The client expects the IOR for the server on the command line. When you ran the server, it printed a long hex string. You must give it to the client. Something like this: $ python client.py IOR:010000000e00000049444c3a48656c6c6f3a312e30000 00001000000000000003200000001010000040000004f692100d20400001e0000005 76861742061726520796f75206c6f6f6b696e67206865726520666f723f That string isn't a valid object reference. You must use the reference for your server. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From aaldv97 at student.remove-this-part.vxu.se Mon Nov 12 12:15:22 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Mon, 12 Nov 2001 18:15:22 +0100 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> Message-ID: <9sp073$k6d$1@news.lth.se> > This, of course, represents a value judgment on your part that loose > typing (and by the way, Python is *strongly* typed, but dynamically so) > is a bad thing. In any case I would argue that the habits beginners would > pick up learning Python would serve them well in the future. When they get > to a statically typed language, or a weakly typed one (Python is neither), > they will question *its* value and ease of use. Depends on the audience I guess, people who are interested in programming tend to be interested in how the computer works and how to write efficient programs. Things like dictionaries are good for non-programmers to get things done, it's good for a simple solution but can not be transformed in a way that BST are simply turned into an R\BST when the requirements change. > No, good teachers who promote consistent coding style, modular > design, unit testing, and so forth teach students how to write good code. > The language has very little to do with it, except insofar as some > languages get in the way of that, while others do not. Python does not. Again, depends on what kind of view one has of teaching and learning, my view is that the students should teach them selves, and that is best done in Ada. > Python has proven very effective for hardware programming. Yes, > via a DLL or driver or something, but then again very little of > what constitutes "hardware programming" involves access to the > hardware, and most involves what you *do* with that access. > AI programming is apparently best done with LISP according to > some, but I've found Python nice for, say, genetic algorithms, > so I wouldn't say it represents a necessarily *bad* choice. We have completely different views on low-level programming, when doing hardware programming I do not simply mean accessing hardware. In AI programming Python can be used, just like C and assembly language or any other language under they sky, however, generic AI programming is done in functional languages for a reason; most solutions in AI is based on recursion, what better language to write recursion in than a functional language. Second, I've never seen selfmodifying code written well in anything but assembly and LISP. From sshws at fury1.lerc.nasa.gov Fri Nov 30 12:11:12 2001 From: sshws at fury1.lerc.nasa.gov (Herb Schilling) Date: Fri, 30 Nov 2001 17:11:12 +0000 (UTC) Subject: Porting Python app ( with C,F77,F90 extensions ) from UNIX to Windows - best method? Message-ID: <9u8ejg$6jr$1@fury1.lerc.nasa.gov> Hello, I have a Python application running on IRIX that I would like to make available to some academic partners. They use PCs so I have to port all of the extensions that I use to Windows. These extensions are C, F77, and F90 codes that I wrapped with SWIG and f2py. ( I don't think this matters a lot to my question but my app also makes use of wxPython, Numeric and PyOpenGL. ) I would then like to take all of my Python code and extensions and make an installer to make it easy for our partners. I have been doing a lot of searching and reading of web pages and Usenet posts looking for other people's experiences when doing this kind of thing. Right now it looks like I could use mingw32 to do what I want but I still feel unsure. I would hate to go down that path and then find a dead end. I would prefer to avoid using Microsoft's tools because I have no experience with them. Does anyone forsee any problems using mingw32? ( What about my f90 code? mingw32 doesn't seem to come with an f90 compiler. ) Thanks in advance. From chase at gnuchina.org Wed Nov 21 22:55:28 2001 From: chase at gnuchina.org (Benjamin Wu) Date: Thu, 22 Nov 2001 11:55:28 +0800 Subject: How to change HTTP version during HTTPlib? Message-ID: <9thtih$2jde2$1@ID-54723.news.dfncis.de> hi, I use HTTPlib to do some coding, How do change HTTP version during I send http request? I just use HTTP class to do so but it work in HTTP version 1.0, and I also know that there is another class named HTTPconnection work in HTTP version, How should I do? thx From logiplexsoftware at earthlink.net Thu Nov 15 13:33:50 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 15 Nov 2001 10:33:50 -0800 Subject: What is "marshal data"? In-Reply-To: <859c71be.0111151028.63227109@posting.google.com> References: <859c71be.0111151028.63227109@posting.google.com> Message-ID: <01111510335000.21269@logiplex1.logiplex.net> On Thursday 15 November 2001 10:28, Soren Ragsdale wrote: > Possible sources of the problem: "uh.py" is imported from MANY > programs on our network. It's being imported by Linux and Irix > machines running 1.5.2 and 2.1.1 versions of Python. Could this be As mentioned in another thread, the bytecode between python versions is not backward compatible, so you may be trying to execute 2.1.1 bytecode on a 1.5.2 interpreter and that may be causing the problem. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From bbollenbach at home.com Sat Nov 17 12:42:57 2001 From: bbollenbach at home.com (Brad Bollenbach) Date: Sat, 17 Nov 2001 17:42:57 GMT Subject: Question to those who know both Java & Python pretty well... References: <2a6e94ef.0111170759.5fe7027a@posting.google.com> <3BF69FBB.9C329E0F@engcorp.com> Message-ID: [snip] > I suggest you start with > > http://www.google.com/search?q=comparison+java+python > > or > > http://www.google.com/search?q=comparing+java+python > > and come back and ask a few more questions once you've done > a little preliminary research. Add: http://www.faqts.com/knowledge_base/view.phtml/aid/2906/fid/199 to that list From marduk at pythonh.net Wed Nov 28 22:27:20 2001 From: marduk at pythonh.net (marduk) Date: Wed, 28 Nov 2001 21:27:20 -0600 Subject: The Editor Poll results are in! References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> <01112813100206.00609@linux> Message-ID: I move for a recount! Besides, how many readers of c.l.p actually use Python? In article , "Jonathan Gardner" wrote: > The results are in! > > Emacs: 13 > Rude people that use emacs: 1. >:-P (No, RMS did not reply.) > *MicroSoft* Visual SlickEdit: 1 brave soul ActiveState Komodo 1.1: 1 > lone voice > Vim (NOT vi): 7592 > Really cool people that use Vim: All of 'em. > > This poll had a total of 7607 respondents, myself included. Therefore, > if you are using emacs and you haven't tried vim yet, you should know > that you are in the minority here! HAHAHA! How does it feel to be the > underdog now? NYA NYA NYA NYA NYA! > > This poll is not affected in any way to my aversion to Emacs. Nope, not > one bit. I am, after all, a saint, because I use Vim. =) I also > remembered to *accidentally* delete the emails so... > > Jonathan > > * Disclaimer for the tragically humor-impaired: No, I don't hate emacs. > No, I don't hate you. (Well, maybe YOU, but not you.) Yes, I did > manipulate the results, and yes, I am a jerk. Yes, it looks like about > 75% of the people here use emacs. Can't blame them - python mode is > really good. Posted Via Usenet.com Premium Usenet Newsgroup Services ---------------------------------------------------------- ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** ---------------------------------------------------------- http://www.usenet.com From p.vrijlandt at aig.azn.nl Wed Nov 14 12:03:49 2001 From: p.vrijlandt at aig.azn.nl (Patrick Vrijlandt) Date: Wed, 14 Nov 2001 18:03:49 +0100 Subject: open DOS window and start application References: <3bf27da9.14337531@news.easynews.net> Message-ID: <9su85j$380$1@odysseus.uci.kun.nl> Hi, > How can I start several jobs (one after the other) in THIS window? > (not open new windows for each job) > > How can I change the current dir in this window? > Did you try creating a batch file and starting that? In a batch file you can do C:\windows>cd \myprog then use os.system to start the batch file (or use windows api functions from win32 extensions) > Thanks > Marcus HTH -- Patrick From stepken at little-idiot.de Mon Nov 12 02:43:25 2001 From: stepken at little-idiot.de (Guido Stepken) Date: Mon, 12 Nov 2001 08:43:25 +0100 Subject: IsPython really O-O? - Think different ! References: <9smovs$cbu$02$1@news.t-online.com> Message-ID: <9snugr$bbc$06$1@news.t-online.com> VisualPython is a windows port of the unix python from G.v.Rossum, done with cygnus (now redhat) GNUPRO suite. Microsoft has bought a Content Management System (CMS), which was written in Python......and they rewrote it in C++ .....hmmm.... seems, they haven't unterstood really......But i am happy with microsofts change-mind in things like opensource, .net. But their licenses are still horror (EULA). IMHO they do forbid the use of their software together with GPL ....but i have no evidence (i dont't use M$ !). I there anybody out there, who has a copy of this M$ license ? regards, Guido Stepken >Gerhard H?ring wrote: ... > A minor correction: VisualPython is an ActiveState product. Microsoft has > AFAIK nothin to do with it except that they provide VisualStudio 7 with a > plug-in API for other languages, debuggers, etc. > > Gerhard From gdemmy at layton-graphics.com Sat Nov 17 17:45:46 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 17 Nov 2001 17:45:46 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: <3BF6C202.7EB544E0@alcyone.com> <3BF6D902.BC8742FA@alcyone.com> Message-ID: Erik Max Francis writes: > George Demmy wrote: > > > My understanding of Pythonic truth anything other than None, (), [], > > {}, '', and 0 is true. I don't know what mathematical truth is -- got > > a approachable reference for an interested non-mathematician? > > When you're using filter, the function you need maps an object to a > truth value, but the identity function maps an object to itself. In > Python this happens to be the same thing, but what you "really mean" is > lambda x: operator.truth(x). Ahhh... OK. I see your point, and I agree. Your example is excellent. Thanks, G -- George Demmy From nomad*** at ***freemail.absa.co.za Wed Nov 14 04:42:46 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Wed, 14 Nov 2001 11:42:46 +0200 Subject: Open a windows database file with a path name? References: <1005317748.433.44382.m12@yahoogroups.com> Message-ID: <5ve4vtgt0o67mtbc0fit6t45svn4esos07@4ax.com> On Fri, 9 Nov 2001 16:27:15 -0500, "Bill Bell" wrote: > >Nomad wrote, in part: >> Is there anyway that I can open a database (MSAccess in this case) >> using the path and file name rather than a DSN? > >It goes something like this: > >conn = win32com.client.Dispatch ( r'ADODB.Connection' ) >connString = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA >SOURCE=;' >conn.Open ( connString ) >rs = win32com.client.Dispatch ( r'ADODB.Recordset' ) >rs.Open ( SQL, conn, 1, 3 ) > >There's a good web page offering clues about working with ADODB >and Python. (If I could remember where it is I'd even tell you!) > >Bill Excellent - exactly what I was looking for. After writing the origninal post, I realised that as I was using an access database, the non cross-platform nature of using win32com wouldn't really matter. However, I haven't even scratched the surface of the win32 extensions, so thanks for the example to get me started. If you do remember the URL please post it up here. Thanks. PS, what's the "r" for in "( r'ADODB.Recordset' )"? -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From eppstein at ics.uci.edu Thu Nov 15 12:59:43 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 15 Nov 2001 09:59:43 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: In article , com-nospam at ccraig.org (Christopher A. Craig) wrote: > You think that is bad. What do you think "1, 2 .. 5" specifies? > > 1) 1, 2, 3, 4, 5 > 2) 1, 3, 5 > 3) 1, 3 > > If I saw it on a math paper, I would immediately presume (1). After > all, (2) and (3) don't even include "2" which, it would seem should be > the second element of the sequence. If it is (1), then what do we do > about "0, 2 .. 6"? Is this "[0, 2, 5]"? No, it is [0,2,4,6]. More generally, as I said before, I would expect [a, b, ... c] to be essentially equivalent to range(a, c+b-a, b-a) -- i.e. the step size should be b-a and the last element in the range should be c. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From shriek at gmx.co.uk Sun Nov 11 22:12:27 2001 From: shriek at gmx.co.uk (Stephen) Date: 11 Nov 2001 19:12:27 -0800 Subject: Designing socket messaging format Message-ID: <97ae44ee.0111111912.14006c7f@posting.google.com> I'm developing a program which sends messages back and forth between two servers using sockets. The message format I've been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" Where ~ Y is the message type, which in turn affects the message length. T represents a text message. (eg. "Hello World"). Note that it could also contain newlines (eg. "Hello World\nGood bye") This was easy to build ontop of SocketServer ~ import SocketServer class RequestServer(SocketServer.ThreadingTCPServer): allow_reuse_address = 1 class RequestHandler(SocketServer.StreamRequestHandler): def handle(self): request = self.rfile.readline() print "Received message, %s" % request self.wfile.write("Received OK") print "Ending request" host = "127.0.0.1" port = 1111 server = RequestServer((host, port), RequestHandler) print "SERVER : listening to socket [%s:%s]" % (host, port) server.serve_forever() However, the readline() makes it necessary to send a "\n" at the end of the message. So, the message format becomes "YYYYTTTTTTTTTTTTTTTTTTTTTTT\n" This introduces the problem that if any of the text characters (T) are a "\n", the message will be terminated too soon. A previous post to CLP provided the following solution which looks out for a "\r\n" message termination string ~ import SocketServer class RequestServer(SocketServer.ThreadingTCPServer): allow_reuse_address = 1 class RequestHandler(SocketServer.StreamRequestHandler): def handle(self): request = '' while 1: line = self.rfile.readline() if line in (None, "\n", "\r\n", ""): break request = request + line self.server.request = request request = string.rstrip(request) print "Received message, %s" % request self.wfile.write("Received OK") host = "127.0.0.1" port = 1111 server = RequestServer((host, port), RequestHandler) print "SERVER : listening to socket [%s:%s]" % (host, port) server.serve_forever() So, should the message format change to ~ YYYY\n TTTTTTTTTTTTTTTTTTTTTTT\n \r\n Other than facilitating use of SocketServer.ThreadingTCPServer, it seems that asyncore also looks out for termination strings, and the "Python Sockets HowTo" infers that using fixed-length for message termination is a bad idea. So everything seems to be pointing this way. Am I correct in my understanding ? Stephen From terabaap at yumpee.org Tue Nov 6 07:23:09 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Tue, 06 Nov 2001 12:23:09 GMT Subject: Python VM on Lego Mindstorms Message-ID: <3BE7D665.8030904@yumpee.org> Hello all, Has there been any work on porting the Python VM to run on a Lego Mindstorms RCX brick? So that robot control programs can be written in Python. I've heard of Pippy and Deeply Embedded Python, but it will probably take a really stripped-down Python to fit in the 32KB of RAM on the Mindstorms RCX (and probably running on top of legOS). But peopele have squeezed a JVM (tinyvm.sourceforge.net) into the RCX, so this should be doable. Could be an interesting, if somewhat perverted, little project ... Manoj From sholden at holdenweb.com Fri Nov 30 17:39:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 17:39:43 -0500 Subject: Using Python with a webserver References: Message-ID: "Sam Scholey" wrote ... > Hey Folks > > I was interested in the prospect of using python with my webserver but a > search on the python site and on deja produced virtually zero results. Can > it be done? is it as easy as editing a few lines of code in the apache > httpd.conf file? > > I am using Windows xp pro, apache 1.3.22 (for windows) > Sam: If I remember correctly, no config changes are required for Python cgi scripts in the cgi-bin directory. You just have to put the correct shebang line at the head of the Python, which in my case was something like C:\Python20\python -u The -u gives you unbuffered output, which is useful in many contexts. regards Steve -- http://www.holdenweb.com/ From pj at sgi.com Fri Nov 30 14:22:09 2001 From: pj at sgi.com (Paul Jackson) Date: 30 Nov 2001 19:22:09 GMT Subject: Non-Indented python References: Message-ID: <9u8m91$cf5bf$1@fido.engr.sgi.com> |> Hard tabs in source files serve no useful purpose ... Unless the source file is a Makefile. -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From tim at vegeta.ath.cx Fri Nov 2 15:34:26 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 02 Nov 2001 20:34:26 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: Message-ID: Me parece que Steven D. Majewski dijo: > On Thu, 1 Nov 2001, Tim Hammerquist wrote: > > > You mean "the humour is lost on _some of_ us Americans," right? > > > > Of course, I had a non-standard American growth in which I was exposed > > to many things British, including but not > > limited to: > > Dr. Who (mainly Tom Baker) (recorded). > > Red Dward (1st season, carrier did not renew) (recorded). > > Monty Python's Flying Circus and any of the movies I could find. > > How to Irritate People (John Cleese et al.; not "officially" Monty > > Python). (purchased) > > ...et cetera. > > Peter Cushing horror movies. ;) > > Susan Cooper's The Dark Is Rising sequence including dialects from > > Cornwall and Wales. > > A great many movies and series taking place in Yorkshire, probably > > responsible for my ability to understand more dialects than > > usual. :) > > Neil Gaiman novels. :) > > Far too many others to count. > > You're missing one important link that is well represented in the > python-list archives: The Goon Show -- with Spike Milligan and > Peter Sellars. The Goon Show was a BBC radio show that was the > inspiration for Monty Python. Yup. Missed that one. Not many networks carry PBS-type show over here in the western states at, much less BBC radio shows. :( > Spike Milligan beat out John Cleese for 1st place in the BBC's > millenium poll of the top 10 funniest people: > Never heard the man, but John Cleese isn't even my favorite. Michael Palin's my fave from the Flying Circus, et al. [ snippage ] > > Many foreigners call America's culture (or lack thereof) bland. Well, > > from this American's perspective, they tend to be correct. "Tend to be," while it is general, has two distinguishing characteristics: it is not absolute, and it is in the present tense. I'd like to point out the age of most items on your list. > Bland American Culture ??? -- how about (while we're on the subject of > humor): > the Firesigh Theatre > Mad Magazine (the good old years) Just didn't hit me right. Sorry. > The Onion > The Marx Brothers Obviously modern comedy. > Abbott and Costello ( "Who's on First": > ) Never liked them. Call me commie. > Harry Shearer ( "Who's on First" -- (a tradition in American Humor!): > > [Don't blame me if you're not old enough to get this one!]) > the Simpson's What?! I'll be damned if the Simpson's go down in history as a representative of American humour. > Robert Crumb > the Coen Brothers > George Bush (What other country has such a dedication to Humor!) I disagree. I find him to be rather _too_ dry. And I prefer some of Clinton's older, funnier campaigns myself. And...oh yeah: I'm (mostly) conservative. > .... > > -- Steve $0.03, Tim -- Love is like racing across the frozen tundra on a snowmobile which flips over, trapping you underneath. At night, the ice-weasels come. From peter.milliken at gtech.com Thu Nov 29 18:18:00 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Fri, 30 Nov 2001 10:18:00 +1100 Subject: Python evangelists unite! References: Message-ID: <9u6fnl$b343@news1.gtech.com> Start avoiding him :-) There is no real justification that works for these "features" of python - they can be convenient sometimes but generally violate a lot of "standards" considered good practice for general software engineering (first lesson I learnt was don't write self modifying code! :-)). I use Python as a good, quick and dirty hacking language. For real (read production) stuff that I expect a customer to run or will require more than a single person working for a couple of hours, I look elsewhere :-). Sure there are examples of Python being used for "large" jobs - and very successful they have been too - but these people are masochists (IMO) :-). They could have been more productive with other languages that provide better support for generic software engineering principles/standards. There, that should bring the 'vangelists out of the woodwork! :-) It's just too easy, they rise like starving trout - each language has it's strengths and weaknesses. Python has some very nice features, I use it a good deal. But it definitely has its place! In the meantime, my advice is don't get "emotionally" hooked into the language. Analyse its strengths and weaknesses, consider other languages and their strengths and weaknesses and then you can hold an intelligent conversation with another programmer! :-) Peter wrote in message news:baf2f841.0111291428.591f515 at posting.google.com... > Okay, I was extolling the benefits of Python to a friend of mine. He > took strong exception to Python's OO model. > > ME: Python's great--you can add members to instances OR classes > on-the-fly! > FRIEND: Why would you want to do that? > ME: Uh... > FRIEND: Besides, that's awful Object Orientation. If I start adding > attributes to an instance of a class, it ceases to be an instance of > that class. If I create a bunch of instances of the same class, they > should be the same; they should have the same members. > ME: Yeah, but with dynamicism, I can add a new pane to a GUI > while it's running. I just change an instance to include a new pane, > and... > FRIEND: That's pretty cool, but it's not a reason, in and of itself, > to make a language so dynamic. There must be some advantage to being > able to add attributes during runtime. What are they? > ME: Uh... > FRIEND: And another thing! What's with encapsulation? There's no > private!?!?!? > ME: > > So, I need some help. I've checked out c.l.p and some on-line > articles, and I just can't find good practicle examples of a program > that adds members to instances (or classes) at runtime. Anybody got > any? I don't want to have to start avoiding my friend.... > > TIA, > b. From emile at fenx.com Wed Nov 14 10:36:20 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 14 Nov 2001 07:36:20 -0800 Subject: How to know when a variable is set References: Message-ID: <9su3bm$169lra$1@ID-11957.news.dfncis.de> "-" wrote in message news:fef0a228.0111140715.24b5cfc7 at posting.google.com... > How can I test if a variable has been given a value, or if it's undefined? >>> try: ... if q: ... dowith(q) ... except NameError: ... print "q doesn't exist" ... q doesn't exist >>> -- Emile van Sebille emile at fenx.com --------- From Administrator Wed Nov 28 04:40:48 2001 From: Administrator (Administrator) Date: Wed, 28 Nov 2001 02:40:48 -0700 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <033301c177f0$c2674a10$0e0fbb82@corp.es.com> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = Krzysztof Czarnowski Recipient(s) = python-list at python.org Subject = Re: Scanning Time = 11/28/2001 02:40:47 Engine/Pattern = 5.600-1011/173 Action on virus found: The attachment SETUP.DOC.scr contains WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to administrator. ScanMail has detected a virus. 11/28/2001 02:40 AM TORINO SETUP.DOC.scr/Deleted python-list at python.org Krzysztof Czarnowski Re: From phd at phd.pp.ru Fri Nov 30 07:44:07 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 30 Nov 2001 15:44:07 +0300 Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: <3C07357A.2935.24FC2A4@localhost>; from bill-bell@bill-bell.hamilton.on.ca on Fri, Nov 30, 2001 at 07:30:02AM -0500 References: <1007084325.890.69394.m11@yahoogroups.com> <3C07357A.2935.24FC2A4@localhost> Message-ID: <20011130154407.S27931@phd.pp.ru> > Jonathan Gardner wrote, in part: > > They'd have to be [young]. I can't seem to find a place to get paid to work in > > Python yet. I can't imagine a guy with 3 kids trying to make a living > > by programming python unless he is the rare guy that has a job in it. I am 34 yo, with exactly 3 children. For more than 5 years I earn living by Web programing using Python and ONLY Python (I mean Python as a programming language; of course I use SQL, write JavaScript, but not Perl, for example.) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From m.faassen at vet.uu.nl Thu Nov 15 19:15:31 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 16 Nov 2001 00:15:31 GMT Subject: OT: Mobile Internet Toolkit EULA References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> Message-ID: <9t1lr3$adu$1@newshost.accu.uu.nl> [free software, open source, licenses, microsoft, oh my, oh my] Excellent work folks -- we're adding centuries to the lifetime of the universe this way. The PSU thanks you. :) Regards, Martijn From loredo at astro.cornell.edu Tue Nov 20 22:46:03 2001 From: loredo at astro.cornell.edu (Tom Loredo) Date: Tue, 20 Nov 2001 22:46:03 -0500 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> <9t9h3j$7r9$1@tyfon.itea.ntnu.no> Message-ID: <3BFB237B.3FC46A84@astro.cornell.edu> Steve Holden wrote: > > > locals()[['a','b'][idx]] = val > > > This is absolutely verboten. I quote from Section 2.3 of the 2.0 manual, but > I don't think anything has changed since: """locals () > Return a dictionary representing the current local symbol table. Warning: > The contents of this dictionary should not be modified; changes may not > affect the values of local variables used by the interpreter. > """ But the code only modifies one of the references "a" or "b", not the locals dictionary. Or am I missing something? -Tom Loredo From dhaaron at hotpop.com Sat Nov 24 19:00:55 2001 From: dhaaron at hotpop.com (Aaron Sterling) Date: Sun, 25 Nov 2001 00:00:55 GMT Subject: File creation Message-ID: <1103_1006646455@t4q4p0> Hi, To create files, I am currently using: temp_file = os.open(file_name, O_CREAT) temp_file.close() open(file_name, 'w') Is this the cannonical way of doing it? If so, would it be usefull to have a function, create_file(file_name, mode, bufsize), linked to the interpreter, that would create the file and return an associated file object? Is their a better way to do it, or is it something that shouldn't be done, and if so why? Aaron, dhaaron at hotpop.com From sg_oneill at hotmail.com Tue Nov 13 01:32:41 2001 From: sg_oneill at hotmail.com (goonfist) Date: 12 Nov 2001 22:32:41 -0800 Subject: Using browser as interface to python app References: Message-ID: <572d36a5.0111122232.15f24a93@posting.google.com> "Bill Bell" wrote in message news:... > sandskyfly at hotmail.com (Sandy Norton) > > I'm simply trying to use the browser as an interface to a small python > > program that retrieves and parses webpages and then publishes the > > results in an html page. I would like for example for the user to be > > able to configure the app via the browser (by selecting checkboxes and > > whatnot) without having to use a command-line menu or a full blown GUI > > such as wxPython or Tkinter. > > Have you considered using Webware (webware.sourceforge.net)? I > can't tell you anything about it since I've just started learning about > it myself. 400K download. Looks really cool. > > Bill > "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery Failing that , you could just whack together a CGI (or ASP-python if yer in windows world). Both of those solutions implement reasonably easy access to get & post variables , and you just write out the results to a file (or pipe or whatever) From dcinege at psychosis.com Thu Nov 22 19:05:11 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Thu, 22 Nov 2001 19:05:11 -0500 Subject: Non-Indented python In-Reply-To: <5C0L7.159189$IR4.55612315@news1.denver1.co.home.com> References: <9sbd8i$680$1@wanadoo.fr> <5C0L7.159189$IR4.55612315@news1.denver1.co.home.com> Message-ID: On Thursday 22 November 2001 1:06, you wrote: > "Dave Cinege" wrote in message > news:mailman.1006401758.28916.python-list at python.org... > > > I don't make excuses for poor editors. A programming editor worth > > anything (IE nedit) will let you define the display of tabs to > > how many ever spaces you like. > > Tabs should not be displayed as spaces at all. I'm inclined to say that > any editor that does display them as spaces is broken. Here on earth, tabs are typically represented by 8 * space width. A good editor allows to set the mutiple to anything you desire. A very bad editor will display a tab as a symbol, in raw form, or not at all. Maybe you use one of these? If what you mean is, you press the tab key and the editor inserts X * spaces then yes this is the most evil form of blasphamy. Tab is: ASCII 0/9 is decimal 009, hex 09, octal 011, bits 00001001: called ^I, HT, TAB Official name: Character Tabulation Other names: Horizontal Tab, \t Binding a 'macro' to the key like this is like pressing '1' and having the editor output 'one'. Authors of such works shall be drawn and quartered before reaching death. So let it be written. So let it be done. Dave -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From jtdubs at eos.ncsu.edu Wed Nov 14 18:23:56 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Wed, 14 Nov 2001 18:23:56 -0500 Subject: does \1 in re work? References: <9surpa$eek$1@uni00nw.unity.ncsu.edu> Message-ID: <9suub4$glq$1@uni00nw.unity.ncsu.edu> "Justin Dubs" wrote in message news:9surpa$eek$1 at uni00nw.unity.ncsu.edu... > "Michael P. Soulier" wrote in message > news:slrn9v5qvc.u31.msoulier at pmerd071.ca.nortel.com... > > Hello. > > > > Looking at the documentation for python 1.5.2, the now aging version > that > > I'm using, in the re module it states that the standard \1, \2 keys that > > reference that matched value in parenthesis in the pattern do in fact > work, as > > do \g<1>, \g<2>, etc. > > > > So, I tried this: > > > > new = re.sub("^(-?\d+)(\d{3})", '\1,\2', amount) > > > > new always ended up being '\001,\002'. Not what I wanted. > > > > So, I used the alternate... > > > > new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', amount) > > > > Which worked perfectly, giving me, for example, > > > > '100000,000' where amount was '100000000'. > > > > So, my question is, what was wrong with my first pattern? > > > > Thanks very much, > > > > Mike > > > > -- > > Michael P. Soulier, TD12, SKY Tel: 613-765-4699 (ESN: 39-54699) > > Optical Networks, Nortel Networks, SDE Pegasus > > "...the word HACK is used as a verb to indicate a massive amount > > of nerd-like effort." -Harley Hahn, A Student's Guide to Unix > > Python is getting to your strings before re.sub() is. It's changing the \1 > and \2 into the corresponding characters before re.sub() ever sees the > string because the \'s are escape characters. Two easy solutions, offhand: > > re.sub(...., r"\1,\2", ...) > > Notice the r in front of the quotation marks. This will stop python from > messing with those \'s. > > re.sub(...., "\\1,\\2", ...) > > In this case, the change is the double \'s which will be processed by Python > and turned into the single \'s that you wanted originally. > > Either way, it'll work. Have fun and good luck, > > Justin > > Oh, just a nitpick, but your re.sub only works if you need to add one comma to the number. If you want a quick function that will work on arbitrary numbers than here's one I whipped up real quick. I couldn't figure out how to do it in a single regex, but then, I'm not that good with regex's. >>>import re >>>def addcommas(s): ... while(1): ... s, c = re.subn("(\d)(\d{3})((,\d{3})*)$", r"\1,\2\3", s) ... if c==0: break ... return s ... >>> addcommas("10000000000") '10,000,000,000' >>>^Z I tested it for the first couple power of ten and it seems to work fine. Anyway, hehe, I was bored. Have fun, Justin Dubs From sholden at holdenweb.com Wed Nov 14 13:06:25 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 13:06:25 -0500 Subject: How program a particilar algorithm ? References: <9sua59$3lh$1@wanadoo.fr> Message-ID: "Michel Bonnifait" wrote in message news:9sua59$3lh$1 at wanadoo.fr... > Hello, > I think my question is more on programming than specifically on programming > with Python. > I want to generate all possible lists with elements from another one. For > example, from a list like [1,2,3,4] i want to program an algorithm which > will give this result > [[1,2],[1,3],[1,4],[1,2,3],[1,2,4],[1,3,4],[1,2,3,4],[2,3],[2,4],[2,3,4],[3, > 4]] Haven't you forgotten [1], [2], [3] and [4]? > It's seems to me it should be a recursive programming answer but i can't > find it. > thanks in advance for your help ! > Take a look at the following entry from the Python Programmer's Cookbook, and good luck with your homework ;-) http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66465 when-i-was-a-student-there-was-no-google-to-ignore-ly y'rs - steve -- http://www.holdenweb.com/ From loewis at informatik.hu-berlin.de Sun Nov 25 07:24:24 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Nov 2001 13:24:24 +0100 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> <3bfecd77@brateggebdc5.br-automation.co.at> <97ae44ee.0111232129.550244cd@posting.google.com> <3c001e3a$1@brateggebdc5.br-automation.co.at> Message-ID: "Werner Schiendl" writes: > But this does not mean, that one cannot just take one's own C extension and > link it statically with the interpreter. I'm not sure about the double negation: Yes, it is very possible to link your own extensions into the Python interpreter. Just generate an appropriate config.c (see /pythonX.Y/config/config.c for an example). You need to link it with libpythonXY.a > Personally, I think the term 'built-in' tells more about whether it is 'in' > the interpreter (python) binary or a seperate file (no matter if Python or > C). As I said: This is a matter of terminology. Of course, terminology alone doesn't affect at all what you can or cannot do with Python. > I'd call the modules coming with Python 'The Python Standard > Library' - but this if of course personal taste. That would have confuse the OP, who, after being told that rotor is in the standard library, went straight to the Lib directory and did not find the source. Regards, Martin From bill-bell at bill-bell.hamilton.on.ca Sat Nov 10 14:43:30 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sat, 10 Nov 2001 14:43:30 -0500 Subject: Using browser as interface to python app In-Reply-To: <1005415116.1063.70108.m5@yahoogroups.com> Message-ID: <3BED3D12.25441.124F68B@localhost> sandskyfly at hotmail.com (Sandy Norton) wrote, in part: > I've just been prototyping a simple multi-threaded internet news > monitor ... I can't claim to understand what you're doing ... > I thought about using CGIHTTPServer in the Standard Lib but its use of > forking doesn't make sense for Windows. OTOH, I'm also sure that > there's a COM way to do this somehow, but I'd really like to try to > make the end app as portable as possible. Another consideration is > distribution footprint...(we wouldn't want the user to have to > download and set up apache :-) How about Zope? Download is 5 Mbytes, extremely easy to install, includes web server. I've installed it for use by one of my smallest clients in maintaining their documentation. For what they need, it's very easy to maintain. Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From martin.franklin at westgeo.com Wed Nov 14 04:27:16 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Wed, 14 Nov 2001 09:27:16 +0000 Subject: PEP proposal: enhanced string functions References: Message-ID: <9stdc2$6abo$1@mail1.wg.waii.com> Matthew Dixon Cowles wrote: > On 13 Nov 2001 12:54:47 -0800, Stephen Ferg wrote: > > Steve, > >>Title: Optional pad character for string justification functions > > I like this. Me too. > >>Title: Optional argument for string strip functions > >> The proposal is to allow these functions and methods to take one >> optional argument in addition to the arguments that they now >> accept. The argument is called "stripchar". If the stripchar >> argument is unspecified or is specified as None, then these >> functions and methods will do exactly what they now do, and strip >> whitespace. If the stripchar argument is specified, and not >> specified as None, it must contain a single character. If the >> stripchar argument is specified, then rather than stripping out >> whitespace, the functions and methods will strip out the >> specified stripchar character. > > This bothers me a bit for the same reason that the split() method > does. It strikes me as weird that without arguments, split() splits on > all whitespace but that it will only take one character as an > argument. I'd prefer to be able to pass a sequence to strip() and have > any of those characters stripped. how about adding new methods stripc(), rstripc(), lstripc(), (or stripchar()) then maybe stripword() etc for what you want...... > > Regards, > Matt > From amitp at Xenon.Stanford.EDU Mon Nov 5 12:43:43 2001 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 5 Nov 2001 17:43:43 GMT Subject: python-mode for Emacs 21.1? References: Message-ID: <9s6j4f$fpe$1@usenet.Stanford.EDU> Roman Suzi wrote: | Is there python-mode for Emacs 21.1? | (My old one for 20.5 doesn't compile correctly, it seems) | | I wonder why python-mode not in standard Emacs distro... Having python-mode as part of the distribution was one of the things that made me switch to XEmacs. :-) - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From spike at oztourer.nl Mon Nov 19 12:35:58 2001 From: spike at oztourer.nl (Steve Pike) Date: Mon, 19 Nov 2001 17:35:58 GMT Subject: [ANN] PikiePikie 0.4 released Message-ID: <3bf94296.2561657@textnews.casema.net> 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 previous release are: - weblog paging and archiving - title lists can be generated for weblogs - preview of edited pages prior to commit - dollar and sterling amounts on a page can be totalled automatically - templates can now included PikiePikie formatting commands as well as native HTML - support for RSS (RDF Site Summary or Rich Site Summary) feeds 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 brian at rk-speed-rugby.dk Wed Nov 7 04:19:39 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 07 Nov 2001 10:19:39 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> Message-ID: Cliff Wells writes: > On Tuesday 06 November 2001 15:07, David Andreas Alderud wrote: > > > Having a non-declarative language as a first choice is bad, teaches them to > > write sloppy code. > > Yes and no. Like many others, my first language was BASIC (on an > Apple //e). Mine too on Commodore 64 . > Later, I took some CS > classes where we learned Pascal. I had indeed > developed some bad >habits due to language deficiencies in BASIC (everything > global, no >argument passing, jumping in and out of routines, etc). However, > it >was a good, simple introduction to programming and I like to think I > >wasn't permanently crippled by the experience. Me too. > That depends upon your perspective on what "good code" is. Code > that is easy to read? Easy to modify? One of Python's strengths is > that almost every line of code is related to solving the > programmer's goal rather than telling the compiler how to compile > the code. Not having a lot of extra statements that have nothing to > do with solving the problem results in cleaner, easier to understand > code. Exactly, you don't have to do it perfectly, when you start learning how to do it. In schools nowadays you are awarded for a cribbled, backwards, upside-down G, the first day and is punished for it two years after. I believe this must be the way you should teach programming, too. No reason to worry about all the perfectionist stuff at first. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From jeff at ccvcorp.com Thu Nov 15 18:56:43 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 15:56:43 -0800 Subject: PEP 276 Simple Iterator for ints References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> <9t0jko$14b$1@thorium.cix.co.uk> <3BF43EA3.42A5A4B6@ccvcorp.com> Message-ID: <3BF4563B.74A259DA@ccvcorp.com> David Eppstein wrote: > In article <3BF43EA3.42A5A4B6 at ccvcorp.com>, > Jeff Shannon wrote: > > > > >>> for i in int[2:10:2]: print i, > > > 2 4 6 8 > > > > > > > This doesn't look too bad to me. I'd go for it. > > Why is int[2:10:2] an improvement over range(2,10,2)? > > They have the same number of words and the same argument values with the > same amount of punctuation, the only difference to me is that int[2:10:2] > is in a much less familiar syntax. Well, to be honest, I have no problem with range()/xrange() as they stand. You're right, though, in that the int[:] notation doesn't gain anything. Thus, my vote (for what little it's worth ;) ) is to do nothing, and leave range()/xrange() as the proper way to do things. Jeff Shannon Technician/Programmer Credit International From wurmy at earthlink.net Tue Nov 27 21:47:43 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 28 Nov 2001 02:47:43 GMT Subject: function operators References: Message-ID: <3C045042.7A99705F@earthlink.net> "James A. H. Skillen" wrote: > > On Tue, 27 Nov 2001 01:43:34 +0000, James A. H. Skillen wrote: > > Thanks for the feedback from everyone. > Perhaps I should have made it clear: yes, I realise that my suggestions > can be done quite easily using classes and the magic methods. > > But any simplicity gained would be offset by the added hassle of wrapping > the functions with instances. > > I was just suggesting that __add__ etc. should be implemented for the > built-in "function" type. > > I can't see that it would make Python code that much harder to read, > indeed it would simplify things in many cases. > > There would be no ambiguity with classes that define both __call__ and > __add__, as > > f = a + b > > would *always* mean > > f = a.__add__(b). > > It would be up to the author whether to define __add__ to be equivalent > to: > > f = lambda x: a(x) + b(x). Yes, you have a point there. If the author wants his object to behave like a function, he goes for the lambda, otherwise for the addition. Well, I don't know. You could write a PEP for this, and see what Guido thinks about it. Personally, I am reluctant to welcome new features that can easily be done or emulated in Python itself. So many redundant features have been added lately... then again, YMMV. But every new feature is a step closer to creeping featurism and away from "Python the compact language". That is not to say that I don't like your idea. Heck, if "".join() made it into the language, why not this? ;-) --Hans From stephen at theboulets.net Wed Nov 28 00:05:08 2001 From: stephen at theboulets.net (Stephen Boulet) Date: Tue, 27 Nov 2001 23:05:08 -0600 Subject: windows to linux pickled objects? Message-ID: I pickled a list in windows but couldn't open it in linux without first running the handy dos2unix program on it. Is this expected behavior? I thought pickled objects were cross platform? To provide full disclosure, this might not be python's fault: The python script resides on an HPUX partition mounted to an NT box. The python that did the pickling is 2.1 for windows. From a unix shell I gzipped the picked file and used split on it. On linux at home I rejoined the parts with cat and gunzipped it. It went from 1.6 MB to 8.2 MB. Those pickles can get big. -- Stephen From peoter_veliki at hotmail.com Thu Nov 15 17:08:11 2001 From: peoter_veliki at hotmail.com (Peoter Veliki) Date: Thu, 15 Nov 2001 14:08:11 -0800 Subject: anonymous functions? class? Message-ID: I'd like to be able to use a function as an argument without declaring it externally. This is what I don't want to do: def func(): pass callFunc(func) I want to do this: callFunc(def func():pass) I'm guessing this can't be done because of python's indentation syntax. In ECMAscript (JavaScript) you can do this: callFunc( new func(){ blah blah } ) or something like that. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From ykingma at accessforall.nl Wed Nov 7 15:08:24 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Wed, 07 Nov 2001 21:08:24 +0100 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> Message-ID: <3BE994AF.3A757AB4@accessforall.nl> Jive, you wrote: > [snip] > > There's a pragmatic reason I'm asking for this feature. One of our > customers has suggested that we implement scripting using Python. I've > looked into Python, and I am very impressed with what I see. But I > would have grave misgivings giving it to customers with variable > declarations the way they are now. I'm not sure I could sell the boss > on it, and don't know if I would want to. The situation is quite > different from writing code on ones own computer to be used in-house. I suppose you know that using an unitialised variable will cause a NameError exception? > These programs will run equipment, often in foreign countries, that can > break literally a million dollars worth of merchandise, and could even > hurt somebody. It is very important to find bugs BEFORE a program goes If that is the case you might consider not using python, but a more typesafe language, and make sure that your customer only uses his own code _after_ inspecting and testing it thoroughly. Python is dynamic and not typesafe, which means that any object can do almost anything to any object at any point in time. For example when a class defines a method, that method can be overriden for any object of that class _dymically_, even while the overriden method is being executed. I have not tried it, but I would not be surprised if the method can even be removed from the class while the program is running. By the way, this dynamic nature would also render your proposed enhancement non functional: a variable can be deleted from some namespaces at any time. Using such a variable after its deletion will cause a NameError exception. > into production use. I won't have any say over who writes these > programs, but bugs that appear to be compiler bugs ("Why doesn't that > variable change when I assign to it?") will get bounced right to me. > > Of course, since the source code is freely available, I could implement > it on our copy only. But that would be inefficient. By your own > account, lots of other people want the feature also. > > Jive Regards, Ype -- email at xs4all.nl From deltapigz at telocity.com Mon Nov 5 23:50:13 2001 From: deltapigz at telocity.com (Adonis Vargas) Date: Mon, 5 Nov 2001 23:50:13 -0500 Subject: RE Module Question. Message-ID: i am trying to fidn specific word within a string and am unable to findanything suitable for it, i have tried looking into the RE module but it just is written in hebrew, and can not grasp any of it. looked into the python.org/howto's and under the library/module index and nothing i just cant understand it. is there a simple example to this or simple explanation? all i want to do is find i.e.: test = "this is a test" if "test" in test: print "found string." this is just pseudocode to get the concept im trying to achieve. any help would greatly be appreciated. thanks, Adonis From emile at fenx.com Fri Nov 23 09:12:45 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 23 Nov 2001 06:12:45 -0800 Subject: PLEASE OH PLEASE UNSUBSCRIBE ME! References: <3BF95C82.A5688F06@nrc.ca> <3BFA9EEF.61CFBC43@nrc.ca> Message-ID: <9tllql$3bkl0$1@ID-11957.news.dfncis.de> "Fredrik Lundh" wrote in message news:dEfL7.7732$Z_1.1276663 at newsc.telia.net... > wait until the mail arrives, delete it in Lady MacBeth manner, and re-post your plea! ;-) Out-damn-post-out!-ly yr's -- Emile van Sebille emile at fenx.com --------- From hungjunglu at yahoo.com Thu Nov 29 12:32:06 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 29 Nov 2001 09:32:06 -0800 Subject: which is best for a singleton, module or class? References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C045C07.BA7B3FE6@engcorp.com> <3C05AE56.E2261313@engcorp.com> <3c05b472$1@207.229.64.20> <3C05C9C3.ADC96FB5@engcorp.com> Message-ID: <8ef9bea6.0111290932.4afa618a@posting.google.com> Peter Bismuti wrote: > What is best for a singleton, making it a module or a class within a module? > I guess the reason why having a class within a module undesirable is that it > adds to the namespace of the object mymodule.mclass.property instead of > mymodule.property, and so fourth. I know you can import it in a way to > reduce the path length of the object, but still, it seems like a cleaner > coding style to just use the module itself. Opinions? THanks. You can simply put your object into the __builtins__ namespace: #--------------------------------------- class Spam: x = 0 def f(self): print self.x __builtins__.__dict__['eggs'] = Spam() eggs.x = 1 eggs.f() #--------------------------------------- Using modules is fine for singletons, but classes allows you things like inheritance. regards, Hung Jung From peter at engcorp.com Thu Nov 8 21:45:07 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 08 Nov 2001 21:45:07 -0500 Subject: Games Programmed in Python References: <9sahq0$qi1$1@slb6.atl.mindspring.net> Message-ID: <3BEB4333.20CAFB79@engcorp.com> nobody at nowhere wrote: > > Could somebody direct me to some examples of games programmed in Python? Have you tried google? http://www.google.com/search?q=games+programmed+in+python -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From wurmy at earthlink.net Tue Nov 13 11:14:39 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 13 Nov 2001 16:14:39 GMT Subject: Request for Validation of Python as Development Language References: Message-ID: <3BF146EC.723AF090@earthlink.net> "A. Keyton Weissinger" wrote: > > Does anyone have a more recent list of commercial products out there that > use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima > Online. I'd like more. I don't have a list, but I know about Xerox DocuShare and Severance: Blade of Darkness (a 3D shooter). Also, when I bought my new computer last week (a Hewlett-Packard Pavilion mx50), I found py152.exe in the hp/bin directory... hmmm... wonder what they did with that. --Hans From sholden at holdenweb.com Fri Nov 16 10:26:08 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 10:26:08 -0500 Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: <0baJ7.43107$vQ1.1408848@atlpnn01.usenetserver.com> "Skip Montanaro" wrote ... > > Huaiyu> So my question really is this: Is there any major practical use > Huaiyu> for an object to be unequal to itself? Would it be better to > Huaiyu> just define (a==b) to take a shortcut of (a is b), always? > > The "is" operator is defined to just do pointer comparisons. Here are just > three different ways to generate objects that are equal but not "is": > > >>> a = 457 > >>> b = 99+358 > >>> a is b > 0 > >>> a == b > 1 > > >>> a = "now is the time..." > >>> b = " ".join(a.split()) > >>> a is b > 0 > >>> a == b > 1 > > >>> a = [1] > >>> b = [1] > >>> a == b > 1 > >>> a is b > 0 > > In the first two cases perhaps Python could make sure that a and b shared > references to the same object, but I think that would require the > interpreter to do a lot more work just to maintain that consistency. > > In the last case you most definitely don't want "is" and "==" to be > synonyms. That would imply that a and b referred to the same object. If > they did, any list-modifying methods applied using one name would be > reflected when that object was viewed using the other name, which is > generally not what you want for mutable objects. > Skip, I think you just turned this discussion on its head. THe question you responded to was not "should equal values compare true with 'is'", but "is it useful for 'a != b' and 'a is b' to be true for the same a and b". regards Steve -- http://www.holdenweb.com/ From mwh at python.net Tue Nov 13 05:14:32 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 13 Nov 2001 10:14:32 GMT Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > Tim Bradshaw: > > Languages such as Perl and (I think) Python are *single instance* > > classes - there is only one implementation, and the language > > is defined implicitly by that implementation. > > As a minor clarification, there are several distinct implementations > of Python (or a Python-like language). The ones I know of are: [snip] But they very much take their lead from CPython, so Tim's points all remain valid. Well, except for vyper, but that doesn't have enough influence to count (perhaps unfortunately). Cheers, M. -- That one is easily explained away as massively intricate conspiracy, though. -- Chris Klein, alt.sysadmin.recovery From plakal at cs.wisc.edu Tue Nov 13 14:33:27 2001 From: plakal at cs.wisc.edu (Manoj Plakal) Date: Tue, 13 Nov 2001 13:33:27 -0600 Subject: wxPython & asynchronous i/o References: <9srhiv$uih$1@rhodos.FTA-Berlin.de> Message-ID: <3BF17587.50807@cs.wisc.edu> bernard wrote: > I'm thinking of using wxPython in an app that requires the use of sockets. > > Is there any way to handle socket events via the wxPython mainloop > or to use a select loop to 'implement' the wxPython mainloop - or am I on > the wrong track altogether ? Take a look at http://wiki.wxpython.org/index.cgi/LongRunningTasks Also see this xmlrpc-server mixin for wxPython: http://lists.wxwindows.org/pipermail/wxpython-users/2000-December/003935.html Manoj From prabhu at aero.iitm.ernet.in Tue Nov 6 12:25:33 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 22:55:33 +0530 Subject: Tkinter bind single key In-Reply-To: <3BE81420.FD104F8D@metaslash.com> References: <3BE81420.FD104F8D@metaslash.com> Message-ID: <15336.7437.296636.766979@monster.linux.in> >>>>> "NN" == Neal Norwitz writes: NN> John Hunter wrote: Try using the "dialog". In your example, NN> this would be root. ie: NN> root.bind('z', press_z) NN> I think I had to do this to get keys to work. Yes, I also had to do something like this. prabhu From logiplexsoftware at earthlink.net Tue Nov 6 19:23:57 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 6 Nov 2001 16:23:57 -0800 Subject: How much is set in stone? In-Reply-To: <3BE8724E.7482C881@ix.netcom.com> References: <3BE8724E.7482C881@ix.netcom.com> Message-ID: <01110616235702.19608@logiplex1.logiplex.net> On Tuesday 06 November 2001 15:29, Jive Dadson wrote: > I expected better from this group. I had skipped most of this thread because after reading you initial post, I saw that the feature you were requesting didn't interest me (and yes, I USE Python in commercial applications). However, after seeing this post, I had to wonder what happened later so I went back and read the entire thread. What I saw was people trying to have an intelligent conversation with you (with the occasional misunderstanding, as per usual in conversations on technical topics) and you getting more belligerent as you realized that others weren't seeing it your way. You expected better than... you? Don't bother responding as I'll simply "[dump] the rest of your message unread." -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From rdsteph at earthlink.net Sun Nov 25 18:08:56 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sun, 25 Nov 2001 23:08:56 GMT Subject: 11-15 new Python Books on the way! Message-ID: <3C017B53.EE277644@earthlink.net> A few days ago I posted book reviews on the 15 Python books I have read. Embarrassed by having read so many, and wondering how close I was to "completion", I decided to do some research and see how many total Python books were out there and how many more were soon to be published. I have now chronicled all I could find on my website. There are fully 11 new Python books I found, three at book stores, which another 8 more coming almost immediately! These new books include a Deitel and Deitel, two Python/web books, a text processing book, two XML books, and a lot more. That makes 15 + 11 = 26. And that doesn't even count the 3 newish Zope books I found and the one Jython book due out next month. Nor does it count the old Python and the Internet (by Guido et. al. and out of print) and the hoped for Alex Martelli Python Cookbook and Python in a Nutshell, nor a possible Bruce Eckels book. 15 + 11 + 4 +1 +3 = 34 possible Python books, and I didn't count two that I found with Python in the title along with other languages! Truly a surfeit of books. But, for what it is worth, I have listed all I could find out about them all at http://www.awaretek.com/plf.html I would appreciate it if anyone would send me a review of any of the new books, once they have read them, so I can add it to the website and also because it will help me decide which of the new ones to purchase. Any question of being a completeness freak and trying to own them all went out of my head when I saw how many are coming! But it would be nice to keep a log of book reviews of all the books; including if anyone disagrees with my reviews of any of the original 15, I would like to post that too out of fairness. Also I have now posted there a much more complete report on the Lightweight Languages Conference held at MIT a week ago Saturday. Looking back on how I spent my Thanksgiving week I am embarrassed to have spent so much time on this. I apologize for wasting bandwidth on here asking folks to look at what I did, but as I go back to work now I will just leave it there, and it would be nice to think some people might find some of it useful in the future Ron Stephens http://www.awaretek.com/plf.html From richard at bizarsoftware.com.au Thu Nov 29 16:33:10 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Fri, 30 Nov 2001 08:33:10 +1100 Subject: HOWTO: Programming S/MIME in Python with M2Crypto In-Reply-To: References: Message-ID: <200111292132.fATLWw368380@bigboy.bizarsoftware.com.au> On Thursday 29 November 2001 23:11, Graeme Longman wrote: > Please could you let me know exactly how you got this working. Is the > sendsmime() method you refer to the same one that is given in the HOWTO ? It's equivalent code. > Or is there another smime method which is part of the python package ? > > I've been trying to get the examples in the HOWTO to work with Netscape > Messenger and haven't been able to. They should work fine - there's nothing at all special about those examples. Richard. From huaiyu at gauss.almadan.ibm.com Tue Nov 6 21:19:32 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 7 Nov 2001 02:19:32 +0000 (UTC) Subject: How much is set in stone? References: <3BE8724E.7482C881@ix.netcom.com> Message-ID: On 06 Nov 2001 23:29:57 GMT, Jive Dadson wrote: >I expected better from this group. > >Jive Presumably this is your reaction to the comments about your proposal. Suppose someone says, "It's an idiotic idea", don't take it personally. Suppose someone says, "Only idiot can have this idea", do take it personally. The comments in this thread have been much nicer than both. If there is an impression (real or imagined) that certain proposal was due to unfamiarity with Python or prejudice carried from other languages, and have well-known deficiencies, don't you expect people to say so? It appears that's exactly what people are saying. If you care about the idea, the only way to proceed is to demonstrate that it is well thought-out, by explaining it well and rebuke all the counter arguments. Believe me, for any comments on any article, there are many more people who have given it a thought but let others comment. An idea posted here is often considered more thoroughly than many papers in journals. Huaiyu From not.this at seebelow.org Sun Nov 4 23:25:30 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sun, 04 Nov 2001 22:25:30 -0600 Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: <3BE614BA.BAB07827@seebelow.org> Cliff Pruitt wrote: > > Hello, I've just started looking into Python and am considering delving into > it a bit. My main reason is that it seems to be pretty portable across > platforms. Perl and TCL are quite portable as well, so you might also want to consider them. I won't go into a comparison of Python to those except to say that Python's major strength compared to those is its clean, simple constructs and syntax--which make it much easier to learn, write, and read. Very important! > I work on a Mac for the most part but I do work on windows > machines durring the day and it would be fun (I think) to develop for both. > So far I've downloaded the Python files and flipped through a little bit of > the documentation but haven't gone into much detail with it. I'm wondering > if anyone could sort of give me a good idea of what Python is really capable > of and maybe more importantly what it's NOT capable of. If speed is a big issue, a scripting language of any kind is probably not a good choice. What I use Python for (and I used to use Perl for, before I discovered Python) mostly falls into the category of "off-line data processing", e.g. file-format conversion, extracting statistics from data files, etc. In those cases, speed-of-execution isn't a big concern, yet speed-of-development _is_ a big concern. That's the essential tradeoff: execution speed versus development speed. Once you get good at it, you can develop a given application in Python faster than just about anything else (or at least that's true for me.) In that vein, Python is sometimes used for prototyping that you think might eventually end up being written in a compiled language. > The extent of my > programming experience involves VBScript for the web. If i had, say, a > microsoft access Database, is python capable of displaying records and doing > searches on that database? Maybe more importantly is it capable of adding > records? Sure. Python's has a large and useful standard library, as well as a lot of nice third-party applications. > Out of curiousity, what are the nicest or most complex > applications you've seen done in Python? A lot of what I've read referrs to > Python as being useful as "glue" to hol dother languages like C++ and others > together. This is to get the best of both worlds. Experience shows that only certain parts of even speed-sensitive applications need to be speedy; most of the speed (or lack thereof) is due to a small portion of the code. Therefore, you can code, say, 20% in C/C++ (for execution speed) and code the remaining 80% in Python (for development speed.) Although I think this is a good idea, I haven't personally done it, for whatever reason. Instead, I've typically coded speed-sensitive things entirely in C/C++, and non-speed-senstive things entirely in Python. > I dont know any of those so I'm wondering if Puthon will really > be somethign useful to learn or not. If folks in this newsgroup told you "no", they'd probably think they were lying . Learning Python will make you a better programmer (as learning nearly any new language probably would). But beyond that, I view it as a very significant tool in my toolkit. In fact, I think all professional programmers should learn Python (or at least another scripting language). We programmers do a lot of everyday tasks that are quite painful to program in C/C++, yet pretty easy in Python. For example, any form of text processing is pretty easy to whip out in Python in an hour or so, yet the equivalent C/C++ program might take days to do. (I find that sort of thing to be a common task, even though my "real" programming work is to write C/C++ for embedded systems.) Think of Python as a screwdriver that you suddenly realize is a better way to screw in the screws you've been hammering (with C/C++) because you didn't know there was such a thing as a screwdriver. That's not to say, though, that your screwdriver is the best choice for hammering in nails, so don't throw away your hammer. > Your insight is greatly appreciated. thanks-for-listening-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 gmcm at hypernet.com Wed Nov 7 15:25:21 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 07 Nov 2001 20:25:21 GMT Subject: A smarter(?) package importer. References: Message-ID: Prabhu Ramachandran wrote: >>>>>> "GMcM" == Gordon McMillan writes: [snip] > GMcM> If you *don't* cache failure, you get 3 (4 on Windows) > GMcM> attempted opens per directory that you could have avoided. > > Well, I'm not sure it does 3/4 opens but yes it does do 3/4 > imp.find_modules which will be more expensive than a > sys.modules[mod_name]. It really does do all those opens. If Windows had strace, it would be easy to verify. [back to recursive-relative imports] > So, I'll ask again, how about making this behaviour standard? :) I think not. I'd rather see import get less magical than more magical. If "import" meant "absolute import", and "rimport" meant "relative import" (and maybe "rrimport" meant "recursive relative import") then all name- masking problems would disappear. - Gordon From jeff at ccvcorp.com Wed Nov 21 14:53:17 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 21 Nov 2001 11:53:17 -0800 Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> <9tdhon$aht52$1@hades.rz.uni-sb.de> Message-ID: <3BFC062D.F6DB3F1F@ccvcorp.com> Glenn R Fulford wrote: > "Huaiyu Zhu" wrote in message > news:slrn9vlstk.4ut.huaiyu at gauss.almadan.ibm.com... > > > > Mathematicians do not really care about whether the index starts with zero > > or one. They just need some index, which could start from 42 if you want. > > But when they do care, such as defining the axioms of natural numbers, > they > > seem to prefer starting from zero as well > > On the other hand, most work with matricies has indexing starting from 1. > Noone uses matrix indices (0,0). Note that MatLab does it's indexing from 1, > and I thought that nupy is thought of as a replacement for matlab? The whole > idea of using software to do mathematics is to have a language which feels > natural to translate the maths into the program. > > . I initially learned > > programming in Fortran, but when I learned C later it felt much more > > natural. I guess some other people might feel the same way too. > Not me! For a good explanation of why zero-based indexing is a *very* good idea in programming, read this lovely explanation by (the much missed) Alex Martelli: http://groups.google.com/groups?q=g:thl3498076713d&hl=en&selm=9dhrmn0308b%40news1.newsguy.com (all one line, in case that gets broken...) It typically does take a little bit to adjust to, but once that adjustment is made, off-by-one errors are *much* less likely than with 1-based indexing. Jeff Shannon Technician/Programmer Credit International From tdelaney at avaya.com Mon Nov 5 20:23:11 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 6 Nov 2001 12:23:11 +1100 Subject: Considering getting into Python... Any Pros-Cons? Message-ID: > From: d_blade8 at hotmail.com [mailto:d_blade8 at hotmail.com] > > I agree with everything said here (for the most part), but I think it > is all a bit biased (most readers of this newsgroup are python progs) Actually, only a few readers are python progs ... see the effbot, TimBot, MartelliBot, etc. Tim Delaney From uwe at rocksport.de Thu Nov 8 04:35:01 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 8 Nov 2001 09:35:01 GMT Subject: Numerical Python Bug ? References: <9sbs59$96vag$1@hades.rz.uni-sb.de> Message-ID: <9sdjk5$9bpf8$1@hades.rz.uni-sb.de> Prabhu Ramachandran wrote: |>>>>> "US" == Uwe Schmitt writes: | US> Hi, during a *large computation* I get problems with vectors / | US> arrays: | Can you reduce this to a problem that others can reproduce? If so | that would most probably get you a more relavant answer. Simple tests | on Numeric seem to work fine for me. No, thats my *problem*. Me myself can only reproduce it in my "big" programm, neither on the commandline nor in a small testprogram. What shall I do ? Are there any pyhton-gurus who are interested to examine my program ? Yours, Uwe. -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From brian at sweetapp.com Thu Nov 29 22:34:37 2001 From: brian at sweetapp.com (Brian Quinlan) Date: Thu, 29 Nov 2001 19:34:37 -0800 Subject: What's the value of "None" between 2.1.1 and 1.5.2 In-Reply-To: <3C06FB65.B27A6A12@earthlink.net> Message-ID: <005a01c1794f$efbe2dc0$445d4540@Dell2> > >>> class MuchoGrande: > def __cmp__(self, other): > return 1 # larger than anything else > def __repr__(self): > return "MuchoGrande" > I'd change that to: def __cmp__(self, other): if ininstance(other, MuchoGrande): return 0 else: return 1 That way you the result of cmp won't depend on the order of the arguments. Cheers, Brian From sholden at holdenweb.com Thu Nov 29 07:39:03 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 07:39:03 -0500 Subject: message returned by poplib to email.Messge instance References: <1103_1007015547@news.mindspring.com> Message-ID: "Aaron Sterling" wrote in message news:1103_1007015547 at news.mindspring.com... > Hi, > > The poplib.POP3.retr() method returns a tuple (size_string, content_list, size_int). The email package provides a > function message_from_string(string) that returns an object tree describing the string as an rfc2822 message. My > problem is in how to convert content_list into a string that message_from_string will recognize as a multipart > message. What I have so far is > > msg = email.message_from_string('\n'.join(content_list)) > > this executes without error. It is a message object but: > > >>> msg.is_multipart() > 0 > > I know it is a properly formatted message, because I made it myself, using email package, and check its validity by: > > >>> message.is_multipart() > 1 > > as well as succesfully extracting all of the information I need to from it. I send it over the internet with smtplib. I send it > directly to my isp's smtp server, as i believe smtplib is supposed to be used. > > to do this I use smtplib.SMTP.sendmail(fromaddr, toaddr, str(message)) > > I am fairly sure that stringing the message is not causing the problem, as smtplib requires a string and: > > >>> message = email.message_from_string(str(message)) > >>> message.is_multipart() > 1 > > any light that could be shed on the issue would be greatly appreciated. > It's possibly as simple as the ommission of carriage returns? Offhand I don't remember for sure, but I suspect that missing CR's can cause problems. Here's an example I use in "Python Web Programming" - it uses a StringIO to stringify the message, but apart form that it's probably not too different from your code (cStringIO would be faster...): import poplib import rfc822, sys, StringIO SRVR = "mymailserver.com" USER = "user" PASS = "password" try: p = poplib.POP3(SRVR) except: print "Unable to contact server %s" % (SRVR, ) sys.exit(-1) try: print p.user(USER) print p.pass_(PASS) except: print "Authentication failure" sys.exit(-2) msglst = p.list()[1] for m in msglst: mno, size = m.split() lines = p.retr(mno)[1] print "----- Message %s --------------" % (mno, ) file = StringIO.StringIO("\r\n".join(lines)) msg = rfc822.Message(file) body = file.readlines() addrs = msg.getaddrlist("to") print "%-15s %s" % ("Recipient", "Email Address") for rcpt, addr in addrs: print "%-15s %s" % (rcpt, addr) print len(body), "lines in message body" print "-------------------------------" p.quit() sys.exit() -- http://www.holdenweb.com/ From fperez528 at yahoo.com Sun Nov 18 08:53:02 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 19 Nov 2001 13:21:02 +2328 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> <3BF429F1.146759EA@ccvcorp.com> <9t9bk1$np2$07$1@news.t-online.com> <3BF96692.77666218@ccvcorp.com> Message-ID: <9tbpo9$g2l$2@peabody.colorado.edu> Jeff Shannon wrote: > Or, alternatively > > import operator > > def bool(x): > return operator.truth(x) simpler: bool = operator.truth More pythonic, more efficient (one less function call). cheers, f From bhs3133 at aol.com Thu Nov 1 18:03:00 2001 From: bhs3133 at aol.com (BHS3133) Date: 01 Nov 2001 23:03:00 GMT Subject: Learning Python Message-ID: <20011101180300.21692.00000997@mb-mr.aol.com> What is a good tutorial for learning Python? From sheershion at mailexpire.com Sat Nov 24 11:31:49 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Sat, 24 Nov 2001 16:31:49 -0000 Subject: getting string parameterz in pyd References: <39ce62b8.0111240404.1a952eeb@posting.google.com> Message-ID: Ens wrote: > i have a problem in getting a string parameter with > > PyArg_ParseTuple(args, "s", &s) // s is (char*) > > length of string is unknown and i want to get > strings of any length. Well, the *obvious* answer is to use strlen() from the standard C- library. However, if the string can contain null-bytes that doesn't work, and then you *must* do someting like: PyArg_ParseTuple(args, "s#", &s, &len) // s is (char*), len is int For more information, and a plethora of other formatting options, read the format string specification in the Python documentation: chapter "Extending and Embedding", section 1.7: "Extracting Parameters in Extension Functions". (I know, you'd expect to find detailed information like that in the "Python/C API" chapter, but it isn't.) Robert Amesz From fperez528 at yahoo.com Wed Nov 14 11:54:26 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 15 Nov 2001 16:22:26 +2328 Subject: Scientific Libraries in Python References: Message-ID: <9t1iqq$es0$2@peabody.colorado.edu> I'd like to draft a rough map of the problem landscape. Hopefully it will help us get oriented. Comments and extensions encouraged. Please note that the summaries and other information are straight cut'n'paste from the various websites. I'm going to include a few things beyond just numerical libraries, going into graphing. I just don't think any system today is a realistic competitor to things like IDL or Matlab if it doesn't have immediate access to a professional quality graphical engine. I won't bother mentioning Numeric in detail. It's obviously a given base for the rest. *************** Libraries: SciPy at http://scipy.org ----- Summary: SciPy--an open source library of scientific tools for Python. SciPy supplements the popular Numeric module, gathering a variety of high level science and engineering modules together as a single package. Within SciPy are modules for graphics and plotting, optimization, integration, special functions, signal and image processing, genetic algorithms, ODE solvers, and others. There is also an experimental "compiler" that takes a Numeric array expression in Python and compiles it to C++ code on the fly. Version: SciPy 0.10 released 2001-08-20 Comment: This seems to be by consensus the horse to bet on as a base platform. It seems to have a great architecture and very good ideas (the compiler is *really* cool). But its coverage is still very patchy. ScientificPython at http://starship.python.net/crew/hinsen/scientific.html ---------------- Summary: ScientificPython is a collection of Python modules that are useful for scientific computing. In this collection you will find modules that cover basic geometry (vectors, tensors, transformations, vector and tensor fields), quaternions, automatic derivatives, (linear) interpolation, polynomials, elementary statistics, nonlinear least-squares fits, unit calculations, Fortran-compatible text formatting, 3D visualization via VRML, and two Tk widgets for simple line plots and 3D wireframe models. Version: 2.2 Comment: very good quality code, only covers certain things. Several people advocate integrating its functionality into SciPy, doing a good job of unformizing naming conventions (and calling the whole thing Scientific). Personally I tend to agree with that general idea. GSL -- The GNU Scientific Library at http://sources.redhat.com/gsl --------------------------------- Summary: The GNU Scientific Library (GSL) is a collection of routines for numerical computing. The routines are written from scratch by the GSL team in ANSI C, and present a modern Applications Programming Interface (API) for C programmers, while allowing wrappers to be written for very high level languages. Version: 1.0, released 12 November 2001 Comment: I think this should be a critical piece of the puzzle. There's a ton of good, difficult work already done here, it would be silly to replicate it. See next topic. There may be licensing issues that need to be addressed. PyGSL at http://sourceforge.net/projects/pygsl ----- Summary: python interface to gsl library Version: gsl-0.0.3 May 23, 2001 Comment: this is the complement to GSL: someone has already done the python bindings (or is working on it, at least). So pygsl going into the main project would automatically give us access to gsl. Ideally, wrappers could be generated to make ufunc versions of all the functions there so that calling them on Numeric arrays could be done efficiently. GMP at http://www.swox.com/gmp --- Summary: GMP is a free library for arbitrary precision arithmetic, operating on signed integers, rational numbers, and floating point numbers. Version: GMP 3.1.1 has been released (2000-10-10) Comment: for some applications having arbitrary precision floating point is critical (Python already has native long ints). This is the base library, see next for python. mxNumber at http://www.lemburg.com/files/python/mxNumber.html -------- Summary: Extended Numeric Types for Python (a wrapper around GMP). Version: 0.4.0 Comment: well, brings the (IMHO necessary) GMP into the game. GMPY at http://gmpy.sourceforge.net ---- Summary: same as above. Appears stalled at 0.9 pre-alpha. GMP Extension Module at http://www.amk.ca/python/code/gmp.html -------------------- Summary: same as above, but says that GMPY is more active and complete. Comment: either mxNumber, GMPY or GMP Ext. Mod. will do. Find the best currently, and make it actually work. This is fairly typical of open-source projects: 3 versions which half-work, and not a single complete solution. *************** Visualization: Janko Hauser has a nice summary page at http://starship.python.net/crew/jhauser/plot-res.html so I won't repeat all that here. I think it's a bit outdated though. So below I'm going to list the things I think are currently realistic tools (not every piece of python code under the sun that can paint a line). gracePlot.py at http://azathoth.caltech.edu/~n8gray/code ------------ Summary: This module provides interactive 2-D plotting capabilities via the Grace package. Version: 0.5 Comment: grace is a very solid tool, though it's only 2D. But I think this is a great model of how a full-blown tool should work: scripting access, convenient for interactive at the python prompt, and with a gui for plot fine-tuning. Gnuplot.py at http://gnuplot-py.sourceforge.net ---------- Summary: This is a Python interface to the gnuplot plotting program. Version: 1.5 Comment: gnuplot is pretty powerful, especially with the new additions that support colormaps on 3d plots. But I don't know how realistic it would be to extend it to volume rendering (it only does 2d surfaces in 3d). MayaVi at http://mayavi.sourceforge.net ----- Summary: MayaVi is a free, easy to use scientific data visualizer. It is written in Python and uses the amazing Visualization Toolkit (VTK) for the graphics. It provides a GUI written using Tkinter. Version: 1.0 (I believe a new one is coming up soon). Comment: this seems the most promising tool to me from what I've seen, though it's pretty 'heavyweight'. If a good interface can be made for interactive prompt use and python scripted control, I think it's a winner. I don't know how it handles 2d plots (if at all). But I tend to think it's easier to add 2d functionality to something like this rather than growing a 2d or basic 3d tool into a full blown visualizer that handles volume rendering. *************** Final comment: that's what I see as the key players at this point. In my ideal fantasy world, a single 'import ScientificTools' (whatever you want to call it) would give me python access to all the above functionality, with a sane overall naming structure. Once this fantasy world is a reality, we worry about symbolic tools. I can live without those (using Mathematica separately) for a while. A stopgap solution would be a good interface to Mathematica (I've seen one, don't know how good it is though). Well, this is long but hopefully useful to help a bit the decision-making. Fire away, f. From mal at lemburg.com Fri Nov 16 07:00:15 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Fri, 16 Nov 2001 13:00:15 +0100 Subject: [Python-Dev] Re: PEP 276 Simple Iterator for ints References: <15347.37907.247581.153829@beluga.mojam.com> Message-ID: <3BF4FFCF.60FA6513@lemburg.com> Skip Montanaro wrote: > > >> Below is the first draft of PEP 276 "Simple Iterator for ints". > >> (Available at http://python.sourceforge.net/peps/pep-0276.html) > >> > >> Feel free to comment (positive, negative, bipolar, or in between ;-). > > I liked "for i in 10:" at first, however, the more I see of the Haskell > iterator syntax, the more I like it. Given that > > * it should cause no backward compatibility issues (you can't put "..." > in a list now, can you? NumPy?) > > * it completely replaces range and xrange, not just one use of it > > * it can be made to work for floats, strings and possibly other builtin > data types as well as ints > > * you can optimize it well > > I would tend to view the int-as-iterator as a wart (a neat sort of wart, but > a wart nonetheless), while the Haskell syntax is elegant and seems to fit in > well with existing Python usage. I agree with Skip. Skip, could you tell us more about the Haskell syntax for these things ? Here's a slightly different approach which works now (= it doesn't even require a PEP :-): With the new iterator support in Python, it should be easily possible to write a module which exposes a singleton infinite sequence called e.g. "integers". Then, using the slicing notion we already have in Python, you could write: for i in integers[0,...,10]: print i for i in integers[0:11]: print i for i in integers[0:10:2]: print i for i in integers[0,...,10:2]: print i (or other wild combinations of slice objects and ellipsises) The same would work for any other number type for which slices can reasonably well express a finite sub sequence of the possibly infinite base range, e.g. floats, natural numbers, (finite) fields, prime numbers, rational numbers, Unicode characters, arrays, etc. The above notation obviously looks very natural to mathematicians, not sure about Joe User though. Hmm, seems like a nice addition for my mxNumbers package. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From ecifreo at austin.rr.com Mon Nov 26 17:02:10 2001 From: ecifreo at austin.rr.com (Eric Cifreo) Date: Mon, 26 Nov 2001 16:02:10 -0600 Subject: calling method on dynamically loaded module Message-ID: <3c02bb13$0$11289$39cecf19@nnrp1.twtelecom.net> Hello all, I'm trying to dynamically load a set of modules and then call a specific method on each one. For now there's only one module in the list. The module seems to be loading correctly, but then the method is not found. There IS a 'perform' method defined in the loaded module. I have the following code snip: ##### for mod in self._modules: (fp, pathname, descrip) = imp.find_module(mod) mymod = imp.load_module(mod, fp, pathname, descrip) print ">>>>> my mod is", mymod meth = getattr(mymod, "perform") print "getattr returned", meth meth() print ">>>>> Called perform" ##### When it executes, I get: ##### >>>>> my mod is exceptions.AttributeError 'snmp_mod' module has no attribute 'perform()' ##### Is there any way to do this? Thanks, Eric Cifreo Austin, TX From sheershion at mailexpire.com Tue Nov 13 17:17:18 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Tue, 13 Nov 2001 22:17:18 -0000 Subject: Obfuscator for Python? References: Message-ID: Amitabh wrote: > I wanted to know if there are any products which obfuscate the > python byte code so that it cant be reverse engineered easily? The best code obfuscator is a novice programmer. ;-) Robert Amesz From geert at cs.uu.nl Thu Nov 8 06:00:52 2001 From: geert at cs.uu.nl (Geert-Jan Giezeman) Date: 8 Nov 2001 11:00:52 GMT Subject: Shelve problem: why so big? Message-ID: <9sdol4$2te$1@samos.cs.uu.nl> I am trying to create a shelve from a table of 1100 by 1100 floating point numbers, which I want to store as 1100 lists of length 1100, indexed by a key. Unfortunately, I get an error when I try to create this: bsddb.error; (22, Invalid argument) When I store smaller lists (I tried up to size 1100*600), there is no problem. My guess is that this has to do with the file size. Even with the shorter list the size of the file is 1.01 GB (1,090,331,648 bytes). Continuing in guessing mode, it could be that at a certain moment the size of the file is doubled and that this fails. (I don't know exactly how large files can get on an NTFS file system, but a 2GB maximum does not sound unreasonable). Now on to the questions: 1) Are those large filesizes for shelves normal? A bare minimum for storing the data would be 8*1100*1100 = 9,681,000 bytes. So pickling and database overhead would be a factor 100. 2)Are there ways to circumvent those problems? Use a different database (I like shelves, though), ... From eppstein at ics.uci.edu Thu Nov 15 14:50:59 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Thu, 15 Nov 2001 11:50:59 -0800 Subject: PEP 276 Simple Iterator for ints References: <3BF40F8A.378CC6F8@ccvcorp.com> Message-ID: In article <3BF40F8A.378CC6F8 at ccvcorp.com>, Jeff Shannon wrote: > Which is exactly why I think that the Haskell-ish syntax is a bad idea. This > syntax cries out to be a closed interval, and it would be very confusing if > used as a half-open interval. But that would make it the *only* case of > Python using a closed interval. I find that inconsistency to be *far* more > jarring than the use of range(). I don't buy this argument. Currently AFAIK the *only* cases of Python using intervals at all are range() and xrange(), which I've argued are unsatisfactory -- what's the point of changing to something better if you require it to be consistent with the bad solution currently in place? Don't tell me it's for consistency with C, either -- in C, closed and open intervals are equally easy. Let me see if I can list some likely uses of ranges: - Loops over the elements of a sequence. Better handled by "for item in sequence" or, as someone recently suggested, "for index in indices(sequence)". - Numbering lines of output. Most commonly done from 1..n instead of from 0..n-1. - Functional programming e.g. "def factorial(n): reduce(multiply,range(1,n+1))" vs "reduce(multiply,[1,2,...n])". A closed interval would be more natural. - Loops where you want to execute a given number of times but you don't actually use the index within the loop. "for index in range(n)" and "for index in [1, 2, ... n]" are equally natural. - Dynamic programming type algorithms as in the lecture notes I cited earlier. It's not uncommon to see loops over ranges like [0, 1, 2, ... n], for instance I think this is the natural way to index the longest common subsequence dynamic program. It's also not uncommon for some of the loop indices to run backwards. These are very unnatural to express in half-open format -- e.g. the interval above is range(0,n+1,1) or shorter range(n+1) while the backwards one is range(n,-1,-1) -- quick, which -1 is the increment and which is the end of the interval? Looking through the Python code I've worked with recently, I found only one example of range, in code by Thierry Bousch for reading EXIF data: for i in range(entries): do something with (ifd + 2 + 12*i) It seems to me equally straightforward to do this as a 1-based closed interval: for i in [1, 2, ... entries]: do something with (ifd + 12*i - 10) -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From tim at vegeta.ath.cx Fri Nov 9 19:45:41 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sat, 10 Nov 2001 00:45:41 GMT Subject: newbie Python OO vs Tcl References: Message-ID: Chris Liechti graced us by uttering: [ snip ] >> Is there anything similar in Tcl? So far I can only think of its lax >> syntax... > > i don't know TCL. so i would definetly take python and i guess the other > 99% in this newsgroup would vote for python too, especialy as this is the > python newsgroup / mailing list ;-) While a good number of posters in c.l.p.m _do_ know Tcl, I'm sure that, given a choice between Python and Tcl, most Perl-mongers would choose Python as well. In fact, one of the few reasons many people even have Tcl around (Tk) may be phasing out in favor of wxPython (and wxPerl, etc). BTW, what with the occasional anti-perl sentiment in this newsgroup, it would be a good idea for the OP (and anyone else) not to tout "lax syntax" in any remotely positive way. ;) -ly yrs, Tim Hammerquist -- A woman is like your shadow; follow her, she flies; fly from her, she follows. -- Chamfort From tim.one at home.com Fri Nov 2 14:05:06 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Nov 2001 14:05:06 -0500 Subject: Underscore data hiding (was python development practices?) In-Reply-To: <01110209341800.09296@logiplex1.logiplex.net> Message-ID: [Cliff Wells] > People keep insisting that the Python development team won't introduce > changes that break backward compatability. Who cares what people keep insisting? Certainly not the Python development team . Here's the plain truth: Guido considers backward compatibility to be very important, but not an absolute criterion. There is nothing in Python's design that rates "absolute" status. Every decision is a tradeoff among competing desires, and people who want backward compatibility to win every time are doomed to occasional outrage; ditto people who give infinite weight to "runtime speed", or "obviousness (to me)", or "saving keystrokes", or "more like language L", or "runs on 19-bit minicomputers from 1967", etc etc. That said, Python's name-hiding conventions meet their modest design goals, and not a one of them has ever been changed. New gimmicks have been added every few years, most recently that __all__ at module level can be used to limit the names sucked up by "import *". > ... > However, I would definitely be wary of making my code depend upon > something like the name-mangling scheme, I don't expect it will change (although new gimmicks may be added). > which is clearly a hack Guido didn't think so (and every complaint ever made about it was made at at least once before it was implemented, so the odds of a compelling new argument are approximately nil). > and actually seems a likely place to see a future change. That's only because you think it's a hack . Python *used* to have an "access" keyword, implementing an elaborate name-visibility scheme of the kind some people favor. Guido dislike it so much he never documented it, and eventually ripped out all the code in support of it (making "access" the only keyword ever removed). expected-__tim-to-be-a-mangled-tim-until-he-dies-ly y'rs - tim From sdm7g at Virginia.EDU Fri Nov 30 11:04:08 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 30 Nov 2001 11:04:08 -0500 (EST) Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: <20011130154407.S27931@phd.pp.ru> Message-ID: On Fri, 30 Nov 2001, Oleg Broytmann wrote: > > Jonathan Gardner wrote, in part: > > > They'd have to be [young]. I can't seem to find a place to get paid to work in > > > Python yet. I can't imagine a guy with 3 kids trying to make a living > > > by programming python unless he is the rare guy that has a job in it. > > I am 34 yo, with exactly 3 children. For more than 5 years I earn living > by Web programing using Python and ONLY Python (I mean Python as a > programming language; of course I use SQL, write JavaScript, but not Perl, > for example.) I'm 49, omnivorous, married, with 3 children, 2 dogs and 1 cat, programming mostly in Python, C and Lisp, with a little dabbling in Java, C++ and Objective-C. And all those youngsters I met at the very first Python workshop are all about 10 years older now. -- Steve Majewski From MarkH at ActiveState.com Fri Nov 2 21:43:07 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Sat, 03 Nov 2001 02:43:07 GMT Subject: Need to improve COM performance References: <13b4aacf.0111020720.1f12039c@posting.google.com> Message-ID: <3BE359F8.9020900@ActiveState.com> Tom Fenn wrote: > Hello, > > I'm working on an application that involves calculating some > statistics for data produced by a commercial scientific instrument > (ion trap mass spectrometer). The code works, but takes longer than I > expected to execute. I ran the profiler on it, and got the following > results (which are sorted on cumtime and percall). Access to the data > file is through a COM control provided by the manufacturer. I've > wrapped it using genpy, and then wrapped an easier to use class around > the component. If I read the profile data right, the program is > spending 14 of its 15 minutes of execution time in the ApplyTypes > routine from PythonCOM. Is there anything I can do to speed this up > from within Python? Would implementing the Python class in C++ > improve performance significantly in this case? Happily, the > application is spending only a few seconds in my own code. If you look at _ApplyTypes_, you will notice it is a single line: return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) The time for _get_good_object_ is accounted for in the profile stats. The rest of the time is being spent in InvokeTypes. - ie, in some *other* COM object. ie, I think that all this is telling you is that the COM object you are calling is taking all the time, not your Python code. Mark. From jdadson at ix.netcom.com Thu Nov 1 23:01:21 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 02 Nov 2001 04:01:21 GMT Subject: Source files? References: <3BE200BA.3F271DA0@ix.netcom.com> <7x668toosz.fsf@ruckus.brouhaha.com> Message-ID: <3BE21A76.F6E72CDA@ix.netcom.com> Paul Rubin wrote: > > Jive Dadson writes: > > I just learned about Python a couple of days ago. A customer suggested > > we use it (rather than Java) for an application interface. So, I > > downloaded the latest beta version, Python-2_2b1.exe, and installed it. > > I was under the impression that it came with open source. I can't find > > any source files. Dot-h, yes. Dot-c or dot-cpp, no. How does one > > obtain them? > > They're at www.python.org, you must have just not downloaded the right > tarball. I didn't download a tarball. I downloaded a .ext ("shield"), as the instructions said Windows (spit!) users should do. I'll try downloading the tarball. Jive From erno-news at erno.iki.fi Sat Nov 10 07:08:31 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 10 Nov 2001 14:08:31 +0200 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> Message-ID: In article <7xadxv9wun.fsf at ruckus.brouhaha.com>, Paul Rubin writes: | The security issue with pickle.loads that we spent a long time | discussing is something I think the perl developers would not have | tolerated. could you describe the security issue in some detail? -- erno From pinard at iro.umontreal.ca Wed Nov 14 18:10:01 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 14 Nov 2001 18:10:01 -0500 Subject: How to marshal a function? In-Reply-To: <01111413063906.04702@logiplex1.logiplex.net> References: <01111412544105.04702@logiplex1.logiplex.net> <01111413063906.04702@logiplex1.logiplex.net> Message-ID: [Cliff Wells] > The mechanism you are using (remote execution of python code) introduces a > big security hole (in your current setup this may not be much of an issue > for you, but think of the children!). Why do you say that? I remotely start the Python server using a shell, and doing things through that server, rather than using the shell without the server, is about the same to me, permission-wise. As we do not gain nor loose any permission, I do not see how we introduce a security hole. Besides, I feel a bit safe as I channel these Python services through `ssh', which provides enough user authentication for us, so I presume. If merely using a shell is a big security hole, I'd rather unplug the machine from the power outlet! Some practical considerations apply, here! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From roy at panix.com Thu Nov 29 08:51:04 2001 From: roy at panix.com (Roy Smith) Date: Thu, 29 Nov 2001 08:51:04 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote: > CVS is a layer over RCS that lets multiple people work on the same > files at the same time, and automatically merges their changes at > check-in. That is certainly the theory, but I'm not sure how well it works in practice. I use CVS on a fairly large project (my team of 10 people deals with about 2500 source files, and that's about half the whole project). For us, the real advantage of CVS vs. RCS is the ability to keep our sources on a remote server (yes, we could probably do the same thing with RCS over NFS, but we're not big NFS fans). The relatively new http front end to CVS also makes a really cool source browser. Although we do not enforce it with locked checkouts, we really prefer to work in the "one person editing a file at a time" mode. If we ever go to check a file back in and discover it's got changes to merge from somebody else's work, we generally consider that a problem, and at the very least, manually verify that the merged changes make sense. We organize our stuff so it's very modular -- lots of small files, each with a very self-contained bit of code. If two different people find themselves working on the same source file at the same time, it's more likely to be a breakdown in intra-team communication than anything else. I could see how with a project organized differently, that might not be the case. But, to make a long story short, for a small project, with just one person working on the code, and more importantly, will all the development happening on a single machine, RCS should do just fine and it's probably simplier to learn and set up. Does anybody actually use SCCS any more? We've been watching subversion (http://subversion.tigris.org/) with interest, but I'm guessing it's six months to a year before it'll be stable enough to risk running a major production project on it. From cfelling at iae.nl Thu Nov 29 16:46:16 2001 From: cfelling at iae.nl (Carel Fellinger) Date: 29 Nov 2001 22:46:16 +0100 Subject: Expat XML Parser References: <9u2t5e$kh4$1@aspen.sucs.soton.ac.uk> <3C0694EB.6010000@hp.com> Message-ID: <9u6ab8$9op$1@animus.fel.iae.nl> Garth Grimm wrote: > I think Martin summed up your answer with the phrase "global variables". > Haven written primarily python scripts, I ran into the same issue as you a few weeks ago when I > started doing some XML parsing. I just had to (re)learn scoping issues with Python. no need to go global, use a class instead, like: [[not tested and I know nothing about xml]] class Record: def __init__(self, **kws): self.__dict__.update(kws) class Data: def __init__(self): self.data = [] def s_el(self, name, attrs): self.data.append(Record(type="s_el", name=name, attrs=attrs)) def e_el(self, name): self.data.append(Record(type="e_el", name=name)) def c_data(self, data): self.data.append(Record(type="c_el", data=data)) def printit(self): for r in self.data: if r.type == "s_el": print r.name, "(attributes -->", r.attrs, ")" elif r.type == "e_el": print " (attribute", r.name, "ends)" elif r.type == "c_el": print " `--->", r.data data = Data() prs = xml.parsers.expat.ParserCreate() prs.StartElementHandler = data.s_el prs.EndElementHandler = data.e_el prs.CharacterDataHandler = data.c_data prs.returns_unicode = 0 prs.Parse(xmlpp) data.printit() -- groetjes, carel From andreas at mtg.co.at Fri Nov 30 05:32:37 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Fri, 30 Nov 2001 11:32:37 +0100 Subject: Copy operator (was list.remove for Noivces) In-Reply-To: <001d01c17867$7b7def60$a9e1fea9@carol> References: <001d01c17867$7b7def60$a9e1fea9@carol> Message-ID: <200111301032.fAUAWhY27782@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Donnerstag, 29. November 2001 00:48 schrieb Arthur Siegel: > Chris responds - > > >If anything, this is a good argument for making copy() and deepcopy() a > >built-in, rather than part of a module. > > Yes, I agree. This would accomplish it, probably as well, or better, than > my original suggestion of an operator. One learning the language will > definitely look into the meaning and use of built-ins before they explore > the > meaning and use of one of a myriad of modules. My argument, I guess, is > that copy is somehow different from the other modules, in that it is as if > you > are importing a built_in. Is that totally off-base? Well, then everything in sys, string (well this is being phased out), etc. should be builtin. And no, perhaps because I've learned Python quite late (numerically at least in my list of programming languages), but I do not know what all the stuff is in __builtin__ without looking at the documentation. Think again: You are talking about the copy module that in the current code base is rather seldom used. Why should a function that is that seldom used be moved to __builtin__? > Truth is I probably would have limited use for copy in my own code. But I > am concluding that understanding copy and deepcopy is somehow core Python. > You need to understand why you are not using it, as well as why you are Not, copy/deepcopy are logical after grokking that one works with references. > using it when you are. That you can get away with [:] is perhaps, in > effect, my > operator. > > What is the downside of copy and deepcopy as built_ins. Unnecessary > performance hits in the majority of mods which don't need it, I expect. Nope. Namespace polution. Actually, there is already more than enough baggage in __builtin__ that nowadays wouldn't be needed there. And the need to be backwards compatible for the next decades. > And if Python had no pretense towards being a language suitable > for learning, I would be totally out of place in saying much of > anything here. But I have in fact put considerable effort into learning > programming - to the extent that I have (and I am coming along > fine, thank you) - with Python as my first language. Which I think > makes me my own kind of 'expert' - on nothing more than learning to > program - to the extent that I have - with Python as a first language > (and I am coming along fine, thank you) Obviously there is some contradiction here. Either you are not coming along fine, because you don't understand the copy/deepcopy "wart" of Python, or it's not that significant a thing if you can be productive without understanding it all :) Actually that's what is (has been *eg*, list comprehensions can be quite cryptic) that you do not have to learn all the warts to understand a program. Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8B2BIHJdudm4KnO0RAlMhAJ9ATSigDOOT8g9/6j2EbdTv6NAwewCeLZT+ l5TaGj/8+lECB6oHvHtDbwI= =cTPy -----END PGP SIGNATURE----- From jgardn at alumni.washington.edu Wed Nov 21 20:09:43 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 22 Nov 2001 10:09:43 +0900 Subject: string literals in windows dont show up! In-Reply-To: <9thbln+3do2@eGroups.com> References: <9thbln+3do2@eGroups.com> Message-ID: <01112210094300.00859@linux> Chris Fonnesbeck wrote: > I am trying to append literals (i.e. \n, \r) to the end of lines in a > text output file. However, when the file is brought up in the windows > notepad, there is no line feed or carriage return. Any idea about how > to make windows recognize these literals. Works fine in linux (no big > surprise there!) > Try "\r\n", not just "\n", and not just "\r". I remember I spent over three days trying to figure out how to get a newline appended to the rich text object in Win32. Let's just say I swore never to program for win32 ever again. Jonathan From jedi at group6.net Tue Nov 13 06:53:27 2001 From: jedi at group6.net (jedi) Date: Tue, 13 Nov 2001 03:53:27 -0800 Subject: help for beginner ! In-Reply-To: <9sr9g4$gik$1@wanadoo.fr>; from mbonnifait@wanadoo.fr on Tue, Nov 13, 2001 at 03:07:46PM +0100 References: <9sr9g4$gik$1@wanadoo.fr> Message-ID: <20011113035327.O36699@group6.net> I saw these in the mall the last time I was in there. They do kick ass. but the female is the best. On Tue, Nov 13, 2001 at 03:07:46PM +0100, Michel Bonnifait wrote: > i want to directly print the list or the result of my program > i'm working with idle and i don't know how to do it without copying in one > printable document > > > -- > http://mail.python.org/mailman/listinfo/python-list -- j3di jedi at group6.net http://jedi.group6.net/ From ws-news at gmx.at Sat Nov 24 17:38:08 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Sat, 24 Nov 2001 23:38:08 +0100 Subject: Returning HTTP POST body from CGI module References: <97ae44ee.0111241108.f40c23a@posting.google.com> Message-ID: <3c002216$1@brateggebdc5.br-automation.co.at> Hi, "Stephen" wrote in message news:97ae44ee.0111241108.f40c23a at posting.google.com... ... > If I understand correctly, the body of a HTTP POST should be > URL-encoded, right ? AFAIK, this is only the default, you can also send other data formats in the body, as long as the Content-Type has been specified in the header. (e. g. you can specifiy the encoding in the HTML FORM tag) > Since they are sending XML data in the > HTTP body, and it is not URL-encoded, it's not really > compatible with the CGI module which will be looking for > variable/value pairs. Is it possible to access the raw > HTTP header and body from the CGI module instead ? > Or will I really have to write a socket handler to deal with > this ? If it is just a matter of a missing header, you can probably derive your own class and tweak it or probably copy/modify the original code. hth Werner From jeff at ccvcorp.com Mon Nov 19 21:26:39 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 19 Nov 2001 18:26:39 -0800 Subject: Newbie Q: efficiency of list -> string conversion References: <3BF9A943.F903E057@earthlink.net> Message-ID: <3BF9BF5F.D79DFBC2@ccvcorp.com> Erik Johnson wrote: > I am wondering about the efficiency of converting a list of single > characters into the corresponding string. Here is a trivial example: > > s = "string" > l = list(s) > l.reverse() > > rv = "" > for i in xrange(len(l)): > rv += l[i] > > print rv > > This works, but in general, this seems grossly inefficient for large > lists. Yes, you want to use the string method join()-- s = "string" l = list(s) l.reverse() rv = "".join(l) print rv join() will return a string that's created from all the elements in the list passed to it, separated by copies of the string that it's called on. In the example above, it's called on the empty string ( "" ). You could also use it to create, for example, a string of comma-separated or tab-separated fields-- l = [ 'field1', 'field2', 'field3' ] print ",".join(l) print "\t".join(l) Jeff Shannon Technician/Programmer Credit International From logiplexsoftware at earthlink.net Fri Nov 9 18:22:54 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 15:22:54 -0800 Subject: data size In-Reply-To: References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> <8ZXG7.5723$Yh.305712@atlpnn01.usenetserver.com> Message-ID: <01110915225408.01414@logiplex1.logiplex.net> On Friday 09 November 2001 15:16, harry wrote: > > He is probably asking you which C library your version of Python was > > compiled with. But you don't need to know that, either. > > > > All Python dictionaries are a standard 2.5 cm by 3.6cm. Integers have no > > width and are all 1.2 cm in length. Strings are all 2 mm times the number > > of > > > characters, except Unicode strings, which are 4 mm times the number of > > characters. > > could you explain further about the metric standard you're using. this is > the first time a size of data structure is measured using meters instead of > byte/bit. > i need the information for my post-mortem of my assignment to explain why > using python data structure would be efficient. yes, i'm only a studemt who > is still need to learn lots of stuffs. > thanks. Steve's statement is not entirely correct: it depends what font you use for your data. I often optimize memory usage by selecting a smaller font for my data structures. It can take a little longer for the Python interpreter to render the data into memory, but a speed/size tradeoff is fairly common. I hope this helps answer your question. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From DTSRV10-SA at dutchtone.nl Mon Nov 26 03:59:57 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Mon, 26 Nov 2001 09:59:57 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C71778@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = joanna at mail.utexas.edu Recipient(s) = python-list at python.org Subject = Scanning Time = 11/26/2001 09:59:55 Action on virus found: The attachment stuff.MP3.pif exists WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From timr at probo.com Thu Nov 15 23:02:07 2001 From: timr at probo.com (Tim Roberts) Date: Thu, 15 Nov 2001 20:02:07 -0800 Subject: CGIHTTPServer and Win2k References: Message-ID: <4q39vt4silvue8rl0qv4ff4tar6942r9g3@4ax.com> "Andrew Post" wrote: > >from BaseHTTPServer import HTTPServer >from CGIHTTPServer import CGIHTTPRequestHandler >import os > >print "Starting Python Web Server..." >port = 80 >os.chdir('C:/Documents and Settings/apost/Desktop/Python Web Server') >servr = HTTPServer(('', port), CGIHTTPRequestHandler) >servr.serve_forever() > >The server output follows: > >APOST2 - - [14/Nov/2001 20:55:42] "GET /ccl.html HTTP/1.1" 200 - >APOST2 - - [14/Nov/2001 20:55:49] "GET >/cgi-bin/creat_calc.py?age=70&weight=70&s >Cr=1.7 HTTP/1.1" 200 - >APOST2 - - [14/Nov/2001 20:55:49] command: C:\Python21\python.exe >C:\Documents a >nd Settings\apost\Desktop\Python Web Server\cgi-bin\creat_calc.py >APOST2 - - [14/Nov/2001 20:55:49] CGI script exit status 0x2 Exit status 0x2 is "file not found". You have a permissions problem. On Windows 2000, the user profile directories in "Documents and Settings" are readable only by the owner. You should either place these in "Documents and Settings\All Users", or in some other public directory. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From peter at engcorp.com Sun Nov 11 14:40:25 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 11 Nov 2001 14:40:25 -0500 Subject: Unit testing (was Re: Is this considered black magic?) References: Message-ID: <3BEED429.655826AB@engcorp.com> Laura Creighton wrote: > > I want to do something which is conceptually very simple. Given a list of > objects, make everybody call the same method you want to run. Sort > of like apply(), but for methods. >[...] > foreach ('say', [h, e, s]) > > foreach('speak_up', [e]) > foreach('speak_up', [h, e, s], 'sandwich') > foreach('speak_up', [h, e, s], None) #can i pass None? Peter Hansen replied in an email: > By the way, what you are writing is on the verge > of being an automatic testing facility. Are you trying > to write something as part of a testing framework? Laura Creighton replied: > Absolutely correct. What else do I need to know? I'm not sure, but I was wondering whether you knew about unittest.py (aka PyUnit) and automatic testing frameworks? I'm no expert (just learning) but you should spend a bit of time reading the *brilliant* online book by Mark Pilgrim http://diveintopython.org . The chapter on unit testing, if you can take the time to read through it thoroughly and haven't already, provides an exceptional introduction to the value of unit testing in Python, and how to do it: http://diveintopython.org/roman_divein.html Integrating your foreach() method into that kind of framework could give you a helpful structure in which to work, rather than reinventing the wheel. (Of course there's nothing to indicate you didn't already know all this. Just thought I'd check. :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From vincent_a_primavera at netzero.net Thu Nov 29 09:21:08 2001 From: vincent_a_primavera at netzero.net (Vincent A. Primavera) Date: 29 Nov 2001 14:21:08 +0000 Subject: pyplets In-Reply-To: <3C0649F8.4000509@ivs.tu-berlin.de> References: <655abd4a.0111290417.4b28a0f2@posting.google.com> <3C0649F8.4000509@ivs.tu-berlin.de> Message-ID: <1007043670.4165.29.camel@del-vap-bos.ralphpill.com> Hello, Just installed IBM's Java SDK, and Jython. Could someone walk me through the process of compiling the "Hello World!" program below with jythonc. Thank you, Vincent A. Primavera. #!/usr/bin/env python print 'Hello World!' On Thu, 2001-11-29 at 14:45, Andreas Ulbrich wrote: > Or you may use jython, the Java implementation of Python. Write your > applet (or pyplet :-) in Python and compile it with jythonc to a .class > file. see: www.jython.org > > This is nothing new, we have it and it works. > > > e toffi wrote: > > > i was thinking (which i dont do often), and came up with an idea > > (which i *do* do often -- dont ask me how). the idea is pyplets -- the > > analogue to java applets with a fittingly silly name. anyway the > > premise is to define an api that lets programmers write small programs > > that execute in a browser. > > > > whatdyathink? > > > > From tatebll at aol.com Wed Nov 7 08:49:16 2001 From: tatebll at aol.com (Bill Tate) Date: 7 Nov 2001 05:49:16 -0800 Subject: Considering getting into Python... Any Pros-Cons? References: <7396d2b2.0111051718.34610f8e@posting.google.com> Message-ID: d_blade8 at hotmail.com (Lemniscate) wrote in message news:<7396d2b2.0111051718.34610f8e at posting.google.com>... > I agree with everything said here (for the most part), but I think it > is all a bit biased (most readers of this newsgroup are python progs) > so check this out: > http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf - Hey I'll take that bias anyday. Let's see - many projects with core pieces built using python (runs the range of small, medium to large). Where performance has been found wanting, the authors have migrated parts of their code base to a language more suited to the task (i.e., C or C++). That strikes me as a developer community that doesn't blindly use one language, which, unfortunately, often can't be said of the "do everything in java" crowd. p.s. which would you rather do, maintain and extend a code base consisting of: a. 40K lines of Python code b. 40K lines of C++ code c. 40K lines of PERL code From john at yates-sheets.org Sat Nov 10 11:08:15 2001 From: john at yates-sheets.org (John S. Yates, Jr.) Date: Sat, 10 Nov 2001 16:08:15 GMT Subject: I just got in! References: <9sep77$eg6$1@slb4.atl.mindspring.net> <9sf2n1$c4u$3@newshost.accu.uu.nl> <3BEBA214.4A206D96@student.gu.edu.au> <3BEC9870.746F2407@engcorp.com> Message-ID: <6ljqutsfq3eup71454tgb64mp6i5c4c9ph@4ax.com> On Sat, 10 Nov 2001 03:49:51 GMT, grante at visi.com (Grant Edwards) wrote: > and people start to roll >their eyes when you tell stories about PDP-11s and paper >tape... Grant, I was going to suggest getting together for a beer and swapping stories (I delivered PDP-8 systems on paper tape, hand punched patches, etc). But I looked up visi.com and it would appear that you live in the Minneapolis area. My PDP-8 experience followed a first addictive exposure to computers via PDP-11 assembly language. I always love it when the PDP-11 gets mentioned. So many fond memories... /john -- John Yates 40 Pine Street Needham, MA 02492 781 444-2899 From fredrik at pythonware.com Fri Nov 30 19:46:42 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 01 Dec 2001 00:46:42 GMT Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: Neil Schemenauer wrote: > I think the solution for this problem is not to add extra syntax > to the language but to have smarter editors. in most cases, "move block right/left" (e.g. smart select followed by Tab or Shift-Tab in PythonWorks) is all you need. compared to what a really smart editor can do, that's a rather dumb operation. > I believe effbot and the other people at Python Labs are working > on a "refactoring browser" for Python. Secret Labs != Python Labs. and yes, we have a refactoring browser for PythonWorks. it does a lot more than keeping the indentation intact, though; it helps you reorganize code (inline functions, move code fragments into a separate functions, encapsulate attributes, rename classes/methods/attributes, get rid of arguments, etc) while doing its best to make sure that the resulting code has *exactly* the same meaning as before. (and no, it's not quite ready for public consumption. maybe in PythonWorks 2.0...) From nika at kassube.de Sat Nov 10 16:59:16 2001 From: nika at kassube.de (Nils Kassube) Date: 10 Nov 2001 22:59:16 +0100 Subject: Python in a hospital application please help References: <9sjuab$42c$07$1@news.t-online.com> Message-ID: <87itci70ej.fsf@kursk.kassube.de> "Achim Domma" writes: > depending on the detailed requirements of your application I would stick to > a web based solution with Zope. If you use SSL your data is encrypted on the However, you should think twice before using Zope for mission-critical data. I was a big fan of Zope but at work we're currently facing serious stability problems. These are not new issues but have been experienced by many others for years and several releases. Just search the Zope mailing lists for "Zope hangs", "Hanging Zope" and so on. > wire. You are free to use Zopes database (ZODB) or to use another one. The I recommend using a real RDBMS with SQL like PostgreSQL for your content. Then you're not held hostage by one project. Also if you need ACID support in your data model, the ZODB is not up to the task. However it's fine for storing the presentation layer for which Zope and its DTML language is a very nice solution. If later you decide that Zope is not for you, you can always switch to another platform. From jbarham at octopuswireless.com Fri Nov 23 02:05:27 2001 From: jbarham at octopuswireless.com (John E. Barham) Date: 22 Nov 2001 23:05:27 -0800 Subject: python on handhelds References: <9tjsvr$90i$2@moonstone.imsb.nrc.ca> Message-ID: wrote: > Hello, > > I have inherited a 180,000 line VC++ project that I received a > green-light to rewrite/redesign. I come from a Unix background and would > very much like to go ahead and do it in Python however one of the > requirements is that a part of the app runs on a Palm. I have heard of > pippy (the python port for palmos) - but have no experience with it. My > manager is leaning towards Java. Does anyone have any experiences to > share as to the usability of the python port to palmos? Ease of > development? Any comparisons with Java for palms? Hi there, I've done (and am currently doing) a lot of work in Python--mainly on Windows--and on the Palm, using Metrowerks C++. Presumably you're already comfortable with C++ in which case I'd recommend sticking with it on the Palm. Although the Palm API is straight C, we use full-blown C++ (including the STL) for our application. C/C++ on the Palm is very different from the server-side due to the idiosyncracies of the Palm file system, the fact that Palm database records can be read and written to (with care ;) as if they were RAM and the lack of stdio (no printf() debugging means you really appreciate the debugger!). Basically you leave behind the standard C library on the Palm. Palm provides excellent documentation for the C API(http://www.palmos.com/dev/tech/docs/palmos/) and includes the C source code for many of the standard Palm apps (http://www.palmos.com/cgi-bin/sdk40.cgi/sdk40-examples.zip) which I've found invaluable in creating our own applications, albeit wishing I was reading Python instead... BTW, I've installed and played around with Pippy but it seems far too immature for any real Palm development, especially if you want a GUI for your app. A lot of fun, but not something I'd entrust with my salary... Keep in mind that for any substantial Palm application, much of the work is in the desktop conduit where again the default language is C wrapped in C++ and wrapped again recently for COM. I'm thinking of attempting to write our conduit in Python via the COM API. Has anyone else done this? Any reason why it can't be done (with the appropriate C++ bootstrap code)? Although I've never attempted to do Java programming myself on the Palm, we've spoken to others who have and their experience was that performance was a problem and there was no standard Java wrapper to the Palm API. AFAIK, there is no official Palm support for Java on the handheld. Feel free to email me if you need more details. John From jtlispl at poczta.NOSPAM.onet.pl Fri Nov 30 04:23:57 2001 From: jtlispl at poczta.NOSPAM.onet.pl (Tomasz Lisowski) Date: Fri, 30 Nov 2001 10:23:57 +0100 Subject: Strange Tkinter behaviour References: <9u4kf5$ran$1@news.onet.pl> <9u5l8i$dh9$1@news.onet.pl> Message-ID: <9u7j53$lhp$1@news.onet.pl> Uzytkownik "Michael Hudson" napisal w wiadomosci news:ulmgpr2i9.fsf at python.net... > "Tomasz Lisowski" writes: > > > I wonder, whether there is a mechanism suspending the Tkinter event > > loop, so that other event-based applications (not using Tkinter) > > could get access, and perform their duties. > > Unix or Windows? Windows > > Have you looked at createfilehandler? ??? What for? This does not seem to concern 'files'. > > What are you trying to do again? I think I've got a bit confused... Please read my original post. Nevertheless ... I am trying to make the text drawing routine (from the native CAD system producer's module) to show the text immediately, as it used to do, when Tkinter was not used. If I am using Tkinter, and the root window is functionning, the text id displayed only if the button adding the text is clicked again. > > Cheers, > M. > > -- > The only problem with Microsoft is they just have no taste. > -- Steve Jobs, (From _Triumph of the Nerds_ PBS special) > and quoted by Aahz Maruch on comp.lang.python From 1010news at ostermiller.com Wed Nov 28 08:23:23 2001 From: 1010news at ostermiller.com (Stephen Ostermiller) Date: 28 Nov 2001 05:23:23 -0800 Subject: a question of using regular expression References: Message-ID: <6f77396a.0111280523.7d098d8b@posting.google.com> There are lots of good resources listed here if you are looking for some place to start: http://directory.google.com/Top/Computers/Programming/Languages/Regular_Expessions/FAQs,_Help,_and_Tutorials/ Stephen Java utilities: http://ostermiller.org/utils/ From donn at drizzle.com Sun Nov 11 23:45:19 2001 From: donn at drizzle.com (Donn Cave) Date: Mon, 12 Nov 2001 04:45:19 -0000 Subject: Designing socket messaging format References: None <97ae44ee.0111111912.14006c7f@posting.google.com> Message-ID: <1005540314.835539@yabetcha.sttl.drizzle.com> Quoth shriek at gmx.co.uk (Stephen): | I'm developing a program which sends messages back and forth | between two servers using sockets. The message format I've | been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" | | Where ~ | Y is the message type, which in turn affects the message length. | T represents a text message. (eg. "Hello World"). Note that | it could also contain newlines (eg. "Hello World\nGood bye") ... | Other than facilitating use of SocketServer.ThreadingTCPServer, | it seems that asyncore also looks out for termination strings, | and the "Python Sockets HowTo" infers that using fixed-length | for message termination is a bad idea. So everything seems to | be pointing this way. I just looked briefly through asyncore.py, and I don't see the termination string support you mention. As I understood it, the readline() in your SocketServer example was your own code, and your decision to use a line format. I didn't look at the howto. If you want to use a line separated format, that's OK with me, and \r\n is definitely a classic line separator. But it isn't by any means the only right way to do things, and particularly if the data can conceivably under any circumstances contain the separator, it's actually the wrong way. The right way would, of course, be XML! (Just kidding.) A common alternative to line separation and fixed length is counted length - send the size of the text data, and then the text itself. Donn Cave, donn at drizzle.com From stojek at part-gmbh.de Mon Nov 5 15:51:21 2001 From: stojek at part-gmbh.de (Marcus Stojek) Date: Mon, 05 Nov 2001 20:51:21 GMT Subject: find network drives, win References: <3be6c267.21367859@news.easynews.net> Message-ID: <3be6fb60.35952906@news.easynews.net> >I think you cannot find that out with the standard Python libraries. I propose >you get the ActivePython distribution from ActiveState or install their >Windows-Extensions, named win32all on top of your existing Python installation. Hihi, I already have. Just didn't know about that function. Thanks a lot. Marcus From chrishbarker at home.net Wed Nov 28 16:03:53 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 28 Nov 2001 13:03:53 -0800 Subject: reading tabular data References: Message-ID: <3C055139.5F553460@home.net> Mark Fardal wrote: > what do people use when they want to read in long tabular files into > a (NumPy) array? I have only tried Scientific.IO.readArray and > read_ascii from Nick Bower's PYDL. read_ascii is very simple and > needs some work to be robust, but it was much faster than readArray > for the example I tried. Is there something else I should know > about? You might also want to take a look at TableIO (http://www.python.org/topics/scicomp/storage.html) and FortranFormat. > I can imagine the.re are tradeoffs between speed and generality. > (I.e., do you want to preserve types of the columns, control over > comment characters, are strings read in as well, etc.) Usually I would > prefer speed over generality, as my input files are usually very simple. Me too, which is why I have been planning for a long time to write a clone of MATLAB's fscanf. It is very fast and simple. Maybe someday. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From ssmith619 at hotmail.com Sun Nov 25 14:02:40 2001 From: ssmith619 at hotmail.com (Stephen Smith) Date: Sun, 25 Nov 2001 19:02:40 GMT Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> Message-ID: http://www.python.org/ftp/python/2.1.1/ Download Python-2.1.1.exe, hope you like Python, it is really great! "Fred Flintsone" <__x__ll at yahoo.com> wrote in message news:3c013d0d.26717374 at news... > Hi. I went to the Python.org page to pick up a copy of Python, and > was faced with a choice of which version I want to d/l. As a rank > beginner, does it matter? I'll be working on a Windows ME machine. > Between the O'Reilly book I just bought, and all those great looking > tutorials, I'm anxious to dig in. > > Thanks. > FF > Please post any responses to this to this newsgroup. From sanner at scripps.edu Tue Nov 27 01:27:14 2001 From: sanner at scripps.edu (Michel Sanner) Date: Mon, 26 Nov 2001 22:27:14 -0800 (PST) Subject: **Python 10 Registration Fees** Message-ID: <200111270627.WAA19093@goliath.scripps.edu> Dear Barbara, I understand that the conference should not be a financial burden for the organizers. However, it seems to me that it is unfair to charge the same amount or people contributing to the conference and people who are simply attending without contributing in any other form than paying their registration fee. Contributors invest time into writting a good paper or organizing a session. It is my opinion that good quality papers increases the "return on investment" for attendees. By changing Fortec's policy onthis issue, IPC would encourage the submission of papers thereby increasing the competitivity and the quality of the conference. Cordially, -Michel > X-Sender: bfuller at colossus.foretec.com > Date: Mon, 26 Nov 2001 17:48:41 -0500 > To: sanner at scripps.edu > From: "Barbara B. Fuller" > Subject: **Python 10 Registration Fees** > Cc: Albert Vezza , David Ascher > Mime-Version: 1.0 > > Dear Michel: > > David Ascher forwarded your question regarding registration fees for > authors of papers accepted for presentation at Python 10. Unfortunately, > Foretec Seminars, Inc., the organization that produces the International > Python Conferences, is unable to offer reduced registration fees to authors > of accepted papers. > > Over the past few years, Foretec has produced the Python conferences at a > financial loss in order to support the growth of the Python community, and > in the hopes that the conference would also grow and one day become > profitable. I am sad to say that the conference is a long way from > profitability, and Foretec has lost a *significant* amount of money on the > previous events. > > Attendance at Python 9 exceeded attendance at Python 8, and we were hoping > to see another growth spurt this year. However, the downturn in the > economy, the bursting of the ".com" bubble, and the events of September 11 > have all but dashed our hopes. > > I sincerely hope that you and your co-authors are all able to attend Python > 10. However, if that is not possible, then I encourage at least one of you > to attend and present your paper, which has been nominated for the Best > Paper Award. > > We appreciate your participation and support of the conference, and thank > you for your understanding of the situation. > > Regards, > > Barbara B. Fuller > Conference Coordinator > Foretec Seminars, Inc. ----------------------------------------------------------------------- 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 h.jehadalwan at student.kun.nl Sun Nov 4 07:53:16 2001 From: h.jehadalwan at student.kun.nl (Husam) Date: Sun, 04 Nov 2001 13:53:16 +0100 Subject: How can i retrieve a key from a dictionary? References: <3BE519E0.34312B48@student.kun.nl> <87668qivhp.fsf@kursk.kassube.de> Message-ID: <3BE53A3C.D7C45CFB@student.kun.nl> Nils Kassube wrote: > Husam writes: > > > dict.keys() will gets all the keys. but, i need to select explicitly one > > key for printing along its value. > > >>> dict={} > >>> dict[1]="Foo" > >>> print dict[1] > Foo > > This dictionary method is also useful: > > >>> print {}.get.__doc__ > D.get(k[,d]) -> D[k] if D.has_key(k), else d. d defaults to None. > > i.e. to have a default value of 42 for the key 2 which is used > when an entry for 2 is missing: > > >>> print dict.get(2, 42) > 42 > > Please read the tutorial before asking any other question. > Danke. wrong answer! this is not what i ment. From fperez528 at yahoo.com Thu Nov 22 16:28:07 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 23 Nov 2001 20:56:07 +2328 Subject: Bug in sys.stdout.flush()? Message-ID: <9tn5qb$fr3$1@peabody.colorado.edu> I have the following problem (Py2.1, Linux). I can't seem to flush stdout, only calling an explicit 'print' seems to work. The following code (part of something bigger, so trust me :) doesn't work unless the print line is called: sys.stdout.write(self.output_sep2) sys.stdout.flush() print ' out2,',self.output_sep2 If print isn't called, the value of self.output_sep2 is never printed. My problem is that I can't use print because of the extra space it always adds even for a blank string. So I'm stuck: print puts an extra space, and sys.stdout doesn't flush properly! Any ideas? Cheers, f. From tim.one at home.com Sun Nov 4 16:09:21 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 16:09:21 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message-ID: [Tim] > An odd thing is that, when this comes up, people complain that under > Python's current rules it's not necessarily the case that > > (-i)/j == -(i/j) > > Across decades of integer numeric programming, I can't recall any > *use* for that identity; but that i%j >= 0 whenever j>0 is endlessly > useful, as is your identity relating int-div and int-mod. [John Roth] > Useful as it is, it makes division not be the > inverse of multiplication, so it's mathematically incorrect, > and hence astonishing to people who don't know the score. What does "it" mean? Sorry, but I can't make sense out of your comment. I was talking about truncating integer divsion versus flooring integer division; i/j == k does not imply i == j*k under either of those. From fredrik at pythonware.com Wed Nov 7 14:21:21 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 19:21:21 GMT Subject: Creating a list of files in a directory References: Message-ID: Jeff Klassen wrote: > for allfiles in workingdir: > matchedfile=filespec.search(allfiles) > if matchedfile > 0: no, no, no: None isn't a number (and neither are match objects), and to quote the language reference: objects of different types always compare unequal, and are ordered consistently but arbitrarily consider this: Python 2.0 (#8, Jan 4 2001, 12:33:41) >>> None > 0 1 Python 2.2b1 (#25, Oct 19 2001, 21:26:51) >>> None > 0 0 assuming you don't really want arbitrary behaviour, you better leave that "> 0" out. From jjl at pobox.com Mon Nov 5 13:28:33 2001 From: jjl at pobox.com (John J. Lee) Date: Mon, 5 Nov 2001 18:28:33 +0000 Subject: Solving Partial Differential equation in Python In-Reply-To: <3BE6AF97.3000308@stu.ust.hk> References: <3BE6AF97.3000308@stu.ust.hk> Message-ID: On Mon, 5 Nov 2001, Calvin wrote: > I need some backgound in Numeric Analysis to solve the PDE. > so, hard to answer your question > > Trond Eivind Glomsr?d wrote: > > > Roman Suzi writes: > > > > > >>Probably, if you could find library like LAPACK for linear algebra > >>and use SWIG to make bindings to C for Python, you will have > >>PDE solving functionality in Python. > >> > > > > LAPACK doesn't do PDEs? All I know about numerical solution of PDEs is that it isn't a one-size-fits-all problem: it's a big subject, and there is no single algorithm, or even LAPACK-sized collection of algorithms, that will solve all PDE problems. Good places to look (other than your library) are: the SAL website (scientific applications on linux), netlib (linked to from SAL), the SciPy website, and maybe the Scipy or Numerical Python mailing lists if you want to find out if someone has already wrapped a library you have your eye on. There are many books on PDE solving and numerical analysis in general. Numerical Recipes (2nd ed) is a friendly place to start, though the actual implementations in the books aren't the best, according to the experts. If you want to write your own implementation for learning purposes, you could write it in Python -- it will be slow, but who cares, since it won't be used in anger. John From skip at pobox.com Fri Nov 2 15:24:16 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 2 Nov 2001 14:24:16 -0600 Subject: delattr()+dir() problem in 2.2b1 In-Reply-To: <5.1.0.14.0.20011102115004.0424b140@mail> References: <5.1.0.14.0.20011102115004.0424b140@mail> Message-ID: <15331.240.103695.55897@beluga.mojam.com> Chuck> So dir() is now returning attributes that the object doesn't Chuck> really have, but inherits. Is that intentional? Yup. In the common case (executing dir() at the interpreter prompt), this is more useful than the old behavior. Chuck> Is there another function that I should be using to get the data Chuck> attributes of a particular instance and no more? I don't think so. I think you'll either have to catch the exception or rummage around in the object's __dict__. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From slinkp23 at yahoo.com Mon Nov 5 10:17:33 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 05 Nov 2001 15:17:33 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: On Sun, 4 Nov 2001 16:00:02 -0500, Tim Peters wrote: >Why do almost all PC keyboards have a giant CAP LOCKS key where the CTRL key >ought to be? It's not really because they wanted to trick Sun keyboard >users (or, at least, I hope not ). BUT IF THERE WAS NO CAPS LOCK KEY THEN WE WOULD BE DEPRIVED OF THE DELIGHTFULLY EXUBERANT USENET NEWBIE SHOUTING STAGE!!!!!! HELLO!!! IM NEW HERE!! HOW ARE U???? CAN U TELL ME WHEERE I CAN DOWNLOAD PYLON? I HERD IT WAS COOL BUT I CANT FIND IT. I DONT KNOW HOW 2 USE A SREACH ENGINE! leaving-out-the-html-tags-ly-y'rs - Paul From jonathan.doyle1 at ntlworld.com Wed Nov 28 20:52:55 2001 From: jonathan.doyle1 at ntlworld.com (ntlworld) Date: Wed, 28 Nov 2001 17:52:55 -0800 Subject: problem Message-ID: why do i get the error "the buffer for python shell is not saved when i try to open saved documents in *python shell*??? From objectway at divalsim.it Wed Nov 14 11:12:18 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Wed, 14 Nov 2001 17:12:18 +0100 Subject: Parser Generators: which is best? Message-ID: <3BF297E2.4D900A75@divalsim.it> Hallo. While searching for parser generators in Python I came across Aaron Watters's kw(j)Parsing and John Aycock's SPARK. Before I make my choice I'd like to know about experiences with these or other tools. Keep in mind that I'm (still!) a Python beginner and that I'm more interested in ease of use than performance. Thank you, Nicola Musatti From tim at bladerman.com Mon Nov 5 18:05:06 2001 From: tim at bladerman.com (Tim Gahnström /Bladerman) Date: Mon, 05 Nov 2001 23:05:06 GMT Subject: How to ? References: Message-ID: "A" > can I prevent users from seeing the content of this text file? > Thank you for reply. > Ladislav I dont know if there is som nice suport for anything like that in python but otherwise the simplest would be to use some utterly simple encryption and use a weired name for the textfile. Tim From alexis.layton at post.harvard.edu Sat Nov 17 22:45:59 2001 From: alexis.layton at post.harvard.edu (Alexis Layton) Date: Sun, 18 Nov 2001 03:45:59 GMT Subject: enhancing dictionary update method and the dict type constructor References: Message-ID: <3BF72F94.5010106@post.harvard.edu> Ah yes, bitten by the fact that characters are not first class Python objects again.... :-) Alexis Tim Peters wrote: > > Since d.update(pairs) is dead on arrival, enhancements to it probably don't > stand a better chance . I especially squirm at this one, since, e.g., > it would mean that > > d.update("oops") > > deletes the keys "o", "p" and "s" from d ("oops" is a sequence of > 1-sequences), and that's way too obscure. From skip at pobox.com Tue Nov 20 06:37:41 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 20 Nov 2001 05:37:41 -0600 Subject: Try block problem In-Reply-To: <9tcnls$42k$1@news1.ucsd.edu> References: <9tcnls$42k$1@news1.ucsd.edu> Message-ID: <15354.16517.28230.114587@beluga.mojam.com> Jeff> It seems like the following makes sense to me: Jeff> try: Jeff> ... Jeff> except: Jeff> ... Jeff> finally: Jeff> ... Jeff> I know it doesn't work, my question is: why? They are solving two different language problems, so it also makes some sense to keep them separate. Typically, try/finally is used to perform some local cleanup before a function exits. I've never seen it used to perform cleanup of data from deeper frames of execution. Try/except, on the other hand, is frequently used to recover from problems detected in (possibly deeply) nested frames of execution. If you really need both, you can be explicit: try: try: 1/0 except OverflowError: print "hey dummy! looks like you might have divided by zero!" finally: print "thank god that block is done! that was rough!" The thing that is perhaps slightly misleading is the use of the "try" keyword to begin both constructs. There's really no "try" connotation to try/finally. It has more the semantics "do this/then clean up before you leave", but those would be rather cumbersome keywords to type. I also suspect the two uses of "try" were added at different times. Perhaps that's not the case for the Ruby construct you mentioned. Jeff> Is it difficult to implement in python? I suspect it wouldn't be trivial, but I don't know. That it took heroic efforts to allow continue statements within try blocks (new with 2.1 or 2.2 I think) suggests that getting too elaborate with what you allow would be fairly hard to implement. On the other hand, I don't believe Guido views it as an implementation deficiency the way "continue within try" was. Jeff> ... which brings another question: does every language make new Jeff> keywords for the same concept of exceptions, or are they different Jeff> somehow? So it would seem. I'm sure there's a bit of NIH going on. ;-) -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From export at sendme.cz Thu Nov 15 03:09:30 2001 From: export at sendme.cz (Lad) Date: 15 Nov 2001 00:09:30 -0800 Subject: GUI toolkit References: Message-ID: <52ac9479.0111150009.6bcf8111@posting.google.com> Cary Coulter wrote in message news:... > While I've learned a lot of Python in the last year, all my scripts > have run from the command line or as CGI programs. I'm very happy > with it all. > > I am interested in developing gui wrappers for a couple of my command > line scripts to make them easier to use, especially under Windows. I > don't have any experience with the gui toolkits yet. I'm looking for > some hints on the pros/cons to help make a good choice. I'm really > looking at just learning one of them. > > I have looked at the demos for wxPython. Have to say I like what I > see, but I haven't tried to develop anything yet. > > Platforms would be Linux (primary), Windows, and AIX (didn't see any > prebuilt code for wxPython). > > Your help/ideas are greatly appreciated. > > TIA > Cary I use wxPython and it works well. Guys from that discussion groups are very helpful. I recommend it From peter at engcorp.com Thu Nov 8 22:03:14 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 08 Nov 2001 22:03:14 -0500 Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> Message-ID: <3BEB4772.72038893@engcorp.com> Skip Montanaro wrote: > > Peter> On Wed, 31 Oct 2001 18:42:03 -0600, Skip Montanaro > Peter> wrote: > > >> Smiley or not, you seem to be trying a bit too hard to compare Python > >> with C++. They serve dramatically different audiences. > > Peter> what are these dramatically different audiences? > > Perhaps I should have phrased that "designed for dramatically different > audiences". Stroustrup designed C++ with the high-performance applications > of his employer in mind (e.g. telephone switching). He also had C > compatibility in mind. I recall differently. I think it was for *simulating* telephone switches. The need for speed was probably related only to the fact that the hardware back then sucked, so it needed the raw performance only C provided. The object-oriented nature was essential for the complexity of the problem, but given the power of today's hardware, maybe even Stroustrup would prefer to use Python for the same thing... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tatebll at aol.com Mon Nov 5 09:30:47 2001 From: tatebll at aol.com (Bill Tate) Date: 5 Nov 2001 06:30:47 -0800 Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: Cliff Pruitt wrote in message news:... > Hello, I've just started looking into Python and am considering delving into > it a bit. My main reason is that it seems to be pretty portable across > platforms. I work on a Mac for the most part but I do work on windows > machines durring the day and it would be fun (I think) to develop for both. > So far I've downloaded the Python files and flipped through a little bit of > the documentation but haven't gone into much detail with it. I'm wondering > if anyone could sort of give me a good idea of what Python is really capable > of and maybe more importantly what it's NOT capable of. The extent of my > programming experience involves VBScript for the web. If i had, say, a > microsoft access Database, is python capable of displaying records and doing > searches on that database? Maybe more importantly is it capable of adding > records? Out of curiousity, what are the nicest or most complex > applications you've seen done in Python? A lot of what I've read referrs to > Python as being useful as "glue" to hol dother languages like C++ and others > together. I dont know any of those so I'm wondering if Puthon will really > be somethign useful to learn or not. > > Your insight is greatly appreciated. > Thanks. Cliff, Its been my experience using Python - internet, intranet, GIS, DB programming, gluing up, etc.,etc., that I have a hell of lot fewer grey hairs if I tried to do them using Python. The best I can tell you is the app's I've worked on were not toys, required real computing power and needed to be maintained for the long haul - the latter is NOT a trivial issue. When I use Python, I know I have an insurance policy that goes along with it - its called C & C++. I've done everything I've ever needed to do (most often with a DB backend)either using Python alone (frequently the case), using freely-available python extensions or building my own python extensions. Sam Rushing's windll and calldll are great examples of the kinds of tools freely available to python developers for extending python. SWIG is another. While I routinely use Java, the fact is Java does not give me the same sense of security as I have with Python. I need to know Java because its widely in use, but I sure as hell don't stake a claim that I can do everything using Java. Java hides a lot of details from the developer which can easily give someone a false sense of security that an application will ultimately perform as expected. And the cross-platform issue with Java is not something I would take on blind faith. The fact is java on the client sucks, no matter how you try to spin it. Yet I have no such constraints using Python or say a cross platform framework like wxWindows (C++) and wxPython (wxWindows for Python). This is an excellent framework for cross platform development and you don't have the associated cost - check out what Kylix is going to cost you. Like most folks, you frequently have to deal with applications where you are forced to deal with multiple-language codebases. Some critical and core piece of functionality is implemented say in C or C++ (for whatever reason)and your new application requires access to this functionality. Java's JNI is not a guaranteed solution either. Its my experience that the java "guys" turn to the python guy to get it done. Bottom line, my comfort level is substantially higher that I can solve the problem in whole or part using Python or using python extensions. I don't want to even think about what happens if I need to access a commercial COM library using Java. Its a snap using Mark Hammond's PythonCOM module if the COM component implements IDispatch (which is often the case). The alternative of simply re-implementing in J2EE is often not an option and idiotic from a business standpoint. Bioinformatics, cheminformatics, gaming, artificial intelligence all are dominated by industrial strength C and C++ libraries. I think you will find that the pulling the pieces together using Python stands out. Bear in mind that Python also has an excellent numerics module as well. Python isn't you only solution, but given my choices, its definitely part of the mix. From kerstin.dressler at web.de Thu Nov 8 07:45:46 2001 From: kerstin.dressler at web.de (Kerstin Dressler) Date: 08 Nov 2001 14:45:46 +0200 Subject: Newbie with Tkinter problems Message-ID: <3bea8c8a$1@netnews.web.de> Hi, I need to make a GUI with three columns. gif | Label | Label Label | Button | Button Listbox | Button | Button " | Button | Button and so on (another 4 rows like this) Button | nothing | nothing and last another Button centered My problems now are: - I wish to have some sort of border around the complete column 2 and 3 (not around each cell)? - When the user resizes the GUI, I wish the Listbox to expand, but the other columns are to stay as wide as they are. The space between the Buttons (vertical) may change. Also I've got problems with opening the files (the gif as well as the file I need for the Listbox). -> logo = PhotoImage(file="./Power at work_transparent_8farben.gif") -> liste = open('./envliste', 'r') In both cases I get the error message: IOError: [Errno 2] No such file or directory: './envliste'. But both files are in the same directory as the py-script? What could be wrong there? I'm working on Win95 and Python 2.1.1 where the Tkinter module is already included. Hope anyone can help me. Thanx in advance, Kerstin -- __________________________________________________________ News suchen, lesen, schreiben mit http://newsgroups.web.de From skip at pobox.com Tue Nov 20 08:41:05 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 20 Nov 2001 07:41:05 -0600 Subject: Try block problem In-Reply-To: References: <9tcnls$42k$1@news1.ucsd.edu> Message-ID: <15354.23921.928826.70642@beluga.mojam.com> Marcin> Tue, 20 Nov 2001 05:37:41 -0600, Skip Montanaro pisze: >> The thing that is perhaps slightly misleading is the use of the "try" >> keyword to begin both constructs. There's really no "try" >> connotation to try/finally. Marcin> Maybe it's because try:except: would have to be used to simulate Marcin> try:finally: if it wasn't available natively. I don't know how you'd do this. For example: def f(d): try: return d.keys() finally: d.clear() How would that be handled with try/except? (IOW, where's the exception?) The natural way to code it (without try/finally) would be def f(d): keys = d.keys() d.clear() return keys Marcin> In other words try:finally: is one of things which do something Marcin> non-trivial with exceptions instead of silently propagating them Marcin> up. Try/finally isn't directly concerned with exceptions at all. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From rnd at onego.ru Mon Nov 5 04:40:22 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 5 Nov 2001 12:40:22 +0300 (MSK) Subject: python-mode for Emacs 21.1? In-Reply-To: Message-ID: On Mon, 5 Nov 2001, Roman Suzi wrote: > Is there python-mode for Emacs 21.1? > (My old one for 20.5 doesn't compile correctly, it seems) Problem solved: .emacs.el compilation errors prevented me from using python-mode setup. But still: * I wonder why python-mode not in standard Emacs distro... > Sincerely yours, Roman A.Suzi Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From gh_pythonlist at gmx.de Fri Nov 2 04:03:40 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 2 Nov 2001 10:03:40 +0100 Subject: newbie question In-Reply-To: <20011102004821.02918.00002310@mb-fi.aol.com>; from the1eagle@aol.com on Fri, Nov 02, 2001 at 05:48:21AM +0000 References: <20011102004821.02918.00002310@mb-fi.aol.com> Message-ID: <20011102100338.A566@lilith.hqd-internal> On Fri, Nov 02, 2001 at 05:48:21AM +0000, The1Eagle wrote: > Hello All, > I am trying to read in a file and place each word in the file into an > array or list so that those words can be manipulated (ie alphabetized, > counted, deleted, > compared, etc). For some reason I can seem to find a way to get split > to work in this manner. Any ideas? Here is the code so far, but this > may be the wrong approach. Thanks. > > > #function that does all the work > def handledata(input): > text = input.readlines() > #need to parse text. Would be nice to have \n and other punctuation > removed. The readlines() string method returns a list. If you want to iterate over all the lines, chances are you want something like: for line in input.readlines(): # ... do stuff with line here To remove the trailing newline, you want something one of the the strip() methods: for line in input.readlines(): line = line.strip(): # continue doing stuff here You can get very fancy with removing punctuation, but for the start I recommend sticking to simple things like temporary variables and for-loops. Later on the functional features of Python like filter, map, apply, and so on are useful to write more compact code. Next thing you want is the split() method of strings. It will return a list again, have a look at the docs (it defaults to ' ' as delimiter). For counting words, you should look into dictionaries. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From sheershion at mailexpire.com Sun Nov 18 15:17:58 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Sun, 18 Nov 2001 20:17:58 -0000 Subject: Python IDE Opinion Request References: Message-ID: A. Keyton Weissinger wrote: > I am a recent inductee into the Pythonista Cult. Please note: the rumour we sacrifice virgins here is totally and fully without base whatsoever. That would be a waste of good virgins: we let them debug the standard library instead. Well -- some might argue that *is* sacrificing virgins... > 1) Do you use a code editor (SlickEdit, emacs, etc) or an IDE > (IDLE, etc)? Why? I use SciTE, from www.scintilla.org. It's tiny, but it looks good and has everyting I need. (For both Windows and Unix (GTK). You didn't specify which platform you're working with, although that omission is usually the hallmark of a Windows user.) > 2) Are there any IDEs out there that allow me to do UIs easily > (ala VB)? I don't want a big code generator, but being able to > drag and drop some simple forms would be nice... For wxPython there's Boa Constructor, in which any Delphi or C++ Builder programmer will find him/herself at home immediately. It's on Sourceforge somewhere. Though I still prefer to do wxPython programming on my tiny little text editor. It just gives me better control. > Thank you all. I know I'm telling you nothing you don't already > know, but Python rocks! > > Why is it not out there more???? In the world of computer languages, widespread adoption (if only in a particular field) is often a matter of fortuitous timing (that's dumb luck to you and me, mate). Merit is often of secondary importance. Once languages get established in their particular niches, it's nearly impossible to shift them from that position. If you don't believe me, just ask yourself why Cobol is still around. Python may have found a good niche for itself as an embedded interpreter[*] and a glue language. Let's see hoe it fares from there. Robert Amesz -- [*] For instance, Pegasus 4 will have Python scripting embedded into it a few months time, if everything goes well. I'd advise against holding your breath for this, however, as Pegasus 4 already has a history of missed deadlines, but I'm sure they'll get around to it eventually. From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Wed Nov 21 19:05:24 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Thu, 22 Nov 2001 00:05:24 GMT Subject: Non-Indented python References: Message-ID: In article , "Delaney, Timothy" wrote: [...] > The problem is simply that people use the tab key and character to mean > different things. Originally the tab key was designed to do the same thing > as on a typewriter - advance to the next tab stop (i.e. a certain number of > spaces). Thus you end up with editors which distinguish between indentation > and tab because a tab is too big for indentation. [...] Typewriters had *moveable* tab stops, so they *were* used for indenting as well as "tab"les... From skip at pobox.com Sun Nov 18 12:37:19 2001 From: skip at pobox.com (Skip Montanaro) Date: Sun, 18 Nov 2001 11:37:19 -0600 Subject: something Evil happens when large hashes destroyed In-Reply-To: <9t8m1c019qd@enews1.newsguy.com> References: <9t8m1c019qd@enews1.newsguy.com> Message-ID: <15351.61903.681787.343837@beluga.mojam.com> guuge> I was trying to sort about 100,000 items by splitting them into guuge> groups (using a python dictionary type) and then successively guuge> splitting these groups until they were small enough to use a guuge> brute force method. guuge> My test program, which used only two or three keys to create the guuge> first split, worked fine. When I tried the real thing, using 256 guuge> keys, the program slowed to a crawl. The python interpreter took guuge> forever to destroy the dictionaries. I believe this topic has been discussed recently. When a dictionary is deleted, the keys are traversed in their "natural order", that is, as they are laid out in the dict. However, the values stored in the dict are scattered all over the place, so lots of small chunks of memory are freed. Your underlying malloc library is probably spending lots of time trying to coalesce small chunks of freed memory into bigger chunks. One workaround seems to be to compile Python with pymalloc enabled. Another is to use sys._exit to exit your program (assuming the storage for your big hashes are getting reclaimed at program exit). On the other hand, are you sure you're not just running out of memory? -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From amk at localhost.debian.org Mon Nov 5 08:55:20 2001 From: amk at localhost.debian.org (A.M. Kuchling) Date: 5 Nov 2001 13:55:20 GMT Subject: no setuid for CGI scripts? References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: <9s65o8$3eh$2@bob.news.rcn.net> On Mon, 5 Nov 2001 12:04:27 +0000, Robin Becker wrote: >If you can get a wrapper program onto your machine it's as easy as this >(at least for freeBSD) There's a wrapper included with the Python source distribution, Misc/setuid-prog.c. It's not compiled or installed by default, though. --amk From Peter.Mayne at au1.ibm.com Tue Nov 27 02:44:51 2001 From: Peter.Mayne at au1.ibm.com (Peter Mayne) Date: Tue, 27 Nov 2001 18:44:51 +1100 Subject: Non-Indented python References: <3BFD3804.3020502@movilogic.com> Message-ID: <9u104l$ub2$1@news.btv.ibm.com> "Chris Tavares" wrote in message news:R2oL7.4488$eT3.447925 at newsread1.prod.itd.earthlink.net... > "Dave Cinege" wrote in message > news:mailman.1006474590.24778.python-list at python.org... > > Commandment #2 > > Thou shalt terminate thy line with but one byte. Let he who hath > > understanding recognize the number of the byte, 0xA0. Death to thee who > > terminates thine with any other byte! > > > > You use a defective OS built with defective editors. REPENT! > > > > Dave > > > > It sounds like somebody is overdue for a visit from the cult deprogrammers. Indeed. And what of those of us who have used operating systems with record-based (rather than stream-based) filesystems, where the text files don't require any line terminators at all? Far from defective, I assure you. Not to mention Unicode encodings. PJDM -- Peter Mayne IBM GSA (but the opinions are mine) Canberra, ACT, Australia This post is covered by Sturgeon's Law. From tjreedy at home.com Sat Nov 10 10:21:19 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 10 Nov 2001 15:21:19 GMT Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> Message-ID: "husam" wrote in message news:3BED344B.5050703 at sci.kun.nl... > hi, > im trying to learn programming with python. one of the things confusing > me is the difference between data structures and data bases. so, can you > tell me what the difference is between them? Examples of data structures: set, list (stack, queue, deque are specialized examples), dictionary, tree, heap, matrix. A particular organization of data with associated methods of operation upon them. An abstract data structure is defined by the interface of the methods -- what you can do -- rather than by the bit-by-bit organization of any particular implementation of that structure. Database: a collection of data on a particular topic using some data structures. Example: phone book, address book, a business database of suppliers and customers, product and services, purchases and sales. Relational database: a set of tables, each of which is a set/list of records, each of which is a set/list or association of named fields. Hope this help a bit. Terry J. Reedy From phr-n2001d at nightsong.com Mon Nov 5 16:46:17 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 13:46:17 -0800 Subject: Program very slow to finish References: <3BE706ED.1264548E@chello.nl> Message-ID: <7xitcoevrq.fsf@ruckus.brouhaha.com> Roeland Rengelink writes: > You've convinced/reassured me that it can't be Python. I'm not convinced > it's the cache. That basically leaves free(). I'm curious if anybody > else has seen this behaviour. I hope some more people try this Next thing to do is profile the python interpreter running those examples. I may try to get around to this. From Marcus.Franke at gmx.net Sat Nov 10 12:30:38 2001 From: Marcus.Franke at gmx.net (Marcus Franke) Date: Sat, 10 Nov 2001 18:30:38 +0100 Subject: XML Schema References: <87vggivo5r.fsf@strindberg.maisel.enst-bretagne.fr> Message-ID: <3BED643E.70106@gmx.net> Martin von Loewis wrote: > Jesper Holmberg writes: > > >>However, I'm more specifically looking for Python implementations of >>XML Schema-validating parser. Does anyone here know of any >>tool-kit/parser that supports XML Schema? >> > > XSV does that. Please have a look at > > http://pyxml.sourceforge.net/topics/software.html > > for a list of software known to xml-sig. There is even a very good book about this. Its called: Processing XML with Python by Sam Garth Bye, Marcus From nospam at bigfoot.com Fri Nov 2 11:07:20 2001 From: nospam at bigfoot.com (Gillou) Date: Fri, 2 Nov 2001 17:07:20 +0100 Subject: Learning Python References: <20011101180300.21692.00000997@mb-mr.aol.com> Message-ID: <9rufvr$288t$1@norfair.nerim.net> For newbies and gurus (same guy a couple of weeks later) http://diveintopython.org/ "BHS3133" a ?crit dans le message news: 20011101180300.21692.00000997 at mb-mr.aol.com... > What is a good tutorial for learning Python? From rdsteph at earthlink.net Sun Nov 4 20:57:27 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 05 Nov 2001 01:57:27 GMT Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: <3BE5F36E.4BC6E7F2@earthlink.net> I heartily recommend that you look into Python. But beware ! ;-))) If your experience is anything like mine, you will begin to look into Python, as if you have free will and can stop anytime you like, and go back to VB, or baseball, or whatnot. You will find yourself enjoying yourself, and thus spending more and more time writing Python code, reading Python books, corresponding on Python mail lists. Python will seduce you, ever so subtly, that you will be unaware of its tremendous power. You will begin to love object, classes and polymorphism. Soon, you will seldom even use your old procedural techniques. One day you will wake up and be hopelessly, head over heels in love. Going back to your previous ways will no longer be an option. Ron Stephens (see my choosing your programming language script at http://www.awaretek.com/Decision_Analysis.py ) Cliff Pruitt wrote: > Hello, I've just started looking into Python and am considering delving into > it a bit. My main reason is that it seems to be pretty portable across > platforms. I work on a Mac for the most part but I do work on windows > machines durring the day and it would be fun (I think) to develop for both. > So far I've downloaded the Python files and flipped through a little bit of > the documentation but haven't gone into much detail with it. I'm wondering > if anyone could sort of give me a good idea of what Python is really capable > of and maybe more importantly what it's NOT capable of. The extent of my > programming experience involves VBScript for the web. If i had, say, a > microsoft access Database, is python capable of displaying records and doing > searches on that database? Maybe more importantly is it capable of adding > records? Out of curiousity, what are the nicest or most complex > applications you've seen done in Python? A lot of what I've read referrs to > Python as being useful as "glue" to hol dother languages like C++ and others > together. I dont know any of those so I'm wondering if Puthon will really > be somethign useful to learn or not. > > Your insight is greatly appreciated. > Thanks. > > -- > C. Pruitt > mail at cliffpruitt.com > http://www.cliffpruitt.com From Gareth.McCaughan at pobox.com Wed Nov 14 04:14:08 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 14 Nov 2001 09:14:08 +0000 Subject: PEP 276 Simple Iterator for ints References: Message-ID: James_Althoff at i2.com wrote: > Below is the first draft of PEP 276 "Simple Iterator for ints". > (Available at http://python.sourceforge.net/peps/pep-0276.html) > > Feel free to comment (positive, negative, bipolar, or in between ;-). [SNIP: James proposes that e.g. 5.iter() should be roughly equivalent to xrange(5), so that you can say "for x in 5: stuff".] -0.7. Here's why. - It's deeply unintuitive and apparently arbitrary. And I speak as a mathematician with quite a lot of set theory in my background, so I'm used to a world in which 5 really *does* equal {0,1,2,3,4}. If every Python user were a set theorist, it might make more sense. - I'm decidedly unexcited about the major difference between "for x in 5:" and "for x in 5,:", both of which would be valid if the PEP took effect. - I agree that Python needs a better way of doing simple iterations over sequences of numbers. I'm concerned that if this PEP is accepted then it may discourage the implementation of something clearer. - For all that, the proposal *is* quite elegant, and the syntax it offers is certainly concise. And if numbers are going to provide iterators, James has chosen the right ones. Well-written PEP, though. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From pbrian at demon.net Sat Nov 17 13:04:40 2001 From: pbrian at demon.net (Paul Brian) Date: Sat, 17 Nov 2001 18:04:40 -0000 Subject: The Wayback machine - an interesting poke into the past Message-ID: <1006021175.16175.0.nnrp-01.c2de2503@news.demon.co.uk> Dear all, For no particular reason I thought people might be interested in this. The same people who brought us Alexa and WAIS, have been archiving as much of the web as they could spider for years. Now they have set up a web farm to let us all browse our pre-history. For example, the python.org home page from january 1997. http://web.archive.org/web/19970414030137/http://python.via.ecp.fr/ The logo has not changed a bit :-) Amazingly enough most of the links work too. I found an article by Frank Williamson with some funny quotes just a click away. Actually there are some interesting debates being brought up by this, from defamation postings suddenly being resurrected, to people trying to forget embarrassing statements, that come back to haunt. but really its just for fun... ---------- Paul Brian From edream at tds.net Mon Nov 5 15:06:38 2001 From: edream at tds.net (Edward K. Ream) Date: Mon, 05 Nov 2001 20:06:38 GMT Subject: IDLE breakpoints on Windows? Message-ID: <3BE6F149.BD4CBD32@tds.net> Hi, Do breakpoints work with any version of IDLE on Windows? If so, how does one set them? If not, what needs to be done to make them work? No one on idle-dev seems to know. BTW, various Python documents offer different opinions about whether breakpoints work on Windows. Edward -------------------------------------------------------------------- Edward K. Ream email: edream at tds.net Leo: Literate Editor with Outlines Leo: http://personalpages.tds.net/~edream/front.html -------------------------------------------------------------------- From asgard at hellnet.cz Sun Nov 4 07:50:10 2001 From: asgard at hellnet.cz (Jan Samohyl) Date: Sun, 4 Nov 2001 13:50:10 +0100 Subject: passing parameters to generators ? Message-ID: <20011104135009.D5094@blackbox.hell> Hello, I would like to pass different parameters to a generator while it's generating, is there some simple way to do that? I want to write a synchronous server, that would go through all the active connections and when the client response is available, it would call a generator with the client response, and resume the conversation with the client exactly at the point it yielded out to let other talk. I think it would be very cool to do it this way, but unfortunately, current generator implementation doesn't allow to do it that simply. Why is a function with yield *always* a generator factory? Why it isn't simply the generator, and generator factory or iterator would be done as a function factory returning generator next()? And when you would call generator again with different parameters, they would be different inside the generator (but the locals would stay the same and you would enter behind the last yield statement). Regards Jan Samohyl From logiplexsoftware at earthlink.net Wed Nov 14 16:06:39 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 14 Nov 2001 13:06:39 -0800 Subject: How to marshal a function? In-Reply-To: <01111412544105.04702@logiplex1.logiplex.net> References: <01111412544105.04702@logiplex1.logiplex.net> Message-ID: <01111413063906.04702@logiplex1.logiplex.net> On Wednesday 14 November 2001 12:54, Cliff Wells wrote: > > > > Earlier today, I wondered how to marshal a function, in view of > > transmitting it to a remote machine and executing it there. The idea was > > to not transmit Python source, when the byte-compilation has already been > > done on this side. Another reason to use pickle rather than marshal: The mechanism you are using (remote execution of python code) introduces a big security hole (in your current setup this may not be much of an issue for you, but think of the children!). As such you will want some sort of security measure in place. This will undoubtedly involve wrapping the pickled code in another structure that includes authentication information. Marshal won't support this, but pickle will. You could also use the wrapper to transmit version information for the byte-code. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From DeepBlue at DeepBlue.org Fri Nov 9 12:28:26 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Fri, 9 Nov 2001 11:28:26 -0600 Subject: Trouble with cgi.FieldStorage() on iis/asp References: <3bebd556$0$25387$edfadb0f@dspool01.news.tele.dk> Message-ID: maxm Sorry, I should have been careful. I did not notice the ASP part :) although i see now it was all over the post. I just saw the cgi part. DeepBlue "maxm" wrote in message news:k5UG7.1169$Gt.58419 at news000.worldonline.dk... > "DeepBlue" wrote in message > news:tunvpsbktq0ac5 at corp.supernews.com... > > > This works flawlessly with me, and file is found with no problems. > > Hope this helps. > > DeepBlue > > Yes, but as far as I can tell, you are using the cgi module in a cgi script. > I am trying to do the same thing under Active Server Pages on Microsoft IIS, > and there I dont have the same enviroment variables available. So calling > FieldStorage() without any argumants will not work there. > > Thats why I call FieldStorage with parameters. But apparantly it isn't > working like i believed. > > Regards Max M > > From logiplexsoftware at earthlink.net Wed Nov 7 14:57:08 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 7 Nov 2001 11:57:08 -0800 Subject: identify x,y coordinates in an image In-Reply-To: References: Message-ID: <01110711570801.21497@logiplex1.logiplex.net> On Wednesday 07 November 2001 08:48, John Hunter wrote: > Cliff> PIL is an excellent choice and will allow you to zoom to > Cliff> particular point in an image. wxPython is an alternative > Cliff> to Tkinter (there isn't any native support for wxPython > Cliff> from PIL, but a couple of simple routines will convert > Cliff> between PIL images and wxImages - I can provide them if you > Cliff> like). > > I would like these conversion routines; thanks. Since I've been asked for them so often (three times and counting!), I'll post them to the list. I believe I got the original code from Piddle... it's been a while, so I'm not too sure. And yes, those are tab-indentations (damn you four-spacers!). def PILToWX(image): "convert a PIL image to a wxImage" if (image.mode != 'RGB'): image = image.convert('RGB') imageData = image.tostring('raw', 'RGB') imageWx = wxEmptyImage(image.size[0], image.size[1]) imageWx.SetData(imageData) return imageWx def WXToPIL(image, mode = 'RGBA'): "convert a wxImage to a PIL RGBA image" imageData = image.GetData() size = (image.GetWidth(), image.GetHeight()) imagePIL = Image.fromstring('RGB', size, imageData) if mode != 'RGB': imagePIL = imagePIL.convert(mode) return imagePIL -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From ognen at bioinfo.pbi.nrc.ca Fri Nov 23 10:56:18 2001 From: ognen at bioinfo.pbi.nrc.ca (ognen at bioinfo.pbi.nrc.ca) Date: 23 Nov 2001 15:56:18 GMT Subject: python on handhelds References: <9tjsvr$90i$2@moonstone.imsb.nrc.ca> Message-ID: <9tlrj2$c2n$2@moonstone.imsb.nrc.ca> John E. Barham wrote: > Hi there, > I've done (and am currently doing) a lot of work in Python--mainly on > Windows--and on the Palm, using Metrowerks C++. Presumably you're > already comfortable with C++ in which case I'd recommend sticking with > it on the Palm. Although the Palm API is straight C, we use > full-blown C++ (including the STL) for our application. C/C++ on the > Palm is very different from the server-side due to the idiosyncracies > of the Palm file system, the fact that Palm database records can be > read and written to (with care ;) as if they were RAM and the lack of > stdio (no printf() debugging means you really appreciate the > debugger!). Basically you leave behind the standard C library on the > Palm. Palm provides excellent documentation for the C > API(http://www.palmos.com/dev/tech/docs/palmos/) and includes the C > source code for many of the standard Palm apps > (http://www.palmos.com/cgi-bin/sdk40.cgi/sdk40-examples.zip) which > I've found invaluable in creating our own applications, albeit wishing > I was reading Python instead... Hello, thank you for the educational reply. We were hoping to have an app run on a desktop PC and then provide a way to capture data on the palm and upload it to our application. I have never done any palm programming so I was hoping that I could retain at least some of the code from the PC application to use on the palm, although I had a feeling this was a really long shot :). Ognen From wurmy at earthlink.net Thu Nov 29 12:43:24 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Thu, 29 Nov 2001 17:43:24 GMT Subject: __setattr__ recursion problem References: <3C066BF8.8D911FCB@olen.to> Message-ID: <3C0673BC.3C463530@earthlink.net> Joonas Paalasmaa wrote: > > The code above causes an infinite loop. How can I set an attribute of > Class > without overloading the __setattr__ function? Or does someone have some > other > solution to make that script work? > > class Class2: > eggs = 1 > spam = 2 > > class Class: > base = Class2() > def __setattr__(s,attr, value): > if hasattr(s.base, attr): > setattr(s.base, attr, value) > else: > setattr(s, attr, value) > > Class().foo = "eggs" The short answer is that setattr(s, ...) calls s.__setattr__. Which calls setattr again, and so on. This code strikes me as curious though, and I wonder why you would want to write it like this. The default idiom for a class and its subclass would be something like class Class2: def __init__(self): self.eggs = 1 self.spam = 2 class Class(Class2): pass In your approach, > class Class: > base = Class2() creates an instance of Class2 *that is shared by all instances of class*. I'm not sure if this is intentional, but I haven't seen people use this a lot. Maybe it's possible to rewrite this code without the setattr and the shared base. --Hans From loewis at informatik.hu-berlin.de Mon Nov 5 15:01:31 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Nov 2001 21:01:31 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Michael Abbott writes: > I would have thought that the nature of the beast is likely to require > quite substantial modifications to key parts of Python. > > Can you describe what you mean by "intrusive" in this context? The patches changes nearly everything in the core interpreter, and it is not clear whether all these changes are really necessary and for the better. It *is* clear that some things just cannot continue to work as they did. Is just isn't clear (to me) that all the complexity that the stackless patch adds is really necessary. It's been quite some time since I studied it last, so here's what I found after a quick glance right now: - it adds 17 new members to the frame object, doubling the number of members. Usage of some of these members isn't obvious to me. - It adds a field nesting_level to the thread state, without ever checking its value (it just counts the nesting level) - it adds a number of _nr variants of functions (non-recursive), e.g. for map and eval. In __builtins__, the _nr versions are available as "map" and "eval", while the original versions are preserved as apply_orig and map_orig: * Are the _nr versions functionally completely backwards-compatible? If not, why? If yes, why is the original version preserved? * Just to implement map, 150 lines of builtin_map had to be rewritten into 350 lines (builtin_map, make_stub_code, make_map_frame, builtin_map_nr, builtin_map_loop). The author indicates that the same procedure still needs to be done for apply and filter. Just what is the "same procedure"? Isn't there some better way? - The code adds PREPARE macros into each branch of ceval. Why? - It adds a long list of explicitly not-supported opcodes into the ceval switch, instead of using 'default:'. No explanation for that change is given, other than 'unused opcodes go here'. Is it necessary to separately maintain them? Why? It may be that some of these questions can be answered giving a good reason for the change, but I doubt that this code can be incorporated as-is, just saying "you need all of this for Stackless Python". I don't believe you do, but I cannot work it out myself, either. Regards, Martin From calves at coelce.com.br Wed Nov 28 15:22:26 2001 From: calves at coelce.com.br (Alves, Carlos Alberto - Coelce) Date: Wed, 28 Nov 2001 17:22:26 -0300 Subject: 1st day newbie question. Message-ID: <29A97D00F387D411AC7900902770E14802BE3885@lcoeexc01.coelce.net> > -----Original Message----- > From: cruciatuz [mailto:sasoft at gmx.de] > Sent: Wednesday, November 28, 2001 10:17 PM > To: python-list at python.org > Subject: Re: 1st day newbie question. > > > On Wed, Nov 28, 2001 at 05:06:10PM -0300, Alves, Carlos > Alberto - Coelce wrote: > > short hint: > If you're under windows and you're not used to use the command prompt, > you can put a > > raw_input() How should look like that use of raw_input() function?! > > at the end of your script and you can start the text-file with a > double-click if it has the *.py extension. > try that if you want to avoid the command prompt at the beginning. > > -- > Stefan Antoni > ---------------------------- > Mit Nov 28 20:12:31 EST 2001 > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andreas at andreas-jung.com Tue Nov 27 18:03:18 2001 From: andreas at andreas-jung.com (Andreas Jung) Date: Tue, 27 Nov 2001 18:03:18 -0500 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: <089901c17797$b466fd60$3e17a8c0@suxlap> In Microsoft we trust ! On good example of "supporting" standards is WebDAV. When WebDAV came up some years ago, Microsoft claimed to support this standard. Nowadays Microsoft support WebDAV in a way where you can talk through WebDAV from MS clients to MS servers. I have spent a long time debugging problems between Microsofts WebDAV implementation and other WebDAV servers. They violate the HTTP 1.1 and WebDAV specs in many ways, making it nearly impossible to write compliant server side WebDAV implementations. Andreas --------------------------------------------------------------------- - Andreas Jung Zope Corporation - - EMail: andreas at zope.com http://www.zope.com - - "Python Powered" http://www.python.org - - "Makers of Zope" http://www.zope.org - - "Life is a fulltime occupation" - --------------------------------------------------------------------- ----- Original Message ----- From: "Ken Seehof" To: "python-list" ; "stephen cox" Sent: Monday, November 26, 2001 22:08 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) > > > I see "a few socially conscious businesses" should use software from THE > > > socially conscious business of the World ;) > > Stephen Cox wrote: > > Except for the webserver, they do. MySQL as the backend database, ASP and > > PHP are the scripting langs. I'm learning Python so I can use ZOPE more. > > True, I think .NET is cool - but I'll only use it if MS keeps it promise > and > > ports it too Linux and such. > > Odds of MS keeping any promises of this kind: 0.027% > > .NET will be cool until everyone starts using it as an industry standard. > At > that precise moment, MS will introduce various incompatibilities that will > maximize problems for their competitors. In the mean time, they will > continue > to promote .NET as the standard for open archetecture development. Of > course, if MS hadn't created .NET, somebody in the open source community > would have, and MS would have lost a great deal of control over the market. > They know this, and that is why they occupied the nitch with .NET. > > It has never been in MS's best interest to be compatible with the rest of > the > computing world. > > - Ken > > > > -- > http://mail.python.org/mailman/listinfo/python-list > From sholden at holdenweb.com Mon Nov 26 09:40:03 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Nov 2001 09:40:03 -0500 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <3BFC1E16.62F22494@home.net> <3BFC92FC.FEEC75BF@engcorp.com> Message-ID: "Peter Hansen" wrote in message news:3BFC92FC.FEEC75BF at engcorp.com... > Chris Barker wrote: > > > > Peter Hansen wrote: > > > The usual approach is simply to profile the > > > code and recode the "hot spot" in C. > > > > This is a problem, not a solution! Most of the code I write is in Python > > and it is "fast enough", but not all. And while I end up having to write > > only little bits in C, those little bits take me a whole lot longer than > > a large bits of Python code. > Aa, yes, the good old 80/20 rule strikes again. > I still see it as a solution, but obviously that's a personal > opinion (which, as the "customer", I then impose on the team :-). > I consider 95% of all optimization that programmers do to be > entirely unnecessary, amounting to nothing more than "faster" > and for no other reason than "we need it faster" (which is > usually not true). > It's surprising how often the question "How fast is fast enough" isn't asked in advance of a project's testing stages. Clearly there are some areas (scientific computing, image analysis) that do benefit from liberal applications of C, but Python tends to be used as a glue language in these contexts. > The only acceptable reason for optimization (in this view) > is "our customer requires response time of X and we are > running at Y" (where Y is slower than X). The only acceptable > amount of optimization is up to the point where Y equals X. > Correct. > So far, other than casual improvements as we refactor the > code for other reasons, we have not in two years of use > of Python actually *needed* to optimize anything. I can > readily dissuade anyone in our group from trying very hard > to optimize by pointing out that their best efforts would > produce only a tiny fraction of the speedup we would see by > using C. The fact that rewriting in C is non-trivial just > serves to keep us focused back on functionality that *is* > required by the customer, rather than constantly answering > the siren song of "faster, faster". > Indeed. My own experience with Python (though I don't do any scientific computing, and not much with images either) is that it goes fast enough. In areas where it doesn't go fast enough, using Python plus C modules is still quicker (I believe) than writing the whole project in C from the start. > (Yes, obviously a somewhat obtuse attitude, and no doubt > we're not quite that extreme, but I think it makes the > point.) > > But then again, I'm still using a Pentium 233 MMX which > is lots fast enough for home use. Those with PCs slower > than this might have more credibility arguing for > speed-ups in Python than those with the latest 2GHz > chips... > My ancient hardware still drives Python fast enough for my purposes. When it doesn't, I'll use that as an excuse to upgrade the old stuff, not winge about the expense of writing in C <0.8 wink>. I'm looking forward to my 1.7GHz laptop... old-codgers-have-to-stick-together-ly y'rs - steve -- http://www.holdenweb.com/ From kwg at renre-europe.com Wed Nov 14 09:37:35 2001 From: kwg at renre-europe.com (Ken Guest) Date: 14 Nov 2001 14:37:35 +0000 Subject: PEP proposal: enhanced string functions In-Reply-To: References: Message-ID: <1005748660.25769.12.camel@lewis> On Wed, 2001-11-14 at 13:46, Mikael Olofsson wrote: > > On 14-Nov-2001 Matthew Dixon Cowles wrote: > > I'd prefer to be able to pass a sequence to strip() and have > > any of those characters stripped. > > On 14-Nov-2001 Oliver Fromme wrote: > > For the center() case, it might be useful to optionally > > allow another argument, so you can have different padding > > on the left and on the right. > > > > Example: > > >>> string.center(" Title ", 25, ">", "<") > > '>>>>>>>>> Title <<<<<<<<<' > > To conform with Matthew's proposal about strip(), you might want to use > the same argument for left and right padding in center(), as in > > >>> string.center(" Title ", 25, "><") > '>>>>>>>>> Title <<<<<<<<<' Mikael, I think you're wrong to think that center should only take only 3 parameters. What if somebody wants the result to look like "-=-=-=-= Title ......."? That said, how about having it that: 1. When there are 3 parameters, the third parameter is used for padding on both the left and right of " Title" eg: >>> string.center(" Title ", , "-=") '-=-=-=-=- Title -=-=-=-=-' 2. When there are 4 parameters, the third parameter is used for padding on the left of " Title " and the fourth parameter is used for padding on the right. eg: >>> string.center(" Title ", , "-=", "#") '-=-=-=-=- Title #########' k. From hurst at hik.fzk.de Mon Nov 19 09:34:15 2001 From: hurst at hik.fzk.de (Christof Hurst (FZK)) Date: Mon, 19 Nov 2001 15:34:15 +0100 Subject: [IO] Communication between Java and Python Message-ID: <3BF91867.3BBDD486@hik.fzk.de> i want to send data between a Java-Applet and a python servlet. how do i get a Connection and how do i send values? is there a possibility to send binary streams or integer-values? i want to send in both ways. From kriol at boopsie.fnal.gov Thu Nov 15 13:19:43 2001 From: kriol at boopsie.fnal.gov (Oleg Krivosheev) Date: 15 Nov 2001 12:19:43 -0600 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> <97ae44ee.0111140921.281c4b7@posting.google.com> Message-ID: shriek at gmx.co.uk (Stephen) writes: > > >> IMHO the SMTP and POP protocols provide the same benefit (and there > > >> are Python modules for those protocols). > > > > shriek> Using a mailserver as a messaging platform for middleware ? > > > > It's not all that far-fetched. I know some people have experimented with > > XML-RPC over SMTP (which is no longer XML-RPC, but that's a nit). > > OK, let me show an example where I think we need some sort > of basic message queue ~ > > > I'm guessing this means that the server is max'ed out and > can't handle any more. thread per request is not scalable... Use async io capabilities with fixed number of threads. Usually it will be better discussed in comp.programming.threads because it is quite platform insensitive > > How should I handle this error ? Yes, with a "try/except" > but what should the "except" do, because if the server is > too busy, it's probably no point retrying immediately. > > So, you see, I was looking for something more immediate than > SMTP, that also takes care of the message queueing. Writing > code to manage the queue and buffering could be horrendous. > > Is there any way to get this up to say 1,000 requests/sec peak load ? see above > In reality, I'm going to want to put some Database query > into the RequestHandler too so it'd be even slower. > Does this sound possible ? > > Am-I-asking-too-much-of-Python-ly-your's, maybe yes, maybe no if overall your server would be mostly IO bound, then Python might be ok, just plan to use a bit more power CPU > Stephen OK From kragen at canonical.org Sun Nov 25 20:56:15 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 20:56:15 -0500 Subject: python compiler compiler google results References: <3c009440$1@207.229.64.20> Message-ID: <83u1vithvk.fsf@panacea.canonical.org> "Peter Bismuti" writes: > Ok, I know, Google 1. Post 2. > > I found PLY (Python Lex-Yacc). > I also found PyLR -- Fast LR parsing in python. > Any Others? SPARK? > One with a wide range of languages already > implemented is important. I'm interested in Java, > Python, Perl, but not C or C++. There are no correct parsers for Perl. The only one that comes close is perl itself, and it has to actually run bits of the code to figure out how to parse the rest. No lie. From rpb at soton.ac.uk Wed Nov 28 09:42:52 2001 From: rpb at soton.ac.uk (Richard Boardman) Date: Wed, 28 Nov 2001 14:42:52 -0000 Subject: Expat XML Parser Message-ID: <9u2t5e$kh4$1@aspen.sucs.soton.ac.uk> Hello, I've only been using Python for about a week or so, having previously used Tcl for all my scripting needs. However, on the recommendation of a friend, I have forayed into the world of Python. I am trying to use the Expat XML parser to extract some data for processing - sounds simple enough - although I am having great difficulty finding documentation for Expat and am consequently very stuck. Here is the code I have; mostly gleaned from the one or two examples I managed for find for Expat. After taking out some of the extraneous bits, my problem reads thus: # read in XML for processing filetoread = "xyz.xml" sourcexml = open(filetoread, 'r') xmlpp = sourcexml.read() def s_el(name, attrs): print name, "(attributes -->", attrs, ")" def e_el(name): print " (attribute", name, "ends)" def c_data(data): print " `--->", data prs = xml.parsers.expat.ParserCreate() prs.StartElementHandler = s_el prs.EndElementHandler = e_el prs.CharacterDataHandler = c_data prs.returns_unicode = 0 prs.Parse(xmlpp) # end The problem major is that I can't seem to return any of these values at all - they will all print on the screen, but I can't actually *do* anything with these values. I don't think it's anything to do with Expat; more my lack of experience with this language. I can't find any documentation explaining how Expat works. What I'd like to do is have something that works thus: readInXML foreach element in XML if element = "abcdefg" { getCharacterData doStuff with characterData } ... so in the following ... 1 2 3 4 ... I could check the value is 'data', return the attribute identified as '1' and then return the block of data in, say, a list. A few pointers/websites/ideas/pieces of code or whatever would be *greatly* appreciated. Thanks very much in advance. -- Regards, Richard Boardman High Performance Computing Group Level 3 Zepler Building (59) University of Southampton Southampton SO17 1BJ e-mail: rpb01r at ecs.soton.ac.uk From sdm7g at Virginia.EDU Fri Nov 16 17:27:23 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 16 Nov 2001 17:27:23 -0500 (EST) Subject: python vs ecmascript In-Reply-To: Message-ID: On Fri, 16 Nov 2001, Peoter Veliki wrote: > > > also a bit annoyed at some things like having to wrap objects in a str() > > > before > > > printing, I don't see why this can't be automatic. > > > > Since when? The print statement automatically invokes str() on its > arguments. > > From the documentation: > > I'm using Python 2.0 at the moment (it is necessary as it is integrated > into another product), perhaps this limitation was removed in later > versions. If I try to do this: > > print "integer i = " + i > > it will barf on this and tell me that i is not a string, I must do this: > > print "integer i = " + str(i) > You don't need the 'str' -- you can do: print "integer i =", i print doesn't require the 'str' : '+' does! string concatenation and integer addition don't mix, and it's not exactly clear what an expression like: "6" + 2 ought to yield: "62" or 62 or 8 or "8" ? Labeling ambiguous statements as an error makes for stronger typing than auto-magic conversions. [ I still think it was a mistake to use the same token for both addition and concatenation, but it's too late to fix that glitch! ] -- Steve Majewski From ursus_horibilis at hotmail.com Tue Nov 27 13:24:08 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Tue, 27 Nov 2001 13:24:08 -0500 Subject: Integer Overflow References: <9u0jor$2li$1@peabody.colorado.edu> Message-ID: "Fernando P?rez" wrote in message news:9u0jor$2li$1 at peabody.colorado.edu... > Ursus Horibilis wrote: > > > Is there a way to force the Python run time system to ignore > > integer overflows? I was trying to write a 32-bit Linear > > Congruential Pseudo Random Number Generator and got clobbered > > the first time an integer product or sum went over the 32-bit > > limit. > > well, you can always put the relevant parts in a try:..except block, but I > suspect that will kill the speed you need for a rng. Yes, I did put the computation in a try-block and you're right, it killed the speed, but worse, it also didn't store the low-order 32-bits of the computation. > If it's just an academic > algorithm exercise It's not. Such computations are routinely used in algorithms like PRNG's and cryptography. > Out of curiosity, though: I've never written a rng myself. In C, an integer > overflow silently goes to 0. No. In C, an integer overflow silently throws away the high-order bits, leaving the low-order bits just as they would be if you had a larger field. As an illustration, assume we are working with 8-bit integers instead of 32-bit. Then here's what happens with integer overflows: signed char a = 127; /* in binary = 01111111 */ a = a * 2; /* Because of sign, a = (-2) */ a = a * 2; /* Because of sign, a = (-4) */ a = a + 128; /* Sign bit gets inverted, a = 124 */ > Are you relying on this 'feature' in your > algorithm? I'm just curious about to whether asking to ignore an overflow > without triggering an exception is a design feature or a flaw of the way you > are doing things. The algorithm relys on the ability to ignore the fact that overflow has occurred and continue with the computation using the low-order bits. This is not my algorithm; it's as old as computer science, and then some. Here is how we implement one particular 32-bit Linear Congruential Pseudo Random Number Generator in C: unsigned int Lcprng(unsigned int *seed) { *seed = 29 * (*seed) + 13; return (*seed); } How do you do this in Python? From sandskyfly at hotmail.com Thu Nov 22 08:35:30 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 22 Nov 2001 05:35:30 -0800 Subject: Proper usage of properties in 2.2 Message-ID: Hi, I've been playing round with properties in 2.2b2 and I'm having a bit of trouble understanding what I _shouldn't_ be doing when I use them. For example this simple code doesn't work: Python 2.2b2 (#26, Nov 16 2001, 11:44:11) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. IDLE 0.8 -- press F1 for help >>> Example #1 >>> class Room: def __init__(self, width, length, fixed='length'): self.width = width self.length = length self.fixed = fixed def get_area(self): area = self.width * self.length return area def set_area(self, area): if self.fixed == 'length': self.width = area / self.length if self.fixed == 'width': self.length = area / self.width area = property(get_area, set_area, None, "Area of Room instance") >>> r = Room(10.0, 30.0, fixed='width') >>> r.area 300.0 >>> r.width 10.0 >>> r.length 30.0 >>> # So far so good. Now why doesn't this work? >>> r.area = 500 >>> r.length 30.0 >>> r.length = 500 / r.width # this should have happened >>> r.length # giving this: 50.0 >>> # Example 2: another version that also doesn't work: >>> class Room: def __init__(self, width, length, fixed='length'): self.width = width self.length = length self.fixed = fixed self.__area = None def get_area(self): self.__area = self.width * self.length return self.__area def set_area(self, area): self.__area = area if self.fixed == 'length': self.width = self.__area / self.length if self.fixed == 'width': self.length = self.__area / self.width area = property(get_area, set_area, None, "Area of Room instance") >>> r = Room(10.0, 30.0, fixed='width') >>> r.area = 500 >>> r.length 30.0 Now what am I doing wrong here? Is it that I'm not supposed to change the value of another instance vars in a property set method? Do I have to write property set/get methods for 'length' and for 'width' then? Also another minor question: how does one get access to the doc string of the property? Thanks in advance, Sandy From dalke at dalkescientific.com Thu Nov 1 22:17:25 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 1 Nov 2001 20:17:25 -0700 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> <3BE20B6E.F9275CD0@cosc.canterbury.ac.nz> Message-ID: <9rt3co$rid$1@slb2.atl.mindspring.net> Greg Ewing: > input = ''.join(range(256)) input = "".join(map(chr, range(256))) Andrew From skip at pobox.com Wed Nov 14 07:27:34 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 13:27:34 +0100 Subject: Python .elc and /etc/magic In-Reply-To: References: Message-ID: <15346.25398.863239.868725@beluga.mojam.com> >> And even, if one knows the proper incantations, how do we proceed >> then for having that `/etc/magic' file more universally modified? Michael> I have no idea. I hope it's not a case of badgering each Michael> distro separately... I hope not, but you never know. From the file(1) man page: History ... Primary development and maintenance from 1990 to the pre- sent by Christos Zoulas (christos at astron.com). Altered by Chris Lowth, chris at lowth.com, 2000: Handle the ``-i'' option to output mime type strings and using an alternative magic file and internal logic. Altered by Eric Fischer (enf at pobox.com), July, 2000, to identify character codes and attempt to identify the lan- guages of non-ASCII files. Availability You can obtain the original author's latest version by anonymous FTP on ftp.astron.com in the directory /pub/file/file-X.YY.tar.gz My guess is that if you send mods to all three of those people, one of them will be able to wedge them into the distribution. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From wurmy at earthlink.net Thu Nov 22 22:41:25 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Fri, 23 Nov 2001 03:41:25 GMT Subject: Indenting with tabs vs spaces References: <3BFDB593.39AFC7FD@earthlink.net> Message-ID: <3BFDC564.691550FB@earthlink.net> Ron Stephens wrote: > > OK, now you all have got me worrying about a new thing. All my code so far is > indeented with single tabs (four spaces I think). Since I use IDLE or sometimes > PythonWin when I code, will my tabs screw up anyone else trying to run my code? > H9ow about if I use Windows Notepad? > > I hate spaces, like tabs. Single tabs are alright. So are spaces. It's the mixing of the two that causes indentation errors. --Hans From guy.theisen at isp.lu Fri Nov 16 05:56:08 2001 From: guy.theisen at isp.lu (GT) Date: 16 Nov 2001 02:56:08 -0800 Subject: Sign Problem in Python Message-ID: Hi, I'm working on a Win2000 platform. I try to make a query in a database, but Pyhton has little problems to manipulate signs like ????? etc... Is there a possibility that Python could understand this. Or is there an octed or hex solution to resolve this. Or can I set an ISO Norm in Python like in Java. my query looks like this: query = eq('?mission') --> problem is the "?" Thanks for any help GT From richard at bizarsoftware.com.au Mon Nov 19 19:33:40 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Tue, 20 Nov 2001 11:33:40 +1100 Subject: Two questions about Python.. In-Reply-To: <3BF99E55.2C300858@hotmail.com> References: <3BF99E55.2C300858@hotmail.com> Message-ID: <200111200034.fAK0Y5317917@bigboy.bizarsoftware.com.au> On Tuesday 20 November 2001 11:05, Ken wrote: > I'm looking into using Python for a project, and was wondering how does > Python rank up against other scripting languages for speed? Very well. > I assume its not as fast as something like C, which isn't an option as I > need a > scripting language. You have the option of throwing in C extension modules for python, which aren't that hard to code, and do help speed things up considerably. http://www.python.org/doc/current/ext/ext.html > Second question is, does Python have a robust exception handling system? > > Ie.. if a program loads a module and that module has a logic error in > it, > can the program recover? Or will it crash? Absolutely. http://www.python.org/doc/current/tut/node10.html Richard From david at dataovation.com Mon Nov 26 10:45:48 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 26 Nov 2001 07:45:48 -0800 Subject: smtplib help In-Reply-To: <1006787411.9902.0.nnrp-08.c1c3e1d9@news.demon.co.uk> Message-ID: I do call quit(). Is is possible that the script is moving too fast for the smpt server to keep up? If so, how can I slow it down? David -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Paul Brian Sent: Monday, November 26, 2001 6:55 AM To: python-list at python.org Subject: Re: smtplib help David, its hard to comment, but I suspect that the error you are getting comes from the SMTP server. Basically line 222 in smtplib calls on the socket module, which has an error code: errorTab[10048] = "The network address is in use." (line 79) (I am using 2.1.1 - Your version presumably has a different error msg ) So I suspect that the server is keeping alive sessions - I would check by quiting the session each time (xxx.quit()) you send a message. Hope that helps David A McInnis wrote in message news:mailman.1006768891.31431.python-list at python.org... Any ideas why smtplib would crash on me after about sending 150 email msgs (i did not count, but that is a good estimate)? This is the error that I am getting. File "C:\Python21\mm_mime.py", line 93, in Send server = smtplib.SMTP(host) File "C:\Python21\lib\smtplib.py", line 187, in __init__ (code, msg) = self.connect(host, port) File "C:\Python21\lib\smtplib.py", line 222, in connect self.sock.connect((host, port)) File "", line 1, in connect error: (10048, 'Address already in use') David McInnis -- http://mail.python.org/mailman/listinfo/python-list From fredrik at pythonware.com Tue Nov 6 19:51:14 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 00:51:14 GMT Subject: importing a tcl/tk widget References: <3daa1aa8.0111051555.125dbd8e@posting.google.com> Message-ID: <6A%F7.4683$R43.747420@newsb.telia.net> "Jeffrey" wrote > I know that you can write a Tkinter wrapper function but I don't > really know how to do this. assuming you mean what you wrote, it's not that hard to write wrappers for new widgets (the hard part is probably to link them into Tkinter). here's a minimal wrapper which wraps a small portion of the standard Entry widget. import Tkinter class Entry(Tkinter.Widget): def __init__(self, master=None, cnf={}, **kw): Tkinter.Widget.__init__(self, master, "entry", cnf, kw) def delete(self, first, last=None): self.tk.call(self._w, "delete", first, last) def get(self): return self.tk.call(self._w, "get") def index(self, index): return int(self.tk.call(self._w, "index", index)) def insert(self, index, string): self.tk.call(self._w, "insert", index, string) ::: details: the Tkinter.Widget constructor takes a master (None for the default window), the name of the Tk widget, and two dictionaries (which provide options; they're merged inside the constructor). the constructor takes the widget name, the master, and the options, and turn that into a Tcl command: entry .1020213 -option value -option value self._w is the Tk name for the widget (set by the constructor). it's usually a sequence of dot and obscure integers. the self.tk.call method takes one or more arguments, and execute the corresponding Tcl command: self.tk.call(self._w, "get") is mapped to a Tcl command looking something like: .1020213.3221021 get tuples are converted to Tk lists (recursively), None is ignored, and all other types are converted to string arguments. that's it. ::: or maybe you're just looking for the create_window function. see laura's answer for details. From James_Althoff at i2.com Thu Nov 1 16:15:44 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 1 Nov 2001 13:15:44 -0800 Subject: python development practices? Message-ID: Peter Wang wrote: >thanks for the warning. we're adopting the convention of all data is >default private (unless in a rare, commented exception case), using >get/set functions, and the rule of "if it ain't in the unit test, >don't use it." Bravo. (Yet another victory for the _Anti_Underscore_Secret_Society__) Jim From syring at email.com Wed Nov 28 12:40:44 2001 From: syring at email.com (Karl M. Syring) Date: Wed, 28 Nov 2001 18:40:44 +0100 Subject: writing to parallel port? References: <55881dd4.0111280848.3d2b38ab@posting.google.com> Message-ID: <9u37ml$5she0$1@ID-7529.news.dfncis.de> "Markus" schrieb > Hallo everybody, > > is it possible to write to the > parallel printer port from > Python? > > (win32 system) What about: printer = open('lpt1:','w') printer.write("a blast from the past!") printer.close() Karl M. Syring From lfini at arcetri.astro.it Mon Nov 26 02:50:22 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Mon, 26 Nov 2001 08:50:22 +0100 Subject: Does Anybody Know How To Get Tkinter Working?? In-Reply-To: References: Message-ID: On Sat, 24 Nov 2001, Ben Ocean wrote: > I just configured Tcl--itworks--and I went to configure tk (both latest > stable distros) on my RH71 box and ran into all sorts of errors on *make*. > Both installations are in /usr/lib and I'm in as root. It exits with Error RH 7.1 comes with python and Tkinter ready for use. You should use that instead of compiling yourself unless you have a specific reason to do so. If you do not find python and/or tkinter on your systems maybe you did not do a full installation and you must install the required packages: go and look for python related packages on the RH distribution CD. Cheers, l.f. -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From jcmason at student.math.uwaterloo.ca Tue Nov 20 16:22:58 2001 From: jcmason at student.math.uwaterloo.ca (Joe Mason) Date: 20 Nov 2001 21:22:58 GMT Subject: Basic question about SWIG Message-ID: <9tehji$b02$1@watserv3.uwaterloo.ca> I'm trying to make a Python wrapper for a C library using SWIG. The library API is defined in a single header file (http://www.eblong.com/zarf/glk/glk.h) After applying the patch at the end of this post, I'm trying to run swig directly on the .h file ("swig -python glk.h") The problem I'm running into is with typedefs. The .h file does: typedef unsigned long glui32; ... extern glui32 glk_gestalt(glui32 sel, glui32 val); extern glui32 glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, glui32 arrlen); It seems to me from reading the user's manual that SWIG should pick up this typedef and know enough to treat glui32 as an int thereafter. But when I try to compile the glk_wrap.c file, I get: glk_wrap.c:558: warning: parameter names (without types) in function declarationglk_wrap.c:559: parse error before `glk_gestalt' glk_wrap.c:559: warning: parameter names (without types) in function declarationglk_wrap.c:559: warning: data definition has no type or storage class glk_wrap.c:560: parse error before `glk_gestalt_ext' glk_wrap.c:560: parse error before `*' Followed by about a thousand more errors for the other functions using glui32. Checking glk_wrap.c I find that the lines it's complaining about are: extern glui32 glk_gestalt(glui32 ,glui32 ); extern glui32 glk_gestalt_ext(glui32 ,glui32 ,glui32 *,glui32 ); And glui32 isn't defined anywhere in the file. Here's a minimal interface file showing the problem: %module test %{ testint add_to_a(testint a) { return a+1; } %} typedef int testint; extern testint add_to_a(testint a); So what's my bad assumption? Why is SWIG ignoring these typedefs? Also, I was under the impression that if glui32 weren't typedef'd to int, SWIG would assume it was a complex structure and create wrappers to treat it as an opaque structure, but that doesn't seem to be happening either. Why not? Joe (Here's the patch if anyone wants to try this with glk.h itself. I know there'll be other problems with it, though, due to weirdnesses in the structure of the glk libraries.) --- ../glk.h Tue Nov 20 14:45:01 2001 +++ glk.h Tue Nov 20 14:59:38 2001 @@ -1,3 +1,7 @@ +#ifdef SWIG +%module glk +#endif + #ifndef GLK_H #define GLK_H @@ -171,8 +175,10 @@ extern void glk_main(void); extern void glk_exit(void); -extern void glk_set_interrupt_handler(void (*func)(void)); extern void glk_tick(void); + +typedef void (*glk_interrupt_func)(void); +extern void glk_set_interrupt_handler(glk_interrupt_func func); extern glui32 glk_gestalt(glui32 sel, glui32 val); extern glui32 glk_gestalt_ext(glui32 sel, glui32 val, glui32 *arr, From spam at melkor.dnp.fmph.uniba.sk Fri Nov 2 15:08:28 2001 From: spam at melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Fri, 2 Nov 2001 21:08:28 +0100 Subject: ANNOUNCE: PySteroids 2.0 References: Message-ID: Lucio Torre wrote: : Im happy! this is public release of pysteroids 2.0. my asteroids game : done with pygame. : Nothing near paradigm shifting in games, but its my baby. : check it out at: : http://vampira.dyndns.org/zope/software/ you meant https://vampira.dyndns.org/zope/software/, right? -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik | | __..--^^^--..__ garabik @ fmph . uniba . sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From bh at intevation.de Tue Nov 20 06:07:57 2001 From: bh at intevation.de (Bernhard Herzog) Date: 20 Nov 2001 12:07:57 +0100 Subject: Try block problem References: <9tcnls$42k$1@news1.ucsd.edu> <3bf9eacb$0$79564$6e49188b@news.goldengate.net> <9td60p$g15$1@news1.ucsd.edu> Message-ID: <6qoflxem42.fsf@abnoba.intevation.de> Jeff Davis writes: > I am not sure you understood my question. I wanted to know why the > "finally" could not be used with "try", i.e. why did the developers of The original question was about "try" and both "except" and "finally". (just for clarification to get the context right) > python choose to make the language that way. IIRC, the reason is that the precise sematics are not clear in every situation. For instance, what happens if an exception is raised in an except clause? Should the finally clause be executed in that case or not? Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From grey at despair.dmiyu.org Fri Nov 30 18:10:44 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 30 Nov 2001 23:10:44 -0000 Subject: Indenting with tabs vs spaces References: Message-ID: On Thu, 22 Nov 2001 03:58:08 -0800, Peoter Veili wrote: > Indenting with tabs can be done such that it will look the same on every > editor that uses fixed-width fonts, meaning everything will line up > correctly, it least in the sense that really matters. Here's an example of > what I mean: Uhhh.... > function helloThere("hello", > "there"){ > } ...no. > The proper way to do this is the second line needs to be typed with one tab > followed by enough spaces to line up the "hello" and "there". A tab is a variable. I have tab set to 2 spaces. You have it set to 8. So by your logic you hit tab + 32 spaces. To you that would b 40 spaces. To me that is 32. 40 != 32, even for large values of 32. > This way the "hello" and "there" will line up correctly on any editor. If > the person was lazy and tabbed all the way out to right before "there" and > then filled in with a few spaces, it may not line up depending on what your > tabwidth is set to. Which is what happens if you use a single tab or 32 tabs. A space is a space. 1=1. All others are variable. > Besides this I know of no problems with using tabs. I find them cleaner and > more efficient. I'd rather tab 10 times than hit the space bar 40 times. I > never have to go through a whole file and manually line things up because at > one place in the file I accidentally didn't indent with the right amount of > spaces and half the file needs fixing. Auto-indent helps, but still.... So does moving blocks back and forth (>> and << in vim, ^K> and ^K< in Joe, etc...). Mark the beginning, mark the end, move block. No biggie. As for hitting space 40 times or tab 10 I rather hold down the space bar once. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From cliechti at gmx.net Tue Nov 13 17:15:52 2001 From: cliechti at gmx.net (Chris Liechti) Date: 14 Nov 2001 00:15:52 +0200 Subject: PEP 276 Simple Iterator for ints References: Message-ID: David Eppstein wrote in news:eppstein-CAD736.14225013112001 at news.service.uci.edu: > As a possibly-related side note to this debate: > > I have been moving towards using Python-like pseudocode in my > algorithms classes in place of the C/C++/Java-like pseudocode I was > previously using; that is, using colons and indentation to mark blocks > of code instead of curly braces, etc. As well as conciseness, Python > offers some other advantages e.g. in the ability to write code with > list comprehensions. The single biggest barrier for me to write actual > working Python code is the range/xrange syntax: I just don't feel > comfortable writing code like > > for i in range(n-1,-1,-1): > for j in range(i+1,n+1): > ...do something... > > because I don't expect my students (who are not required to learn > Python) to understand from that syntax that the outer loop runs > backwards from n-1 to 0 and that the inner loop runs from i+1 to n. > > Instead I have to make up some non-Python syntax which is less formal > but immediately clear: > > for i in [n-1, n-2, ... 0]: > for j in [i+1, i+2, ... n]: > ...do something... > > (actual example from ). > As far as I can see, the PEP under discussion (which simply replaces > the word "range" by "iter", creates an iterator instead of a list, and > perhaps only allows the single-argument version of range) doesn't help > me at all in my desire to have lecture notes which are both intuitively > understandable and runnable. python has callable instaces, which led me to the following experiment :-) how a about something like that: >>> class Int: ... def __call__(self, *args): ... return int(*args) ... def __getitem__(self, index): ... if isinstance(index, types.SliceType): ... if index.step: ... return range(index.start, index.stop, index.step) ... else: ... return range(index.start, index.stop) ... else: ... return range(index) ... >>> myint = Int() #and now for the user's view #thats like the original: >>> myint('123') 123 >>> myint('abc',16) 2748 #that's new: >>> myint[1:7] [1, 2, 3, 4, 5, 6] >>> >>> for i in myint[1:10]: ... print i, ... 1 2 3 4 5 6 7 8 9 >>> for the "for" loop you have to write "myint[...]" and not just "[..]" as in your example above, but you can think about selecting the number space for the operation. (e.g. "mylong[...]" or "myfloat[...]" etc.) of course the "range" should be replaced with an iterator, but i haven't played around with them yet, so i took what i know that it works. instead of "myint" this could be named "int" and override the builtin function. this should not be a problem as it behaves like the original when used like the original. backwards compatibility is also no problem, since until now "int[]" raised a "TypeError: unsubscriptable object". for your student you could pack this into the site customization script. i have to admit that this soloution doesn't yet looks that good when counting backwards (like in your example above). but at least nobody asks about what "range" is... chris -- Chris From spamtrap at magnetic-ink.dk Fri Nov 9 14:13:44 2001 From: spamtrap at magnetic-ink.dk (Klaus Alexander Seistrup) Date: Fri, 9 Nov 2001 20:13:44 +0100 Subject: CORBA client & server with Python References: <01c168fd$978fe8d0$06d1178b@mvn40020> Message-ID: <4d0238a4-9842-4f12-a592-c6da04a5c05a@zigzag.magnetic-ink.dk> Murat Demir wrote: > did someone try to write CORBA client and server applications > with Python? Fnorb is a CORBA ORB written in Python, see . // Klaus -- ><>? vandag, m?re, altyd saam From ab at spkypc.demon.co.uk Tue Nov 27 10:59:46 2001 From: ab at spkypc.demon.co.uk (ab) Date: Tue, 27 Nov 2001 15:59:46 GMT Subject: poll() on a linux box always returns POLLIN Message-ID: <200111271559.fARFxkq01774@linux.local.spkypc> Thanks for this. Found a change request in he kernel which stated that when a remote client disconnects, poll keeps returning POLLIN, and you need to do what you recommend, checking the return length from recv ! Never quite as simple as poll returning POLLHUP ! Anthony From skip at pobox.com Wed Nov 14 10:32:36 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 16:32:36 +0100 Subject: How to know when a variable is set In-Reply-To: References: Message-ID: <15346.36500.337425.454231@beluga.mojam.com> >> How can I test if a variable has been given a value, or if it's >> undefined? try: x except NameError: pass -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problem. Of course, if we only want to solve 25% of our problem it becomes a 100% solution. From jtdubs at eos.ncsu.edu Thu Nov 15 15:49:43 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Thu, 15 Nov 2001 15:49:43 -0500 Subject: Explain string boolean expression References: <3bf428ba@skynet> Message-ID: <9t19lt$bin$1@uni00nw.unity.ncsu.edu> "Serg" wrote in message news:3bf428ba at skynet... > Explain please what exactly > "" or "Some" or "abbyds" > does? > > -- > Keep in touch. Your partner Maltsev. > > The empty string, "", is false. All other strings are true. Hope this is what you wanted to know. Have fun, Justin Dubs From terabaap at yumpee.org Mon Nov 12 21:03:28 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Tue, 13 Nov 2001 02:03:28 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> Message-ID: <3BF07FA7.10807@yumpee.org> Manoj Plakal wrote: > Basically, we need a portable, light-weight messaging > protocol with a simple way of finding out how > to connect to an application and calling some > of the methods it exposes. Without having to > do HTTP and XML and all that stuff that comes > with XML-RPC and SOAP. > > I came across Scarab at http://casbah.org/Scarab/ > This is interesting though the project's been abandoned. Forgot to add: the requirement could be re-stated as that of a portable, light-weight library for "instant-messaging" between applications running on the same machine. This might cover a lot of cases where you don't need RPC semantics (no return value expected) and you're sending simple data values (so no need of full-blown XML or other elaborate encoding). And you may not even need a reliable transport protocol (so no need of HTTP or even TCP). XML-RPC is cool but it seems like a really big and overweight hammer. E.g., sending a message to Word asking it to print a file, or asking Mozilla to open a web page, or an MP3 playlist manager accepting a request to play/pause/stop, etc. Manoj From python at commandprompt.com Tue Nov 27 03:31:43 2001 From: python at commandprompt.com (python at commandprompt.com) Date: Tue, 27 Nov 2001 00:31:43 -0800 (PST) Subject: [OT] PostgreSQL Book In-Reply-To: <3C03287C.C3EED358@engcorp.com> Message-ID: > Please don't do that. Do separate Python and Perl books. > There is no reason to make all of us buy 300 pages wastefully, > and they're so hard to tear out of the middle. Heh :) > > From michael at rcp.co.uk Fri Nov 30 07:15:55 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 30 Nov 2001 12:15:55 +0000 (UTC) Subject: Non-Indented python References: Message-ID: "Tim Peters" wrote in news:mailman.1006987971.23934.python-list at python.org: >> Personally, I would prefer that future versions of Python would allow >> ONLY tabs or ONLY spaces, but clearly there would be a major >> disagreement about which to use. > > It would be spaces -- "4-space indents, no hard tab characters > anywhere" is the coding standard for the Python library. > Tools/scripts/reindent.py is routinely run over the Lib directory to > ensure it stays that way, too. Please, please, it would be helpful if Python had a (configuration settable) option to reject tabs in all source. I'm glad to hear you work to keep tabs out of the Python sources, but a little more direct help from Python to prevent them creeping into my sources when someone else edits would be very helpful. From richard at bizarsoftware.com.au Wed Nov 28 18:56:09 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Thu, 29 Nov 2001 10:56:09 +1100 Subject: danny@clari.net.au Message-ID: <200111282356.fASNu0354406@bigboy.bizarsoftware.com.au> Addition to the BizarShop product install README: You will also need the following components installed: . Core Session Tracking http://www.zope.org/Members/mcdonc/Products/CoreSessionTracking Just follow the installation instructions there, and you'll be fine. Richard From rdsteph at earthlink.net Mon Nov 19 14:23:14 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Mon, 19 Nov 2001 19:23:14 GMT Subject: Help with my first CGI program??? Message-ID: <3BF95D73.2886D584@earthlink.net> Any help would be appreciated. I am getting a KEYERROR when I run my CGI program as a standalone python program. Maybe its just because the standalone python program doesn't have the input data from the FORM I use in my HTML input page to my CGI. Howver, I get no error messages from actaully running my CGI on the web (just a general serer error), even though I set sys.stderr = sys.stdout I know I'm a clueless newbie, but even any general help will be greatly appreciated. I think I am almost there, but I can't figure out a way to effectively debug my CGI program. IDLE gives me the following error message when I run the program in IDLE as a stand-alone program:: Content-type: text/html Traceback (most recent call last): File "C:/Python21/aaacgi.py", line 26, in ? rankings = {"ease of learning" : form['easelearning'].value, File "C:\PYTHON21\lib\cgi.py", line 547, in __getitem__ raise KeyError, key KeyError: easelearning The input HTML page is::: CGI 101

A first user interaction: forms


Input an integer from 1 to 100, as a weight or relative importance factor for each of the citeria below. 1 means not very importnat to you, 100 menas extremely important to you

ease of learning

ease of use

speed of program execution

quality of available tools

popularity

power and expressiveness

cross-platform

cost

The CGIU program follows. The data for FORM is fed into the cgi program by the HTML FORM above::: #!/usr/bin/python ####################################################### # runs on the server, reads form input, prints html; # url=http://server-name/root-dir/Basics/test3.cgi ####################################################### import cgi import string import sys sys.stderr = sys.stdout form = cgi.FieldStorage() # parse form data print "Content-type: text/html" # plus blank line html = """ test3.cgi

Greetings


%s


""" 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 = {"ease of learning":form['easelearning'].value, "ease of learning" : form['easelearning'].value, "ease of use" = form['easeuse'].value, "speed" = form['speed'].value, "tools" = form['tools'].value, "pop" = form['pop'].value, "power" = form['power'].value, "cross"] = form['cross'].value, "cost"] = form['cost'].value} 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} result = {} for o in options: value = 0 for c in criteria: value = value + rankings[c] * score[o, c] result[o] = value 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 html % ("Hello, %s." % form['easeuse'].value) print html % form['easeuse'].value From prabhu at aero.iitm.ernet.in Tue Nov 6 15:38:28 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 7 Nov 2001 02:08:28 +0530 Subject: (no subject) In-Reply-To: References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: <15336.19012.68375.860248@monster.linux.in> hi, >>>>> "BH" == Bernhard Herzog writes: BH> Do you mean that pkg_root is the CVS module? Ouch! BH> Well, there's a way to achieve it without much renaming in CVS BH> with CVS' modules file. If you create a new CVS module named BH> app with app.py and a line like BH> app app &pkg_root BH> a cvs checkout app should create an app directory with BH> pkg_root as subdirectory. Caveat: I'm not a CVS expert and I BH> haven't used this feature myself yet, but it's used quite a BH> bit in GNOME's CVS. Oh thanks for the hint! However, I dont have direct access to the repository - this is a sourceforge project (http://mayavi.sf.net) http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mayavi/mayavi/ But in any case I think I have it covered. I hacked knee.py to do exactly what i want. i need to test it more though. >> (1) Check if module is available in the same directory, if >> available - use it. >> (2) If not found walk up to parent dir. check there, if not >> there go up until out of package. >> (3) If not found in (2) look at sys.path for module. BH> I don't think that will help with your problem. At least not BH> as far as the app.py part is concerned. If you execute app.py BH> in pkg_root, all sub-packages are on the top-level, i.e. there BH> is not parent package, because pkg_root is in sys.path. Oh, app.py is not the problem. Actually the app.py I was talking of is a script that can handle itself and I dont mind fooling with one file to get things working but changing everything else to use FQN's (fully qualified names) is a pain. Anyway I modified knee.py to make my approach work! The fix was about 10 lines of code. Will test it some more out early tommorow and mail you folks the code. Its late, so God knows what goofs I may have made but so far it works great for my silly test package!! Will fill you folks in later tommorow. prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 From kzander at hot.rr.com Thu Nov 8 10:34:59 2001 From: kzander at hot.rr.com (Kristen Zander) Date: Thu, 08 Nov 2001 15:34:59 GMT Subject: Reading a comma delimited file Message-ID: I am creating a system to load existing flat files that are not "truly" comma delimited from the web onto a server, run a macro on them and "fix" them, and then dump the data into a database. I've got the files coming over, running the macro ok, and the data looks good. I am getting the data out and trying to get it into a list, tuple structure in order to use the executemany() call in ODBC. Here's my code so far: dbfile = open(newname,'r') table = [] lines = dbfile.readline() newtable = [] for line in lines: *Split the .csv file into rows and take off the newline character line = line[:-1] r = string.split(line,',') table.append(r) for x in table: *Take each list of strings within the list and change the numbers from strings to dump into the table t=[] for all in x: if all.isalpha() == 0: num = float(all) else: num = all t.append(num) newtable.append(tuple(t)) **Make a new table with the list, tuple structure Here's what it looks like when I'm done: [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1, 20.0, 0.0, 167.30000000000001), ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0, 6.0999999999999996, 13.9, 0.0, 239.0)] Just what I need except I don't want all those decimal places. I've tried searching the help and I'm sure there is a very simple call to fix this. Can someone help me out on this. Also, I'm new at Python and am not sure this is the best way to accomplish my task, and any suggestions as to how I might increase speed by doing it another way would be great. One .csv file could and many times will have up to 14000 rows of data to be dumped into the database. Thanks, Kristen Zander From phd at phd.pp.ru Mon Nov 26 16:20:45 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 27 Nov 2001 00:20:45 +0300 Subject: smtplib help In-Reply-To: <83wv0ds4pk.fsf@panacea.canonical.org>; from kragen@canonical.org on Mon, Nov 26, 2001 at 02:38:15PM -0500 References: <83wv0ds4pk.fsf@panacea.canonical.org> Message-ID: <20011127002045.A18893@phd.pp.ru> On Mon, Nov 26, 2001 at 02:38:15PM -0500, Kragen Sitaker wrote: > Have you tried running the code on an operating system that doesn't suck? Have you ever saw a piece of software that does not suck? :( Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From gh_pythonlist at gmx.de Sun Nov 18 03:15:09 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 18 Nov 2001 09:15:09 +0100 Subject: ssl error In-Reply-To: <%yJJ7.1850$7b2.60534@news1.mts.net> References: <%yJJ7.1850$7b2.60534@news1.mts.net> Message-ID: <20011118091508.A1286@lilith.hqd-internal> On Sun, Nov 18, 2001 at 01:38:47AM -0600, Reid Nichol wrote: > Gerhard H?ring wrote: > > > On Sat, Nov 17, 2001 at 01:40:22PM -0600, Reid Nichol wrote: > >> I got a client/server app that I am triing to build and am having > >> problems. > >> [snip] > > > > The Python builtin SSL doesn't support servers, but only SSL clients. > > [...] > Do you know if there is any plans to fix this issue? I've started a discussion about fixing Python's SSL on python-dev. But I'm very short on time currently. Most probably, the next-generation SSL support (whenever this will happen) will be either a rewrite or an integration of an existing external SSL package. That being said, there's a patch floating around at Sourceforge to add SSL server support to the current codebase. I've recommended not to add it, as the current interface is broken enough as it is. Here's the link: http://sf.net/tracker/?group_id=5470&atid=305470&func=detail&aid=452110 Python 2.2 will only contain bugfixes (much better error handling, Windows fixes, memory leak fixes and nonblocking IO) for the current client-side support, but no new functionality. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From altis at semi-retired.com Wed Nov 14 13:16:54 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 14 Nov 2001 10:16:54 -0800 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: Some other suggestions which you may already be covering: 1. OS platforms supported by each toolkit 2. Whether the toolkit uses native widgets (wxPython does, tkinter does not). 3. Widget and classes list and notable widgets. For example, the tkinter canvas widget. 4. Supported events and whether idle, timers, and event posting is available. 5. Strategies for handling long running tasks with the toolkit. Does the toolkit support separate threads outside of the GUI event loop, yield, or other mechanisms? 6. What GUI layout tools are available for the toolkit. 7. Costs associated with using the toolkit on different platforms. 8. How does the toolkit deal with cross-platform issues such as fonts and different widget sizes? 9. Online documentation sources and places to get further information. Does the toolkit have an associated mailing list to get help? 10. Is the toolkit still being actively updated? ka "Michael 'Mickey' Lauer" wrote in message news:3beedf26 at nntp.server.uni-frankfurt.de... > Hi group, > > I'm currently writing a Python GUI book, where several toolkits > (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... > of course... Tkinter) are presented and explained. > My idea is that besides going into some detail of every Toolkit I > construct _one_ application scenario with a skeleton, which I > later complete with each of the toolkits. > This should give the reader the means to choose the toolkit > which matches their personal taste & programming philosophy. > > Given this approach, the main question I'm currently trying to > figure out is: What application shall I present? It must be complicated > enough to show some advanced topics (not only presenting a tour of > the widgets and voila...) but at the same time small enough to cover > it within 50 pages or so (remember: for each toolkit!). > > I first thought of some contact application - in outlook style - or > some kind of presentation program - powerpoint style - ... here's a plea > for your input. > > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? > > Apart from this concrete question do you have some topics which you > think should be a _must_ in such a book? Imagine you're a not a total newbie > in python GUI programming... what did you want to read in such a book? > > thanks for your input! > > Yours, > > Mickey. > From pinard at iro.umontreal.ca Fri Nov 23 10:12:06 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 23 Nov 2001 10:12:06 -0500 Subject: string.join() syntax quirky? In-Reply-To: References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: [Marcin 'Qrczak' Kowalczyk] > Thu, 22 Nov 2001 18:51:07 GMT, Erik Johnson pisze: > > is there a logical reason why it was implemented as a string method > > rather than a list method? > > Does it seem backwards to you or does it make intuitive sense to you? > It seems backwards for me - the sequence is more important than the > separator - but I wouldn't treat it as a list method either. More as > a global function. You assertion about the sequence being much more important than the separator is supported by Python designers of the string module. The separator is indeed optional in string.join(), and then implied to a single space. It always looked ugly to me that it became mandatory in the new syntax, and this ugliness always got me to think that there is something fundamentally wrong with it, even if many clever people torn their mind at finding it nice. Maybe that a mere built-in function "join(SEQUENCE)" should exist, equivalent to "string.join(SEQUENCE)", a kind of "' '.join(SEQUENCE)" where ' ' would have been made optional, and dropped. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From db3l at fitlinxx.com Tue Nov 13 14:52:13 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Nov 2001 14:52:13 -0500 Subject: wxPython & asynchronous i/o References: <9srhiv$uih$1@rhodos.FTA-Berlin.de> Message-ID: bernard writes: > I'm thinking of using wxPython in an app that requires the use of sockets. > > Is there any way to handle socket events via the wxPython mainloop > or to use a select loop to 'implement' the wxPython mainloop - or am I on > the wrong track altogether ? The pure wxWindows way to do it with the event loop would be to use wxSockets, which generate appropriate events on I/O. However, I don't believe that wxSockets are wrapped by wxPython yet. Personally, I'd just spin off a background thread to handle your socket I/O, and post your own events to your GUI when you needed to do something with the data with respect to the UI. Then you could have a normal select loop or even blocking I/O in that background thread. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From loewis at informatik.hu-berlin.de Thu Nov 22 07:05:35 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 22 Nov 2001 13:05:35 +0100 Subject: Getting the class of a method in Python 2.2 (semantic change from 2.1) References: <64a28082.0111220257.22e463f6@posting.google.com> Message-ID: kalipygian at hotmail.com (Kali Kim) writes: > In order to analyze class relationships and informations (something > like pydoc) dynamically, for example, in a class browser or code > analyzer. To find out what methods a class has, you should look at its __dict__; that should be portable across versions. Regards, Martin From ws-news at gmx.at Tue Nov 20 05:01:37 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 20 Nov 2001 11:01:37 +0100 Subject: list to list of pairs References: <3BF94B42.346E96EF@uniserve.com> Message-ID: <3bfa2ac6$1@brateggebdc5.br-automation.co.at> Hi, here an alternative way using generators (new in Python 2.2) from __future__ import generators def pieces(seq, num_item=2): start = 0 while 1: item = seq[start:start+num_item] if not item: break yield item start += num_item result = [item for item in pieces([1, 2, 3, 4, 5, 6])] print result result = [item for item in pieces([1, 2, 3, 4, 5, 6], 3)] print result - produces [[1, 2], [3, 4], [5, 6]] [[1, 2, 3], [4, 5, 6]] hth Werner wrote in message news:3BF94B42.346E96EF at uniserve.com... > > I've sure I've seen this somewhere...but I can't today... > > I need to convert a list like [1,2,3,4,5,6] to a list of pairs [[1,2], > [3,4], [5,6]]. Isn't there a way to do this with map() or zip()??? > > -- > Bob van der Poel ** Wynndel, British Columbia, CANADA ** > EMAIL: bvdpoel at uniserve.com > WWW: http://users.uniserve.com/~bvdpoel From timr at probo.com Sat Nov 24 00:56:46 2001 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Nov 2001 21:56:46 -0800 Subject: Indenting with tabs vs spaces References: Message-ID: "Peoter Veili" wrote: > >> >Tabs are wrong, because different editors will treat them differently. >> > >> >Spaces are right, because a space is a space is a space, everywhere you >> >go. > >Indenting with tabs can be done such that it will look the same on every >editor that uses fixed-width fonts, meaning everything will line up >correctly, it least in the sense that really matters. That's just not true. The crux of the problem is that "tab" does not have a universal meaning. As long as there is a physical tab character at the beginning of a line, the file will look different in my vim, where tabstop is 8, and in my Visual C++, where the default hard tab is 4. It might look similar, but it will not look the same. >Here's an example of what I mean: > > function helloThere("hello", > "there"){ > } > >The proper way to do this is the second line needs to be typed with one tab >followed by enough spaces to line up the "hello" and "there". You're still assuming that the first tab you typed means "4 spaces". Plus, I should not have to type a jillion spaces to get that to line up. Now, I certainly should be able to TYPE that line with the tab key, but when it's written to file it should have spaces. That's the only way to guarantee that it will look the same in your editor as it looks in mine. >Besides this I know of no problems with using tabs. I find them cleaner and >more efficient. I'd rather tab 10 times than hit the space bar 40 times. I >never have to go through a whole file and manually line things up because at >one place in the file I accidentally didn't indent with the right amount of >spaces and half the file needs fixing. Right. You should be able to hit the "tab" key 10 times (or 5 times) to get 40 spaces, but the file you save to disk should have spaces. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From clpy at snakefarm.org Thu Nov 29 08:17:29 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Thu, 29 Nov 2001 14:17:29 +0100 Subject: xmlrpc tutorial? Message-ID: <3C063569.8230ADD0@snakefarm.org> Hi there, is there any step-by-step intro to the xmlrpc module? I'm not very happy with the online docs especially concerning the server setup. Regards Carsten. -- For dealing with Matrix you need something more powerful than Python. Otherwise ... Matrix has you! -- scenes from comp.lang.python From R.Brodie at rl.ac.uk Thu Nov 22 11:57:30 2001 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Thu, 22 Nov 2001 16:57:30 -0000 Subject: Newbie needs "interface" References: <3BFD2536.7B4AFFC6@irisa.fr> Message-ID: <9tjapr$193s@newton.cc.rl.ac.uk> "Roberto Bonato" wrote in message news:3BFD2536.7B4AFFC6 at irisa.fr... > Sometimes I want the results to be written on the stdout, > sometimes on a Tkinter Text widget, sometimes to a file. I feel the need > of something like a Java Interface with a method "write" to wrap all > such devices into. A Java interface is a 'promise' to implement a method. In Python, just make classes with a write method. Trivial example: class T: def write(self, input): sys.stdout.write('DEBUG-->' + input) t = T() print >> t, (1,2), DEBUG-->(1, 2) From ChuckEsterbrook at yahoo.com Mon Nov 5 00:07:33 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Mon, 05 Nov 2001 05:07:33 GMT Subject: Python packages - problems, pitfalls. References: Message-ID: On Saturday 03 November 2001 22:37, Prabhu Ramachandran wrote: > Are there better ways to get around this packaging problem???Is?this?a > know problem that folks are working on????Why?is?it?that?Python?does > not deal with this issue more sensibly? In my project, Webware, we did ended up with the multiple import problem you described. eg, where a module was imported twice under under "bar" and "foo.bar". This lead to technical problems that were unacceptable. At some level, this was related to the current directory of the process. We solved this by tweaking our app server to make sure it changed the current directory to the highest level of our packaging system (despite its existence in a subpackage) at the very start before any project-specific imports. This solved it. We use "import SomeModule" when we are importing a module in the same directory, or one that is in the python path such os and sys. Otherwise we use "import SomePackage.someModule". This works very well and has not resulted in any confusion or technical problems. -Chuck From garys at ihug.com.au Wed Nov 7 17:34:33 2001 From: garys at ihug.com.au (Gary Stephenson) Date: Thu, 8 Nov 2001 09:34:33 +1100 Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) References: <9sacsk$r82$1@bugstomper.ihug.com.au> <8_dG7.4760$R43.760797@newsb.telia.net> <9sbvsa$925$1@newsg2.svr.pol.co.uk> Message-ID: <9scc8a$g8b$1@bugstomper.ihug.com.au> It should to totally apparent to all and sundry that Steve Irwin comes from an entirely different planet! Classifying him as Australian would be equally as fallacious as classifying him human. Rolf, otoh, is a national treasure. I mean anybody who could give us such classic masterpieces as "Jake the Fake" (with my extra leg, deedle-ee deedle-um) and "Tie me Kangaroo down, sport", not to mention a squillion others of similar calibre, deserves to be permanently lodged in the pantheon of stars. Surely any country on Earch would be proud to count Rolf as one of their own, .. surely.. for sure... without a doubt... gary "Duncan Smith" wrote in message news:9sbvsa$925$1 at newsg2.svr.pol.co.uk... > > "Fredrik Lundh" wrote in message > news:8_dG7.4760$R43.760797 at newsb.telia.net... > > Gary Stephenson wrote: > > > Umm, I'm not really sure this is a claim we should be making! Next > thing > > > you'll have us claiming responsibility for making disco popular - and > then > > > they'll just have to shoot us! ;-) > > > > but Steve Irwin is your fault, right? > > And Rolf Harris. > > > > > > > > > > > From feldspar at ix.netcom.com Thu Nov 1 12:55:26 2001 From: feldspar at ix.netcom.com (Antaeus Feldspar) Date: Thu, 01 Nov 2001 13:55:26 -0400 Subject: Monty Python (was: Freeware Python editor) References: Message-ID: <3BE18C8E.D9E75CD4@ix.netcom.com> Mikael Olofsson wrote: > > On 01-Nov-2001 Oleg Broytmann wrote: > > On Thu, Nov 01, 2001 at 07:39:31AM -0500, Steve Holden wrote: > > > [Makes note to remember that Oleg isn't a Monty Python viewer.] > > > > Few years ago I tried to view the scetches - there was Russian > > translation of them on TV - but found them stupid and boring. Well, I was > > in bad mood those days, may be now I'd find it more interesting :) > > You should really watch them in their original language. And I admit, > some of them are not that great (those where legs and arms are cut off > and blod everywhere). But then there are the others (for instance the > dead parrot sketch), where the humour is in the language. And they are > fantastic. > > /Mikael Even some of those were much funnier at the time because the audience understood the references being made. For instance, one of those sketches with "blood everywhere" is supposedly the movie "Salad Days" where a happy, laughing garden party is marred by a series of absurd, bloody accidents -- the lid on a piano keyboard accidentally comes down on a pianist's fingers and severs them immediately, and blood fountains from the stumps, for example... What makes this much funnier is if you know of the *real-life* director to whom this fictional film "Salad Days" is credited to, Sam Peckinpah, whose films are noted for extreme amounts of shocking violence springing up, often in supposedly tranquil settings. -jc From opengeometry at yahoo.ca Mon Nov 26 13:43:23 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 26 Nov 2001 13:43:23 -0500 Subject: Keeping Python loaded In-Reply-To: <9tndpi$qbe$1@slb0.atl.mindspring.net>; from mgerrans@ix.netcom.com on Fri, Nov 23, 2001 at 10:08:42PM -0800 References: <9tndpi$qbe$1@slb0.atl.mindspring.net> Message-ID: <20011126134323.B3840@node0.opengeometry.ca> On Fri, Nov 23, 2001 at 10:08:42PM -0800, Matt Gerrans wrote: > Is there some existing facility for keeping Python running in memory > at all times, ready to execute scripts, rather than having it load > each time a script runs? I think I can figure out a way to do this, > but I wanted to check first and see if a clever solution (probably > better than what I'm brewing) already exists... If you want Python in the memory, then just do that: python some_dummy_never_ending_file & This will avoid the time it takes to load the Python executable. But, on my Linux, the subsequent loads are pretty fast even without this. -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From tjreedy at home.com Wed Nov 14 02:01:47 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 14 Nov 2001 07:01:47 GMT Subject: may be a dumb question,but I can't understand why? References: <1103_1005719571@t4q4p0> Message-ID: "Aaron Sterling" wrote in message news:1103_1005719571 at t4q4p0... > > the following function is in bpnn.py > > def makeMatrix(I, J, fill=0.0): > > m = [] > > for i in xrange(I): > > m.append([fill]*J) > > return m This makes a matrix of J equal but *different* rows. > > I rewrite it to : > > def makeMatrix(I, J, fill=0.0): > > m=[[fill]*J]*I > > return m This makes a matrix of J references to the *same* row > > the result is defference > > Can someone tell me the defference between the two function? The first is almost certainly what you want. The second will almost certainly lead to unexpected bad behavior. > it seems to work alright on my machine. That makeMatrix2 runs is not the question. Its the behaviour of the result. I defined a function to test it to arbitrary parameters without a proplem. > > def test(max): > i = j = 0 > for i in xrange(max): > for j in xrange(max): > if makeMatrix(i, j) != makeMatrix2(i, j): > print i, j run m1 = makeMatrix(5,5,0) m2 = makeMatrix2(5,5,0) print m1 == m2 m1[1][1] = m2[1][1] = 1 print m1 == m2 Terry J. Reedy From nas at python.ca Fri Nov 30 15:42:00 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 30 Nov 2001 12:42:00 -0800 Subject: A modest indentation proposal In-Reply-To: ; from gat@jpl.nasa.gov on Fri, Nov 30, 2001 at 11:30:43AM -0800 References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: <20011130124200.A5254@glacier.arctrix.com> Erann Gat wrote: > My point is that there is not enough information at the moment for a > smarter editor to do the Right Thing with. The information just isn't > there. In this code: if x: foo() bar(); your proposed extra information says that bar() should only be called if x is true. I propose that the information is also present in this code: if x: foo() bar() The relevant information is the four spaces before the characters "bar()". How is a semicolon at the end of a statement better than indentation before a statement? The second bit of code seems clearer and cleaner to my eyes. Perhaps I've been writing Python code too long and have been brainwashed by Guido. :-) What problem are you trying to solve with the extra semicolon? If it's to make copy and pasting code easier I find that using the block indent feature of my editor works well. When I paste a chunk of code I ident to de-indent things until it looks right. Neil From lac at strakt.com Sat Nov 10 11:57:19 2001 From: lac at strakt.com (Laura Creighton) Date: Sat, 10 Nov 2001 17:57:19 +0100 Subject: data structures versus data bases??? In-Reply-To: Message from husam of "Sat, 10 Nov 2001 15:06:03 +0100." <3BED344B.5050703@sci.kun.nl> References: <3BED344B.5050703@sci.kun.nl> Message-ID: <200111101657.fAAGvJua011026@ratthing-b246.strakt.com> > hi, > im trying to learn programming with python. one of the things confusing > me is the difference between data structures and data bases. so, can you > tell me what the difference is between them? > In common usage, a data structure is something you make to put your data in. A class, a list, a dictionary, anything you can put data in. A database is somebody else's data structure(s), possibly already full of data. You can buy them from people like Oracle, or get free ones like Postgres, but they all share the property that they are _somebody else's box of stuff_. If you want to use the data in a database, you have to use whatever rules the somebody else came up with on how to get at and use the data. They are traditionally quite complicated, but do not have to be. All databases are data structures. You could go write one. Then you would get to be the somebody else, whose data structures made up your database. Laura Creighton From barabba72 at hotmail.com Wed Nov 7 02:26:14 2001 From: barabba72 at hotmail.com (barabba) Date: 6 Nov 2001 23:26:14 -0800 Subject: problems when starting python Message-ID: <8ec33ba5.0111062326.1035edf2@posting.google.com> Hi, I just started using python and have the following problem. when i double-click the pythonw.exe the application does not start !! Anybody knows why ? Thanks, Barabba From jussij at zeusedit.com Tue Nov 27 19:30:28 2001 From: jussij at zeusedit.com (Jussi Jumppanen) Date: Wed, 28 Nov 2001 11:30:28 +1100 Subject: C++ debugger for python/scintilla? References: Message-ID: <3C043024.EA1@zeusedit.com> Ken Seehof wrote: > Any know how I might go about implementing a C/C++ debugger in > python for debugging python extensions? Is such a project being > worked on? As thinks happens I have just completed adding this feature to the Zeus editor due for release next year :) > Is anyone using PyGDB? Is it what I'm looking for? At first > glance, it appears to be inside-out compared to what I want. PyGDB > apparently is a python script that uses gdb to debug python code, > rather than a python module that debugs extensions (in other words, > PyGDB set breakpoints in python code, but I want to set breakpoints in > C++ code inside extensions). Perhaps I can use gdb.py directly as a > module? All I did was execute the script using a command line like this: python.exe c:/python/lib/pdb.py example.py then manage the running executable on behalf of the user via editor commands. > It should run on Windoze, Lunux, and popular Unix platforms > (anywhere wxPython runs). I can only talk for Windows systems. For me this approach seems to work fine on all versions of Windows. The one problem I found was that for any of the Windows MS-DOS based system (ie Win 95,98,Me etc) I had to add this method to the pdb.py before any debug output was displayed. # Added new method to flush buffers so Zeus can capture output def postcmd(self, stop, line): # flush the output buffers sys.stdout.flush() sys.stderr.flush() return stop > Once the functionality is in place, I'd want to wrap it into > Scintilla to add python extension debugging capabilities to a > custom IDE. > > I'm only likely to do this project if it turns out ot be > relatively easy This turns out to be pretty easy todo (for Windows anyway). One place suggest you start is Vide. The Vide IDE has debug suppport for the GDB debugger and as it turns out running the python debugger is very similar to running the GDB debugger. Jussi Jumppanen Author of: Zeus for Windows, Win32 (Brief, Emacs, etc) FTP Text Editor "The C/C++, Java, HTML, Pascal, Cobol, Fortran programmer's text editor" Home Page: http://www.zeusedit.com From peter at engcorp.com Sun Nov 11 17:42:55 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 11 Nov 2001 17:42:55 -0500 Subject: Teaching python (programming) to children References: <9slmuc.3vuikrp.1@kserver.org> Message-ID: <3BEEFEEF.AA4EC47B@engcorp.com> Sheila King wrote: > > Laura Creighton wrote: [...] > :This means that an educational policy has to be crafted so that > :the bottom members of the profession can use it effectively to > :educate. > > I'm afraid that I simply, fundamentally disagree with your idea of > crafting an educational policy that can protect the idiot teachers from > themselves. > > For one thing, you seem to think that teaching is a science, where we > can decide upon "the best policy" and then all use it with good results. > But this is not the case. Teaching is an art, and what works well as a > method in some situations and with some students, is not the best method > in other situations with other students. [snip thoughtful discussion points] Perhaps the pragmatic Python philosophy could apply to this issue as well. Teaching, as with many other things such as software engineering, is neither purely science nor purely art; it's both! Having no official policy of any kind would, and I'm sure does where this situation holds, lead to chaos. The "idiot teachers"/"bottom members of the profession" mentioned above need some kind of guidance, by definition, or they will do more damage than good. Having a strict official policy, on the other hand, will just as certainly lead to stagnation, and a situation where the stellar teachers/top members of the profession will feel too restricted to realize their full potential and that of their students. -*always*-avoid-extremes-ly and my-mother-was-a-teacher-ly yr's, ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From mini.atmbiz at mail.com Thu Nov 1 01:07:33 2001 From: mini.atmbiz at mail.com (mini.atmbiz at mail.com) Date: Wed, 31 Oct 2001 23:07:33 -0700 Subject: Thank You For Your Interest.......... Message-ID: Everyone uses ATM machines at one time or another, and if you are seriously looking for a way to generate income in a secure and consistent manner, the ATM business might be what you are looking for. We can show you how to Profit daily and be a part of this $ 375 Billion dollar industry. Our ATM program offers: Immediate Income, Proven Profitability, No Time Investment, 24 Hour Profit Centers, No Overhead, No Employees, High Demand, No Maintenance, No Experience or Selling Required, Tax Advantages, Unlimited Growth Potential ! High Traffic National Brand Name Fast Food Franchise Locations are currently available now and are included in this lucrative turn-key opportunity. Own your own ATM machines and Profit Daily! Timing is Everything ! For a full information package at no cost or obligation, Call Anytime - (954) 481-1450 To Unsubscribe to our list, please reply with "Unsubscribe ATM" in the SUBJECT Line. From parz at shaw.SpamBucket.ca Fri Nov 23 01:52:14 2001 From: parz at shaw.SpamBucket.ca (Parzival Herzog) Date: Fri, 23 Nov 2001 06:52:14 GMT Subject: Python 2.1 crashes under specific circumstances when called during processing of Win32 WM_PAINT message. Need help. Message-ID: ---------*---------*---------*---------*---------*---------*---------*------ ---* I am using a simple Python extension module written in C++ to do some specialized graphics, on Win 20000, using Activestate Python 2.1. The module works very well generally, but under a specific circumstance, a crash occurs, and I am unable to find a cause. I am hoping someone could look at the code fragments below and tell me what is wrong. The specific circumstance is that a WM_PAINT message is being processed for the window managed by the extension module and the window is partially obscured. Then a mouse right-click event is processed through the window procedure, calling a python call back method, and a popup menus is displayed. The menu appears, and the WM_PAINT message arrives (presumably to bring the window to the top). The window procedure attempts to call a python method to do the re-drawing, and an access violation occurs somewhere in python21.dll, before the python method call actually takes place. (I.e. the crash is not caused by the subsecuent processing of drawing code, it seems to be caused by the attempt to invoke the interpreter using PyObject_CallMethod(...). There is no difference in arguments to PyObject_CallMethod whether successful or not: same Python object reference, same argument list. Other types of wondow messages can be processed successfully while the managed window is obscured. I am debugging by 1) using print statements (yes this GUI application also has a console!), 2) starting the program, and debugging by attaching to the running Python porcess. Consequently, I can set breakpoints and examine variables in my own extension module, but there when the access violation occurs, the only information is the dissassembled location, and that it is in python21.dll. There is no call stack shown in the debugger. So, (1) Does some experienced person know what could be going wrong here? (2) Can anyone give me simple directions for being able to debug into Python21.dll? I am somewhat afraid of getting mixed up with the sourec code, and I fear the problems of having both the source and its executables in an environment where the distributed binary is installed. So perhaps someone can let me know how to let a locally built Python coexist with a binary distribution. TIA, - Parzival If replying by e-mail, please remove the spam bucket from the reply-to address. ------------------------------------------------ Here is the code of the window procedure in my extension module (MyWin.pyd). _App is a global variable containing a reference to a Python class instance, with member functions that are used as callbacks. (Yes, the reference is kept alive with a PY_INCREF.) static long PASCAL MyWinProc (HWND Window, UINT Message, UINT wParam, LONG lParam) { switch (Message) { case WM_CREATE: { return 0; } break; case WM_CLOSE: { if ( _App ) if ( PyObject_CallMethod(_App, "OnClose", NULL) == NULL ) { if ( PyErr_Occurred() ) PyErr_Print(); // MessageBox (NULL, "OnClose call failed", "MyWin callback Error", MB_ICONSTOP | MB_APPLMODAL); } return 0; } break; case WM_DESTROY: { PostQuitMessage (0); return 0; } break; case WM_ENTERMENULOOP: { _MenuModal++; return 0; } break; case WM_EXITMENULOOP: { _MenuModal--; return 0; } break; case WM_COMMAND: { if ( !_MenuModal && _App ) if ( PyObject_CallMethod(_App, "OnCommand", "i", wParam & 0xFFFF /* new command identifier */ ) == NULL ) { if ( PyErr_Occurred() ) PyErr_Print(); // MessageBox (NULL, "OnCommand call failed", "MyWin callback Error", MB_ICONSTOP | MB_APPLMODAL); } else return 0; } break; case WM_SIZE: { if ( (wParam == SIZE_MAXIMIZED || wParam == SIZE_RESTORED ) && _App ) if ( PyObject_CallMethod(_App, "OnResize", "ii", lParam & 0xFFFF, /* new width */ lParam >> 16 /* new height */) == NULL ) { if ( PyErr_Occurred() ) PyErr_Print(); // MessageBox (NULL, "OnResize call failed", "MyWin callback Error", MB_ICONSTOP | MB_APPLMODAL); } else return 0; } break; case WM_MOVE: { if ( _App ) if ( PyObject_CallMethod(_App, "OnMove", "ii", lParam & 0xFFFF, /* new width */ lParam >> 16 /* new height */) == NULL ) { if ( PyErr_Occurred() ) PyErr_Print(); // MessageBox (NULL, "OnResize call failed", "MyWin callback Error", MB_ICONSTOP | MB_APPLMODAL); } else return 0; } break; case WM_PAINT: { PAINTSTRUCT ps; if ( Window != _Window ) break; BeginPaint (Window, &ps); RECT Rect; GetClientRect (Window, &Rect); #define DOUBLEBUFFERING #ifdef DOUBLEBUFFERING _Dc = CreateCompatibleDC(ps.hdc); HBITMAP MemBitmap = CreateCompatibleBitmap(ps.hdc, Rect.right - Rect.left, Rect.bottom - Rect.top); HBITMAP OldBitmap = (HBITMAP) ::SelectObject(_Dc, MemBitmap); #else _Dc = ps.hdc; #endif printf("WM_PAINT 4\n"); fflush(stdout); int saved = SaveDC(_Dc); // Do the drawing here if (ps.fErase) FillRect (_Dc, &Rect, _BgndBrush); _Redrawing = true; if ( _App ) //--------------- An access violation occurs when PyObject_CallMethod is called. if ( PyObject_CallMethod(_App, "OnRedraw", NULL) == NULL ) { //-------------------------------------------------------------------------- --------------- if ( PyErr_Occurred() ) PyErr_Print(); // MessageBox (NULL, "OnRedraw call failed", "MyWin callback Error", MB_ICONSTOP | MB_APPLMODAL); } _Redrawing = false; #ifdef DOUBLEBUFFERING // Copy buffer to screen BitBlt (ps.hdc, ps.rcPaint.left, ps.rcPaint.top, ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top, _Dc, ps.rcPaint.left, ps.rcPaint.top, SRCCOPY); #endif // Reset graphics state RestoreDC(_Dc, saved); #ifdef DOUBLEBUFFERING // Cleanup double-buffering SelectObject (_Dc, OldBitmap); DeleteObject (MemBitmap); DeleteDC (_Dc); #endif printf("WM_PAINT 9\n"); fflush(stdout); EndPaint (Window, &ps); printf("WM_PAINT 10\n"); fflush(stdout); return 0; } break; case WM_RBUTTONDOWN: { SetFocus (Window); POINT Point; Point.x = (short) LOWORD(lParam); Point.y = (short) HIWORD(lParam); ClientToScreen (Window, &Point); if ( _App ) if ( PyObject_CallMethod(_App, "OnRClick", "ii", Point.x, Point.y) == NULL ) { if ( PyErr_Occurred() ) PyErr_Print(); // MessageBox (NULL, "OnRClick call failed", "MyWin callback Error", MB_ICONSTOP | MB_APPLMODAL); } return 0; } break; } long rc = DefWindowProc(Window, Message, wParam, lParam); fflush(stdout); return rc; } ------------------------------------------------ Here is the Python class definition of the object that receives all the method calls from the code above: class wxApp: _top = None def __init__(self): MyWin.CreateWindow(self, "Sample") MyWin.SetBgndBrush(RGB(192, 220, 200), wxSOLID) global dw, dh dw,dh = MyWin.GetDisplaySize() MyWin.SetWindowPos (dw/4.0, dh/4, dw/2, dh/2) MyWin.Show() MyWin.MessageBox("Hi there","Message for you",0) def MainLoop(self): MyWin.MessageLoop() def OnClose(self): keep_going = 0 MyWin.MessageBox("Closing Time","Time to close...",0) MyWin.Destroy() def OnRedraw(self): print "OnRedraw"; sys.stdout.flush() OnRedraw() print "End OnRedraw"; sys.stdout.flush() def OnResize(self, x, y): print "OnResize", x, y def OnMove(self, x, y): print "OnMove", x, y def OnRClick(self, x, y): print "OnRClick", x, y OnRClick(x, y) def OnEvent(self, dest, event): #print "OnEvent args=", str(dest), str(event) pass def OnCommand(self, id): print "OnCommand: id=", id if __name__ == "__main__": app = wxApp() app.MainLoop() From jeff at ccvcorp.com Thu Nov 15 17:10:44 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 14:10:44 -0800 Subject: PEP 276 Simple Iterator for ints References: <3BF40F8A.378CC6F8@ccvcorp.com> Message-ID: <3BF43D64.A8B25CEA@ccvcorp.com> David Eppstein wrote: > In article <3BF40F8A.378CC6F8 at ccvcorp.com>, > Jeff Shannon wrote: > > > Which is exactly why I think that the Haskell-ish syntax is a bad idea. This > > syntax cries out to be a closed interval, and it would be very confusing if > > used as a half-open interval. But that would make it the *only* case of > > Python using a closed interval. I find that inconsistency to be *far* more > > jarring than the use of range(). > > I don't buy this argument. Currently AFAIK the *only* cases of Python > using intervals at all are range() and xrange(), No, Python also uses intervals in slicing notation--mylist[0:10] is a half-open interval. And slicing is very common. And if you're using square brackets to build a range in Haskell-ish, closed-interval style, as well as for slice notation, then you're *really* asking for confusion. Jeff Shannon Technician/Programmer Credit International From tim.one at home.com Tue Nov 6 02:27:33 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 6 Nov 2001 02:27:33 -0500 Subject: python-mode for Emacs 21.1? In-Reply-To: <7x7kt48jp6.fsf@ruckus.brouhaha.com> Message-ID: [Someone asked] > I wonder why python-mode not in standard Emacs distro... [Barry replied] > Stupid licencing issues. :( > > Grab it from > > http://www.python.org/emacs/python-mode/ [Paul Rubin jokingly asks, but without realizing it's a joke ] > Are you serious about the licensing issues? Heh. Barry and I tried for a couple of years to get the copyright on python-mode assigned to the FSF. Last I heard, I *thought* that finally went through. But I thought that several times over the years, and there was always some new objection to overcome (but, no, I don't know what the current one may be). > I just looked at that url and found no license mentioned. Since it's > at python.org I'm guessing it's under the Python license which is GPL- > compatible since 2.0.1 or something like that, I thought. The .el file still contains this, "the license" I originally slapped on it: ;; Copyright (C) 1992,1993,1994 Tim Peters ;; Author: 1995-2001 Barry A. Warsaw ;; 1992-1994 Tim Peters ;; Maintainer: python-mode at python.org ;; Created: Feb 1992 ;; Keywords: python languages oop ;; This software is provided as-is, without express or implied ;; warranty. Permission to use, copy, modify, distribute or sell this ;; software, without fee, for any purpose and by any individual or ;; organization, is hereby granted, provided that the above copyright ;; notice and this paragraph appear in all copies. Anyone who wants to argue about whether that's GPL-compatible can do so without me -- as far as I'm concerned, the FSF holds the copyright to this work now, and I sure signed enough papers saying so . spent-more-time-on-the-license-than-the-code-ly y'rs - tim From tim.one at home.com Sun Nov 11 02:13:24 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Nov 2001 02:13:24 -0500 Subject: How much is set in stone? In-Reply-To: <7xadxv9wun.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > It's not intended as FUD. Other people did report similar crashes. For vague enough values of "similar", which amounts to "something crashed, I have no idea why, and can't correlate to anything I was doing except running Python at the time". Perhaps I'm too used to that from rebooting Windows ten times a day, though <0.7 wink>. > It's conceivable that my crashes weren't caused by Python bugs, but > signs don't point that way. To my eye they didn't point at Python either. But when a Perl program crashes, neither do I assume it's Perl's fault, etc. > Comparing Python with Perl, generally I find Python better designed > but its implementation more likely to take short cuts. Heh -- I take it you haven't looked much at either implementation. > The security issue with pickle.loads that we spent a long time > discussing is something I think the perl developers would not have > tolerated. Can't guess, but would be very surprised if it didn't vary by developer. Some developers think "potential exploits" are occasion for worldwide alarm, others yawn, and most of us are somewhere in between. Overall, you appear to be to the left of the PythonLabs mean on that scale, but we're not glued to right-hand wall either. Barry Warsaw is inclined to try to make some time for that one for 2.2b1 -- which was predictable, since he's the only one of us who disables JavaScript in his browser <0.9 wink>. > There's all kinds of other missing functionality in the runtime system > as well, that doesn't result directly in unrobust programs, but does > make it more difficult to write robustly. This seems a stretch. > A lot of this ng is about the resulting issues. > > I think Python is promising and exciting and I like programming in it. > It's just inaccurate to say it's as far along in development as some > other languages. I didn't say it was, and I agree it isn't: in person-years devoted to its development so far, Python is near the bottom of the pack. But the issue was stability, and the first pre-alpha 0.9.0 Python I got from Guido was already orders of magnitude more reliable than the production Perl 4 I was using at the time. My last employer used gcc and Perl and Python too: no bug reports were filed against Python as a result of that; several bad codegen reports were filed against gcc (not counting many filed against a new-platform gcc port); several more against Intel's compiler; a few against MSVC; and we saved a collection of Perl binaries and hardcoded paths to them in each script, because we were wasting too much time "pinning the blame" on the Perl du jour for crashes before that. It's impossible to say whether that's "typical", but it was my experience, and after countless hours staring at the implementations, it's consistent with what I'd expect. From duncan at NOSPAMrcp.co.uk Fri Nov 9 05:03:09 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 9 Nov 2001 10:03:09 +0000 (UTC) Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> Message-ID: hungjunglu at yahoo.com (Hung Jung Lu) wrote in news:8ef9bea6.0111060838.24996280 at posting.google.com: > How soon does a beginner run into the following problem? (see also the > "How much is set in stone?" thread) > > #------------------ > flag = 0 > > def f(x): > flag = 1 > return 2*x > > y = f(3) > print y, flag > #------------------ > output: > 6 0 > > (2) After being shocked by the above example, students start to put > 'global' statements in every single function for every single > variable. They don't understand what is going on, they just don't want > to be bitten by the same bug, again. So perhaps the students should be taught not to use the global statement at all in situations like the one above: def f(x): return 2*x, 1 y, flag = f(3) And if they need to store state, it may be time to introduce classes: class F: def foo(self, x): self.flag = 1 return 2*x f = F() y = f.foo(3) -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From nicolasvandyck at hotmail.com Tue Nov 13 10:13:16 2001 From: nicolasvandyck at hotmail.com (Nicolas) Date: Tue, 13 Nov 2001 16:13:16 +0100 Subject: Zope application developer/creator wanted, database project to be created Message-ID: Hi We are looking for a Zope developer that can develop an online database in Zope with the following contents: - a calendar (with a listing per month) - news items (with a title, content, date, picture) - liks (listed by category) This little database need to be integrated in the existing (simple) html layout. We would really appreciate a price estimate in developing this database, email me if you're interested. Greetings, Nicolas Ps: feel free to pass this message along to others who might be interested in this little project. From jdadson at ix.netcom.com Mon Nov 5 17:40:41 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 22:40:41 GMT Subject: how to start Idle under Windows References: <3BE60B50.88B1E792@ix.netcom.com> <9s5fj2$ges$1@slb6.atl.mindspring.net> Message-ID: <3BE71544.DC10A613@ix.netcom.com> Jyrinx wrote: > > If the newbie might lead the newbie :-) ... > > I think there are two versions of the IDLE program file, one whose extension > is "py" and the other which ends "pyw". Try opening the "pyw" one. > Thanks. That worked. From jeff at ccvcorp.com Wed Nov 7 19:19:57 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 07 Nov 2001 16:19:57 -0800 Subject: Use a COM-server with python References: <3BE83CFC.7060103@gmx.de> Message-ID: <3BE9CFAD.FB2713C1@ccvcorp.com> dsavitsk wrote: > "Marc Gehling" wrote in message > news:3BE83CFC.7060103 at gmx.de... > > Hello, > > > > I installed a comserver and i can use it with VB. I would like to use > > the server with python. I read some artikels and take a look at "python > > programming on win32". > > > > Can someone translate this vb into python ? > > > > Dim oRepo As MXLib.MXRepository > ...... > > oRepo.CreateFolder "testfolder", "folderdescr", 0, "Administrators", > > oNewFolder > > >>> oRepo.CreateFolder("testfolder", "folderdescr", 0, "Administrators") > >>> # oNewFolder # not sure what this i as it was never set in the vb > example I can't be sure without looking at the specifics for that COM api, but many COM objects return values through "out" parameters--passed by reference. (This is because COM uses return values to indicate errors.) Since Python doesn't support the usual notion of passing by reference, the PythonCOM implementation translates "out" parameters into return values (and error returns into exceptions). Therefore, (presuming that oNewFolder is indeed an "out" param), this final line should be written as: oNewFolder = oRepo.CreateFolder('testfolder', \ 'folderdesc', 0, 'Administrators') Hope that helps... Jeff Shannon Technician/Programmer Credit International From steve at ferg.org Fri Nov 16 16:33:38 2001 From: steve at ferg.org (Stephen Ferg) Date: 16 Nov 2001 13:33:38 -0800 Subject: PEP proposal: enhanced string functions References: Message-ID: One of the questions raised by the proposal for extending strip() functionality is -- How much would such a language feature would be used? Basically, it is a request for a cost/benefit analysis. We want to know whether the added benefit of implementing it in the language would be worth the effort that it cost. A couple of days ago, I realized that I had the material for an empirical investigation of this question. I have a legacy system of about 52,000 lines of code. It is very text-processing intensive, and it is written in REXX, a language that supports the kind of extended strip() functionality that was proposed for Python. I realized that I could count the occurrences of the extended strip() functionality in this system. The most that we could say after such an investigation would be that we had some hard numbers from a single system that was text-processing intensive. But surely that was better than nothing. What I found was that more than a third (36%) of the invocations of strip() used the option of stripping other-than-whitespace characters. Here are the actual numbers. Number of lines of code : 51605 Number of uses of strip : 380 uses of strip() : 223 uses of lstrip() : 8 uses of rstrip() : 13 ========================== Total 244 (64%) uses of strip(stripchar): 52 uses of lstrip(stripchar): 16 uses of rstrip(stripchar): 68 ========================== Total 136 (36%) These numbers suggest that if this functionality were available in Python, it certainly would be used. -- Steve Ferg steve at ferg.org From jeff at ccvcorp.com Wed Nov 28 21:05:29 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 28 Nov 2001 18:05:29 -0800 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <3C0597E9.4CEB1455@ccvcorp.com> With all this discussion of CVS, I have a question that I've not been able to find a satisfactory answer to, myself. My current place of employment does not use any significant form of version control. Due to the nature of most of our codebase, using CVS for it would be unrealistic anyhow. Despite all of this, I would like to begin using CVS for those projects that I can, even if I'm the only one using it. The problem with this, is that I don't have access to a Unix/Linux server to install CVS on (our one Unix server is host to our virtual-OS (non-SQL) database, and I don't think I could convince anyone to install anything unnecessary there ). What I'd really like, is a version (or clone) of CVS that will allow me to use a local repository under Windows. Does any such thing exist? (I'm very frustrated, trying to teach myself good software engineering practices in a workplace that doesn't support that at all... ) Jeff Shannon Technician/Programmer Credit International From ajs at ix.netcom.com Fri Nov 30 20:57:30 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Fri, 30 Nov 2001 20:57:30 -0500 Subject: Copy operator (was list.remove for Noivces) Message-ID: <001001c17a0b$8a1d75e0$a9e1fea9@carol> >> My argument, I guess, is that copy is somehow different >>from the other modules, in that it is as if you are importing >>a built_in. Is that totally off-base? Andreas responds - >Well, then everything in sys, string (well this is being phased out), etc. >should be builtin. How far over my head am I getting by arguing with you here. I see *no* similarity between the kind of functionality sys brings in to that of copy. Copy just operates - and only on objects that are. Sys provides functionality and information, that among other things, is platform and version specific. I feel better when someone clearly needs to stretch to this extent to defeat a point I am trying to make. I take it as a no, I am not totally off-base. >And no, perhaps because I've learned Python quite late (numerically at least >in my list of programming languages), but I do not know what all the stuff is >in __builtin__ without looking at the documentation. And perhaps also in the process you have gotten far out of touch with the process of learning one's *first* language. >Think again: You are talking about the copy module that in the current code >base is rather seldom used. Why should a function that is that seldom used be >moved to __builtin__? > > What is the downside of copy and deepcopy as built_ins. Unnecessary > performance hits in the majority of mods which don't need it, I expect. >>Nope. Namespace pollution. Actually, there is already more than enough baggage >>in __builtin__ that nowadays wouldn't be needed there. >>And the need to be backwards compatible for the next decades. Namespace pollution? I assume you mean you might want to use "copy", and its been taken. Not sure that in itself is a big thing. I do assume that back compatible issues - there could be a lot of custom defined copy def and classes out there - could be a *big* issue. >>,And if Python had no pretense towards being a language suitable >> for learning, I would be totally out of place in saying much of >> anything here. But I have in fact put considerable effort into learning >> programming - to the extent that I have (and I am coming along >> fine, thank you) - with Python as my first language. Which I think >> makes me my own kind of 'expert' - on nothing more than learning to >> program - to the extent that I have - with Python as a first language >> (and I am coming along fine, thank you) >Obviously there is some contradiction here. Either you are not coming along >fine, because you don't understand the copy/deepcopy "wart" of Python, or >it's not that significant a thing if you can be productive without >understanding it all :) The only wart I see is in "packaging". I couldn't understand the importance of gaining an understanding of these concepts *on my own*, until pretty far down the road. Knew I was missing something important, but had no way to put my finger on what it was. If it was fundamental, it would somehow be built_in, was the implicit assumption I was making. Turns out that assumption was wrong - is my current understanding. In most other respects, the dialogue with Python and its fundamental documentation has been *quite* satisfactory. So I am holding Python to its own high standards, in leading a learner - while encouraging him/her to explore on their own. Art From fgranger at alussinan.org Sat Nov 10 09:16:45 2001 From: fgranger at alussinan.org (=?ISO-8859-1?Q?Fran=E7ois_Granger?=) Date: Sat, 10 Nov 2001 15:16:45 +0100 Subject: Using browser as interface to python app References: Message-ID: <1f2nvkz.k318fgjrv6b1N%fgranger@alussinan.org> Sandy Norton wrote: > I've just been prototyping a simple multi-threaded internet news > monitor and have gotten to the point where I need to make a decision > about the direction(s) the user interface might take: I've ruled using > wxPython and Tkinter as I think a GUI is overkill, however I'm > intrigued by the possibility of running a simple local webserver which > would serve a set of webpages (with checkboxes, text fields, etc..) > directly to a browser which would then allow the user to interact with > the running python app. You don't need a webserver to run html pages. Just "open" them with the local available browser. Have looked at anygui? they have simple interfaces to many gui toolkits. And one of there aim is to use html as one back en. -- "Au royaume des aveugles, on lapide ? mort les borgnes" - Joan D. Vinge in "Cat le psion" From paulsid at home.com Thu Nov 1 18:12:22 2001 From: paulsid at home.com (Paul Sidorsky) Date: Thu, 01 Nov 2001 16:12:22 -0700 Subject: List transpose method References: Message-ID: <3BE1D6D6.64BF9CE8@home.com> Tom Harris wrote: > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > only come up with an ugly multiliner. apply(zip, a) seems to work for most cases: >>> a = ((1,2), (3,4), (5,6)) >>> apply(zip, a) [(1, 3, 5), (2, 4, 6)] >>> a = ((1,3,5), (2,4,6)) >>> apply(zip, a) [(1, 2), (3, 4), (5, 6)] >>> a = ("Hello world", "Goodbye all") >>> apply(zip, a) [('H', 'G'), ('e', 'o'), ('l', 'o'), ('l', 'd'), ('o', 'b'), (' ', 'y'), ('w', 'e'), ('o', ' '), ('r', 'a'), ('l', 'l'), ('d', 'l')] >>> a = ((1,2,3,4),(5,6,7,8),(9,10,11,12)) >>> apply(zip, a) [(1, 5, 9), (2, 6, 10), (3, 7, 11), (4, 8, 12)] >>> a = [[1, 2, 3, 4]] >>> apply(zip, a) [(1,), (2,), (3,), (4,)] >>> a = ((1, 2, 3), (4, 5)) >>> apply(zip, a) [(1, 4), (2, 5)] -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From ajs at ix.netcom.com Sun Nov 11 08:55:33 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 11 Nov 2001 08:55:33 -0500 Subject: Teaching python (programming) to children Message-ID: <000701c16ab8$89a05f40$a9e1fea9@carol> Laura writes - >The _policy_ itself is evil. What other evils do you >have, and how do you get them, and why can't responsible teachers such >as yourself get rid of evil damaging policies? If that is not worth >getting angry about, I don't know what is. Your post does illuminate the bind. You want conformity to standards, but then realize that the standard setting bodies are likely, in practice, to be misinformed, out-of-touch and just plain wrong. You and I might agree, for example, that Python is a sensible choice for a first programming language in an educational setting, and C++ an absurd choice. The chances of a standard setting body coming to that conclusion at this point in the game, are slim to none. It is not inconceivable that they will get there. But it can only happen if the system is flexible enough to allow pilot type projects like those being undertaken by folks like Sheila and a number of others. If we insist on conformity to standards to an extent that will cut off the possibility of this kind of informed and responsible "experimentation", isn't all hope gone? The other point you make is the difficulty of teaching as a profession. I agree. I would love to be a teacher. A rich and famous one. In other words, the profession requires a kind of selflessness beyond the scope of folks like myself - and I ain't that bad. But I do see the Open Source movement in general as leading the way toward an ethic that will ultimately have a great beneficial impact on education - and am in that sense an optimist. But it won't be smooth and quiet. I, for one, will make sure of that. Art From dale at riverhall.NOTHANKS.co.uk Wed Nov 14 04:44:18 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Wed, 14 Nov 2001 09:44:18 +0000 Subject: Are there any list comparison optimizations in Python? References: Message-ID: <77f4vto2m7bp2fipvtt7kd65dm7c12ims9@4ax.com> "Tim Peters" wrote: > >(*) It's "paradoxical" because MSVC doesn't generate correct fp comparison >from 754's viewpoint. But toss in a few other accidents, and by the time >Python reports a result, an even number of mistakes cancel out. > Not very reassuring! -- Dale Strickland-Clark Riverhall Systems Ltd From phr-n2001d at nightsong.com Fri Nov 2 22:59:31 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 19:59:31 -0800 Subject: Python/QT Book no in final edit References: Message-ID: <7xady4cxng.fsf@ruckus.brouhaha.com> jd at commandprompt.com (Joshua Drake) writes: > The Py/QT book (which covers QT 2 and 3) is now in final edit and will > be shipping before the end of the month. For those interested you may > view the book online at: > > http://stage.linuxports.com/projects/pyqt > > There is a link to preorder on the site as well. Looks nice. It would be nice to have a link to render it all on one web page. From jeff at ccvcorp.com Fri Nov 9 19:09:27 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 09 Nov 2001 16:09:27 -0800 Subject: Teaching python (programming) to children References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> Message-ID: <3BEC7037.1658CCF@ccvcorp.com> John Roth wrote: > "Michael Hudson" wrote in message > news:u4ro4nddv.fsf at python.net... > > Laura Creighton writes: > > > > > In the same vein, if any of you out there are writing (or revising) > > > 'how to program in Python' books or papers, could you please put > > > the section on exception handling _early_, say, right after 'what > > > is a loop', rather than in the last chapter? > > > > That's what my tech review for one such said over the summer :) This > > may have been too late, of course. > > > > But Laura is right here. Very very right. > > Then possibly the decision to make exceptions classes was > wrong from a tutorial veiwpoint? Technically, it was the > right decision, but it does shove exception handling rather > late, after classes have been introduced. > > John Roth Not necessarily. Unless you're defining your own exceptions, you don't have any reason to care whether they are strings or classes or transfinite cardinals. ;) A beginner doesn't need to know what a ValueError is, they just need to know how to catch it, and when to expect it. The main practical effect of using classes, is that you can catch a variety of exception types by catching a base class, but I don't think this feature is essential to beginners. By the time you're ready to exploit that polymorphism, you should be ready to understand classes and inheritance anyhow. (My $0.02, anyhow...) Jeff Shannon Technician/Programmer Credit International From mats at laplaza.org Sat Nov 24 11:13:10 2001 From: mats at laplaza.org (Mats Wichmann) Date: Sat, 24 Nov 2001 16:13:10 GMT Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> <3BF9B512.A784475C@ccvcorp.com> Message-ID: <3bffbf1a.72709340@news.laplaza.org> :The full solution is to find an IDE that executes programs in a separate :process. I couldn't tell you offhand which IDEs do this, but neither IDLE nor :PythonWin do, and it's fairly likely that you would need to use a commercial IDE :for this (though you may find one that's free for open-source development). The experimental IDLE, hosted on SourceForge as the Idlefork project, can do this. Mats Wichmann From claird at starbase.neosoft.com Tue Nov 13 16:34:01 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Nov 2001 15:34:01 -0600 Subject: Request for Validation of Python as Development Language References: Message-ID: <45FF84258633F54C.865AE420A1A42E7B.5C06556A2FFB29FC@lp.airnews.net> In article , A. Keyton Weissinger wrote: . . . >Python). They need to hear "object oriented application development >language" or I need to buck up and realize I'm barking up the wrong tree. . . . So say that. You have every right to present Python as an "object-oriented application development language", without once labeling it a "scripting language". In fact, I frequently argue (even in published articles, although none of them seem to be available on the Web now ...) that Python is *more* "scalable" than Java. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From alexis.layton at post.harvard.edu Fri Nov 30 13:46:12 2001 From: alexis.layton at post.harvard.edu (Alexis Layton) Date: Fri, 30 Nov 2001 18:46:12 GMT Subject: Python 2.2b1 dicts, iteration, and subclassing Message-ID: <3C07D496.5040308@post.harvard.edu> Note: Python 2.2b2 is not yet available for the Macintosh platform so this may have been fixed/changed already. I created a new-style subclass of "dictionary" ("dict" in 2.2b2) in which the order of insertion of keys is remembered, the SequencedDict. I redefined the keys, values, and items methods, as well as the iterkeys, itervalues, iteritems, and __iter__ methods. Everything works as expected, except that it seems repr (which I did not redefine) is using the built-in dictionary iteration or doing its own. The question for all you Pythonistas out there is, should it? To what extent should the built-in behavior of objects like dictionaries be affected by subclassing? Alexis Layton alexis.layton at post.harvard.edu From mickey at tm.informatik.uni-frankfurt.de Tue Nov 27 07:11:07 2001 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 27 Nov 2001 14:11:07 +0200 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> Message-ID: <3c0390eb@nntp.server.uni-frankfurt.de> Laura Creighton wrote: > One defect that most GUI books I am aware of suffer from is that they > are written almost exclusively from the point of view of providing > ways for users to provide _input_ to your program, database, or whatever. [...] > And then, on your first job, you have to write code that handles > real-time updates of a package tracking system. Many people need > to write applications where the user _is_ a passive receiver of > data. This is hard to do well, and worth a chapter all to itself, > in my opinion. This is a very good suggestion - thank you. But can you imagine a scenario where this can be combined into one example application which both reacts to user input and change of internal data ? :M: From cliechti at gmx.net Wed Nov 21 19:44:33 2001 From: cliechti at gmx.net (Chris Liechti) Date: 22 Nov 2001 01:44:33 +0100 Subject: string literals in windows dont show up! References: Message-ID: [posted and mailed] "Chris Fonnesbeck" wrote in news:mailman.1006383692.28423.python-list at python.org: > I am trying to append literals (i.e. \n, \r) to the end of lines in a > text output file. However, when the file is brought up in the windows > notepad, there is no line feed or carriage return. Any idea about how > to make windows recognize these literals. Works fine in linux (no big > surprise there!) > > Thanks > Chris Fonnesbeck > if you use the "b" modes under windows [eg. open(filname,"wb")] the data is written as you write it, no conversion (b for binary data). but if you specify only "w" (or "r") cr-lf <-> lf transformation is done. (on linux/unix no such conversion is needed as "\n" is the linefeed which is the natural line break on these OS) this should write two lines, on windows with cr-lf line endings >>> open("test.txt","w").write("line1\nline2\") does this help? if not, try to post a small python example to illustrate your problem. chris -- Chris From emile at fenx.com Thu Nov 8 06:26:47 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 03:26:47 -0800 Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: <9sdqjf$12rkdu$1@ID-11957.news.dfncis.de> "Geert-Jan Giezeman" wrote in message news:9sdol4$2te$1 at samos.cs.uu.nl... > > 2)Are there ways to circumvent those problems? Use a different > database (I like shelves, though), ... I'm *not* using shelve, so I can't help you directly there. I do read in and create a dict from a csv formatted file with a data set of floats (92 byte key, 96 fields/record, ~83000 records, lots of zeros in records) and it eats about ~24 Mbytes on disk, so smaller is certainly manageable. -- Emile van Sebille emile at fenx.com --------- From sholden at holdenweb.com Thu Nov 15 13:28:59 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 15 Nov 2001 13:28:59 -0500 Subject: =?ks_c_5601-1987?B?UmU6IFvIq7q4XSDG+rbzt87AzLXlIMSruN6287OqILfO?= =?ks_c_5601-1987?B?uLi81SDEv8fDvcOw6MHfIL/4x8+9w7TCILDNwLsgteW4sw==?= =?ks_c_5601-1987?B?tM+02S4gs/XEocH2ILi2vLy/5CEhIQ==?= References: Message-ID: Don't you just hate being spammed in languages you'll never understand? And I *didn't* mean HTML... turning-japanese-oh-yes-i'm-turning-japanese- oh-yes-i-think-so'ly yrs - steve -- http://www.holdenweb.com/ From nomad*** at ***freemail.absa.co.za Fri Nov 9 09:08:33 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Fri, 09 Nov 2001 16:08:33 +0200 Subject: Open a windows database file with a path name? Message-ID: Hi, Is there anyway that I can open a database (MSAccess in this case) using the path and file name rather than a DSN? I can't seem to get it to work. TIA -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From psycho at tex.ro Tue Nov 13 12:57:21 2001 From: psycho at tex.ro (Ciobanu Vladimir) Date: 13 Nov 2001 09:57:21 -0800 Subject: Threading Message-ID: Consider this: class DataBase: def __init__( self): self.__dictionary = {} def __getitem__( self, key): return self.__dictionary[key] def __setitem__( self, key, value): self.__dictionary[key] = value This is a very simplified version of the class. It only contains enough stuff to ask my question. ( I mentioned this so I wouldn't get answers such as "Why the hell aren't you using a plain dictionary ?") Now, consider that this DataBase class is to be used in a real world program, specifically in a threaded world. This would imply I use locks, which brings me to the actual question. Unfortunately the Python Library Reference isn't clear enough ( to me, at least) about this particular detail: Is it safe to call __getitem__ without placing locks ? To make it more clear, it is quite obvious that allowing two threads to simultaneously write ( call __setitem__) isn't desired; but what about reading ( call __getitem__). Are there any guarantees that threads don't interfere ( read things that aren't there, resolve in undefined behaviour in any way) when reading data ? My first guess would be that I shouldn't be adding locks to __getitem__, but this depends on the implementation so it's quite tricky. PS: I'd love if Python added a const modifier for methods at least ( if not for objects too). Thanks in advance. From joonas at olen.to Thu Nov 29 12:10:16 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 29 Nov 2001 19:10:16 +0200 Subject: __setattr__ recursion problem Message-ID: <3C066BF8.8D911FCB@olen.to> The code above causes an infinite loop. How can I set an attribute of Class without overloading the __setattr__ function? Or does someone have some other solution to make that script work? class Class2: eggs = 1 spam = 2 class Class: base = Class2() def __setattr__(s,attr, value): if hasattr(s.base, attr): setattr(s.base, attr, value) else: setattr(s, attr, value) Class().foo = "eggs" From sandysj at juno.com Tue Nov 6 13:11:03 2001 From: sandysj at juno.com (Jeff Sandys) Date: Tue, 6 Nov 2001 18:11:03 GMT Subject: Teaching python (programming) to children References: <7xsnbs65ke.fsf@ruckus.brouhaha.com> <9s77qb.3vv4gtl.1@kserver.org> Message-ID: <3BE827B7.D5616361@juno.com> Sheila King wrote: > > I think that 8 year olds could easily do some simple programming. This seems to be about the right age to get started in my experience. While some 2nd graders (about age 7) will get Logo others will become frustrated, in a large class there are just to many breakdowns for one teacher to manage. By third grade their spelling and reasoning abilities are reasonably mature for beginning programming. It is also useful to put the students in pairs so that they help and learn from each other, then the teacher can manage the large group. Thanks, Jeff Sandys From eppstein at ics.uci.edu Wed Nov 28 19:05:37 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 28 Nov 2001 16:05:37 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> <3C05758F.DBD8833@engcorp.com> Message-ID: In article <3C05758F.DBD8833 at engcorp.com>, Peter Hansen wrote: > > You are missing the point. Typing 'i in range(5)' gives the same result at > > the interactive prompt. So does 'i in [0, 1, 2, 3, 4]'. > > I don't understand the point. I wouldn't have expected > anyone to type "i in range(5)" at the prompt, but simply > "range(5)", resulting in a list, from which the hypothetical > newbie would likely infer that the for statement was iterating > over the items in that list. I take it you are viewing the syntax of a for-loop as "for" variable "in" expression: where "for" and "in" are keywords and expression must be something that returns a list or iterator. So the "in" of a for-loop has very little other than spelling to do with "in" operator for list expressions. I would rather view a for-loop as "for" expression: where (currently) the expression must have as its top level operation the "in" operation and the lhs must be a variable. The variable is set in all possible ways that make the expression true. From this point of view, "for x in 5" looks really ugly, and "for 0 <= x < 5" makes a lot more sense: we now simply allow one more kind of expression in a for loop, one where the top level is a three-way comparison and the middle side of the comparison must be a variable. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jason at jcrowedesign.com Sat Nov 17 16:20:13 2001 From: jason at jcrowedesign.com (jcrowe) Date: Sat, 17 Nov 2001 15:20:13 -0600 Subject: drawing functionality Message-ID: I am concidering creating an app that would basicly be a database frontend. But I would like to have the ability to make small (300 X 300 dpi) drawings. This would be used to create a rough floorplan drawing for each entry (real estate) in the database. I am planing on running this on a linux server that is being accessed by window 98/95 client machines. Thanks for any URL's or insites that you can provide. Jason Crowe From johnny at debris.2y.net Tue Nov 6 11:20:38 2001 From: johnny at debris.2y.net (Johnny deBris) Date: 6 Nov 2001 08:20:38 -0800 Subject: newbie: selecting text by script in Tkinter fails Message-ID: Hello!! I have a question about selecting text in a Tkinter Text-widget using the tag_remove and tag_add-methods: there is a small explanation on how it should be done in 'an Introduction to Tkinter', but I cannot get the work done the way the author proposes (http://www.pythonware.com/library/tkinter/introduction/x8369-methods.htm). Can anybody tell me how I can select a piece of text from script? I'm working on a texteditor in Python, and this is part of a search-option I would like to add. For people who think they're suffering from deja-vu or something: I have posted a question quite similar to this one a few days ago, but no-one seemed to be able to or want to answer. (maybe a classical case of RTFM? If so, please tell me where to find that FM!! :) Thanx again, Guido Wesdorp From fredrik at pythonware.com Wed Nov 7 13:07:54 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 18:07:54 GMT Subject: re OnInteger division References: Message-ID: <_LeG7.4769$R43.762969@newsb.telia.net> John Thingstad wrote: > To achive a inverse you need to use the modulo as well > > so: > 9/4 = 2 > 9 %4 = 1 > > and > (9/ 4) *4 + (9%4) = 9 on the other hand, >>> from __future__ import division >>> (9/4)*4 + (9%4) 10.0 oh well. From mlh at idi.ntnu.no Sun Nov 18 14:49:53 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 18 Nov 2001 20:49:53 +0100 Subject: Standard download for "current version" for various platforms? Message-ID: <9t93d1$ai$1@tyfon.itea.ntnu.no> I'm trying to write a step-by-step guide on how to download and install the most recent version of Python for various platforms, but the layout of the web pages seems to change a bit from version to version... (For instance, I wrote that one could follow the link named RPMs from the download page, but that has been moved to the margin.) One thing that would be useful is something like having a "current" directory in the FTP server, containing source, binaries, rpms etc. Then one could have a fixed URL which always would point to the most recent version for a given platform. Does something like this exist already? -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From hweaver at pinetel.com Thu Nov 8 11:02:36 2001 From: hweaver at pinetel.com (Hal Weaver) Date: Thu, 08 Nov 2001 08:02:36 -0800 Subject: Python, FreeBSD, idle References: <9sd9jv$2e5m$1@mail1.wg.waii.com> Message-ID: <3BEAAC9C.455C7CD8@pinetel.com> Martin Franklin wrote: > > dsavitsk wrote: > > > i installed a new FBSD 4.4 system. i installed Python 2.1.1 from the > > packages menu. i then installed idle (0.5) from the ports collection. > > this > > inturn installed python 1.5.2. from a terminal when i type "python" 1.5.2 > > is started. is there a trick to linking idle to 2.1.1, and easily > > resetting it (2.1.1) as the default? > > > > or better yet, i notice that idle is up to 0.8 on windows ... has anyone > > done any work to update the FreeBSD port? > > > > doug > > > > > > > > Doug, > > idle is in the source distribution under the Tools/idle directory. Its > allways a good idea to have acopy of the python source around, plus it has > lots of extra goodies..... > > ftp://ftp.python.org/pub/python/2.1.1/Python-2.1.1.tgz or > > http://www.python.org/ftp/python/2.1.1/Python-2.1.1.tgz > > Martin I recently installed Python 2.1 on the FreeBSD 4.3 Stable distribution. In order to use idle I had to install py-tkinter from the X11-toolkits folder in ports. Hal From ws-news at gmx.at Mon Nov 19 09:57:32 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 19 Nov 2001 15:57:32 +0100 Subject: Create Windows Font Message-ID: <3bf91ea0$1@brateggebdc5.br-automation.co.at> Hi, I would like to create an Windows Font from a bitmap. The bitmap contains the characters with a fixed sizing (i. e. it is a non-proportional font), but the sequence of the characters should be defineable by an external text file. Processing such a text file is trivial in Python, but I did not yet find a suitable font library for Python. I would prefer creating a bitmapped font (.FON file), TrueType would be an acceptable alternative (.TTF file). hth Werner From djrassoc01 at mindspring.com Mon Nov 12 01:51:40 2001 From: djrassoc01 at mindspring.com (Dr. David J. Ritchie, Sr.) Date: Mon, 12 Nov 2001 00:51:40 -0600 Subject: Teaching python (programming) to children References: Message-ID: <3BEF7170.4E387A7D@mindspring.com> Laura Creighton wrote: > ... > > David Ritchie and I both teach programming, as a hobby, and we > have independently come up with the principle that it works better > if you have the students code adventure stories. So we do this. > If it turns out we are misguided idiots, are students can always > leave and do something else. It is quite possible that we have > only demonstrated that you should teach students that have joined > a club where you code adventure stories, by teaching them to > code adventure stories. This is a problem with a self selected set. > David Ritchie was teaching people to program in Perl. I don't > approve of that, and am pleased that he is now using python. But > I think that it was an _unfortunate_ choice. But if David Ritchie > was a professional middle school teacher, I would have a much > stronger choice of words to describe what I think of the acceptability > of Perl as a first programming language. > ... Ah, yes, it's going to be really interesting in a couple of months to have a first hand understanding of doing adventure stories in Computer Club with Perl and with Python for Middle Schoolers. As with Perl, the kids taught me how to teach it in a club setting, I am expecting to be taught by the kids how to approach Python. A club approach is really nice in that the kids that show up want to be there. My goals, besides seeing that the kids are having fun doing serious bits of programming is to give them a realistic experience of what it is like to spend your time writing software. This is a time when the students are forming the beginnings of career choices so that have a realistic idea of what a programming activity involves hopefully helps them to make better choices for careers. I want to mention that the November 2001 American Journal of Physics has an interesting article "Physics Education Research--The Key to Student Learning" by Lillian Christie McDermott who won the Oersted Medal from the American Association of Physics Teachers (AAPT) for her research into the teaching of physics. She discusses the success of the PbI (Physics by Inquiry) approach to teaching physics. Some of what I have been doing seems to be similar in approach of--you pick--(Programming, Perl, Python) by Inquiry. I think that considering whether it makes sense to try to transplant her experiences into the programming realm is an interesting idea. --D. -- Dr. David J. Ritchie, Sr. djrassoc01 at mindspring.com http://home.mindspring.com/~djrassoc01/ From fperez528 at yahoo.com Thu Nov 22 12:06:04 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 23 Nov 2001 16:34:04 +2328 Subject: Pls. help me recreate shell trick References: <3BFE4A90.1C0F1E0C@divalsim.it> <9tlmi5$s5d$1@news1.wdf.sap-ag.de> Message-ID: <9tmmeq$4e6$2@peabody.colorado.edu> Daniel Dittmar wrote: >> This was achieved as follows: >> >> $ECHO rm -r / >> >> where ECHO was either set to "echo" or nothing according to a command > Another option: import os def xsys(cmd,verbose=0,debug=0,head=''): """Execute a system command, but optionally print it. With debug=1, only prints.""" stat = 0 if verbose or debug: print head+cmd if not debug: stat = os.system(cmd) return stat cheers, f From nas at python.ca Fri Nov 30 12:41:00 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 30 Nov 2001 09:41:00 -0800 Subject: A modest indentation proposal In-Reply-To: ; from gat@jpl.nasa.gov on Fri, Nov 30, 2001 at 08:19:02AM -0800 References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: <20011130094100.B4450@glacier.arctrix.com> Erann Gat wrote: > Skip: > > In Python, if it looks right, it is right. > > No, that's not true. Consider the following two alternative code fragments: > > if x: > foo() > baz() > > if x: > foo() > baz() > > They both look right, but they can't both be right. How do they both look right? In the first case baz() is always called. In the second case it's called if x is true. A larger indent (say 4 spaces) would make things even more clear. As for moving code around, I agree that it would be nice if the block structure of the code was preserved. I think the solution for this problem is not to add extra syntax to the language but to have smarter editors. I believe effbot and the other people at Python Labs are working on a "refactoring browser" for Python. It would be similar to what has been done for Smalltalk. Neil From murat.demir at icn.siemens.de Thu Nov 8 11:39:09 2001 From: murat.demir at icn.siemens.de (Murat Demir) Date: 8 Nov 2001 16:39:09 GMT Subject: CORBA client & server with Python References: Message-ID: <01c16873$ddd02ce0$06d1178b@mvn40020> hi all ! I'm trying to write a CORBA client and server "hello world" application. For this purpose I used Example 2 in the internet site below : http://www.uk.research.att.com/omniORB/omniORBpy/doc/omniORBpy/omniORBpy002. html#toc6 with this example, I compiled the .idl file, there is no problem with it, I run the server program, it' OK as well, but when I try to run client side program, the message is: bash-2.03$ python client.py Traceback (most recent call last): File "client.py", line 9, in ? ior = sys.argv[1] IndexError: list index out of range bash-2.03$ does someone has an idea about it? thanks murat -------------- next part -------------- An HTML attachment was scrubbed... URL: From DTSRV10-SA at dutchtone.nl Wed Nov 28 13:23:58 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Wed, 28 Nov 2001 19:23:58 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C71809@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = _p.aiale at bcc.tin.it Recipient(s) = python-list at python.org Subject = Scanning Time = 11/28/2001 19:23:57 Action on virus found: The attachment YOU_are_FAT!.MP3.scr exists WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From greg at cosc.canterbury.ac.nz Thu Nov 29 19:44:17 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 30 Nov 2001 13:44:17 +1300 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <3C06D661.9292AD89@cosc.canterbury.ac.nz> James_Althoff at i2.com wrote: > > I would have guessed, though, that given the current direction of Python > vis-a-vis iterators that > > for 0 <= x < 5: > > would have to mean something like "0 <= x < 5" is special syntax built into > the for-loop statement that generates an iterator that enumerates the > integers 0,1,2,3,4. Yes. > It happens to look just like an expression which > *outside* the context of a for-loop evaluates to 0 or 1 instead of > producing an iterator (as was pointed out previously by Peter Hansen). This is also true of the "i in seq" part of "for i in seq", so nothing unprecedented would be going on in that respect. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From phd at phd.pp.ru Fri Nov 9 04:09:07 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 9 Nov 2001 12:09:07 +0300 Subject: Gratuitous post In-Reply-To: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com>; from sholden@holdenweb.com on Thu, Nov 08, 2001 at 06:49:35PM -0500 References: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> Message-ID: <20011109120907.F20597@phd.pp.ru> On Thu, Nov 08, 2001 at 06:49:35PM -0500, Steve Holden wrote: > Free software. Is the word "free" here a verb or a noun? Do you want to make the software free, or just want to say that whatever is not free is not software at all? :))) In any case I agree with you! :))))) > missing-oleg-ly y'rs - steve I am here, sure. Is it a kind of "ping"? ECHO REPLY, then :))) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dwjoker at thenorth.org Thu Nov 8 17:18:22 2001 From: dwjoker at thenorth.org (Firestar) Date: Thu, 08 Nov 2001 22:18:22 GMT Subject: Two way communication between a python class and a C++ class Message-ID: <0r0mut8npqtk8cfp1nato7fmslfkqcv0ki@4ax.com> Hi, I am having a problem obtaining two way communication between a python class and a c++ class. I can get a python class to communcate with a c++ class and a c++ class to communicate with a python class, but i cannot seem to get the communication to go both ways. i.e I have a class CTest in c++ and a class PTest in python and when i create an instance of CTest in c++ it creates an instance of PTest in python, i then want PTest to be able to call methods in the instance of CTest that created the instance of PTest. How can i do this? there seems to be no way to pass the c++ pointer into the python class in the constructor... There must be a way... does anyone know how to do this??? Help much appreciated!! Firestar From wzdd at lardcave.net Thu Nov 29 22:37:07 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Fri, 30 Nov 2001 14:37:07 +1100 (EST) Subject: Non-Indented python In-Reply-To: Message-ID: On 29 Nov, Tim Peters wrote: >> get some wierd error, eventually think to check for tabs. > > Don't you run Python with -tt? This at least solves my problem. I had never noticed -tt. -- - Nicholas FitzRoy-Dale http://www.lardcave.net From gbeasley at tsa.ac.za Mon Nov 26 02:23:52 2001 From: gbeasley at tsa.ac.za (Grant Beasley) Date: Mon, 26 Nov 2001 09:23:52 +0200 Subject: Sockets, DNS and timeouts Message-ID: <9tsqmh$ih1$1@ctb-nnrp1.saix.net> Hi I'm using the DNS module from Anthony Baxter in an attempt to validate email hosts (By an MX/A lookup). It's working very well, except that with certain addresses everything hangs. I think it's an issue with the addresses I'm checking because if I do an nslookup on the same address it eventually times out. The problem appears to be that there isn't a timeout in the DNS module (and sockets in general??). I've read a few older archived messages about implementing timeouts via threads, etc. Generally speaking, they were a bit over my head, so I was hoping there's a simpler solution (maybe with a later version of Python). Is there an easy way to wrap something in a timeout that'll exit gracefully without actually having to change the code in the DNS module? Any help appreciated. Grant From James_Althoff at i2.com Tue Nov 13 19:23:26 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 13 Nov 2001 16:23:26 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: David Eppstein wrote: >As a possibly-related side note to this debate: > >I have been moving towards using Python-like pseudocode in my algorithms >classes in place of the C/C++/Java-like pseudocode I was previously using; >that is, using colons and indentation to mark blocks of code instead of >curly braces, etc. As well as conciseness, Python offers some other >advantages e.g. in the ability to write code with list comprehensions. >The single biggest barrier for me to write actual working Python code is >the range/xrange syntax: I just don't feel comfortable writing code like > > for i in range(n-1,-1,-1): > for j in range(i+1,n+1): > ...do something... > >because I don't expect my students (who are not required to learn Python) >to understand from that syntax that the outer loop runs backwards from n-1 >to 0 and that the inner loop runs from i+1 to n. > >Instead I have to make up some non-Python syntax which is less formal but >immediately clear: > > for i in [n-1, n-2, ... 0]: > for j in [i+1, i+2, ... n]: > ...do something... > >(actual example from ). Thanks for your interesting example. I agree that your notation "[n-1, n-2, ... 0]" is a very nice way of showing a sequence of integers. I'm not sure how one would turn this into programming language syntax that would be as clear. I think your notation works really well for your pseudo-code. Nice! Not so much to defend PEP 276 but more for fun :-), ...since your example is mathematics-oriented ("Dynamic Programming and Optimal Triangulation") and is meant to be a descriptive notation of an algorithm for your (presumably) *math-oriented* students, it might be interesting/amusing to note that PEP 276 would allow the following: for i in [n-1-a for a in n]: for j in [i+1+a for a in n-i]: # do something :-) Jim From jason at jcrowedesign.com Fri Nov 23 01:24:31 2001 From: jason at jcrowedesign.com (jcrowe) Date: Fri, 23 Nov 2001 00:24:31 -0600 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: > what is the equivalent > of ASP pages or PHP pages or JSP pages, for Python?? Shouldn't > we be learning THAT instead of PHP??? As far as I know you are stuck with cgi pages. CGI isn't really bad. there are lots of good web apps written using CGI & Perl. But in my opinion it's like riding a bike when you have the keys to a car. From sholden at holdenweb.com Mon Nov 26 15:28:26 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Nov 2001 15:28:26 -0500 Subject: postgresql triggers to update GUI? References: <20011126.145234.816620091.2222@localhost.localdomain> Message-ID: "Robert Nikander" wrote ... > Hi, > > I am writing a python program that uses a postgresql db backend. I would > like to update the gui whenever a change in certain tables occurs, so it > would be nice to use triggers rather than generating the 'events' when I > update the db. That way I get cascading changes. Does anyone know of a > python module that supports postresql triggers? ie: you can create a > trigger that calls a python function? Is there another solution here > that I am missing? > The purpose of a trigeer is to maintain the database's semantic integrity by running stored procedures whenever particular changes take place. Because triggers are specifically stored procedures, they run within the database engine rather than inside a database client process. It therefore wouldn't seem like a suitable mechanism for triggering updates of a GUI. Sorry... Perhaps what you need is an update process that both the standard database clients and your GUI-based monitor process communicate with? regards Steve -- http://www.holdenweb.com/ From phr-n2001d at nightsong.com Thu Nov 8 19:06:22 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 08 Nov 2001 16:06:22 -0800 Subject: Teaching python (programming) to children References: Message-ID: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> "Arthur Siegel" writes: > The problem with this slant is that there is little justification to > bring the necessary resources to bear for "teaching programming > languages to all (or most) schoolchildren" if the end result is > scripts cataloging mp3s. > > If the end result is a deeper appreciation of math concepts, > scientific concepts, etc. I think a big goal of the Mindstorms crowd is teaching the concept of debugging. Most skills are taught with the idea that you master something by learning it well enough to do it perfectly, so if you make a mistake at it you haven't learned the skill yet. Teaching programming to young kids is supposed to develop the cognitive skill of diagnosing and correcting errors. That's more fundamental than "applications" like cataloging mp3's or even understanding math concepts. From thomasNO at SPAM.obscure.dk Fri Nov 23 04:14:51 2001 From: thomasNO at SPAM.obscure.dk (Thomas Jensen) Date: Fri, 23 Nov 2001 09:14:51 GMT Subject: Could someone explain this multidimensional list behaviour? References: Message-ID: lrl at ou.edu (L) wrote in news:e5f40188.0111222310.5001b6e2 at posting.google.com: > Greetings from a long time java programmer jumping ship, > > I'm not having trouble getting around this behavior: > >>>> spam = [[0] * 3] * 3 spam [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>>> spam[0][1] = 1 >>>> spam > [[0, 1, 0], [0, 1, 0], [0, 1, 0]] > > I was expecting after making the assignment to get this: > [[0, 1, 0], [0, 0, 0], [0, 0, 0]] [snip] > So what is the easy way to allocate an n x n matrix with unique > values? There was a discussions very recently discussing this, but I was unable to find it :-) >>> spam = [[0 for i in range(3)] for j in range(3)] >>> spam[0][1] = 1 >>> spam [[0, 1, 0], [0, 0, 0], [0, 0, 0]] -- mvh Thomas Jensen From db3l at fitlinxx.com Fri Nov 16 21:42:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 16 Nov 2001 21:42:28 -0500 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> Message-ID: "Peoter Veliki" writes: > I'm using Python 2.0 at the moment (it is necessary as it is integrated > into another product), perhaps this limitation was removed in later > versions. If I try to do this: > > print "integer i = " + i > > it will barf on this and tell me that i is not a string, I must do this: > > print "integer i = " + str(i) As others have pointed out, making i a separate argument to print: print "integer i =", i would let it evaluate it (and automatically stringify it if necessary) whereas the + operation (which evaluates independently from the print) is in fact strongly typed and does not perform any automatic conversion. Note that in the above, you'll automatically get a space between the string and i due to how print works, so I removed one space from the actual string prompt. One other useful mention is that the "%s" formatter is Python string formatting operations will automatically apply str() to any non-string object that it is handed. So another approach could be: print "integer i = %s" % i and in this approach you have complete control over spacing and what not since it's all internal to the format string. Note that technically the argument to % is a tuple, but for a single argument it works singly, so you don't have to bother writing (i,). -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From max at alcyone.com Thu Nov 1 04:19:13 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 01 Nov 2001 01:19:13 -0800 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> Message-ID: <3BE11391.BF044772@alcyone.com> Oleg Broytmann wrote: > I have no problem abusing this in case people are trying to > restrict my > freedom. Oh, please. You don't have the "freedom" to dictate to other people what license to put on software that _they_ write. You're the one who brought up the argument, but you're also the one who said you didn't want another GNU flamewar ... yet here you are making such statements as this. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From danielk at aracnet.com Wed Nov 14 15:28:11 2001 From: danielk at aracnet.com (Daniel Klein) Date: Wed, 14 Nov 2001 12:28:11 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> Message-ID: <9nj5vto66nk83romuu3f40qrd72lmrjpui@4ax.com> On Tue, 13 Nov 2001 11:59:00 -0700, "Andrew Dalke" wrote: [snip] >When I first started Python, I wrote a class like: > >class Spam: > def __init__(self, x): > self.x = x > def show(self): > print self.x > >After I figured out it worked, I wanted to add a new method, so >I did > >class Spam: > def double(self): > self.x = self.x * 2 > >then was annoyed that it didn't work the way I expected. So I >don't think you are alone in this view. I bring it up here because >I suspect for many people this is forgotten amoung all the other >confusions in the early stages of learning Python. Just curious to know how it is that you expected this to work and why you were 'annoyed'? I can't see what the problem is with the double() method. >>> class Spam: def __init__(self,x): self.x = x def show(self): print self.x def double(self): self.x = self.x * 2 >>> s = Spam(1) >>> t = Spam('foo') >>> s.double() >>> t.double() >>> s.x 2 >>> t.x 'foofoo' >>> s.show() 2 >>> t.show() foofoo Daniel Klein From hungjunglu at yahoo.com Wed Nov 7 03:30:13 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 7 Nov 2001 00:30:13 -0800 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> <9s9949$hm5$1@news.service.uci.edu> <8ef9bea6.0111061428.28c46fc0@posting.google.com> Message-ID: <8ef9bea6.0111070030.d9c3793@posting.google.com> huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) wrote in message news:... Huaiyu Zhu wrote: > You are confused about the cause of this problem. I don't think so. > It is has nothing to do with namespace. Now you are confused. You think you can do Python without namespaces. statement modification on the globals() namespace dictionary ----------------+------------------------------------------------------ >>> a = [] | (1) yes, entry with key 'a' inserted >>> x = a | (2) yes, entry with key 'x' inserted >>> x.append(1) | (3) no, no action on globals() namespace dictionary >>> print a | [1] | >>> x = [] | (4) yes, value of the entry with key 'x' updated >>> print a | [1] | The difference in (3) and (4) is simply whether action has been performed on the namespace dictionary, regarding the entry with key 'x'. (Forgive me for not entering into issues on pointers and objects in the heap, I don't want to open another can of worms.) It is perhaps more instructive to see this: globals().update({'x': 3}) y = x+1 print x, y And from there you can understand that there is a namespace operation whenever you talk about binding. The difference between your example and my example is simply that your 'x' lives in the globals namespace, mine lives in the locals namespace, which is not the point. The point is one has to understand that Python's assignments, Python's 'global' statement, Python's 'from xyz import *' statement, etc. are merely syntactic sugar, and that the actual operations are performed on the namespace dictionaries. And remember, we are not talking about people here not understanding Python, we are talking about how it is hard to explain to beginners these things. Experienced Python programmers always keep the three Python namespaces in mind. Matter of fact, many good Python programmers, including those that made Zope and hired Guido [:)], do tweak the built-in namespace once in a while. I guarantee you, once you have the namespace dictionaries picture inside your head, you won't need to use terms like "Python distinguishes between mutation and name-binding" and you won't run into namespace problems again. Once you understand the namespace dictionary mechanism, you'll see that all the three examples ('from xyz import *', 'global', and this one) I have mentioned all come from the lack of understanding of the namespace mechanism. Without understanding the namespace mechanism, you think they are three unrelated problems. (Missing the forest because of the trees, as they say in English, or, like blindmen touching the elephant, as they say in Chinese.) Once understood the namespace mechanism, you won't have any of these problems. Frankly, I don't think a person has understood Python until they have understood the namespace mechanism. My advise is: get to see the whole forest, or the whole elephant, or the whole Python. :) However, that's not a task for beginners. Me having to spend 4 postings on this thread should tell you something: many people don't see the whole Python. >feeling-exhausted-explaining-this-many-times-ly yr's Believe me, I am more exhausted than you are. :) Hung Jung From tim.one at home.com Fri Nov 2 14:43:25 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Nov 2001 14:43:25 -0500 Subject: Exception handling wart in Python In-Reply-To: Message-ID: [James_Althoff at i2.com] > But to be fair, you have to admit it's only *half* as ugly as the > double leading underscore plus double *trailing* underscore convention > (I know, it's *suppose* to be ugly -- and it succeeds admirably in this > regard! ;-) > > (Assuming here, for simplicity, that ugliness is linear). Across the entire base of Python programmers active on March 17, 1995, a six-day exhaustive accounting determined that __x__ was deemed to be a mean of 2.7x uglier than __x with a (population) std deviation of 0.42. Curiously, 79% thought that _x was (and I quote) "cute". On the seventh day, Guido rested. I tried in vain to point out that a large number of Python programmers at the time were also C system programmers, so were desensitized against seeing names of the forms __x and _X as "ugly". So I hypothesize that the perceived relative ugliness of __x__ would increase were we to secure funding sufficient to repeat the study with today's larger programmer base. send-your-checks-to-the-psu-ly y'rs - tim From jeff at ccvcorp.com Wed Nov 14 14:54:47 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 14 Nov 2001 11:54:47 -0800 Subject: registering a python prog. as a windos service References: <9sru7r$qkg$1@wanadoo.fr> Message-ID: <3BF2CC07.9CA1EE5C@ccvcorp.com> guignot wrote: > I have to run some python scripts in background on dual boot Windows/Linux > machines. > > For Unix, no pb. The scripts are launched from rc.local, et hop! > > For Windows, I tried to register them as a service to be launched at boot > time, but they always suck... > > I beleive that not any prog can be registered??? > > What did I miss? > > Tks in advance. > J. A program must be specifically designed to be a service. It *is* possible to do this with a python script without too much pain, though it's not quite trivial (see Python Programming on Win32 from O'Reilly for examples). (I'm presuming that you know that Services are a NT/2k/XP feature and don't exist on Win9x ...) The other option would be to put shortcuts for your scripts into your StartMenu->Programs->Startup menu. Programs there will be automatically run at boot time. This is probably the simpler option, depending on just what it is that your scripts are intended to do... Jeff Shannon Technician/Programmer Credit International From tjreedy at home.com Wed Nov 28 23:13:12 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 29 Nov 2001 04:13:12 GMT Subject: [2.2b2]: class variable and classmethod, subclass References: Message-ID: "{-- Rot13 - Hateme" wrote in message news:Xns9168798CBA2B2YouAreNotMeYouKnow at 218.102.23.34... > The problem is that a new copy of the class variable is only > created if it is changed in the child class. If the variable > is not mutable, that is. > I think it is more natural that the new copies of class variables > are created at the time of subclass definition. I believe you can do this by including the variable in the subclass definition instead of inheriting it from the baseclasss. class b(a): value = "whatever" I believe you can have it either way according to what you implicitly or explicitly tell the interpreter. Terry J. Reedy From kragen at canonical.org Sun Nov 25 21:41:30 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 21:41:30 -0500 Subject: list.remove for Novices References: Message-ID: <83elmmtfs5.fsf@panacea.canonical.org> "Tim Peters" writes: > [Arthur Siegel] > > issue which I ran into trying to follow suggestions for > > my permutations problem was addressed beginning at: > > > > > > That looks like an email address; it's unclear what it refers to. It's a Message-ID, obviously. What else could it possibly be? From jason-dated-1006190036.7f044c at mastaler.com Mon Nov 5 12:13:56 2001 From: jason-dated-1006190036.7f044c at mastaler.com (Jason R. Mastaler) Date: Mon, 05 Nov 2001 10:13:56 -0700 Subject: [ANNOUNCE] TMDA 0.40 - SPAM reduction system (now supports Exim) Message-ID: TMDA now supports the Exim MTA in addition to Postfix and qmail. TMDA is an OSI certified Python application designed to significantly reduce the amount of SPAM/UCE you receive. TMDA combines a "whitelist" (for known/trusted senders), a "blacklist" (for undesired senders), and a cryptographically enhanced confirmation system (for unknown, but legitimate senders). TMDA strives to be more effectual, yet less time-consuming than traditional filters. For more information including a demonstration, download locations and installation instructions, visit the TMDA homepage: Enjoy, Jason R. Mastaler

TMDA 0.40 - SPAM reduction system (05-Nov-2001) From sholden at holdenweb.com Fri Nov 16 09:52:12 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 09:52:12 -0500 Subject: anonymous functions? class? References: <9t1ii2$es0$1@peabody.colorado.edu> <3BF48BA4.D03A627C@engcorp.com> Message-ID: "Peter Hansen" wrote ... > Fernando P?rez wrote: > > > > Peoter Veliki wrote: > > > > > I'd like to be able to use a function as an argument without declaring it > > > externally. This is what I don't want to do: > > > > [snip] > > > > Listen, this is the third time you post this question and people actually > > *have* answered it already. Could you be bothered to check for replies first > > before you repost or is that too much to ask? Do you require hand-delivery in > > special stationery or something else we should be aware of? > > Funny thing is, he changed names between the second and third posting... > used to be named Peter Bismuti. I guess while he was out getting the > name-change papers signed he missed our replies. > Perhaps this guy is a troll? Or possibly has multiple personalities... regards Steve From sfam at mailandnews.com Thu Nov 22 14:46:07 2001 From: sfam at mailandnews.com (Kaden) Date: 22 Nov 2001 19:46:07 GMT Subject: Indenting with tabs vs spaces References: Message-ID: <9tjklv$ptt$1@news.xmission.com> On 22 Nov 2001 00:32:05 -0500, David Bolen wrote: > For example, Python mode in emacs will auto-indent a line on tab, but > if it guesses wrong, a single backspace will step back a full > indentation level (4 spaces) so it can still be very efficient to key > in even though spaces are being used. The following will do the same type of thing you describe (and more) if you use vim: set expandtab " expand tabs out to spaces set sw=4 " shiftwidth set to 4 spaces set tabstop=4 " indent 4 spaces per tab set softtabstop=4 " BS and DEL see multiple spaces as a tabstop set bs=2 " allow backspacing over everything in insert mode set ai " always set autoindenting on set list " visualize whitespace set listchars=tab:??,trail:? " show spaces as ? and tabs as ?? " Whenever you type any of the words in the list, it will automatically " set the cursor at the next indention level. au BufRead *.py set smartindent \ cinwords=if,elif,else,for,while,try,except,finally,def,class Of course you could change all these to only take effect when editing a python file, as the last example does, if you don't like tabs expanded or tabwidths of 4 chars in your regular text. One argument I hear from advocates of tabs in source is that it's difficult to see if one line's indention is off by just one space. That's what the list and listchars lines help with. For each tab you should see two of those arrows and three dots. If you don't, something's not lined up right. From fperez528 at yahoo.com Fri Nov 30 14:35:19 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 01 Dec 2001 19:03:19 +2328 Subject: Whatever happened to String Interpolation? References: <9u6dbn$nsj$1@peabody.colorado.edu> <9ubecn$ped$1@peabody.colorado.edu> <837ks6se4c.fsf@panacea.canonical.org> Message-ID: <9uc26v$akh$1@peabody.colorado.edu> Kragen Sitaker wrote: > Skip Montanaro writes: >> (or something else similar) which isn't all that readable either. >> You just >> happen to want to embed literal %-signs in your strings. Please >> correct me if I'm wrong, but changing the character that introduces >> a value to be >> interpolated just moves the problem around a bit. I don't think it >> solves anything. > > Ping's PEP has some advantages over %-syntax; in the common case of > interpolating a variable, you need only type $var, rather than > %(var)s, and in the less-common case of wanting to interpolate an > expression evaluated in the current namespace, you can do that too, > still with one less noise character than the % syntax allows. (I > have a module that lets you evaluate arbitrary expressions with the > % syntax, and I've heard other people have written them too.) Exactly my point. I think when I mentioned my need of inserting % in strange dynamic strings I inadvertedly set the discussion off-course. That was just a side comment, and by no means the meat of my point. My important point is that Ping's PEP allows a _clear_ way of saying "x is $x, f(x) is $f(x)" This to me is readable, unambiguous and very useful. Currently we have a few options. Please keep in mind that this is really important only when the string and evaluations to handle grows dramatically in size and complexity. Think of 50 line strings with 100 complex expression evaluations embedded (and yes, things like that can happen fairly easily): 1) "x is %s, f(x) is %s" % (x,f(x)) Comment: this is very fragile and only works for a few %s. Beyond that it's asking for trouble. Plus visually parsing it is a pain, as you have to go back and forth between the string and the format tuple. 2) tmp = f(x) "x is %(x)s, f(x) is %(tmp)s" % locals() A little better than 1. But requires temporary variables. Again, for complex, long cases it gets fragile quickly. 3) class Eval: def __getitem__(self, key): return eval(key) "x is %(x), f(x) is %(f(x))s" % Eval() The best option, but the Eval trick, though very clever (when I saw it I immediately made a copy of it for future use), is quite deep 'black magic' for a language that prides itself on clarity. So again, I don't really care about embedding explicit %'s in strange strings. That's such a rare case that I don't mind strange solutions for it. What I want is a clear, obvious syntax for a problem that *does* come up constantly. I hope this clarifies what I have in mind. Cheers, f From michael at rcp.co.uk Fri Nov 30 07:27:28 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 30 Nov 2001 12:27:28 +0000 (UTC) Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: Message-ID: Skip Montanaro wrote in news:mailman.1007090560.18985.python-list at python.org: > You were relying on undocumented behavior. There is no obvious ordering > between integers and None. > So why don't comparisons of this type generate an exception? From garth_grimm at hp.com Thu Nov 29 15:04:59 2001 From: garth_grimm at hp.com (Garth Grimm) Date: Thu, 29 Nov 2001 12:04:59 -0800 Subject: Expat XML Parser References: <9u2t5e$kh4$1@aspen.sucs.soton.ac.uk> Message-ID: <3C0694EB.6010000@hp.com> I think Martin summed up your answer with the phrase "global variables". Haven written primarily python scripts, I ran into the same issue as you a few weeks ago when I started doing some XML parsing. I just had to (re)learn scoping issues with Python. Garth Richard Boardman wrote: > Hello, > > I've only been using Python for about a week or so, having previously used > Tcl for all my scripting needs. However, on the recommendation of a friend, > I have forayed into the world of Python. > > I am trying to use the Expat XML parser to extract some data for > processing - sounds simple enough - although I am having great difficulty > finding documentation for Expat and am consequently very stuck. > > Here is the code I have; mostly gleaned from the one or two examples I > managed for find for Expat. After taking out some of the extraneous bits, my > problem reads thus: > > # read in XML for processing > > filetoread = "xyz.xml" > sourcexml = open(filetoread, 'r') > xmlpp = sourcexml.read() > > def s_el(name, attrs): > print name, "(attributes -->", attrs, ")" > def e_el(name): > print " (attribute", name, "ends)" > def c_data(data): > print " `--->", data > > prs = xml.parsers.expat.ParserCreate() > prs.StartElementHandler = s_el > prs.EndElementHandler = e_el > prs.CharacterDataHandler = c_data > prs.returns_unicode = 0 > prs.Parse(xmlpp) > > # end > > The problem major is that I can't seem to return any of these values at > all - they will all print on the screen, but I can't actually *do* anything > with these values. I don't think it's anything to do with Expat; more my > lack of experience with this language. I can't find any documentation > explaining how Expat works. > > What I'd like to do is have something that works thus: > > readInXML > foreach element in XML > if element = "abcdefg" { > getCharacterData > doStuff with characterData > } > > ... so in the following ... > > 1 2 3 4 > > ... I could check the value is 'data', return the attribute identified as > '1' and then return the block of data in, say, a list. > > A few pointers/websites/ideas/pieces of code or whatever would be *greatly* > appreciated. > > Thanks very much in advance. > > -- > > Regards, > > Richard Boardman > High Performance Computing Group > Level 3 Zepler Building (59) > University of Southampton > Southampton > SO17 1BJ > > e-mail: rpb01r at ecs.soton.ac.uk > > > From James_Althoff at i2.com Tue Nov 27 13:27:31 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 27 Nov 2001 10:27:31 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: Greg Ewing wrote: >While trying to think of a range syntax that looks >unambiguously half-open without clashing with list >or tuple constructors, the following blindingly >obvious solution occurred to me: > > for 0 <= i < 5: > ... Greg, Since this looks like a suggestion for replacing xrange in the general case, did you have any thoughts on how one might specify a step value? Jim From schmidp at o000o.org Thu Nov 8 07:42:48 2001 From: schmidp at o000o.org (Philipp Schmid) Date: Thu, 08 Nov 2001 13:42:48 +0100 Subject: unicode strings?! Message-ID: <3bea7e5f$0$36516$5039e797@newsreader01.highway.telekom.at> hi, can anyone help me with this little example program? #!/usr/bin/python2 lala = "aslfjaslkjf lasjflasjkfals faslkfj aljfa?ljfkal?fjal? jflajf" print lala lala = u'%s' % lala print lala if i run it I get the following error, why? aslfjaslkjf lasjflasjkfals faslkfj aljfa?ljfkal?fjal? jflajf Traceback (most recent call last): File "./test.py", line 5, in ? lala = u'%s' % lala UnicodeError: UTF-8 decoding error: invalid data thx philipp -- The Macintosh way is to organize things by things the users do, not the underlying file system. This is a HUGE paradigm shift from the Unix (everything is a file) paradigm, and from the Microsoft (everything is about something). From r.b.rigilink at chello.nl Sun Nov 4 07:30:05 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Sun, 04 Nov 2001 12:30:05 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> Message-ID: <3BE534B7.F0F56060@chello.nl> Hi Jive, Welcome to Python Jive Dadson wrote: > > I'm a newbie at Python, but I've been up to my ears in it for the last > couple of days. -- Considering using it for a scripting language for a > product at work. I'm very impressed with the system. Of course there > are things I would like to change. :-) So the question is, how much is > set in stone at this point? Is the definition of 2.x now the law of the > land, or can we still make suggestions? Well, you can still make suggestions. There's even a formal procedure for it. Look at http://python.sourceforge.net/peps/ for the Python Enhancement Proposals. However, Python is over 10 years old, quite mature, and does have a considerable user base, so you shouldn't expect to get proposed changes accepted without some pretty convincing arguments (i.e 'neat' won't cut it ;). Hope this helps, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From jerry at sky.net.ua Sun Nov 25 13:31:30 2001 From: jerry at sky.net.ua (Serg) Date: Sun, 25 Nov 2001 20:31:30 +0200 Subject: RogueLike Games in Python References: <3BFC9160.24AFA11A@alcyone.com> Message-ID: <3c0139e3@skynet> Not rogue but strategy being made by russian funs. -- Keep in touch. Your partner Maltsev. > > As a side note about the sad level of understanding of Python in the > > world, there was a thread in that newsgroup about how BASIC would be a > > superior choice for creating a Roguelike than Python ... > I started to implement something like that in python, but i'm not > skilled enough to code a robust game engine (threading-problems, > server/client problems, KI problems, lack of gameplay etc.). > Anybody who's working at this kind of game in pure python? > I'm highly interested in this, too. From loewis at informatik.hu-berlin.de Sun Nov 11 10:11:41 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Nov 2001 16:11:41 +0100 Subject: Is this considered black magic? References: Message-ID: Laura Creighton writes: > object.__class__.__dict__[name_key](object, *args) I would write this as getattr(object, name_key)(*args) If you read it aloud, you should say "get me the method(*) name_key of object, and call it with args". That is not much magic. HTH, Martin (*) It doesn't have to be a method. If it is not, calling it will likely fail. From emile at fenx.com Wed Nov 7 07:55:32 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 7 Nov 2001 04:55:32 -0800 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> <9s9949$hm5$1@news.service.uci.edu> <8ef9bea6.0111061428.28c46fc0@posting.google.com> <8ef9bea6.0111070030.d9c3793@posting.google.com> Message-ID: <9sbb99$11qhi6$1@ID-11957.news.dfncis.de> "Hung Jung Lu" wrote in message news:8ef9bea6.0111070030.d9c3793 at posting.google.com... > huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) wrote in message news:... > However, that's not a task for beginners. Me having to spend 4 > postings on this thread should tell you something: many people don't > see the whole Python. > Good examples. Still, as it pertains to teaching younger children, explaining two simple rules fix it: don't re-use names within the same module; and, if you want values back from a function you have to ask for them (use return). Then, when something doesn't appear to work right, you can point to the broken rule, the child says "Oh.. yeah.." and you both move on. When things progress to the point ("Oh.. yeah..Why?" ) where understanding mutability and namespaces is possible, then it's time to move a further step forward in a more complete review. With these rules (and possibly a few more), I won't hesitate to start my kids out on python. Besides, why would you want to start them out on anything else? ;-) -- Emile van Sebille emile at fenx.com --------- From peter at engcorp.com Thu Nov 29 22:33:33 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 29 Nov 2001 22:33:33 -0500 Subject: The Ideals of a Python Hacker (was: Poll Results) References: <3bfd7f87@news.airtel.net> Message-ID: <3C06FE0D.BD7E55A0@engcorp.com> Jonathan Gardner wrote: > > Python and Esperanto: Esperanto was invented for being a useful, simple > language that could be learned by almost any culture. It tried to limit the > number of expressions for a single idea, making it difficult to express > things that may not be understood or misunderstood. That is the same with > Python. English and Perl (TMTOWTDI), and Esperanto and Python. Esperanto also deliberately drew from the set of words with the widest international recognition, to make it easier to learn and more likely to be understood at some level even at first glance. Python, of course, eschews obfuscation and favours high readability, gaining it the sometime-label "executable pseudocode". > > it'd also be cool to see the relative age of new pythonistas -- I suspect > > that they're young, but this is completely unfounded. > > They'd have to be. I can't seem to find a place to get paid to work in Python > yet. I can't imagine a guy with 3 kids trying to make a living by programming > python unless he is the rare guy that has a job in it. Probably true. Havens like my group (13 of us, most using Python 95% of the time) are probably quite rare still. I don't expect that condition to last. Rather than wait for such a group to find/hire you, however, you would be well advised to find ways of integrating Python into the work environment you are already at. I have yet to see a development environment in which it was not often necessary to write little utilities to assist in development, file massagers, and so on. Python is easily one of the most effective at this, and unlike otherwise suitable languages it will be hard for anyone to complain the result is not maintainable. And no one can stop you from using it on your own machine. (Well, I've heard of such companies too, but I can't imagine working for one.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From rjroy at takingcontrol.com Sun Nov 4 22:35:53 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Mon, 05 Nov 2001 03:35:53 GMT Subject: Python packages - problems, pitfalls. References: Message-ID: <3be602d3.635600718@news1.on.sympatico.ca> On Sun, 4 Nov 2001 12:07:50 +0530, Prabhu Ramachandran wrote: >hi, > >Recently I discovered that there is some very unfortunate behaviour >with python packages. > >Lets say I have a directory 'pkg' that is the root of a package. >Inside this directory I have a sub-package, called sub. So its >something like: > >pkg/ > __init__.py > a.py > sub/ > __init__.py > b.py > >Now, from b I'd expect to be able to import 'a' straight away. > Why would you expect that? a.py has no relationship to b.py. It is not a sibling module, it is not a parent. >Say in b.py I do > >import a > >This will not work! I know why it happens but shouldn't Python be >smart enough to avoid such problems? Why I consider this a major >problem is that the importing of a sub-package depends on where its >parent package is!! Its a good thing it doesn't. It would be a maintenance nightmare. See Tim Peter's rules of python programming: Explicit is better than implicit Frankly if I had a situation as you describe above, I would take a good look at why I had structured my modules that way. Most likely I would find that the module structure had outlived its usefulness and needed to be redefined/refactored. > So if pkg is no longer the root of the package >and say its put inside another BigPkg then to make pkg's sub packages >work you'd have to edit *all* the sub packages and change every >reference to pkg.a to BigPkg.pkg.a. This is a huge pain. Use a ".pth" file to tell it where the package resides. Say you re-nest pkg into BigPkg, place a file called pkg.pth in the root directory of your distribution and put the location of pkg in it. See the documentation on module "site". for example (not tested!): Python root pkg.pth (contents would be Lib/BigPkg/pkg) Lib/ BigPkg/ __init__.py pkg/ __init__.py This will allow old pkg references to continue working. > >Are there better ways to get around this packaging problem? Is this a >know problem that folks are working on?? Why is it that Python does >not deal with this issue more sensibly? > Python does, it is not terribly well documented though... bob From ursus_horibilis at hotmail.com Wed Nov 28 09:34:43 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Wed, 28 Nov 2001 09:34:43 -0500 Subject: Integer Overflow References: <9u0jor$2li$1@peabody.colorado.edu> Message-ID: "Gareth McCaughan" wrote in message news:slrna08439.1ra3.Gareth.McCaughan at g.local... > "Ursus Horibilis" wrote: > > > unsigned int Lcprng(unsigned int *seed) > > { > > *seed = 29 * (*seed) + 13; > > return (*seed); > > } > > > > How do you do this in Python? > > Points to note: > > - using a 1-element list is about the nearest equivalent > we have to passing in a pointer as your C code does. > It's not necessarily good style (but then, neither is > the pointer-passing thing). Could you expand on that? It sounds like it has all the makings of a religious war (;-) Would the following be a preferred way of doing things: def Lcprng(state): """Pass this a variable containing the seed. Don't forget to update the seed with the returned value each time this function is called.""" return int((29L*state+13L) & 0x0FFFFFFFL) .......Calling Program...... RanNum = 987654321 # Initialize Random Number Seed ............................................ RanNum = Lcprng(RanNum) # Keep updating seed with value ........................................... > > - After one iteration, the value in "state" will be a > long integer and there will therefore be no danger > of overflow. But you should make sure you start it > off with a long anyway. What will happen if I do this: state[0] = int((29L * state[0] + 13L) & 0x0FFFFFFFFL) ? > > By the way, that's not a very good random number generator. :-) Yes, you're right. Linear Congruential PRNG's are not very good, but they are widely used because of their simplicity. I just whipped an equation off the top of my head that would generate maximal-period pseudo random numbers. I wasn't worried much about the quality. Better is: state = 179418817 + 179419969 * state From prabhu at aero.iitm.ernet.in Sun Nov 11 03:03:59 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 11 Nov 2001 13:33:59 +0530 Subject: Proposal for a modified import mechanism. In-Reply-To: <033301c16a1a$59c1c690$c300a8c0@ericlaptop> References: <3BED6E5B.8E142057@arakne.com> <033301c16a1a$59c1c690$c300a8c0@ericlaptop> Message-ID: <15342.12527.94615.833898@monster.linux.in> >>>>> "ej" == ej writes: [snip] ej> The current runtime overhead isn't so bad. Prabhu sent me a ej> few numbers on the SciPy import (which contains maybe 10-15 ej> nested packages). I attached them below -- the overhead is ej> less than 10%. It should be negligible for standard modules ej> as only packages are really affected (right Prabhu?). It depends on how you do it. If you have a sub-package that tries to import a standard module it will go through all the parent packages searching for the module and when it doesn't find one it will check in sys.path. There are a few things to note: (1) For a module in a package, the first import will be naturally the slowest. (2) Subsequent imports will be faster since failures are cached and the package is already imported. (3) If the module in question is not inside a package there will be no slowdown whatsoever since there is no parent package at all. I've timed this with vtk and it seems to be correct. >>> import my_import, time # NOTE: I am not inside any package. >>> s = time.time (); import vtkpython; print time.time()-s 1.06130003929 >>> import time >>> s = time.time (); import vtkpython; print time.time()-s 1.06413698196 Its slower with standard import you may say - but that might just be my kernel's scheduling affecting things. I think its fair to conclude that there is no slowdown if you are not inside a package and based on my earlier timings, that recursive searching thru package parents is not too expensive either. There is one issue. lets say we have two sub-packages that have modules of the same name. Then if we explicitly want the other sub-packages module to be imported there is currently no way of doing it. In such a case maybe adding a __parent__ or using (__ as ni did) might be a good idea too. prabhu From phr-n2001d at nightsong.com Thu Nov 1 22:03:42 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 01 Nov 2001 19:03:42 -0800 Subject: Exception handling wart in Python References: Message-ID: <7xady5oovl.fsf@ruckus.brouhaha.com> "Leo Lipelis" writes: > I'd like some help with an issue I have with Python. Simply put, I think > having an exception mechanism is a waste if there is no tool that will let > you know which unhandled exceptions exist at point foo.... > > Considering that in Python exceptions are matched by identity instead of > equivalence, it's possible to track all the exception flows, right? Of course not. Since you can execute arbitrary strings, you can create new exception classes at runtime and throw them. > I agree with whoever said that a race horse doesn't belong in the glue > factory. It seems like Python is being used for serious programming, and > it seems to me, if it supports exceptions, it should support them all the > way. It's fairly pointless to provide exceptions if you really never know > whether you handle all the relevant exceptions or not, without the ugly, > bad, and stupid except: foo() statements to catch *all* exceptions. I don't understand the problem. The whole idea of an exception is it's something you don't have to know how to deal with. You catch the exceptions you can handle, and leave the rest for higher levels of the program. You can always catch all the exceptions, and then if you get something you can't deal with, re-raise it. > P.S.: The double leading underscore is the ugliest thing I've ever seen in > language syntax. I've been writing some Python code that uses that > feature, and man, it looks ugly. For a language that prides itself on > indentation based code blocks for readability, double underscore is an ugly > wart that needs to be fixed. That, and having to constantly type > self.__quax, self.__foo, self.__bar(), self.__foobar()... That's > *SEVEN* whopping useless characters on every line. > > P.P.S.: Otherwise Python is a very pleasant and productive language. Yes, I agree with this, I love Python too. But just like with any romantic partner, Python and I sometimes get in quarrels... From dale at riverhall.NOTHANKS.co.uk Fri Nov 16 11:45:33 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Fri, 16 Nov 2001 16:45:33 +0000 Subject: Does smtplib lookup MX records? Message-ID: I've been trying to send emails with smtplib and had a large number of failures. Investigation seems to reveal the the smtplib module does a simple connect passing the hostname to socket.connect without trying to resolve the MX record. In some cases this works where the mail server happens to have an A-type DNS record anyway but otherwise it fails with a connection error. Is this really the case? If it is, what do I need to do to lookup the MX record myself? (This is rather urgent now as this program was hastily written to help a client out who's mail server has died.) Thanks -- Dale Strickland-Clark Riverhall Systems Ltd From fredrik at pythonware.com Fri Nov 23 12:02:02 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Nov 2001 17:02:02 GMT Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> Message-ID: Suchandra Thapa wrote: > However, PHP has some fairly large flaws in comparision to python. if I'm to believe the following paper, "fairly large" is one huge understatement: http://www.securereality.com.au/studyinscarlet.txt ... a remote attacker can create any variable they wish and have it declared in the global namespace ... they can modify the start of the path ... PHP will make a HTTP request to evilhost, retrieve the attackers code and execute it ... this attack can be used to expose the contents of all sorts of sensitive files ... the attacker can simply upload the attack tools, have them saved by PHP then use their code execution ability to chmod() the file and execute it ... but maybe it isn't quite as bad as he makes it sound? From bill-bell at bill-bell.hamilton.on.ca Wed Nov 7 07:44:30 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 7 Nov 2001 07:44:30 -0500 Subject: Use a COM-server with python In-Reply-To: <1005097320.529.78936.m9@yahoogroups.com> Message-ID: <3BE8E65E.28051.78CE7FA@localhost> Marc Gehling wrote, in part: > Can someone translate this vb into python ? > > Dim oRepo As MXLib.MXRepository > Dim oNewFolder As MXFolder > Set oRepo = New MXRepository > oRepo.dbUserName = "rep" > oRepo.dbPassword = "rep" > oRepo.repUserName = "Administrator" > oRepo.repPassword = "Administrator" > oRepo.dbConnectString = "Inf ora8" > oRepo.repositName = "data" > oRepo.connect > oRepo.CreateFolder "testfolder", "folderdescr", 0, "Administrators", > oNewFolder oRepo.Disconnect Marc, I would hazard a guess that there should be a new-line between 'oNewFolder' and 'oRepo.Disconnect' in the final line of code. If so, then Python might be: from win32com.client import Dispatch oRepo = Dispatch ( 'MXLib.MXRepository' ) oRepo.dbUserName = "rep" oRepo.dbPassword = "rep" oRepo.repUserName = "Administrator" oRepo.repPassword = "Administrator" oRepo.dbConnectString = "Inf ora8" oRepo.repositName = "data" oRepo.connect oRepo.CreateFolder ( "testfolder", "folderdescr", 0, \ "Administrators", oNewFolder ) oRepo.Disconnect Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From sholden at holdenweb.com Wed Nov 28 08:29:52 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 08:29:52 -0500 Subject: Database in a simple ascii file References: Message-ID: "Rafael Mentz Aquino" wrote ... > Hi, > > How many lines can I have in a simple ascii file before > I start to loose performance when I open this file and > put all the lines in a dict, turning the first column into the key > and the rest of the line into a list associated to that key. > > (my file has just 100 lines, but that question starts to bother me ;-) > You couls always do some testing ... In fact this is probably the fastest way to do it, for random keys and a file that will fit comfortably into memory. The dictionary implementation works hard to make sure that access time is roughly constant no matter what the size. Posters have in the past reported using dictionaries of 100,000 elements without problems, so your file has to grow some before you hit uncharted territory... regards Steve -- http://www.holdenweb.com/ From niemeyer at conectiva.com Sat Nov 3 17:32:09 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Sat, 3 Nov 2001 20:32:09 -0200 Subject: dictionaries and 'in' in 2.1 In-Reply-To: ; from jjl@pobox.com on Sat, Nov 03, 2001 at 08:46:08PM +0000 References: Message-ID: <20011103203209.A1388@ibook.distro.conectiva> > The Python 2.1.1 manual, section 2.1.6, says: > > k in a 1 if a has a key k, else 0 > k not in a 0 if a has a key k, else 1 I've read this would be a new feature in 2.2. Are you sure you were reading 2.1.1's manual? -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From hfoffani at yahoo.com Sat Nov 24 17:05:20 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Sat, 24 Nov 2001 23:05:20 +0100 Subject: Python Persistant Object Shell References: Message-ID: <20011124170601.299$4f@news.newsreader.com> "Lucio Torre" escribi?: > I want to write an aplication that is a python shell plus: > ... > its something like zope, but with this differences: > + meant to be used by an application, not web broser (better ui) > + much less hassle in 'publishing' objects, all objects get published by > default using introspection, lists and dicts have special 'morphs' > ... I guess that you already knew it, but you can "detach" the object database engine of Zope (ZODB) for other uses. If it doesn't fit for your project there are other persistance object engines for python around if I am not mistaken. But don't know if those support distributed storage and retrieval. -Hern?n. From timo.savola at iki.fi Mon Nov 12 09:28:01 2001 From: timo.savola at iki.fi (Timo Savola) Date: 12 Nov 2001 16:28:01 +0200 Subject: Defining inheritance in C extensions In-Reply-To: References: Message-ID: <1005575281.4206.3.camel@misato> On Fri, 2001-11-09 at 13:45, Michael Hudson wrote: > > Now I'm doing an extension module, or rather a system that I want to > > control via Python. I have a C++ class hierarchy that I want to be > > accessible from Python. > > Have you looked at Boost::Python? I haven't, but I've heard it's good > for this sort of thing. Boost.Python seems to be *exactly* what I need. It even solves some of my minor worries. Timo From dale at riverhall.NOTHANKS.co.uk Thu Nov 15 11:39:44 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Thu, 15 Nov 2001 16:39:44 +0000 Subject: Inter-Thread Communication Message-ID: <4go7vtc8dqm8qsfq8ttv95bopidscj56l2@4ax.com> I have a master thread and a number of subordinate threads. They all need to communicate between each other synchronously - in an OS independent way. A typical exchange might be: T-A waits for a message from somewhere. T-B sends T-A a message about an event and waits for a response. T-A deals with the event and sends a response to T-B. T-A waits for another message. Pretty standard stuff, I would have thought. However, I can't see a tidy way of doing this in Python that doesn't involve three locks: The three locks, all of type threading.Lock, are: Message - global Post - global Response - local to thread 1. T-A acquires Message lock 2. T-B acquires Response lock. 3. T-A tries to acquires Message lock - blocking 4. T-B wants to post a message so acquires Post lock - blocking. 5. T-B get's Post lock and stores message details. 6. T-B releases Message lock - waking T-A. 7. T-B tries to acquire Response lock - blocking 8. T-A get's Message lock, handles message and stores response. 9. T-A releases Response lock - waking T-B 10. T-A releases Post lock ready for another thread 11. continue from 2 This seems awfully fussy to me. Is there an easier way? -- Dale Strickland-Clark Riverhall Systems Ltd From junkster at rochester.rr.com Thu Nov 15 06:09:51 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Thu, 15 Nov 2001 11:09:51 GMT Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <97ae44ee.0111142345.5679aca4@posting.google.com> Message-ID: In article <97ae44ee.0111142345.5679aca4 at posting.google.com>, shriek at gmx.co.uk (Stephen) wrote: > > >> I've been trying to benchmark socket server and can't seem to get it > > >> past serving 200 requests per second. > > > [snip] > > > > > > Thread-per-request servers can't scale up too high (although it might > > > be interesting to see what stackless + microthreads would do). You'll > > > need to use the asynchronous I/O support (see the select module for > > > lower level stuff, asyncore/asynchat for slightly higher stuff). > > > > About 3 years ago, I wrote a Python message-slinger as a drop-in > > replacement > > for my client's C code. It did around 600 msgs / sec (vs <200 / sec for the > > client's code). That was Python 1.4 on 3 year old hardware. > > Thanks for the example, Gordon. Gives me the confidence knowing that > "it is possible" ~ now I just have to work out how. It's very > reassuring, rather than having doubts and asking myself "should I > be doing this directly in C/Java instead?" whenever I hit a problem. > > > So 1000 / sec is quite possible, but you'll never get there with blocking > > sockets. > > Even if they're threaded ? Please keep in mind this might be a OS issue. For example, if your using Windows NT _Client_ (maybe Win 2000 & Win XP as well), that you are limited to 10 concurrent connections at anyone time. I didn't see anywhere where you discussed your setup, so if your threads are taking any significant time, or if you are not closing your threads fast enough, you maybe running into a OS imposed limitation. - Benjamin From mikael at isy.liu.se Mon Nov 5 10:13:50 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 05 Nov 2001 16:13:50 +0100 (MET) Subject: Process intercommunication In-Reply-To: Message-ID: Thanks Greg! On 05-Nov-2001 Grzegorz Dostatni wrote: > For interprocess communications You have a couple of options. If A can > start B at a proper time You could solve Your problem with pipes. (using > popen I believe). If B is started differently, You could look into > signals to catch A's attention. The easisest thing though it so make A a > server and make B connect on a given port. > An example of a server and a client is at: > http://www.python.org/doc/current/lib/socket-example.html Tried it, works perfectly. > It is quite possible to have a client and a server on the same machine. If > You're not going to have more than 10 processes trying to access Your > server (at a time) I'd recommend using the threading module to make things > a bit easier on Yourself. (watch out for mutual exclusion though ;-) ). I will try that too. > A reading list (assuming You'd like to go with sockets) > > http://www.python.org/doc/current/lib/module-socket.html (socket module) > http://www.python.org/doc/current/lib/module-thread.html (thread module) > http://www.python.org/doc/current/lib/module-threading.html (threading > module) > > The last one is a higher level version of the second one. Looks like I will find all I need in the proposed reading. Thanks again. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 05-Nov-2001 Time: 16:09:57 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From tim.one at home.com Tue Nov 6 19:46:08 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 6 Nov 2001 19:46:08 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message-ID: [John Roth] > ... > See my comment above. I'm not refering to integer division. > We've been around that circuit too many times to make > it really appealing to do so again. That's why I pointed out in my first reply that this thread had become *about* integer division. It hasn't been clear what you're on about, and I'm glad to see it clarified. > I'm refering to either rational (in the future) or real division, > in both of which division is supposed to be the exact inverse > of multiplication. That's true of non-exceptional rationals but not of reals (by which I assume you mean floating-point). With floats, it's possible (actually common, alas) to have non-exceptional a, b and c such that a*b == c but neither c/a == b nor c/b == a. Also possible to have a*b == c and c/a == b but not c/b == a. Float arithmetic is also an information-losing process (see last reply). From skip at pobox.com Thu Nov 1 16:09:37 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 15:09:37 -0600 Subject: python development practices? In-Reply-To: <01110112151501.08187@logiplex1.logiplex.net> References: <01110111582600.08187@logiplex1.logiplex.net> <01110112151501.08187@logiplex1.logiplex.net> Message-ID: <15329.47633.40733.376399@beluga.mojam.com> Cliff> As an aside, it wouldn't surprise me to find that many people who Cliff> "can't upgrade from 1.5.2" because some application they've Cliff> written breaks under 2.x are the victims of name collisions Cliff> introduced in newer versions of the standard libraries that they Cliff> are deriving from. The results of such collisions would be Cliff> highly unpredictable and difficult to track down. Hmmm... I wonder if pychecker can be taught to check for this: class A: def __init__(self): self.x = 1 self.y = 1 class B(A): def __init__(self): self.x = 10 A.__init__(self) self.y = 10 Ideally, it would warn about the assignment to self.x in B.__init__, but possibly not the assignment to self.y. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From loewis at informatik.hu-berlin.de Tue Nov 20 07:11:03 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 20 Nov 2001 13:11:03 +0100 Subject: String formatting char References: Message-ID: Dale Strickland-Clark writes: > Is there some way to alter the format escape character from % to > something else? Sure. def format_with_tilde(msg, args): assert msg.find('\200') == -1 msg = msg.replace('%','\200').replace('~','%') msg = msg % args return msg.replace('%','~').replace('\200','%') print format_with_tilde("~d is ~f% of ~d",(3,3.0/8,8)) Regards, Martin From mwh at python.net Fri Nov 16 07:14:23 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 16 Nov 2001 12:14:23 GMT Subject: What is "marshal data"? References: <859c71be.0111151028.63227109@posting.google.com> <3bf4fd0f$1@brateggebdc5.br-automation.co.at> Message-ID: "Werner Schiendl" writes: > just a guess, but even if the magic id in the .pyc file is the same, > does this guarantee that the .pyc file is protable between different > platforms? Yes. This fact is even documented . Cheers, M. -- we're already scrubbing the face of intuition with steel wool, setting it on fire, then putting it out with an axe . -- Tim Peters, on comparing recursive structures From mailto Wed Nov 7 20:37:23 2001 From: mailto (Robert Amesz) Date: Thu, 08 Nov 2001 01:37:23 -0000 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> Message-ID: Fredrik Lundh wrote: > Edy Lie wrote: >> Hi I have setup a class but in the code i could not use it. Anyone >> care to explain ? > > hint: it's usually easier to for the readers of this forum to > figure out what's wrong if you include the error message. > > did you get this message? > > Traceback (most recent call last): > File "\qq.py", line 19, in ? > add = DataBase() > TypeError: __init__() takes exactly 5 arguments (1 given) You're right about the argument count thing, but I suspect he doesn't even get that far, but is greeted by the the 'Wrong input' response all the time, whatever he types. My hint is: type 1=='1' at the interpreter prompt, and see what you get. Python is dynamically typed, *not* weakly typed, no sir. Robert Amesz -- And thank G. for that... From James_Althoff at i2.com Wed Nov 28 20:20:07 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 17:20:07 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Peter Hansen wrote: >What am I missing here? Is the above not just >a far less sane way of writing the following? > >if index >= len(mylist): > print 'index out of range' But "sane" is *such* a loaded term. ;-) I guess you mean if index >= len(mylist) or index < 0: The double condition is what might prompt some to use the range/xrange alternative -- along with the fact that index in range(len(mylist)) works both in a for-loop and an if-statement. I see it quite a lot in code that I come across. YMMV. Jim From jdhunter at nitace.bsd.uchicago.edu Mon Nov 5 15:10:28 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: Mon, 05 Nov 2001 14:10:28 -0600 Subject: identify x,y coordinates in an image Message-ID: I need to get the x,y coordinates of a bunch of points in a 2d image. I would like to mouse click on a point in the image and get the coordinates of that point with reference to some origin (also identified with mouse click) and some x,y scale which could be customized. I will need to be able to zoom in at some points of the image, and perhaps scroll because the image will be large. I suspect some combination of PIL and Tk is what I an looking for, but am soliciting advice and/or prototype code before I begin. Thanks, John Hunter From kragen at canonical.org Sun Nov 25 22:07:57 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 22:07:57 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> Message-ID: <83bshqtek2.fsf@panacea.canonical.org> Hans Nowak writes: > - should I use a license / copyright notice? If you want people to use the code, yes; if they don't have a written license, the code is still copyrighted by you (assuming you live in a Berne Convention country) and they can still infringe your copyright. They might have an 'implied license', consisting basically of what you've encouraged them to do, but I feel a lot more comfortable with an explicit license. > - if so, which one would you recommend? A popular one, because if you don't use a popular one, people who take this stuff seriously and hate legalese won't even consider using your software, because they'd have to read another license. > I know of the GPL, Python license, BSD license etc, and opensource.org > has a long list of them, but I absolutely hate legalese, and reading > all of this and pondering the possible consequences of picking one > over the other makes me cringe. Does someone have a pointer to a > page with some concise explanations of these licenses? The Free Software foundation has a page at http://www.fsf.org/licenses/license-list.html that is more or less what you want. My summary is as follows: - GPL: you can use this software freely but can't incorporate it into proprietary software without negotiating with the author for special permission - BSD: you can do whatever you want with this software. (There's an older version of the BSD license which includes a clause that requires credit be given; this is generally considered annoying.) > Then there's a second point: I see that many projects use version > control (usually CVS). I tried using DJGPP's cvs, but it > (unsurprisingly) doesn't work well on WinXP. There's such a thing > as WinCVS, but the whole process strikes me as clumsy... checking > in and out and committing every time something changes... what is > the point of this? What happens if you forget a step? Does it have > substantial benefits over versioning your files by hand, aside from > having a repository through which you can undo changes? Cygwin cvs works well on pre-XP versions of NT. I haven't tried XP. CVS doesn't require you to check out repeatedly, and you only check in when there are changes. Version control is a huge benefit when you're trying to work on something with other people; it keeps you from accidentally destroying their work. It's not as big a win with individual projects, but it still has some advantages: - I can type 'cvs annotate' to see when each line of code in my work area was added --- what date, what time. (And by whom.) - I can type 'cvs diff -D 2001-10-25' and see the changes since October 25th. - I can type 'cvs diff' and see what changes I haven't committed, which often keeps me from committing typos in comments (where I typed some character in the wrong window) - saving my current work state is quicker than with a copy-tree, and it takes less disk space, which makes it easier to back up my entire work history. That said, I still mostly use it when I'm working with somene else, or when I have multiple copies of files on different machines that I might edit independently. (I keep my PIM stuff --- calendar, addresses --- this way.) From oliphant at ee.byu.edu Wed Nov 28 14:57:53 2001 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Wed, 28 Nov 2001 14:57:53 -0500 Subject: reading tabular data In-Reply-To: <3C055139.5F553460@home.net> References: <3C055139.5F553460@home.net> Message-ID: > Mark Fardal wrote: > > what do people use when they want to read in long tabular files into > > a (NumPy) array? I have only tried Scientific.IO.readArray and > > read_ascii from Nick Bower's PYDL. read_ascii is very simple and > > needs some work to be robust, but it was much faster than readArray > > for the example I tried. Is there something else I should know > > about? > > You might also want to take a look at TableIO > (http://www.python.org/topics/scicomp/storage.html) and FortranFormat. You could try scipy.io.read_array in the SciPy package as well. From prabhu at aero.iitm.ernet.in Fri Nov 9 23:47:03 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sat, 10 Nov 2001 10:17:03 +0530 Subject: mayavi installation problem on Win NT In-Reply-To: <9shiki$gjl$04$2@news.t-online.com> References: <9sdh9v$hgq$01$1@news.t-online.com> <9shiki$gjl$04$2@news.t-online.com> Message-ID: <15340.45383.852985.237578@monster.linux.in> Hi, >>>>> "MF" == Markus Faust writes: MF> Prabhu, I played a bit around with mayavi. It is one of the MF> greatest programs I saw this year! Astonishing how you can MF> rotate and manipulate 3D views. Very good user interface! I MF> also saw that I'll need more graphics performance ... Thanks! :) However, this forum is not the place for discussing MayaVi or its greatness . The MayaVi users list is at mayavi-users at lists.sourceforge.net prabhu From huaiyu at gauss.almadan.ibm.com Fri Nov 2 14:37:22 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Fri, 2 Nov 2001 19:37:22 +0000 (UTC) Subject: Exception handling wart in Python References: Message-ID: On Thu, 01 Nov 2001 19:35:46 -0500, Leo Lipelis wrote: >Hi Pythoneers, > >I'd like some help with an issue I have with Python. Simply put, I think >having an exception mechanism is a waste if there is no tool that will let >you know which unhandled exceptions exist at point foo. I have spoken >about this issue briefly with Neal, of the PyChecker fame, and he seemed to >agree with me. > >I realize that it's a difficult problem to solve, but I think it would be >worth solving at the language level, similarly to the way it's done in >Java. Let's say I call a function in some module, > I've used both Java and Python. My thoughts on this: - Java style exception is simply impossible in Python. To know the exceptions pontentially raised by _something_ refered by a name, you have to know before hand what that _something_ is (types, attributes, arguments, etc). But in Python these properties are associated with objects, not names. For example, you can not determine the exceptions raised by a, b = c(d) until the names are bound to specific objects. But if you can determine them in advance, you might just have solved the problem of static type checking in Python, which would be far more useful. - Python style exception is actually more useful in practice than Java style. Since you are not required to catch exceptions until you want to, you can let them propagate during development until you are ready to handle them properly. The final code is very robust, and any exceptions left would be those that you haven't anticipated anyway. If there is a special section of your code that can't tolerate any exceptions, you can just catch all of them at that point. On the other hand, in Java you are forced to deal with all theoretically possible but practically very improbable exceptions early on during development. To move the process forward some programmers catch all of them and ignore them, or handle them in a very superficial way. This leaves some very subtle bugs in the final product where ignored exceptions go undetected. Exception is a mechanism to treat low probability situations so that they do not distract the main flow of the program. Python allows you to ignore them or handle them any way you like, so that you can concentrate on the main thing you are doing. Java forces you to treat them all explicitly, which sort of defeats its purpose. It becomes essentially a glorified condition-goto structure. Since in any real world situation the probability distribution of cases are far from uniform, I find Python style exceptions far more efficient. Huaiyu From db3l at fitlinxx.com Fri Nov 16 17:26:50 2001 From: db3l at fitlinxx.com (David Bolen) Date: 16 Nov 2001 17:26:50 -0500 Subject: MultiThread Socket on NT References: Message-ID: Cliff Wells writes: > Be sure you are using at least SP5. NT 4 had serious threading issues prior > to that. Do you have any pointers or references to what the problem was? I've been using multi-threaded applications (although not a high density connection server) under NT4 SP4 without any observable problems. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From jeff at ccvcorp.com Wed Nov 28 20:56:12 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 28 Nov 2001 17:56:12 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C056DF5.F9EE5D13@ccvcorp.com> <3C0575F4.9A23C894@cosc.canterbury.ac.nz> Message-ID: <3C0595BB.F44DB0E7@ccvcorp.com> Greg Ewing wrote: > Jeff Shannon wrote: > > > > David Eppstein wrote: > > > > > I don't care for it -- is it really natural and intuitive > > > that "x in y" should be equivalent to "0 <= x < y" when x and y are both > > > ints? > > > > PEP 276 does not make an integer equivalent to the > > list of natural numbers ending below it; > > I think the point Mr. Eppstein was making is that > "for i in seq" can be read as "for all values of i > such that i in seq is true". PEP 276 would break > that, because "for i in 5" couldn't sensibly be > read as "for all values of i such that i in 5 > is true", unless "i in 5" on its own were valid and > had a rather unintuitive meaning. Okay, with this thought in mind, the comments do make much more sense. Though I have to say, it would *never* have occurred to me to read a for-loop that way. :) I also think that this interpretation of a for-loop is already broken with iterators and generators, anyhow. If I have a generator that yields successive values read from a serial port device, then the phrase "if i in serialinput()" is meaningless (or, at best, useless), whereas the loop "for i in serialinput():" makes perfect sense. Jeff Shannon Technician/Programmer Credit International From danyelf at acm.org Tue Nov 6 13:12:06 2001 From: danyelf at acm.org (Danyel Fisher) Date: Tue, 6 Nov 2001 10:12:06 -0800 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> Message-ID: <9s9949$hm5$1@news.service.uci.edu> [global example deleted] > I'd say, most run into this problem soon after they learn to use > functions. It does not matter whether they have seen any other > programming language before or not. > Some have said "don't teach them about 'from xyz import *'". Should we > also not teach beginners about using functions? Python's namespace > feature is such an integral part of the language, that you can't > really neglect it. At many schools, Scheme is taught as a first language. It's a lispy language with nested scopes, and students have _absolutely_ no problem figuring this out. One way to do it is to start off teaching functions without (gasp!) global scope. "A function is something that returns stuff." Students who really need to return multiple things get tuples, so it isn't a big deal. At some point, you get to say "but there's a slightly easier way, sometimes." When teaching lisp, the easier way is through the notion of "environments" and nested scope. In python, we call it a the "globals list"--a list of variables that you can get at without sending them into a function. > Sequence of events: > > (1) Teacher goes through the whole song and dance about global, local > namespace. How assignment actually means name binding, etc. etc. It is > fun to do it once, it is fun to do it twice, but after doing it a few > dozen times, teacher gets exhausted, and starts to cast doubt: "... > maybe Python is not such a trivial language, after all." Nope. Teacher goes through the short song and dance about local variables and ignores globals until the students are already comfortable with locals. > (2) After being shocked by the above example, students start to put > 'global' statements in every single function for every single > variable. They don't understand what is going on, they just don't want > to be bitten by the same bug, again. Again, the students have good "function" habits. They'll only set the global "flag" variable when they need to. You seem to work under the (rather odd) assumption that teaching works by standing in front of a bunch of students, yelling at them, and then letting them run off into the world to be confused. Some of us who are teachers prefer to give students a series of increasingly-sophisticated assignments, any of which can be solved by the material we've covered so far in class, and each of which illustrates an interesting principle of the subject matter. Kudos, for example, to Kojo Duncan's teacher, who asked a striaghtforward question ("write a program that lists all prime numbers less than a prime number a user inputs.") The solution to it requires only traditioanl functions, few namespaces, and yet is fairly easy. For students who know prime numbers--not our target audience of 10 year olds--this is a great assignment. Danyel From mkelly2002NOSPAM at earthlink.net Wed Nov 21 17:38:13 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Wed, 21 Nov 2001 22:38:13 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFB34A9.565BBF2E@engcorp.com> <20011121000734.48b85dde.sthiyaga@operamail.com> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: On Wed, 21 Nov 2001 11:33:22 -0800, Jeff Shannon wrote: > > >Dave Cinege wrote: > >> Rule of God: >> The punishment for non-tab based indentation is death. > >This is exactly backwards. > >Tabs are wrong, because different editors will treat them differently. > >Spaces are right, because a space is a space is a space, everywhere you >go. Thanks for the replies. After reading the comments in Whitespace.py I just changed PythonWin to use 8 spaces per tab, use spaces instead of hard tabs and an indent of 4, with auto-indent enabled, and that seemed to do it. At least I tried pasting out of the same file that hung me up before and didn't get any glitch. The more I mess around with Python the more I like it. I can see the advantage of the indentation scheme since it's not as easy to have an "obfuscated source" file that will actually compile like you can in C. :) Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From johnroth at ameritech.net Wed Nov 7 11:32:37 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 7 Nov 2001 08:32:37 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: "Tim Peters" wrote in message news:mailman.1005094029.14146.python-list at python.org... > [John Roth] > > ... > > See my comment above. I'm not refering to integer division. > > We've been around that circuit too many times to make > > it really appealing to do so again. > > That's why I pointed out in my first reply that this thread had become > *about* integer division. It hasn't been clear what you're on about, and > I'm glad to see it clarified. > > > I'm refering to either rational (in the future) or real division, > > in both of which division is supposed to be the exact inverse > > of multiplication. > > That's true of non-exceptional rationals but not of reals (by which I assume > you mean floating-point). With floats, it's possible (actually common, > alas) to have non-exceptional a, b and c such that a*b == c but neither c/a > == b nor c/b == a. Also possible to have a*b == c and c/a == b but not c/b > == a. Float arithmetic is also an information-losing process (see last > reply). Quite true, but the original point was about sign handling. The approximate nature of floating point arithmetic does not affect this. John Roth > > From cliechti at gmx.net Tue Nov 20 17:37:48 2001 From: cliechti at gmx.net (Chris Liechti) Date: 20 Nov 2001 23:37:48 +0100 Subject: Conversion from tuple to argument list? References: Message-ID: [posted and mailed] "Bruce Edge" wrote in news:LEAK7.2203$px5.169125 at newsfeed.slurp.net: > Forgive the stupid question, probably a C programmer mindset issue here. > > I have a tuple of data items say (0,1,2) I want to pass to struct.pack, > which takes: > pack (fmt, v1, v2, ...) > > How can I pass my tuple to pack as its arg2,3,4,... > > -TIA, Bruce. >>> args = range(3) newer python releases: >>> struct.pack("bbb", *args) '\x00\x01\x02' any version: >>> apply(struct.pack, ["bbb"] + list(args)) '\x00\x01\x02' chris -- Chris From kseehof at neuralintegrator.com Mon Nov 26 22:08:56 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Mon, 26 Nov 2001 19:08:56 -0800 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: <000201c17796$08a02fc0$1d4bb43f@kens> > > I see "a few socially conscious businesses" should use software from THE > > socially conscious business of the World ;) Stephen Cox wrote: > Except for the webserver, they do. MySQL as the backend database, ASP and > PHP are the scripting langs. I'm learning Python so I can use ZOPE more. > True, I think .NET is cool - but I'll only use it if MS keeps it promise and > ports it too Linux and such. Odds of MS keeping any promises of this kind: 0.027% .NET will be cool until everyone starts using it as an industry standard. At that precise moment, MS will introduce various incompatibilities that will maximize problems for their competitors. In the mean time, they will continue to promote .NET as the standard for open archetecture development. Of course, if MS hadn't created .NET, somebody in the open source community would have, and MS would have lost a great deal of control over the market. They know this, and that is why they occupied the nitch with .NET. It has never been in MS's best interest to be compatible with the rest of the computing world. - Ken From daniel.dittmar at sap.com Mon Nov 12 06:18:16 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 12 Nov 2001 12:18:16 +0100 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <9sob5p$mqq$1@news1.wdf.sap-ag.de> > My idea is that besides going into some detail of every Toolkit I > construct _one_ application scenario with a skeleton, which I > later complete with each of the toolkits. How about a tree based XML editor? It would show: - tree widget - resizable panes - entry box, combo box (to edit attributes) If you add the ability to overide the editor for a tag with a custom editor, then you have actually a good base for many an application. And I find a rundown of widgets and layout managers quite helpful. Maybe you can start a Python GUI cookbook site, the result being something like the wonderful wxPython demo for every toolkit. Daniel From root at rainerdeyke.com Sun Nov 11 17:25:05 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Sun, 11 Nov 2001 22:25:05 GMT Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> Message-ID: <5VCH7.127307$IR4.39129314@news1.denver1.co.home.com> "Laura Creighton" wrote in message news:mailman.1005512294.21291.python-list at python.org... > > Okay, new version: > > Did I miss something? You might also want to support keyword arguments. > def foreach(object_list, method_name, *args): def foreach(object_list, method_name, *args, **kwargs): > for object in object_list: > try: > method = getattr(object, method_name) > except AttributeError: > pass > else: > if callable(method): > method(*args) method(*args, **kwargs) -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From tdelaney at avaya.com Tue Nov 13 19:02:27 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 14 Nov 2001 11:02:27 +1100 Subject: dynamically generating a module Message-ID: > From: Steven D. Majewski [mailto:sdm7g at Virginia.EDU] > > On 13 Nov 2001, Hung Jung Lu wrote: > > > Here is one more challenge: is it possible to create a module on the > > fly? > > > > Suppose I have the ASCII Python source code of a > module-to-be, or even > > better, suppose that I have the compiled byte code of a > module-to-be, > > stored in a Python string. Is there a simple way (meaning > not tweaking > > at C++ level) of making the module-to-be into a real module, without > > hitting the harddrive? > > Sure: all you have to do is create an empty module and exec the code > in that modules namespace: Another useful possibility is to stick a class instance into sys.modules. class NewModule: a = 1 b = 2 def func (self, a): """""" return a import sys sys.modules['newmodule'] = NewModule() import newmodule print newmodule.a print newmodule.b print newmodule.func(5) Tim Delaney From uwe at rocksport.de Tue Nov 20 05:52:57 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 20 Nov 2001 10:52:57 GMT Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> Message-ID: <9tdcm9$ai6a0$1@hades.rz.uni-sb.de> Huaiyu Zhu wrote: | On 19 Nov 2001 15:31:13 GMT, Uwe Schmitt wrote: |>I uses MatPy today and think it' quite useful. But there is one |>incompatibility to matlab: in MatPy indices start at zero, in |>Matlab they start at one. Is there a solution to adapt MatPy to |>the Matlab style ? | Although it is possible with some hacking, I don't think you would want to | do that, because in Python all sequences are indexed this way, including | NumPy arrays. If that's changed there would be a lot of confusion when you | transform between plain Python and numerical objects. | Besides, there are many good reasons to start indexing from zero. The open | source Matlab-compatible language Octave allows both indexing from zero and | one. It defaults to start from zero, but if you choose an option (called | "braindead" or something like that) it can start with one. Braindead is not | an easy option here. :-) I'd prefer indexing from zero, because it's the notion used in mathematics, most existing algorithms are formulated this way. Greetings, Uwe. -- Dr. rer. nat. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From krempp at trucs.en.trop.crans.ens-cachan.fr Wed Nov 7 08:34:10 2001 From: krempp at trucs.en.trop.crans.ens-cachan.fr (Samuel Krempp) Date: Wed, 7 Nov 2001 14:34:10 +0100 Subject: Non-Indented python Message-ID: <9sbd8i$680$1@wanadoo.fr> On some rare occasions, the constraint of expressing blocks through identation can be painful. (eg, when I want to write a quick script, but am on a bad computer with no good editor. Or if I want to create a script from a shell command-line, ?-la awk or so.. ) I figure it should be quite simple to implement a program that translates scripts where blocks are expressed by traditionnal block markers like '{' and '}' (or whatever else..) into a well indented python script. I thought it surely was already existing, but surprisingly I could not find any.. Is there such a program ?? If not, what would be the best way to implement a 'python-ni' executable (script or binary) that can be called in place of python to execute those non-indented scripts ? (maybe there is a better way than translating the whole script into an indented one and feeding it to the regular python executable..) -- Sam, the knight who says NI ! From philh at comuno.freeserve.co.uk Fri Nov 23 11:41:55 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 23 Nov 2001 16:41:55 +0000 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> Message-ID: On Fri, 23 Nov 2001 15:05:19 GMT, Suchandra Thapa wrote: >Max M wrote: >>I think you will find that the general concensus is that Python is a >>"complete" language. Which PHP is not. Python can be used for both web >>scripting and, shell scripting, application development, small tools and gui >>apps. And is very good at all of them. Wheras PHP is only useable for >>scripting web pages. > > PHP has a command line interpeter so it can be used for scripting >and the like. I believe there is even a gtk library so it's conceivable to >create a gui app in php. However using php for something other than web >scripting is very rare. That's because PHP *as a language* isn't that good. Python is a much better GUI scripting language. PHP is nice for web pages, but that's all it's nice for. > However, PHP has some fairly large flaws in comparision to python. >For example, using a variable that has never been declared or initialized will >silently be treated as using an empty string It wouldn't bother me if Python did this. > (e.g. if you make a typo while >entering a variable's name, you won't get an error). PHP also has some issues >with case sensitvity. Variable names are case sensitive while function names >are not. In addition, function calls are handled poorly. If you call a >function with 3 parameters when it was declared with less than 3 parameters, >php will silently ignore the extra parameter. PHP is also ugly. As an example, compare: PHP: $object->$member Python: object.member -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From joonas at olen.to Wed Nov 21 10:12:06 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Wed, 21 Nov 2001 15:12:06 GMT Subject: Pil-Libary---write text into an image file References: <3fea95b3.0111210555.5f2ee93@posting.google.com> Message-ID: <3BFBC522.9070107@olen.to> stephan wrote: > Hi there, is it possible to open a image file, write text inside and save it > in an image file iI can display in common Browsers. > Do I have to use the PIL-Libary? Yes you do. > Please help, we are desperate... > And Tommy is suffering... > Thank you. http://www.pythonware.com/library/pil/handbook/imagedraw.htm From jslowery at hotmail.com Fri Nov 30 23:16:47 2001 From: jslowery at hotmail.com (Jeremy Lowery) Date: Fri, 30 Nov 2001 22:16:47 -0600 Subject: load a class dynamically References: <3C08497D.2C92F2B9@earthlink.net> Message-ID: <7PYN7.24373$S93.953955@e3500-atl2.usenetserver.com> Thanks for the post, Yes, I finally figured that out after I made the post. (Always happens that way). Now I'm in search of finding a way to make a dynamic modules, packages to add the classes to. I'm writing an app that stores all of this stuff in a ZODB and lets users write code on a server over a network. And I'm trying to figure out a way to dynamically "pack" all of the class definitions into modules and packages so that I can plug the base package into the namespace before the code is run. like one user importing Users.JLowery.ACoolModule in the code that is going to be piped over the network, and then the module/package structure is dynamically created from the objects in the ZODB. (Like the User package gets put in the global namespace) (Of course, not dynamically recreate it on every request but you get the idea.) Jeremy "Hans Nowak" wrote in message news:3C08497D.2C92F2B9 at earthlink.net... > Jeremy Lowery wrote: > > > > I know that implementing this may be a little bit of work, but could someone > > point me in the right direction? > > > > Have a text file that only contains a class definition, or just a string for > > the sake of simplicity. > > > > str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1" > > > > #the magical code goes here. > > > > obj = myClass() > > # of course, it doesn't have to be called like that, but to > > #get the ability to instantainate that class. > > You can use the exec statement, but you should end the string in > a newline, though... > > >>> str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1" > >>> exec str > Traceback (most recent call last): > File "", line 1, in ? > exec str > File "", line 3 > self.v = 1 > ^ > SyntaxError: invalid syntax > >>> str = str + "\n" > >>> exec str > >>> obj = myClass() > >>> obj > <__main__.myClass instance at 00AB5ED4> > >>> > > --Hans From lac at strakt.com Fri Nov 23 09:52:27 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 23 Nov 2001 15:52:27 +0100 Subject: binding event on tkinter? In-Reply-To: Message from micoud78@hotmail.com of "Fri, 23 Nov 2001 11:33:10 GMT." <9tlc5m+10at6@eGroups.com> References: <9tlc5m+10at6@eGroups.com> Message-ID: <200111231452.fANEqRua031982@ratthing-b246.strakt.com> If you have a linux system, you can look in /usr/X11R6/include/X11/keysymdef.h to find out what a key is called. You are looking for and Laura Creighton From peter at engcorp.com Thu Nov 15 21:18:10 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 15 Nov 2001 21:18:10 -0500 Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: <3BF47762.4322913A@engcorp.com> Huaiyu Zhu wrote: > > It is true that once objects can be unequal to themselves a list of such > objects can be uneqal to itself too. > > So my question really is this: Is there any major practical use for an > object to be unequal to itself? Would it be better to just define (a==b) to > take a shortcut of (a is b), always? > > Yes, I know NaN is a special case. But I do not really see any practical > use of (NaN==NaN)==0, because it violates > > (a!=b) == not (a==b) > > anyway. Well, you just pointed out one case, which is probably enough reason not to add a special case to the language itself. Other practical uses I can think of start with using it during testing, to verify that a particular code path will actually work if it is taken, or for troubleshooting a particularly unclear problem which involves comparisons. Not that it should necessarily matter. If == is defined as using __cmp__, then for consistency (principle of least surprise) one should be able to rely on that definition. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From store_li at sina.com Wed Nov 28 20:17:44 2001 From: store_li at sina.com (Kick) Date: Thu, 29 Nov 2001 09:17:44 +0800 Subject: Does Tk in Python support drog and drop? Message-ID: <9u42cv$649h5$1@ID-12869.news.dfncis.de> Can anyone give some advice? Thank you! From kragen at pobox.com Tue Nov 27 16:48:51 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 16:48:51 -0500 Subject: Keeping Python loaded References: <9tndpi$qbe$1@slb0.atl.mindspring.net> <9tvlns$ca4$1@slb1.atl.mindspring.net> Message-ID: <83ofln6g1o.fsf@panacea.canonical.org> "Matt Gerrans" writes: > Where do I find mod_python and mod_snake? I searched in my Python directory > to no avail. Are they a part of Apache? Or Zope? modpython lives at http://www.modpython.org/ and mod_snake lives at http://modsnake.sourceforge.net/ --- they are both parts of Apache. > One simple trick I was considering was to write a little Tkinter or wxPython > UI that hangs out (keeping the engine running at all times) and just lets me > name a script; it could then simply import it and call main(). Yes, this > assumes there is a main(); I always have the "if __name__ == "__main__": > main()" line at the end of my scripts, so they can all have the same entry > point and can run stand-alone or be imported. This is not a very general > solution, of course... I just wrote this script, which might be a somewhat better solution --- it's fairly general-purpose, but if your scripts look at sys.argv, you'll have to set that first. #!/usr/bin/python def runscript(filename): namespace = { '__name__': '__main__' } execfile(filename, namespace) return namespace def main(): import sys runscript(sys.argv[1]) if __name__ == '__main__': main() HTH. From cbarber at curl.com Fri Nov 16 10:29:10 2001 From: cbarber at curl.com (Christopher Barber) Date: 16 Nov 2001 10:29:10 -0500 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> <9t1uce$5d8$1@nntp1-cm.news.eni.net> <9t2ija$qtl$1@slb5.atl.mindspring.net> Message-ID: "Matt Gerrans" writes: > Well, one simple solution is to continue to discuss it here for another 17 > months or so and we'll have doubled the performance without a single change > to the interpreter, via Moore's Law (unless it is repealed by then). :-) My computer is already over 17 months old and it doesn't appear to be running any faster. ;-) From phd at phd.pp.ru Tue Nov 6 11:42:38 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 6 Nov 2001 19:42:38 +0300 Subject: Freeware Python editor In-Reply-To: ; from DeepBlue@DeepBlue.org on Tue, Nov 06, 2001 at 10:24:06AM -0600 References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> <9s8u5d$11feke$1@ID-11957.news.dfncis.de> Message-ID: <20011106194238.N20452@phd.pp.ru> On Tue, Nov 06, 2001 at 10:24:06AM -0600, DeepBlue wrote: > > > > > Let me add to this that in such a boring predictable world, I have > > > always > > > > > appreciated Oleg's Pushkin-Lermentov-like sensibility and idealism > :) > > > > > > > > Always? Did I really show it *so* many times? :) > > > > oh yes! :) Nothing to be ashamed of anyway! I am not ashamed. Exactly opposite - I am proud! :))) > Would Pierre be ashamed of his noble feelings to Natasha! > Would Malakhov have abandoned Aksenia? Wow! You know "The War and the World" better than I do. Shame on me! :) > Would Oleg turn away from what makes the world tick :) what "makes the world goes round" :) > > > ;-)) > > > About as predictable as waiting for Martijn to jump in about the PS > > > > Hmm. Something funny is in the Russian air if even me (neither Russian, > > nor even born in Russia, though I live in Moscow now) behave like that > :))) > > > hehehehehe! > But I totally understand. It just grows on you. > I am not even close to Russia. It is a state of mind. Certainly. > Would you program using Python? If yes, then you must be an avid reader of > Turginev and Tolstoy :) I do programming only with Python. But unfortunately, these are not authors I love best. My authors are JRR Tolkien and C.S.Lewis (not because it is fantasy, but because it is Cristian fantasy). >--------------------\ | Oleg. | -- | Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru | Programmers don't die, they just GOSUB without RETURN. <-------/ From ursus_horibilis at hotmail.com Tue Nov 27 14:26:46 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Tue, 27 Nov 2001 14:26:46 -0500 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: "Skip Montanaro" wrote in message news:mailman.1006886320.31467.python-list at python.org... > > I suggest you grab the latest beta and start having some fun... > Yeah, man! That's cool as a cucumber. I'm a convert already. And thanks to Hans, Fernando, Michael, Steve and everyone else who came to my rescue! I believe that you all must have set a record for cool-headed responsiveness to a dumb amateur on USENET! You guys are great. From fuessler at informatik.uni-mannheim.de Mon Nov 12 05:08:56 2001 From: fuessler at informatik.uni-mannheim.de (Holger Fuessler) Date: 12 Nov 2001 11:08:56 +0100 Subject: long string constants Message-ID: Hallo! If this is frequently ask, please give me a reference. I couldn't find it. I'm using string building of the form "%s..." % (variable, ...), where the string and the variable list is very long. Now my question. Is it possible to spread very long string constants over multiple lines?. Thanks in advance Holger -- Holger Fuessler Praktische Informatik IV Tel: +49 621 181 2605 University of Mannheim Fax: +49 621 181 2601 L15, 16 68131 Mannheim, Germany fuessler at informatik.uni-mannheim.de From dalke at dalkescientific.com Tue Nov 13 09:27:26 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 07:27:26 -0700 Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> <9sp10u$h36$1@slb0.atl.mindspring.net> Message-ID: <9srami$obp$1@slb2.atl.mindspring.net> Me: > Python calls them "members". Martin von Loewis: >In the same context, it also calls them "data attributes". This is >what I normally use. Right. Python calls them "members" but the Python documentation calls them "data attributes." Me? I call 'em "data attributes." Andrew dalke at dalkescientific.com From anuraguniyal at yahoo.com Thu Nov 29 06:44:50 2001 From: anuraguniyal at yahoo.com (anurag uniyal) Date: Thu, 29 Nov 2001 03:44:50 -0800 (PST) Subject: Unable to deliver your message In-Reply-To: <1007029759.19.15086.m3@yahoogroups.com> Message-ID: <20011129114450.11152.qmail@web11804.mail.yahoo.com> hi all, I am creating a python application which runs embedded in some other software ,this software has some built-in modules which I am using in my pyhton application. Now I wan't to convert my python application to exe. I have done that using Py2Exe. Is it possible to run this exe as embedded in other software. __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From sholden at holdenweb.com Mon Nov 26 09:27:43 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Nov 2001 09:27:43 -0500 Subject: Non-Indented python References: Message-ID: <8gsM7.89521$vQ1.4199717@atlpnn01.usenetserver.com> "Dave Cinege" wrote ... > On Friday 23 November 2001 3:47, you wrote: > > "Dave Cinege" wrote ... > > > > > On Thursday 22 November 2001 12:38, you wrote: > > > > time to find out. i had unzipped the source with winzip (which uses > > > > \r\n) and tried to compile it with cygwin. of course, it couldnt do it, > > > > > > Commandment #2 > > > Thou shalt terminate thy line with but one byte. Let he who hath > > > understanding recognize the number of the byte, 0xA0. Death to thee who > > > terminates thine with any other byte! > > > > > > You use a defective OS built with defective editors. REPENT! > > > > > > Dave > > > > It sounds like somebody is overdue for a visit from the cult deprogrammers. > > How do you expect me to win a religious war without religion? > > > Geeze, lighten up. Oh, and it's 0x0a, not 0xa0. Totally different > > characters. > > DOH! Sorry, a mistype in my translation from Aramaic... > It is not widely known that the TAB war is a device of the Python Secr From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Sun Nov 25 22:57:50 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Mon, 26 Nov 2001 03:57:50 GMT Subject: application scripting References: Message-ID: In article , Chris Liechti wrote: [...] > i assume that the python interpreter is embedded and available for the user > that wants to write scripts (eg a menu entry to start the recorded scripts > and maybe an interactive console, could be nice for testing). Would you know of any examples of this on the internet? [...] > maybe you want to have a look at some sample COM scripts. the approch is > slightly diffrent but its the way msword, excel and may other windows > software is scriptable (ms uses vbscript but there are python bindings too > (win32com extension modules from active state)) Are there examples of COM-scriptable apps that also support recording? From gh_pythonlist at gmx.de Thu Nov 15 04:04:53 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 15 Nov 2001 10:04:53 +0100 Subject: Sending EOF (CTRL-D) to a subprocess In-Reply-To: References: Message-ID: <20011115090453.GA40681@lilith.hqd-internal> On Thu, Nov 15, 2001 at 08:55:12AM +0100, Holger Fuessler wrote: > > Hi all! > > Can anybody tell me how to send a C-D to a subprocess opened with > os.popen()? I think you mean os.popen2. Close the process' input stream, i. e. do a .close() on the first of the two file objects os.popen2() returns. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From horatio at qpsf.edu.au Mon Nov 26 18:55:42 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Tue, 27 Nov 2001 09:55:42 +1000 (EST) Subject: Scientific Libraries in Python In-Reply-To: <375ad208.0111261037.5a591853@posting.google.com> Message-ID: On 26 Nov 2001, Prabhu Ramachandran wrote: > > VTK (Martin et al) - 3D visualization on GTK - personal copyright > > Well, I guess that is a typo but FWIW I'd like to mention that VTK > does not depend on GTK and does not use it at all. Quite so, it is a typo. That's what I get for posting from a Microsoft machine late at night. (: > Thanks for the compliments on MayaVi. :) My thesis topic is in computer-mediated technical collaborations, specifically collaborative scientific visualization. My Sinister Ulterior Motive (TM) is that when I get around to implementing my ideas, I would like to do it in Python. The presence of so much good-quality scientific code gives me hope I can do that; if I can get at it in one place easily, I can concentrate on the computer science instead of reinventing the wheel. If not... there are fallback plans involving Java and Matlab, C and Octave, because I really am here to do research, not hack. It is my hope I won't have to use them. [snip] > That is why I chose the GPL. However, the GPL does force everyone > else who links to it to be GPL. I guess LGPL might also work but I > really don't know. Thanks for considering this idea. > Anyway, I am not sure you want to put all packages into one huge super > package. It would be a nightmare to package/distribute! I'd really > pity the person who'd have to maintain such a beast. Distutils are your friend. (: As for maintainers, one of the better ways of handling this is for everyone involved to pile on to scipy.org, each maintaining the code they brought to the party. The initial assimilation phase would indeed be painful, but once all the namespaces and package structures and the like were unified, the pain would subside. Where there are existing projects, such as MayaVi or Scigraphica, the core library would include them as opt-in parts - much like the current Numeric treats FFTW or LAPACK, and as Scientific treats Numeric. So long as the relevant maintainers are at least talking to each other (and the core library maintainers shoulder the responsibility of writing any impedance-matching code) it's all good. Cheers, Horatio From peter at engcorp.com Wed Nov 28 22:31:05 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 22:31:05 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> Message-ID: <3C05ABF9.971C4482@engcorp.com> Jeff Shannon wrote: > > With all this discussion of CVS, I have a question that I've not been able to > find a satisfactory answer to, myself. > > My current place of employment does not use any significant form of version > control. Due to the nature of most of our codebase, using CVS for it would > be unrealistic anyhow. Despite all of this, I would like to begin using CVS > for those projects that I can, even if I'm the only one using it. The > problem with this, is that I don't have access to a Unix/Linux server to > install CVS on (our one Unix server is host to our virtual-OS (non-SQL) > database, and I don't think I could convince anyone to install anything > unnecessary there ). What I'd really like, is a version (or clone) of > CVS that will allow me to use a local repository under Windows. Does any > such thing exist? (I'm very frustrated, trying to teach myself good software > engineering practices in a workplace that doesn't support that at all... ) There is a version of CVS for Windows, and there is WinCVS (GUI), either of which works nicely with a local repository under Windows. In fact, up until about nine months ago, we were using one of the shared network drives on the Windows network to store the repository, keeping our fingers crossed (and doing backups frequently) to prevent someone from just overwriting the files. It worked well. When the time came finally to set up the pserver on our Intranet box (Redhat 7.0) I just copied the directory tree over with scp and we've continued from there ever since. Check on google for the CVS site... By the way, what is it about the nature of your codebase which makes using CVS unrealistic? If it's source, you should be able to use CVS to control it. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From gry at ll.mit.edu Tue Nov 27 18:03:04 2001 From: gry at ll.mit.edu (george young) Date: Tue, 27 Nov 2001 18:03:04 -0500 Subject: GUI/data object oriented design question Message-ID: <20011127180304.6aa502e6.gry@ll.mit.edu> [python2.1, pygtk-0.6.6, gtk+-1.2.7, postgres-7.1, pygresql-3.2] This is a fairly basic object-oriented design question, I think, about the class structure of data objects and respective GUI elements. How do I subclass an entire heirarchy of objects? All the data is text, with three levels of hierarchy, and resides in a relational DB. In some contexts, data must be manipulated without any graphics. Note especially the kludge of "data_type", "step_type", etc: class Datum: ... class DatumWin(Datum): .... class Run: data_type = Datum step_type = Step def __init__(self, name): name,user = db.fetch_run_hdr(name) self.name = self.data_type(name) self.user= self.data_type(user) for s in db.fetch_run_steps(name): steps.append(step_type(*s)) class Step: data_type = Datum substep_type = SubStep def __init__(self, name, description): self.name = self.data_type(name) self.description = self.data_type(description) for ss in db.fetch_step_substeps(step_id): self.steps.append(self.substep_type(*ss)) class SubStep: data type = Datum param_type = Param def __init__(self, run_id, step_id, seq): self.run_id, self.step_id, self.seq = run_id, step_id, seq for p in db.fetch_substep_params(step_id): self.params.append(self.param_type(*p)) But in case I need a GUI representation of the run, I want to do: class RunWin(Run, gtk.ScrolledWindow): data_type = DatumWin step_type = StepWin def __init__(self, name): Run.__init__(self, name) self.name.set_label('Name') self.user.set_label('User') for n in range(len(self.steps)): self.steps[n].set_label(`n`) self.steps[n].name.connect('activated', act_cb) ... I think this may work, but the explicit manipulation of "data_type" etc. seems pretty kludgy. Is there some "pattern" that solves this? My first thought was for each GUI object to have a reference to it's respective data object, e.g. a StepWin has a Step reference. But then the Run has to maintain it's own parallel list of Steps, while the RunWin has it's list of StepWins. And the resulting references needed by callbacks get very ugly. I've been staring at this stuff far too long and would be very grateful for some suggestions. I hope I've explained the problem enough... George Young, Rm. L-204 g r y @ ll.mit.edu MIT Lincoln Laboratory 244 Wood St. Lexington, Massachusetts 02420-9108 (781) 981-2756 From phony_address at yahoo.com Fri Nov 30 16:28:47 2001 From: phony_address at yahoo.com (Phredd Phlintstone) Date: Fri, 30 Nov 2001 21:28:47 GMT Subject: PythonWin DDE Conversion error Message-ID: <3c07f946.27546641@news> New here. This is my first programming experience. I d/l PythonWin and when I open it from the Start > Programs etc. (Windows ME), I get a delay and then an error message, "There was an error in the DDE conversion with PythonWin." Then the program pops open. What's up with this? When the program opens, is it fully functional in every way? Is there a way to fix this? Is this the wrong place to post a message about PythonWin? Please post any responses to this to this newsgroup. From emile at fenx.com Sun Nov 11 03:06:38 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 11 Nov 2001 00:06:38 -0800 Subject: Splitting on a regex w/o consuming delimiter References: Message-ID: <9slc41$12ulak$1@ID-11957.news.dfncis.de> >>> ", @".join('one two @three @four five @six'.split('@')).split(',') ['one two ', ' @three ', ' @four five ', ' @six'] ;-) -- Emile van Sebille emile at fenx.com --------- "Lars Kellogg-Stedman" wrote in message news:slrn9usaaa.4ao.lars at flowers.house.larsshack.org... > >> Given a string such as: > >> > >> sample = 'one two @three @four five @six' > >> > >> I want to split it on the '@' character, but I want the '@' > >character to be > >> retained in each sequence. That is, I'd like the above string split > >into: > >> > >> one two > >> @three > >> @four five > >> @six > > > >You could do '@'.split(sample)' (which deletes at) and then add back > >to all but first. > > I knew I should have said it the first time: this is a contrived example; > what if the delimiter regex was something like '\s(!|@)\s'? Given: > > foo ! bar @ baz @ xyzzy ! mumble > > You'd end up with: > > [ 'foo', 'bar', 'baz', 'xyzzy', 'mumble' ] > > With no way of recovering the delimeter. > > Really, I just want to be able to split on (?=pattern), or some other > method of splitting a string without consuming the delimiter. > > -- Lars > > -- > Lars Kellogg-Stedman --> http://www.larsshack.org/ > From lucio at movilogic.com Thu Nov 22 12:38:12 2001 From: lucio at movilogic.com (Lucio Torre) Date: Thu, 22 Nov 2001 14:38:12 -0300 Subject: Non-Indented python References: Message-ID: <3BFD3804.3020502@movilogic.com> Delaney, Timothy wrote: >>From: Jeff Shannon [mailto:jeff at ccvcorp.com] >>Dave Cinege wrote: >> >>>Rule of God: >>>The punishment for non-tab based indentation is death. >>> >>This is exactly backwards. >> >>Tabs are wrong, because different editors will treat them differently. >> >>Spaces are right, because a space is a space is a space, >>everywhere you go. >> > >There are actually two things involved here. > >If you use tabs everywhere for indentation (i.e. tab *characters*, not tab >*stops*) you are guaranteed that you can cut and paste from any other source >code that uses tabs everywhere, even if it doesn't look right onscreen >(because they used a different tab size). > > On problem i had several times, is that while cut and pasting code from one source (ie, mozilla) to a editor (ie, komodo), indentation will be wrong. lines would be continued an there would be a real mess because to 'beautify' the source, youd have to understand the code. another problem the soft structure gave me is while trying to compile pippy on windows. not a pippy problem, but something it took us a lot of time to find out. i had unzipped the source with winzip (which uses \r\n) and tried to compile it with cygwin. of course, it couldnt do it, and i had to try everything until i used od and find out the not visible problem. nice for writting, easy for reading, but really really bad for moving it around. lucio. From tjreedy at home.com Thu Nov 8 11:04:38 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 08 Nov 2001 16:04:38 GMT Subject: Reading a comma delimited file References: Message-ID: "Kristen Zander" wrote in message news:DCxG7.2903$qK.166227 at typhoon.austin.rr.com... > Here's what it looks like when I'm done: > > [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1, > 20.0, 0.0, 167.30000000000001), > ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0, > 6.0999999999999996, 13.9, 0.0, 239.0)] > > Just what I need except I don't want all those decimal places. Look up 'format % values' formatting. Terry J. Reedy From maxx at easynews.com Thu Nov 1 14:20:31 2001 From: maxx at easynews.com (Max) Date: Thu, 01 Nov 2001 19:20:31 GMT Subject: Python.NET, MONO and Visual Studio etc. References: <3BDC5777.3873D22A@earthlink.net> Message-ID: On Wed, 31 Oct 2001 21:16:39 -0800, Paul Prescod wrote: >As .NET cranks up, customers may express interest in an equivalent for >Python. Would not the product be sucessful with an opposite strategy? If I understant the CLR concept in .NET correctly, then a component "compiled" to run under the CLR becomes "language invisible", i.e. the target cannot determine (and does not care) what the source language is, correct? This would eliminate all of the cases where developers have good, reliable code already written in Python, Perl, etc., but IT/management will not accept it because they refuse to implement the runtimes on the production servers. It would also allow developers to use the source language that makes them most efficient, and still be that way when it is required to deploy to a Win based platform. Thus, my point is that if a Python.NET is made available before the demand exists, then it can take advantage of forces already existing that do not have a current option. From lac at strakt.com Fri Nov 9 11:18:00 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 09 Nov 2001 17:18:00 +0100 Subject: Tkinter scrollbar question In-Reply-To: Your message of "Fri, 09 Nov 2001 17:08:45 +0100." <200111091608.fA9G8ju3009597@ratthing-b246.strakt.com> References: <200111091608.fA9G8ju3009597@ratthing-b246.strakt.com> Message-ID: <200111091618.fA9GI0ua009624@ratthing-b246.strakt.com> I forgot an important part. You get this error when you click on the arrow part of the scrollbar. It displays just fine -- it just doesn't work any more. Sorry to mail an incomplete discription of the problem, Laura Creighton From simuran at shaw.ca Mon Nov 26 09:49:00 2001 From: simuran at shaw.ca (Alex Rodioukov) Date: Mon, 26 Nov 2001 14:49:00 GMT Subject: Zope database vs. MySQL References: Message-ID: <87lmgta8pv.fsf@bismark.io.sys> "Mich Hiker" writes: > I'm a new Zope user - developing web-based curriculum materials for a school > district. Can anyone tell me the advantages of configuring MySQL to use in > tandem with Zope over using Zope's built-in database? I've heard Zope is > faster using it's own DB, but others have told me it is limited and I should > go with MySQL. Any thoughts? > > Thanks. Mich, ZODB and MySQL are different things. ZODB is an object database which Zope uses to store all of its objects. MySQL on the other hand is a relational database. Those are very different beasts. To make a long story short both should be used for appropriate tasks. RDBMS like MySQL comes very handy when you need to store/retrieve large amounts of data that can be normalized so you can benefit from using relational model (indexes/views/joins). I'm assuming that in your case we are talking about significant amount of content (curriculum) which is not going to be changed very often and can be fit into relational model easily. Then it might be more efficient to use RDBMS to store it because RDBMS will normally outperform ZODB on operations with such data. You can't say that ZODB is limited compared to MySQL. Once again, those are very different things. There are tasks for which MySQL (or any RDBMS for that matter) would be totally unusable. On the other hand, there are situations when one would prefer to use RDBMS for storage because of the performance it might provide in given circumstances. You might want to check http://www.amk.ca/zodb/guide/ (ZODB/ZEO Programming Guide) for more detailed information regarding the subject. A.R. -- Complex problems have simple, easy to understand wrong answers. From darnold02 at sprynet.com Sun Nov 25 20:49:22 2001 From: darnold02 at sprynet.com (Don Arnold) Date: Mon, 26 Nov 2001 01:49:22 GMT Subject: A newbie that needs some HELP References: Message-ID: <9ts712$1be$1@slb2.atl.mindspring.net> On 25-Nov-2001, "The News" wrote: > Now on to the problem. > I'm working on lists. Trying to figure them out. So I decide to write > this > little algorithim for user inserted lists. My proto goes as follows: > > monty = [] > number = input("How many Monty's are there?") > for x in range(1,number): > mln = input("Name a Monty?") > monty.append(aln) > print monty > > It gets through it but prints out some wierd stuff along with each listed > monty. Can someone tell me what I'm doing wrong? Also, when I try to get > it to repeat x at the end of "Name a Monty #", x it gives me an error. > How > could I get around that? > Use 'raw_input()' instead of 'input()'. Don From mjais at web.de Thu Nov 22 06:52:34 2001 From: mjais at web.de (Markus Jais) Date: Thu, 22 Nov 2001 12:52:34 +0100 Subject: question on __dict__ Message-ID: hello can somebody tell me, what the difference is between self.__dict__('foo') = 'bar' and self.foo = 'bar' or is there no difference? thanks markus From emile at fenx.com Fri Nov 9 15:13:11 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 9 Nov 2001 12:13:11 -0800 Subject: Strange __str__ behavior References: Message-ID: <9shev1$136lad$1@ID-11957.news.dfncis.de> --------- wrote in message news:baf2f841.0111091141.7a104b10 at posting.google.com... > I am defining a class w/ method __str__. If I put a print statement > inside __str__, and if I then use the print statement to display an > instance of the class, I get an extra space in the output. > > > > Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> class Test: > ... def __str__(self): > ... print "In method Test.__str__" > ... return "String representation of instance." > ... > >>> test = Test() > >>> print test # causes extra space problem > In method Test.__str__ > String representation of instance. > > > I don't get the same thing on win2k F:\Python22>python ActivePython 2.2 Alpha 2 build 1 (ActiveState) Python 2.2a2+ (#22, Sep 5 2001, 14:10:41) [MSC 32 bit (Intel)] on win32 >>> class Test: ... def __str__(self): ... print "in __str__" ... return "str(self)" ... >>> test = Test() >>> print test in __str__ str(self) >>> I do have other flakey additional/missing line space problems when not directly running from the dos command prompt, more with win2k it seems that with win9x. But I don't know where the problem is. ;-) ps. ms outlook express spell-check wants to correct win2k to ;-)) -- Emile van Sebille emile at fenx.com From phd at phd.pp.ru Wed Nov 28 10:36:27 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 18:36:27 +0300 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) In-Reply-To: ; from sholden@holdenweb.com on Wed, Nov 28, 2001 at 10:23:18AM -0500 References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: <20011128183627.C8311@phd.pp.ru> On Wed, Nov 28, 2001 at 10:23:18AM -0500, Steve Holden wrote: > > There are other merits, not only money. Corporations want power even > > more than money. Down with non-free software. > > :-) > > But seriously, the only advantage of more power is its ability to generate Exactly opposite - the advatage of power is power, and the only advantage of money is... you've guessed it - power. > greater revenues. Any other ultimate goal would be un-American. Ah, those un-American goals... Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From shalehperry at home.com Fri Nov 30 02:18:49 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Thu, 29 Nov 2001 23:18:49 -0800 (PST) Subject: Tools for the job In-Reply-To: <0rFN7.23570$8n4.1770642@e3500-atl1.usenetserver.com> Message-ID: On 30-Nov-2001 Jeremy Lowery wrote: > I'm looking for an easy way to disconnect a class instance that contains biz > logic from the presentation of that object (in this case, HTML), maybe some > kind of delegation is needed. Could someone point me to a module that has a > simple cure? > > As I'm sure a lot of other designers feel, I don't like plugging HTML code > into strings inside my business object's defintions. Maybe a template > mechanism or something? > Of course, there are a lot of the usual ways to do this, I was just > wondering if Python had some snazzy builtin or known module that did this > kind of stuff. > Look at how the htmllib handles output. From db3l at fitlinxx.com Thu Nov 1 19:02:00 2001 From: db3l at fitlinxx.com (David Bolen) Date: 01 Nov 2001 19:02:00 -0500 Subject: Python.NET, MONO and Visual Studio etc. References: <3BDC5777.3873D22A@earthlink.net> Message-ID: Max writes: > Thus, my point is that if a Python.NET is made available before the > demand exists, then it can take advantage of forces already existing > that do not have a current option. Except that my interpretation is that creating a complete (e.g. not the basic pilot/prototype that ActiveState) production Python.NET that - and this is the key - performed well is not trivial. I'm sure it can be done, but it's going to take some real work and resource, which for an average commercial company would likely have a pre-requisite of demand. Reading the white paper on the ActiveState site for Python.NET is interesting, and shows how the CLR and VM for .NET, while powerful, is not necessarily a good fit for dynamic scripting languages. There's no equivalent paper for Perl.NET but I expect that many of the issues were the same. -- -- 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 dcinege at psychosis.com Fri Nov 23 22:32:44 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Fri, 23 Nov 2001 22:32:44 -0500 Subject: Non-Indented python In-Reply-To: References: Message-ID: On Friday 23 November 2001 3:47, you wrote: > "Dave Cinege" wrote in message > news:mailman.1006474590.24778.python-list at python.org... > > > On Thursday 22 November 2001 12:38, you wrote: > > > time to find out. i had unzipped the source with winzip (which uses > > > \r\n) and tried to compile it with cygwin. of course, it couldnt do it, > > > > Commandment #2 > > Thou shalt terminate thy line with but one byte. Let he who hath > > understanding recognize the number of the byte, 0xA0. Death to thee who > > terminates thine with any other byte! > > > > You use a defective OS built with defective editors. REPENT! > > > > Dave > > It sounds like somebody is overdue for a visit from the cult deprogrammers. How do you expect me to win a religious war without religion? > Geeze, lighten up. Oh, and it's 0x0a, not 0xa0. Totally different > characters. DOH! Sorry, a mistype in my translation from Aramaic... -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From dale at riverhall.NOTHANKS.co.uk Fri Nov 23 08:39:32 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Fri, 23 Nov 2001 13:39:32 +0000 Subject: What's this: run_pyc_file: nested_scopes: 0? Message-ID: <99ksvtsp9uipajsfkqehgbi9hc0f8el4mq@4ax.com> This message has started to appear at the end of each use of a system we're developing: run_pyc_file: nested_scopes: 0 It's not one of our messages and my hunch is that it coincides with us using compileall to ensure the main module is compiled. Any ideas what it is and how I can get rid of it? Python 2.1 Cheers. -- Dale Strickland-Clark Riverhall Systems Ltd From phr-n2001d at nightsong.com Mon Nov 5 12:46:06 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 09:46:06 -0800 Subject: Process intercommunication References: Message-ID: <7x8zdlun4x.fsf@ruckus.brouhaha.com> Mikael Olofsson writes: > I feel that I am in quick sand here. I haven't got the slightest idea > how to do this. Any help is welcome. The simplest way is probably with the SocketServer module. A is a server that listens on a unix domain socket. B is a client that connects to the socket and sends the data to A. If you use the ThreadingMixin or ForkingMixin features, A can talk to multiple B's simultaneously. From mlh at idi.ntnu.no Mon Nov 5 09:07:31 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 5 Nov 2001 15:07:31 +0100 Subject: Sequenced dictionaries References: Message-ID: <9s66f4$npj$1@tyfon.itea.ntnu.no> "Morten W. Petersen" wrote in message news:Pine.LNX.4.21.0111051436400.21948-100000 at bcryachts.atsat.com... > Hi, > > I'm wondering if there exists any C-based implementations of sequenced > dictionaries, i.e. dictionaries that will remember the order of the > objects 'added' on it. > > I have a pure python implementation [1] but suspect that it will be > too slow.. Alternatively, if anyone could have a look at it and give > some optimization tips, that would be greatly appreciated. Just a thought... You might want to consider using a tree structure. There you get ordering _and_ logarithmic lookup. I think there are several implementations out there, both in Python and as C extension modules. > [1] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/warp-framework/war p_framework/zen.py?rev=1.14&content-type=text/plain > > -Morten -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From jjl at pobox.com Sat Nov 3 15:46:08 2001 From: jjl at pobox.com (John J. Lee) Date: Sat, 3 Nov 2001 20:46:08 +0000 Subject: dictionaries and 'in' in 2.1 Message-ID: The Python 2.1.1 manual, section 2.1.6, says: k in a 1 if a has a key k, else 0 k not in a 0 if a has a key k, else 1 But when I attempt to use this feature, I get: Python 2.1.1 (#1, Oct 23 2001, 15:59:13) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> d = {1:2} >>> 1 in d Traceback (most recent call last): File "", line 1, in ? TypeError: 'in' or 'not in' needs sequence right argument >>> I must be doing something stupid, but I don't see what. Thanks for any help. John From pete at shinners.org Wed Nov 21 09:43:02 2001 From: pete at shinners.org (Pete Shinners) Date: Wed, 21 Nov 2001 14:43:02 GMT Subject: Pil-Libary---write text into an image file References: <3fea95b3.0111210555.5f2ee93@posting.google.com> Message-ID: <3BFBBE4D.6020509@shinners.org> stephan wrote: > Hi there, is it possible to open a image file, write text inside and save it > in an image file iI can display in common Browsers. > Do I have to use the PIL-Libary? > Please help, we are desperate... > And Tommy is suffering... well, it may be a bit overkill if you are just doing images on fonts, but you could use the pygame library to this effect (and save poor tommy). it can only save BMP files, if that is a concern? http:/www.pygame.org see attachment for the code to do it. (90% of the code is reading the commandline args, the other 4 lines to the work) :] -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: rendertext.py URL: From gustafl at algonet.se Mon Nov 12 06:37:03 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: Mon, 12 Nov 2001 12:37:03 +0100 Subject: Post HTML checkboxes? Message-ID: <9soc2i$ch$1@green.tninet.se> For some reason, my the values of my (X)HTML checkboxes won't show up in the CGI dictionary of name + values. I have a form with these two checkboxes: This form is connected to a script that looks like: #!/usr/usr/bin/python2.0 import cgi form = cgi.FieldStorage() print form.keys() When I run this I get an empty list. Getting values from textboxes is no problem. -- Gustaf From vvainio at karhu.tp.spt.fi Tue Nov 27 03:27:05 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 27 Nov 2001 10:27:05 +0200 Subject: Two questions about Python.. References: <3BF99E55.2C300858@hotmail.com> Message-ID: Ken writes: > I'm looking into using Python for a project, and was wondering how does > Python rank up against other scripting languages for speed? The fact that you consider using a scripting language in the first place implies that Python will be fast enough. -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From dalke at dalkescientific.com Tue Nov 13 13:43:13 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 11:43:13 -0700 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> <9sp073$k6d$1@news.lth.se> <9sq30e$4hp$1@slb1.atl.mindspring.net> <9sr8np$771$1@news.lth.se> Message-ID: <9srph4$9rt$1@slb1.atl.mindspring.net> Me: >> When I started programming I didn't know how the hardware worked. >> Nearly 20 years later, I still don't know. David Andreas Alderud: >when I was teaching the 4:th graders they constantly asked me on >how computers worked, so I showed the everything from the ALU of >the CPU up to operatingsystem interrupts I don't think I ever asked those sorts of questions. I was more interested in getting computers to do math (gcd, lcm, primes, unbounded ints, graphs, morphing, rotation matricies, physics simulations). Hmmm, and you also said (picking nits :) > my view is that the students should teach them selves, So your students weren't teaching themselves about hardware? >I imagine it's hard to go from Python to any other language because it's >easy to become lazy, even I've become lazy. The word 'lazy' has negative connotations in America's traditional Puritan outlook, although the Perl community spins it as a positive characterisitic for programmers. Since I don't know what you mean, I'm not able to comment further. >> I still use dictionaries, heavily. For commentary, see >> >> http://aspn.activestate.com/ASPN/Mail/Message/python-Tutor/538598 > >Ordinary hashtables are bad in worst case, i.e. no better than simple lists, Oh, I understand. I've just never had it hit me in reality. Did you read the URL? Tim says, amoung other things: ] ABC ran very slowly, mostly because the overhead of balanced tree ] operations swamps all other considerations until the trees grow ] quite large. I've never hit the worst case in Python's dictionaries. I've also never seen a post in c.l.py where someone has hit a real life case of getting the worst case. (I do recall some theoretical ways to hit it.) >I normally design datastructures for a specific problem, though in all >fairness I once used Python to implement a DMBS when I first learned Python. I normally design data structures to be easy to understand, and only if there are problems do I switch to something more precisely designed. Because of Python's genericity, it's nearly always done with a trivial change to use the new constructor. >> Eg, I >> recall wondering why I couldn't stick things into an array at position >> arr(1.2) -- why was that the same as arr(1)? > >That's why BNF is so nice :) Pardon? BNF is Backus-Naur Form, right? How does that help? expression ::= variable '(' number ')' variable ::= re(r"[_a-zA-Z]+") number ::= re(r"[0-9]+(\.[0-9]*)?") There's nothing in there about implicit conversion of the numeric value to integer when doing arr(1.2). >> Ada, as I recall, doesn't have that flexibility. So I figure it >> would have been that much harder for me to figure things out. > >True, but there are nice packages for Ada which solve this with OO. Which makes it still harder for a beginning, self-taught programmer. >The Python tutorial is nice, but I don't think it's fair to compare them as >they are intended for different audiences. Are you talking about the tutorial vs. the primer Ada book I have (in which case both are aimed at people like me)? Or about the two langauges? What do you see as their audiences? Eg, I see very little overlap between the audience I work with (research scientists who need a tool for exploring their research problem) and Ada's solution domain. >> I would have needed a better editor than >> Python's current text version. BASIC with line numbers >> makes it possible to edit a single line of code. > >I believe Python is a better choice than BASIC, though VB and BB are pretty >good for being BASIC. Not my point, which is that Python's text version (non-IDE) is worse for developing code than BASIC's text version. If I make a mistake in Python when entering a function then I need to retype (or up-arrow using readline) a lot. In BASIC I could just edit the line number. And BASIC offered auto line numbering, which means original entry was effectively the same as Python's. >> Not sure about the current IDEs either. I heard one talk where >> the presenter chose Tcl (withone of the object extensions) over >> Python because it was easier for her coworkers to change a single >> method interactively, rather than having to reload the whole >> module, with all the trickiness that entails. > >There is no absolute truth about what language to choose; I'd pick Ada, you >pick BASIC, and someone else would pick Logo. Technically, I *picked* BASIC because that was all that came with personal computers in the early 80s. I would pick Python now, but only with an IDE, and I would be concerned because with modules it's hard to tell if you've properly reloaded them after edits. (That issue comes up pretty regularly in c.l.py.) > The important thing is to get the student to code, without ever writing > code it doesn't matter what language one uses. Oh, I agree. But didn't Dijkstra argue that students shouldn't be taught to program until graduate school? 'Course, he's also the one who said "Object-oriented programming is an exceptionally bad idea which could only have originated in California." "It is practically imposible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration." so what does he know? (BTW, these quotes brought to you by the letters 'P' and 'V' ;) Andrew dalke at dalkescientific.com From radix at twistedmatrix.com Sun Nov 11 19:32:33 2001 From: radix at twistedmatrix.com (radix) Date: Sun, 11 Nov 2001 19:32:33 -0500 Subject: doc generator References: <9sku4g$egh$1@peabody.colorado.edu> <9skvfn$fg9$1@peabody.colorado.edu> Message-ID: On Fri, 09 Nov 2001 17:11:24 -0500, Fernando P?rez wrote: >> You'll have to pardon _my_ ignorance, because the only thing that I >> know about Teud is "It looks better than HappyDoc". :) I'm generally >> not interested in documentation generators, and haven't touched PyDoc >> -- I just know the authors, and throught it'd be nice of me to plug >> their project > > Well, I'll fill you in a bit (if you're running Python 2.1 you already > have it). Pydoc is a full blown help/documentation system that now comes > with python. [snip..] Ok, it turns out that Teud does indeed use pydoc as it's backend. I don't know any more than this; I asked Itamar about it and that's all he told me, and he said he didn't have enough time to follow up to the thread. -- I am *not* a PSU agent. -- Chris Armstrong <<< radix at twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/ From logiplexsoftware at earthlink.net Tue Nov 13 12:04:56 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 13 Nov 2001 09:04:56 -0800 Subject: Teaching python (programming) to children In-Reply-To: <200111130925.fAD9PPua015737@ratthing-b246.strakt.com> References: <200111111136.fABBaBua012072@ratthing-b246.strakt.com> <01111212560602.01611@logiplex1.logiplex.net> <200111130925.fAD9PPua015737@ratthing-b246.strakt.com> Message-ID: <01111309045601.02982@logiplex1.logiplex.net> On Tuesday 13 November 2001 01:25, you wrote: > Unless I am misunderstanding this terribly, Cliff Wells, whose > educational experiences were so dreadful that he nearly dropped out > of school and had to be rescued by a heroic mathematician teacher, > wants to base social policy on granting teachers enough personal > freedom that they can circumvent the evil policies crafted by > powerful academic elites that are both so incompetant that they > mandate evil or foolishness, and so corrupt or stupid that they will not > change when you point this out to them. I think that this is what > I just heard. Well, that would be horribly oversimplifying it, but yes. One of the big differences between my high school experience and my college experience is that the college instructors /had/ the freedom to design a curriculum, and more importantly, some of them were even experts in their field. Contrast this with high school where the teachers followed a preset curriculum and most likely all had degrees in education rather than the subject they were teaching (and where the classes were so geared to the LCD that I never did homework and barely listened and still got A's on my tests - hm, why would that be boring?). This is the system you appear to be advocating (correct me if I'm wrong - I can handle it ;-). Of course you will respond with shock and horror, but it's a rare case when a committee delegating anything achieves anything more than utter mediocrity. I'm curious why you chose to respond to that particular part of my post and disregarded the rest, which IMHO, has more relevance to the discussion at hand. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From neal at metaslash.com Sun Nov 11 22:14:35 2001 From: neal at metaslash.com (Neal Norwitz) Date: Sun, 11 Nov 2001 22:14:35 -0500 Subject: distutils for apps? References: Message-ID: <3BEF3E9B.8086D4F4@metaslash.com> Andrei Kulakov wrote: > > Hello pygang, I just read distutils docs and I can't figure out how to > tell it to install one file into path. I have a bunch of .py files, one > of them is meant to be executed by the user, and the rest are modules. > Do I copy it to /usr/local/bin myself? It just seemed logical that > distutils would do that. distutils.core.setup(name='name', #... packages=[ 'pkg1', 'pkg2', 'pkg3', ], scripts=[ 'script1', 'script2', ], #... ) pkg1, pkg2, pkg3 will be copied into the python site-packages directory. For example, /usr/local/lib/python2.1/site-packages/pkg?. pkg? are directories which contain .py files. script1 and script2 will be copied into the local script directory (usually /usr/local/bin). These can be shell scripts. Here's one that I use: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/pychecker/pychecker/setup.py?rev=1.29&content-type=text/plain Neal From m.faassen at vet.uu.nl Thu Nov 1 19:37:23 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 2 Nov 2001 00:37:23 GMT Subject: Freeware Python editor References: <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> <3BE11391.BF044772@alcyone.com> <3BE18A02.76FE1AB@alcyone.com> Message-ID: <9rsps3$9iq$1@newshost.accu.uu.nl> Oleg Broytmann wrote: > On Thu, Nov 01, 2001 at 09:44:34AM -0800, Erik Max Francis wrote: >> > > Oh, please. You don't have the "freedom" to dictate to other people >> > > what license to put on software that _they_ write. >> > >> > When and where was I dictating this? >> >> You're talking about people "restricting your freedoms," presumably by >> providing closed source licenses. What else did you mean? > I m saying this third or fourth time - it was not a complain, just a > clarification: the editor is "freeware", but not "free". I do not force > anyone to change license, or do something. I just want to warn people, not > force them. FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS [Warning: do NOT circulate the dispatch outside the Python Secret Underground. Offenders will be removed from the spacetime continuum] Various PSU members have been confused by the fact that the PSU has allowed GNU flamewars to rage on comp.lang.python recently. There have even been some misguided attempts by PSU members to curb such flamewars into an amusing discussion. The PSU in the past has even encouraged such attempts. However, PSU policy has recently been changed after an exploratory mission into the future using Guido's time machine. The PSU has recently decided to map the future after the the alien whitespace eating nanovirus event in the early 21st century, and we have made a truly shocking discovery. GNU flamewars, far from being useless and disruptive and generally off-topic, will in fact eventually be instrumental in the survival of human kind, nay, we have good reasons to believe they will be directly responsible for the prevention of the final heat death of the universe! The exact explanation of why this is so is rather involved and we are unable to go into further details without risking a cascade paradox tension reduction, which would have disastrous consequences for our galaxy. But, given this new knowledge, the PSU immediately orders all its operatives to let them rage on or even encourage them freely. We should all happily suffer the inconvenience of these flamewars if they can lengthen the age of the universe, after all! We will end this dispatch with some tips on how to encourage further GNU flamewars: * when someone uses the word 'free' in any context, immediately respond with something positive or negative about 'free software'. * when someone mentions 'open source', always correct them and point out that 'free software' is entirely different and the true moral approach, and vice versa. * Post claims that the Python 2.0.1 license is not compatible with the GPL after all. * Post that Richard Stallman is a crazy communist idiot. Argue with anyone who dares to disagree. * Post that Eric Raymond is a crazy gun nut idiot. Argue with anyone who dares to disagree. * Whenever someone says Linux, insist they say GNU/Linux. * Fork off GNU/Python as the Only True Free Python and put it under the GPL. Insist everybody in the newsgroup call Python GNU/Python afterward. * If Python developers leave your company or institute, insist that they change their previously free and open license into something not compatible with the GPL. Preferably make it entirely proprietary. Bring in a lot of lawyers. Put in references to the commonwealth of Virginia in your license. * whenever a message is posted about software under some non-free or non-open source license, be sure to post clear warnings so that other people can gratefully take notice they were about to walk into the evil trap of proprietary software, and thank you. If ungrateful people complain, argue with them. * always argue with people talking about free software or open source in any context. It's very important to reply to their replies as well. * never allow oneself to be distracted by other posters who try to make the discussion veer off into other directions, away from the central flamewar. * Remember, only you are the defender of the Truth, and you have a solid chance of convincing others of that they are wrong. It is your moral responsibility to do so. If you keep these tips in mind and apply them generously, the PSU feels humanity -- and the universe itself -- is in excellent hands. From erno-news at erno.iki.fi Mon Nov 12 22:59:16 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 13 Nov 2001 05:59:16 +0200 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> <7x8zddnroj.fsf@ruckus.brouhaha.com> Message-ID: In article <7x8zddnroj.fsf at ruckus.brouhaha.com>, Paul Rubin writes: | In fact it does the opposite--both the documentation and the pickle | implementation (look at the "security" check for pickled strings) | appear written with the idea that unickling is intended to be safe for | untrusted strings. i can't see that idea in the documentation even if i try. i don't know what the "security" check in the source code is about, perhaps the pickle author was planning to make it safe for untrusted data at some point. the fact that pickle shouldn't be fed untrusted data has been common knowledge in the python user and developer communities as long as i can remember. | If you look at docs for the Cookie module, you see | that it originally used pickle in precisely this dangerous way. If | that got past the maintainers who allowed the Cookie module to be | shipped with the Python library, what chance do most ordinary users | have? iirc the cookie module had this erroneous code before it was accepted into the library. when it was put in the library, warnings were put in its documentation to warn against anyone ever using the functionality. | Re marhsal: is it dangerous to unmarshal an untrusted string? Yes, I | know that marshalled strings can contain code objects, but | unmarshalling the strings doesn't actually RUN such code objects, as | far as I know. I haven't examined marshal super-carefully though. hmm, you may be right. -- erno From max at alcyone.com Wed Nov 21 14:41:25 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 21 Nov 2001 11:41:25 -0800 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> Message-ID: <3BFC0365.21FB6AA1@alcyone.com> "J.Jacob" wrote: > Does anyone have code that produces correct but random Python code ? > This would be useful for a genetic programming (GP) test we want to > do. Python is not a very good choice for genetic programming. Its syntax is too complicated, especially if we take into account that it is indentation sensitive. This is why languages such as LISP are used for genetic programming; their syntax is simple and it's easy to verify if a program is legal or not and to keep it legal while performing genetic operations (mutation, crossover, etc.). I myself in the past have used stack-based languages which are promising since even the constraint on program legality is dropped, provided you make certain concessions such as allowing a bottomless operand stack, having the key variables of the simulation available by means of special operators, etc. With a suitable choice for environment, every sequence of legal operators is itself a legal program. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From duncan at NOSPAMrcp.co.uk Fri Nov 9 04:42:39 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 9 Nov 2001 09:42:39 +0000 (UTC) Subject: What does *x mean? References: Message-ID: gat at jpl.nasa.gov (Erann Gat) wrote in news:gat-0811011133410001 at jansma- mac.jpl.nasa.gov: > I've heard people mention "the new *x syntax". Does Python have a prefix > * operator now? What does it do? (It's not mentioned in the online > language reference at python.org.) Email replies preferred. Thanks! > There seems to be a hole in the documentation. The language reference 5.3.4 has the syntax for function calls and does not cover the *x and **y syntax. It is mentioned in the documentation for apply (library reference 2.1), but not really explained. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From peter at engcorp.com Mon Nov 26 19:00:34 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 26 Nov 2001 19:00:34 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> Message-ID: <3C02D7A2.A7D6EC6E@engcorp.com> phil hunt wrote: > On Sun, 25 Nov 2001 23:42:20 GMT, Hans Nowak wrote: > >Then there's a second point: I see that many projects use version > >control (usually CVS). [...] Does it have > >substantial benefits over versioning your files by hand, aside from > >having a repository through which you can undo changes? > > Depends. If only one person is working on the project, CVS is overkill. > > If lots of people are working on it, it's a good idea. My opinion: a good idea if only one person is working on it. Mandatory if more than one work on it. When I was a wee little hacker, I knew nothing about version control and kept everything "carefully" arranged in different folders. When I wanted to test a new idea, I would make a copy of the contents of the folder. When I wanted to make a new version, I would zip up (actually, zoo) the files and use a name based on the date. Sounds simple, but as time went by I ended up with literally dozens of folders, subfolders, zoo'd and zip'd files (and some .arc, .jar, and probably others), scattered all over the place. No hope ever of recovering from this situation. Now I use cvs (via WinCVS), even for little two-file programs I just whip up. The initial investment makes it appear overkill, but after that it pays you back with every use. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tim.hochberg at ieee.org Tue Nov 13 23:28:09 2001 From: tim.hochberg at ieee.org (Tim Hochberg) Date: Wed, 14 Nov 2001 04:28:09 GMT Subject: PEP 276 Simple Iterator for ints References: Message-ID: "William Tanksley" wrote : > James_Althoff at i2.com wrote: [SNIP] > > - It would be better to reuse the ellipsis literal syntax (...) > > Response: Shares disadvantages of other proposals that require > > changes to the syntax. Needs more design to determine how it > > would handle the general case of start,stop,step, > > open/closed/half-closed intervals, etc. Needs a PEP. > > The last sentance is the only one that matters here. However, I'm > curious: what do you mean "reuse"? I've never seen an "ellipsis literal" > in Python. Reading through the Python documentation, I see an ellipsis > notation for extended slicing, but I'm in the dark as to what it means. > (I can guess, but I'd rather see it in print.) I've never seen it in > Python code, and the documentation doesn't seem to mention it. As far as I know the ellipsis syntax is only currently used in NumPy. It's a builtin, though -- you can see it just by typing Ellipsis at the prompt. You could use it today if you wanted: someObject[a, b, ..., c] gets translated to: someObject.__getitem__((a, b, Ellipsis, c)) So you can use it in your own class if you want. In particular, one could make int[1,3,...,53] act like range(1,53,2) if one wanted. -tim From stagnoNoSpamThank at dei.unipd.it Tue Nov 20 15:25:57 2001 From: stagnoNoSpamThank at dei.unipd.it (stagnoNoSpamThank at dei.unipd.it) Date: Tue, 20 Nov 2001 20:25:57 GMT Subject: MySQLdb undefined symbol References: <62e69c0c.0111180314.37cc1486@posting.google.com> Message-ID: >Red Hat 6.2, python 2.1.1, MySQLdb 0.9.1 >Any ideas? I had some problems with python 2.1.* (under Debian) Can you try under pyhon2.0.* ? good luck ;) ciao ciao! MAS! From johnroth at ameritech.net Thu Nov 15 11:55:14 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 15 Nov 2001 08:55:14 -0800 Subject: How to marshal a function? References: <01111412544105.04702@logiplex1.logiplex.net><0111141538420B.04702@logiplex1.logiplex.net> Message-ID: Uh, this isn't a mailing list. It's a newsgroup. I fail to see what 'procmail', 'mailer agent' and other such things have to do with it. John Roth "Fran?ois Pinard" wrote in message news:mailman.1005789703.29953.python-list at python.org... > [Cliff Wells] > > > BTW, are you aware that you are double-posting? > > Oh, I merely reply to all like I usually do, as there is no `Reply-To:' > to invite my mailer agent (Gnus) to do otherwise. So you receive two > copies, one as the author of the original, the other as a list member. > > Both messages you received from me should be identical even up to the > Message-ID, and many user agents automatically hide duplicates nowadays, > or at least, have provisions for doing so. Otherwise, a simple `procmail' > filter should easily take care of recent duplicates -- I can dig it for > you in the documentation if you do not quickly find it. > > -- > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > > From emile at fenx.com Tue Nov 6 20:54:31 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Nov 2001 17:54:31 -0800 Subject: Yahoo Groups archive of python-list wiped - what happened? References: <3BE878FA.103DA334@letterror.com> Message-ID: <9sa4hk$11vhaf$1@ID-11957.news.dfncis.de> "Fredrik Lundh" wrote in message news:nJ%F7.4684$R43.746961 at newsb.telia.net... > Just van Rossum wrote: > > I hope it's a temporary glitch, and not that they've simply > > wiped their archives... > > note that the first post in their new archive is timestamped > "Nov 5, 2001 7:29 pm". > > before and after Orlijn? > OK... what's that? The closest hit I get is spoorlijn. Has somebody pulled a fast one? -- Emile van Sebille emile at fenx.com --------- From kfarmer at thuban.org Fri Nov 23 15:40:25 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Fri, 23 Nov 2001 20:40:25 GMT Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> Message-ID: "Power-Tech" wrote in message news:3BFEADBB.68E786C2 at verizon.net... > file, when I double click to open the file, a DOS window opens but > closes immediately, without running the program, or if it is a Actually, I suspect it's running the program, and that it's experiencing errors? Have you successfully run this program? Try openning your own DOS window, and executing the program from there ('python C:\path\file.py'-- that way the window won't automatically close. This will give you a chance to read any feedback it's giving you. > calculating program, as soon as I type something, the window closes. Try the same thing. I've never seen that happen. ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From grey at despair.dmiyu.org Fri Nov 30 16:28:24 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 30 Nov 2001 21:28:24 -0000 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: On Fri, 30 Nov 2001 11:54:42 GMT, Bernie wrote: > Erann, I think you find the indentation annoying because you choose 2 spaces > as your tab size, hence making the block not as apparent as it could > be. Try four spaces, or use Tools/Scripts/pindent.py if you really cannot > stand it. In fact I was a strict 2-spaces for indention person until Python. I find 4 more readable for Python while still using 2 for C and Perl. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From uwe at rocksport.de Tue Nov 20 07:19:35 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 20 Nov 2001 12:19:35 GMT Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> Message-ID: <9tdhon$aht52$1@hades.rz.uni-sb.de> Huaiyu Zhu wrote: | On 19 Nov 2001 15:31:13 GMT, Uwe Schmitt wrote: |>I uses MatPy today and think it' quite useful. But there is one |>incompatibility to matlab: in MatPy indices start at zero, in |>Matlab they start at one. Is there a solution to adapt MatPy to |>the Matlab style ? | Although it is possible with some hacking, I don't think you would want to | do that, because in Python all sequences are indexed this way, including | NumPy arrays. If that's changed there would be a lot of confusion when you | transform between plain Python and numerical objects. | Besides, there are many good reasons to start indexing from zero. The open | source Matlab-compatible language Octave allows both indexing from zero and | one. It defaults to start from zero, but if you choose an option (called | "braindead" or something like that) it can start with one. Braindead is not | an easy option here. :-) I'd prefer indexing from one, because it's the notion used in mathematics, most existing algorithms are formulated this way. Greetings, Uwe. -- Dr. rer. nat. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From qrczak at knm.org.pl Fri Nov 16 16:03:47 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 16 Nov 2001 21:03:47 +0000 (UTC) Subject: PEP 276 Simple Iterator for ints References: Message-ID: Wed, 14 Nov 2001 11:40:39 -0800, James_Althoff at i2.com pisze: > A couple of points: it appears that the Haskell syntax mentioned > above assumes a closed interval. Indeed. And it has little choice given that it applies not only to numbers; ['A'..'Z'] looks better than ['A'..succ 'Z'] and we would have a bigger trouble when instead of 'Z' we wanted the last value of the given type - there is no successor to give as the endpoint. Haskell rarely uses indices anyway, because lists are much more common than arrays (what Python calls lists is generally called arrays; Haskell's list are more like Lisp lists). Lists are better processed by functions like map and zip or by recursion than by indexing. s[i] is expensive, s[1:] is cheap - it's opposite in Python. That's why it's not a big problem in the context of Haskell that you need to subtract 1 from the length to get the endpoint in the range of indices. But Python uses indices a lot, and it already uses half-open intervals for ranges. It would be very confusing if some interfaces used half-open interfals and other used closed ones. To be self-consistent, Python needs to continue to use half-open intervals. IMHO this excludes the syntax looking like [i..j] because it suggests that j belongs to the end. Half-open intervals are indeed more convenient for working with indices - the only problem is that they don't have an obvious syntax. IMHO we should either do nothing, or make iterators for ints as a shortcut - leaving range and xrange for more general cases, or maybe arrange that range(len(sequence)) can be spelled range(sequence). > Also, it appears that this syntax creates an actual list, not > an iterator. Haskell's list are lazy (as all data structures), there is no difference - they act similarly to iterators. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From usenet at thinkspot.net Fri Nov 16 01:34:20 2001 From: usenet at thinkspot.net (Sheila King) Date: Fri, 16 Nov 2001 06:34:20 GMT Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <7xg07fwn6l.fsf@ruckus.brouhaha.com> <3BF49DE9.95DC02FA@earthlink.net> Message-ID: <9t1ft2.3vvec7p.1@kserver.org> On Fri, 16 Nov 2001 05:02:33 GMT, Hans Nowak wrote in comp.lang.python in article <3BF49DE9.95DC02FA at earthlink.net>: :Aight, here's a wild-assed idea, unrelated to the proposal... since :Python :and Lisp are both dynamic languages, would it be possible to write a :Python-to-Lisp translator, and then compile the Lisp code using one of :those efficient Lisp compilers? Here is a post from the Python Tutor list that is related and may be of interest: http://mail.python.org/pipermail/tutor/2001-October/009417.html -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From pinard at iro.umontreal.ca Thu Nov 29 19:32:57 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 29 Nov 2001 19:32:57 -0500 Subject: Pymacs 0.12 Message-ID: Hi! A new release of Pymacs is available as: http://www.iro.umontreal.ca/~pinard/pymacs/pymacs.tar.gz Pymacs allows Emacs users to extend Emacs using Python, where they might have traditionally used Emacs LISP. Pymacs runs on systems having sub-processes. Not much changed in this release. The limit of time while starting the Python subprocess has been raised from 5 to 30 seconds, for heavily loaded systems. Time limits may now be preset from the `.emacs' file, as needed. With the publication notice of Pymacs 0.11, I gave this example: import pymacs interactions = {} def hello_world(): "`Hello world' from Python." pymacs.lisp.insert("Hello from Python!") interactions[hello_world] = '' to show how one provides an `(interactive)' specification. Python 2 users may prefer using function attributes, and replace the last line with: hello_world.interactions = '' If this does not work, Pymacs falls back on the old portable method. Enjoy! -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From skip at pobox.com Thu Nov 1 18:27:26 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 17:27:26 -0600 Subject: List transpose method In-Reply-To: <20011101224504.C7406@lilith.hqd-internal> References: <20011101205127.A4219@ibook.distro.conectiva> <20011101224504.C7406@lilith.hqd-internal> Message-ID: <15329.55902.51292.776099@beluga.mojam.com> Gerhard> Hmm. How would I apply zip if I have a variable already, like Gerhard> l = ((1,2),(3,4),(5,6)) zip(*l) >>> l = (";:","--","))") >>> map("".join, zip(*l)) [';-)', ':-)'] -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From x00_ldu at nada.kth.se Fri Nov 2 08:04:56 2001 From: x00_ldu at nada.kth.se (Laurent Dupont) Date: Fri, 02 Nov 2001 14:04:56 +0100 Subject: Non-parsed headers in Python Message-ID: <3BE299F8.41112AB7@nada.kth.se> Hello everybody, How do you specify in a Python CGI-script that you want non-parsed headers, e.g. in order to do a server-push (Content-type: multipart/x-mixed-replace) ? Thanks in advance for your help. /Laurent From gh_pythonlist at gmx.de Thu Nov 1 16:12:16 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 1 Nov 2001 22:12:16 +0100 Subject: List transpose method In-Reply-To: ; from TomH@optiscan.com on Fri, Nov 02, 2001 at 08:42:23AM +1100 References: Message-ID: <20011101221213.A7406@lilith.hqd-internal> On Fri, Nov 02, 2001 at 08:42:23AM +1100, Tom Harris wrote: > Hi, > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > only come up with an ugly multiliner. I guess any single-liner will be obfuscated Python and not necessarily any more efficient. If you need such things often, I'd suggest you take a look at Numeric Python. It contains many functions for matrices. Interesting problem nevertheless ... Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From peter at engcorp.com Fri Nov 9 22:01:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 09 Nov 2001 22:01:04 -0500 Subject: I just got in! References: <9sep77$eg6$1@slb4.atl.mindspring.net> <9sf2n1$c4u$3@newshost.accu.uu.nl> <3BEBA214.4A206D96@student.gu.edu.au> Message-ID: <3BEC9870.746F2407@engcorp.com> Joal Heagney wrote: > > Martijn Faassen wrote: > > I am not sure where the generally nice atmosphere comes from. > > I think the audience is just fairly mature. It may have settled the > > atmosphere early on. Small languages generally attract a more mature > > audience, where the average newcomer has a fair number of languages > > under their belt already, with more knowledge of language theory but > > also language pragmatism. Python is clean and pragmatic enough at > > the same time to be useful for such people. It's where > > theory and pragmatism meets peacefully. Perhaps that's why the > > newsgroup is relatively peaceful as well. > > *chuckles* Or maybe it's just that behaviour is contagious. Shout at > others, eventually they'll leave or shout back. Be polite and kind, and > point out that kindness is expected ... > > *grins* Of course I HAVE to believe this explanation. Despite being > "officially grown up" at 24, I really can't think of myself as "mature" > by any stretch of the imagination!!! Don't worry... adding 10 years doesn't make any difference. :-) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From msowka at spam.com Thu Nov 22 19:25:14 2001 From: msowka at spam.com (Mike Sowka) Date: Fri, 23 Nov 2001 00:25:14 GMT Subject: Python + emacs/oo-browser ... pls help Message-ID: I was wandering if anyone is using oo-browser under emacs21 (linux) and if so... could you tell me how you build oo-browser... I'm ripping hair out trying to figure this out. I've heard oo-browser is REALLY GOOD! but... :( Any suggestions/help MUCH appreciated! Mike From sholden at holdenweb.com Thu Nov 1 07:22:13 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 1 Nov 2001 07:22:13 -0500 Subject: Dictionaries, popitem() method example References: <9rr6p5$psi$1@usenet.otenet.gr> Message-ID: "Antonios B. Kaklis" wrote ... > Hello to everybody...' Hello > There is something that i' don't understand. > In the Python Library Reference, Section 2.1.6 "Mapping Types" > It says: "a.popitem( )" --->Note 6: Is useful to destructively iterate over > a dictionary as often > used in set algorithms! > > I don't understand 1) what is "Destructively iteration over a dictionary" This simply means that the item returned by popitem() no longer exists in the dictionary. So if you popitem() enough you will have destryoed it (left it empty - it's still a dictionary)! > 2) Set Algotithms Algorithms that treat the items in the dictionary as a set! The dictionary is a natural structure for this since the presence of an item under a particular key is easily detected, and a key is either present or not. regards Steve -- http://www.holdenweb.com/ From david at dataovation.com Mon Nov 26 05:00:07 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 26 Nov 2001 02:00:07 -0800 Subject: smtplib help Message-ID: Any ideas why smtplib would crash on me after about sending 150 email msgs (i did not count, but that is a good estimate)? This is the error that I am getting. File "C:\Python21\mm_mime.py", line 93, in Send server = smtplib.SMTP(host) File "C:\Python21\lib\smtplib.py", line 187, in __init__ (code, msg) = self.connect(host, port) File "C:\Python21\lib\smtplib.py", line 222, in connect self.sock.connect((host, port)) File "", line 1, in connect error: (10048, 'Address already in use') David McInnis -------------- next part -------------- An HTML attachment was scrubbed... URL: From syver-en at online.no Mon Nov 26 04:04:49 2001 From: syver-en at online.no (Syver Enstad) Date: 26 Nov 2001 10:04:49 +0100 Subject: pdbtrack in emacs, Great! Message-ID: I'll just have to send a big thank you to the one(s) who made the pdbtrack feature in the new Emacs python mode. I can finally debug python code under emacs. Juhuu! I am currently looking into/fidlling with adding the ability to toggle breakpoints by a command while browsing the source. It would be really nice if pdbtrack turned into some sort of minor mode so that it would be easier to extend without modifying the python-mode.el file, but then I am a elisp newbie. -- Vennlig hilsen Syver Enstad From slinkp23 at yahoo.com Thu Nov 29 00:14:33 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 29 Nov 2001 05:14:33 GMT Subject: The Editor Poll results are in! References: <3bfd7f87@news.airtel.net> <9u4cbu$2ts$1@news.xmission.com> Message-ID: On 29 Nov 2001 04:08:30 GMT, Kaden wrote: >ALRIGHT! Who's gonna pay for this pepsi ruined keyboard now?! That's what you get for drinking that crap! I'm currently using granola with soymilk. It's much more visually disgusting, which helps enhance the comic experience, but it doesn't corrode things nearly as badly. It's still a bitch to clean up. --PW From jhauser at ifm.uni-kiel.de Sun Nov 4 17:40:44 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 04 Nov 2001 23:40:44 +0100 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> <3BE5A1A7.75C7EC9C@attglobal.net> <9s4f79$8b3$1@nntp2-cm.news.eni.net> Message-ID: <87ady25fdf.fsf@lisboa.ifm.uni-kiel.de> "Stuart D. Gathman" writes: > In article <3BE5A1A7.75C7EC9C at attglobal.net>, "Pierre Rouleau" > wrote: > > > Actually, i knew that i can execute a single program inside a command > > shell and get the return code. What i want is to execute a large set of > > commands inside the same shell process and being able to get the return > > code for exach one of the calls. > > > > For example, i would like to be able to do someting like: > > > > myShell = Process('cmd') > > error = myShell.execute('make myproject') if (error == 0) : > > myShell.execute('ls') > > myShell.execute('pj ci makefile') > > > > > > I want to be able to issue a whole list of line commands whithout having > > to create a new process on every one of them. > > When you run commands in a traditional shell script, it creates a new process > for every one of them! > > The equivalent of the above is: > > #!/usr/bin/python > import os > error = os.system('make myproject') > if error == 0: > os.system('ls') > os.system('pj ci makefile') > > ... > > In both cases, a new process is created for each command. > AFAIK this is not right, as for the os.system() call first a shell is started and then the process (ls) is started in this shell. A better way is to use the commands module. It wraps os.popen and I'm not sure if this also didn't open a shell beforehand. Pure ways to start a new process are wrapped in the os module as os.exe?? os.fork and os.spawn??. But using these is more complicated (io handling, finding the path of the executable etc.) HTH, __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From kragen at canonical.org Wed Nov 21 15:25:59 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 21 Nov 2001 15:25:59 -0500 Subject: writnig my first programm References: <9tfrf5$27hfr$1@ID-79019.news.dfncis.de> Message-ID: <83zo5fvpk8.fsf@panacea.canonical.org> Felix Seeger writes: > A "adminclient <--> server <--> server-client" programm (all scripts are > stored in the server and they will be given to the server-client if someone > runs a command from the adminclient. > The adminclient could be a GUI or a WebInterface. > It's nice because the Server has always an uptodate version of the scripts. > > What do you think, is this possible ? As far as I understand, you want to keep your scripts in one place so you can update them, and you want to be able to run them, either on a particular server or on all the servers at once, in response to a GUI or web interface. That's very possible, and probably pretty easy; you could do it with a shell script from a web interface. From bfordham at socialistsushi.com Thu Nov 8 15:11:24 2001 From: bfordham at socialistsushi.com (Bryan L. Fordham) Date: 8 Nov 2001 12:11:24 -0800 Subject: Reading a comma delimited file References: Message-ID: <869dc0d1.0111081211.23288888@posting.google.com> > Here's what it looks like when I'm done: > > [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1, > 20.0, 0.0, 167.30000000000001), > ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0, > 6.0999999999999996, 13.9, 0.0, 239.0)] > > Just what I need except I don't want all those decimal places. Are you not happy with the number of decimal places? If so, play around with this: >>> x='1.234567' >>> float(x) 1.234567 >>> import fpformat >>> fpformat.fix(float(x),2) '1.23' >>> fpformat.fix(float(x),0) '1' Hope that helps... --B From buzzard at urubu.freeserve.co.uk Sat Nov 24 21:43:05 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Sun, 25 Nov 2001 02:43:05 -0000 Subject: XML help needed Message-ID: <9tplso$jea$1@newsg1.svr.pol.co.uk> I have a lot of code written for a particular application I'm working on and I've got to the point where I need to access data from XML files. I will also need to save to XML files. There's almost too much information available and I'd appreciate any advice. SAX? DOM? Some nice easy examples? I have the proposed DTD and examples of supposedly valid XML files. The XML files are apparently well-formed, but (according to XML Spy) not valid. 'Invalid value for datatype NMTOKENS in attribute INDEXES'. I think the following are the relevant lines from the DTD and XML respectively. Can anyone tell me what's wrong? Thanks in advance. 1 0 0 From eosn at rahul.net Sun Nov 18 15:15:24 2001 From: eosn at rahul.net (Ed Ohsone) Date: 18 Nov 2001 20:15:24 GMT Subject: Scripting for both object and non-object Message-ID: <9t94ss$3st$1@samba.rahul.net> I would like to know names of general purpose scripting languages which are capable of going both object and non-object oriented. I know tcl is one of that kind. If you know any others, please let me know URL of their home pages. The reason I am asking this question is we want to select a language which best suits our future projects. One of their requirements is freedom from object-oriented shackles. Object-oriented design is a great idea but we are going to waters where it can be impediments. Thanks in advance ------------ Ed From kragen at canonical.org Tue Nov 20 05:51:35 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 20 Nov 2001 05:51:35 -0500 Subject: python vs ecmascript References: Message-ID: <83g079u348.fsf@panacea.canonical.org> "Peoter Veili" writes: > Anyone familiar with ECMAscript (JavaScript)? How does it compare to > Python? I'm reasonably familiar with it. Here are my thoughts, including summarized thoughts earlier on this thread: JavaScript, of course, is the standard language for writing HTML-page-embedded client-side scripts; it is the only language that is a contender here. Python's syntax is mostly nicer. Python has a module system so you can reuse code in multiple programs without cutting and pasting it and so you can keep your code files small and manageable. Python makes it easier to define classes. JavaScript notionally has prototype-based inheritance like Self, but in reality, it ends up having class-based inheritance, although of a particularly lightweight sort. Python doesn't have (many) implicit conversions, which means your code gives you errors instead of giving you wrong answers with no indication that they are wrong. JavaScript development environments are mostly pretty terrible. Python's are reasonable. JavaScript unifies objects and dictionaries; the keys of a dictionary are the same as the attributes of an object. This sometimes has disadvantages. Python has a large and good standard library. JavaScript doesn't. Python has a number of good nonstandard libraries. JavaScript might, but I haven't found them. JavaScript has nested lexical scopes, including closures. Python didn't until 2.1, and they're still turned off by default. JavaScript makes all variables global by default, and its lack of a module system worsens this. This is an unbelievably stupid idea. JavaScript has an ECMA standard and multiple implementations. Python doesn't have a standard, and only sort of has multiple implementations. From shalehperry at home.com Thu Nov 22 14:04:45 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Thu, 22 Nov 2001 11:04:45 -0800 (PST) Subject: string.join() syntax quirky? In-Reply-To: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: > > This works fine, but it seems syntactically backwards to me: > ># s = l.join("") > > makes much more sense to me. The thingy I want to do something to is my > list. I am just trying to learn Python, so no doubt there will be some > Python things I will just have to get used to, but is there a logical > reason why it was implemented as a string method rather than a list > method? Does it seem backwards to you or does it make intuitive sense to > you? Comments? (other than of the "it's moot" flavor) > Yep, this has been pounded before. I actually liked it better when it was string.join(s, l), but oh well. The problem here is that "".join(l) works for ANY sequence. l.join() would have to be reimplemented for every sequence like object. From jdadson at ix.netcom.com Thu Nov 1 21:11:34 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 02 Nov 2001 02:11:34 GMT Subject: Source files? Message-ID: <3BE200BA.3F271DA0@ix.netcom.com> I just learned about Python a couple of days ago. A customer suggested we use it (rather than Java) for an application interface. So, I downloaded the latest beta version, Python-2_2b1.exe, and installed it. I was under the impression that it came with open source. I can't find any source files. Dot-h, yes. Dot-c or dot-cpp, no. How does one obtain them? Best regards, Jive From andreas at mtg.co.at Thu Nov 8 05:55:46 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Thu, 8 Nov 2001 11:55:46 +0100 Subject: wxWindows link error In-Reply-To: <3BE9D199.592FC63F@ccvcorp.com> References: <3BE8AA75.1090101@yahoo.com> <3BE8BFC8.3000803@yahoo.com> <3BE9D199.592FC63F@ccvcorp.com> Message-ID: <200111081057.fA8Av8G00896@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Donnerstag, 8. November 2001 01:28 schrieben Sie: > Have you tried checking the wxPython site itself (www.wxpython.org)? There > are detailed build instructions for win32 and unix (the unix version is at > http://wxpython.org/BUILD.unix.txt), and if you can't find the answer to > your problems there (or already looked with no success), then ask this > question on the wxpython-users mailing list. Robin Dunn, the author of > wxPython, is *very* good about answering questions there. Didn't solve my (similiar) problem. But then, I've asked on wx-users :( My wxGTK is ok, as I can compile C++ stuff. I presume, that it's the LINKCC=c++ problem mentioned in the Python FAQ for C++ library modules, but at the moment I'm stuck with recompiling the SuSE 7.3 python.spm (.src.rpm), so I couldn't confirm that this is the problem for the ImportError below. andreas at lap1:~> python Python 2.1.1 (#1, Sep 24 2001, 05:28:47) [GCC 2.95.3 20010315 (SuSE)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import wxPython.wxc Traceback (most recent call last): File "", line 1, in ? File "/usr/lib/python2.1/site-packages/wxPython/__init__.py", line 20, in ? import wxc ImportError: /usr/lib/python2.1/site-packages/wxPython/wxc.so: undefined symbol: SeekI__13wxInputStreamx10wxSeekMode - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE76mS0HJdudm4KnO0RAptbAJsHYVoQ99cHOBBuUFGpC7YZ+6F7FACgu9Hx 3EYp6lEMSMMq1gey/tnVO5U= =kqER -----END PGP SIGNATURE----- From sholden at holdenweb.com Tue Nov 27 14:06:14 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 27 Nov 2001 14:06:14 -0500 Subject: Redirect output from os.system() References: <6749bb94.0111270841.c808c39@posting.google.com> Message-ID: "Era Akost" wrote ... > Hi all, > > Searching through the group emails, I've found out how to redirect > output from python functions. Now I would like to redirect the output > from a os.system() process to a Text widget. How can I do it? > > Python Reference Library says the following on stdout, stdin of sys > module: > > "(Changing these objects doesn't affect the standard I/O streams of > processes executed by os.popen(), os.system() or the exec*() family of > functions in the > os module.)" > > So, what should be done?? Instead of calling system(), use one of the popen()'s to give you a pipeline, which will allow you to read the output from the process and do with it what you will. regards Steve -- http://www.holdenweb.com/ From marc.engel at recif.com Wed Nov 14 04:34:14 2001 From: marc.engel at recif.com (Marc ENGEL) Date: 14 Nov 2001 01:34:14 -0800 Subject: Pproblems using Python, COM, Event (or Connection Point) and thread Message-ID: <6411841c.0111140134.48720bff@posting.google.com> Dear all, I am trying to do a kind of Event Manager in Python. The architecture I want is the following: - A main python scripts start all the COM object needed by the application with DispatchWithEvents and then wait for messages using PumpMessage - The EventManager registered to each COM object do litle processing: it just delegates the event processing to a new thread and return (I don't need to return a value for events) - The Threaded Event Manager do the actual processing and mainly I want it to call the method that can process the event on other COM objects. The Event manager may also do some additional processing depending on the event. In order to test this, I started from the Excel event script example and I modify it. See script source at the end of the message. It is running on my computer I have 2 problems: 1 - If I try to access the COM object in the Event Thread by uncommenting Target.Column in classe ExcelEvents (line >>> print "Column = "#, Target.Column), I get the following error: File "d:\program files\python21\win32com\client\__init__.py", line 334, in _ApplyTypes_ return self._get_good_object_(apply(self._oleobj_.InvokeTypes, (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) pywintypes.com_error: (-2147417842, "L'application a appel\xe9 une interface qui \xe9tait maintenue en ordre pour une thread diff\xe9rente.", None, None) Sorry the error message is in french (but actually I am french :)). It means "Application has called an interface that was maintained in order for a different thread" Any hint? 2 - I would like that class EventManager does not define all events it can manage but dynamically create a function to be called for each event that it is asked to manage. I thought it would be intersting to use the magic method __getattr__ to create the method with the event name dynamically. But as you will see if you execute the script, this method is never called. Is there anything I did not understand about this method? Thanks for any hint, Marc ENGEL -----------------> Start Python script import sys, time, msvcrt, win32com.client, win32gui, thread, win32ui, win32api, win32con sys.coinit_flags = 0 #COINIT_MULTITHREADED #COINIT_APARTMENTTHREADED = 0x02 import pythoncom class EventsManager : def __getattr__(self, attr): print "Trying to call event ", attr args=self._prop_map_get_.get(attr) if args is None: raise AttributeError, attr return apply(self._ApplyTypes_, args) # Default handler for Event OnSheetBeforeDoubleClick # Delegates treatment to class ExcelEvents into a new thread def OnSheetBeforeDoubleClick(self, Sh, Target, Cancel): thread.start_new_thread(ExcelEvents().OnSheetBeforeDoubleClick, (Sh, Target, Cancel)) return 0 class ExcelEvents: def OnSheetBeforeDoubleClick(self, Sh, Target, Cancel): pythoncom.CoInitializeEx(0) print "Column = "#, Target.Column time.sleep(5) print "Finished processing event for column "#, Target.Column pythoncom.CoUninitialize() return 0 def ThreadWaitingForUserInput() : win32api.MessageBox(0, "Press OK when you want to stop the message loop", "Info") # Post message to dummy window in order to get out of the main event loop PumpMessages win32gui.PostMessage(MyDummyWindow, win32con.WM_QUIT, 0, 0) return 0 # Create new Execel application excel = win32com.client.DispatchWithEvents("Excel.Application", EventsManager) excel.Visible=1 excel.Workbooks.Add() # Create a dummy window for posting WM_QUIT message MyDummyWindow = win32gui.CreateWindow("BUTTON", "TestWindow", 0, 0, 0, 100, 100, 0, 0, 0, None) # Start new thread to display the MessageBox to exit application thread.start_new_thread(ThreadWaitingForUserInput, ()) # Give it a chance to start win32api.Sleep(100) win32ui.PumpWaitingMessages() # Main event loop waiting for quit message posted from thread ThreadWaitingForUserInput pythoncom.PumpMessages() print "Quitting script..." # Don't want dialog box for saving document before closing Excel excel.DisplayAlerts = 0 # Remove the workbook excel.Workbooks.Close() # Quit application excel.Quit() # Release excel object excel = None # This is just a trick to have the script displaying error message if any! print "Press OK on Popup Message box to stop scipt..." win32api.MessageBox(0, "Press OK to stop script", "Info") -----------------> End Python script From phr-n2001d at nightsong.com Sun Nov 11 12:29:17 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 11 Nov 2001 09:29:17 -0800 Subject: Is this considered black magic? References: Message-ID: <7x4ro1nrma.fsf@ruckus.brouhaha.com> Laura Creighton writes: > But is it white, grey, or black magic? Is there a better way I should have > done? Suggestions on what to name the function gratefully welcomed. Use getattr to find the method, then apply it. From gat at jpl.nasa.gov Fri Nov 30 14:30:43 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Fri, 30 Nov 2001 11:30:43 -0800 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: In article , Neil Schemenauer wrote: > Erann Gat wrote: > > Skip: > > > In Python, if it looks right, it is right. > > > > No, that's not true. Consider the following two alternative code fragments: > > > > if x: > > foo() > > baz() > > > > if x: > > foo() > > baz() > > > > They both look right, but they can't both be right. > > How do they both look right? They are both equally valid programs. They are both syntactictically and stylistically correct. But in a given application at most one of them can be semantically correct. > As for moving code around, I agree that it would be nice if the block > structure of the code was preserved. I think the solution for this > problem is not to add extra syntax to the language but to have smarter > editors. I believe effbot and the other people at Python Labs are > working on a "refactoring browser" for Python. It would be similar to > what has been done for Smalltalk. I agree this is basically the right approach. My point is that there is not enough information at the moment for a smarter editor to do the Right Thing with. The information just isn't there. I'd just like to add it in a (semi-)standard way. E. From mmillikan at vfa.com Thu Nov 22 13:08:59 2001 From: mmillikan at vfa.com (mmillikan at vfa.com) Date: 22 Nov 2001 13:08:59 -0500 Subject: Conversion from tuple to argument list? References: <3BFAE47F.C014585B@earthlink.net> Message-ID: <8zcy4r0k.fsf@vfa.com> mmillikan at vfa.com writes: > However, it doesn't work when the sequence to be unpacked is in any other > position in the parameter list: > > >>> zip(*seqseq,seq) > File "", line 1 > zip(*seqseq,seq) > ^ > SyntaxError: invalid syntax > > Could this syntax be extended to allow the splicing to happen at any > position within the parameter list? > > In the interim, the following module allows the construction: > > >>> zip(*splice(unnest(seqseq),seq)) > [(1, 'a', 'x'), (2, 'b', 'y'), (3, 'c', 'z')] > > More elaborate splicing also appears to work: > > >>> splice([10,20,30],[],unnest(['sam',unnest(unnest(['barney','fred']))]),seq,()) > [[10, 20, 30], [], 'sam', 'barney', 'fred', ('x', 'y', 'z'), ()] > > Only lightly tested, on 2.1.1 > > Feedback on utility and/or horrible flaws appreciated > > ------------------------------------------------------------------ simplified to ... #splice3.py from __future__ import nested_scopes class unnest: '''A minimal wrapper for any sequence. When passed as an argument to the function the elements of the sequence will be spliced into the list returned replacing the instance.''' def __init__(self,seq): if isinstance(seq,self.__class__): self.seq = seq.seq else: for item in seq: break self.seq = seq def __getitem__(self,index): return self.seq[index] def __len__(self): return len(self.seq) def splice(*args): '''Returns a list of its args with any instances of replaced by the items of the unnests sequence attribute.''' def _splice(flat,*args): for arg in args: if isinstance(arg,unnest): _splice(flat,*arg.seq) else: flat.append(arg) return flat return _splice([],*args) From grahamd at dscpl.com.au Sat Nov 24 20:20:53 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 24 Nov 2001 17:20:53 -0800 Subject: DateTime strangeness when returning MySQLdb results thru xmlrpcserver References: Message-ID: Ken Guest wrote in message news:... > OK, I've been writing an XML-RPC server in python to serve as an > intermediate between a client app and a mysql database - this works fine > for the most part in that I can open a database, execute sql and close > the database at will. > I'm using MySQLdb, xmlrpclib and xmlrpcserver to make all this work, > the version of python that I'm using is 2.0.1 and my xmlrpclib is at > version 0.9.9 with the last comment by Fredrik Lundh dated 2001-02-26. > > And it works just fine until the resultset being returned references a > datetime column - and keep getting an Internal Error (ie status code = > 500). > > I tweaked xmlrpcserver.py to return the error type and value [1] and > found that the reason is that xmlrpclib "cannot marshal 'DateTime'> objects". > To be honest I'm not sure how the timestamps get converted to this type > as MySQLdb returns them as strings and examining xmlrpclib.py hasn't > shed as much light on the problem as I'd like. If the DateTime package from egenix is installed, MySQLdb will use its date and time types instead of returning strings. To cope with this when using that particular XML-RPC server framework, you would need to extend the marshallar class to handle that type. I can't remember if one can instead override MySQLdb not to use the date and time types from egenix package. As an alternative that already does what you want, you might look at: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81613 This particular code already handles the possibility that MySQLdb might return a DateTime class instance rather than a string, converting it back to a string when it does. From weismann at netvision.net.il Tue Nov 6 18:10:20 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Wed, 07 Nov 2001 01:10:20 +0200 Subject: Python icons Message-ID: <016501c16718$35d17500$1395003e@rashome> Where can one find Python icons (e.g. The python , A sign - Python programmer etc . ) ? TIA Amit ---------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From marcoxa at cs.nyu.edu Mon Nov 12 12:38:59 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 12 Nov 2001 12:38:59 -0500 Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: Manoj Plakal writes: > Marco Antoniotti wrote: > > > "Morten W. Petersen" writes: > > Apart from the existence of very good native compilers, there are a > > number of nice features - all standard - that allow you to use Common > > Lisp as a "language kit": something very few other language are good at. > > > > Take for example one of the latest additions to Python: list > > comprehension. > > > > This is essentially incorporating regular set-theoretic notation in > > the language. I.e. to have notation that allows you to say things like > > > > {x | even(x) /\ x >= 0 /\ x <= 100} > > > > (the set of "numbers" between 0 and 100 - assuming integers or rational, > > this is a finite, enumerable set). > > > > To get this kind of notation into Python (alas a similar one), AFAIU, > > the (1) parser had to be modified, and (2) the interpreter had to be > > modified as well. This are not things that (AFAIK) where done in > > Python itself. > > > > In Common Lisp you just changed the "readtable" to recognize the > > special nature of the characters #\{, #\}, #\[, and #\] (think of > > Emacs and what it does with characters) and you write a couple of > > macros. The code is all written in CL and the above example may be > > rendered as > > > > {x / x in (range 0 100) / (evenp x)} > > > > This effectively constructs a list of the even integers. All of this is > > all CL and it is all compiled down to native code. (The above expression > > "expands" into a LOOP, which is happily compiled by the CL system. The > > code runs on all CL implementations and it can be used to shorten your > > programs. > > > I'm curious (I haven't done much programming in Lisp). > > Doesn't this make CL programs harder to read? I can see > why a programmer would love it since it allows you to > define your own little language that fits your way > of thinking and a problem domain. I've heard of Lisp > programmers going gaga over the macro facility. > > But isn't it going to be difficult for someone other > than the original programmer to come along and try to > figure out what's going on? They're going to have to absorb > the macro definitions before trying to read even > a small part of the code that uses these macros. I believe you make a very good point w.r.t. the "SetL" package for CL. That is, the extension to CL I wrote to use set theoretic notation within CL programs. When using it, you are writing in a "non traditional" CL/Lisp notation, hence, your programs may not be "readable" by people who are not familiar with the notation. The "SetL" package was written to illustrate a capability of CL systems and to provide a package for people who want to use it. If you want to use it, you'd better advertise that you are using it and point to the relevant documentation (which I guiltily did not provide :) ). In a more "traditional" setting, writing macros in CL is a useful thing, because "regular" macros do not - in my experience - deviate much from "traditional" CL code. Let's take the (standard) macro `defclass'. You write (defclass my-class (super-class-1 super-class-2) ((slot1 :accessor slot1 :initarg :s1) (slot1 :accessor slot1 :initarg :s1))) this is usually defined as a macro and its syntax is "traditionally" CL. A different macro is (defsystem bio-l :source-pathname "BIOL:" :components ((:file "biol-package") (:module "sequences" :components ("seq" "alignments")))) `defsystem' is another macro (in the publicily available "MAKE" package). All in all when you see a `def*' form in a CL program, you know that (most likely) you are looking at a macro. Hence you have a visual clue. Other "traditional" macros are of the form `with-*'. THe typical example is `with-open-file' (with-open-file (f "the-file") (read f)) This effectively expands into something like (let ((f (open "the-file" :direction :input :if-does-not-exist :error))) (unwind-protect (read f) (close f)))) I.e. the macro is used to ensure that some "cleanup" form is effectively used. In my experience, the most common forms of macros fall three cathegories: defining macros, with-* style macros and "efficiency" macros. Of course, you have other forms of macros. Large packages give you several macros that you must understand before you use them. But in these cases (I am thinking, e.g. of the SERIES package), you know that you need to learn how to use them. > A similar thing happens when > people go nuts with the C preprocessor or C++ > operator overloading. You get either innocent-looking > code that actually has very different semantics > than what you thought, or completely baroque code > which can only be understood by reading a whole > lot of other code that is defining macros and stuff. > > How much of a problem is this in practice for CL? As I said before, macro use in CL is extremely powerful, but it is also used in some "patterns". This helps. Operator overloading in C++ has been the source of misunderstandings. I think this is because of the initial confluence of "namespace" and "classes". In CL classes are not used for namespace purposes. CL packages are like (well, almost) Ada packages and newer C++ namespaces. Moreover, to "overload" a function you must either design it to be like that from scratch or go against the standard. Let's take an example. Writing a "Matlab-like" math package, requires you to redefine '*' to take matrix operands. >From the point of view of the programmer this requires to state at the package level that you are "shadowing" the standard '*' operator. ============================================================================== (defpackage "MATRIX" (:use "COMMON-LISP") (:shadow cl:*) ; Note the explicit reference to the standard '+' operator (:export "*") ) ============================================================================== Then you need to write *in the MATRIX package* the "overloaded" version. ============================================================================== (in-package "MATRIX") (defmethod * ((n1 number) (n2 number)) ; This '*' is really matrix:* (cl:* n1 n2)) ; Explicit reference to the standard '*'. (defmethod * ((n number) (m matrix)) ;; code for scalar product ) (defmethod * ((n complex) (m matrix)) ;; code for scalar product, specialized on complex scalar. ) (defmethod * ((m matrix) (n number)) ;; code for scalar product; commutative version ) (defmethod * ((m1 matrix) (m2 matrix)) ;; code for matrix product ) ... ============================================================================== Now, this allows you to "overload" the '*' operator. >From the "user" point of view, he needs to know what s/he can use. If s/he decides to work in the MATRIX package, s/he will have to know that '*' has been "extended". IMHO, in cases like this, CL offers more control over what you see. Add to this the tendency of CL programmers to use very-long-and-explicative-names-for-their-functions and you see how the problems are tamer that they may seem. Of course your mileage may vary, and "RTFM" is the commandament you must follow :) Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From jeff at ccvcorp.com Wed Nov 21 19:08:14 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 21 Nov 2001 16:08:14 -0800 Subject: Tkinter without the window References: <6hu1vn92lb.fsf@hare.demon.co.uk> Message-ID: <3BFC41ED.4C0EFB37@ccvcorp.com> Les Smithson wrote: > I have a working Tkinter application that uses a canvas to draw > graphics in an X window. Is it possible for Tkinter to draw the same > graphics straight to a PNG/JPG/whatever file without going through a > windowing system? > > I have in mind using this application for an External script in a Zope > server. This would be called to generate a img tag on the fly. I want > to do this in the server, rather then in the browser. Any ideas how I > can generate PNG/JPG directly from Python, other than Tkinter? You probably ought to look at the Python Imaging Library-- http://www.pythonware.com/products/pil/index.htm It can rotate, transform, crop, filter, and generate images on the fly, and save them in any standard graphics format. Jeff Shannon Technician/Programmer Credit International From fperez528 at yahoo.com Thu Nov 29 11:49:41 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 30 Nov 2001 16:17:41 +2328 Subject: 2.1 loop with try & continue -> bug? References: <9u93uh$4m$1@peabody.colorado.edu> Message-ID: <9u9447$4m$2@peabody.colorado.edu> Fernando P?rez wrote: > Am I missing something? > Yes, I missed the bug report :) Well, time for 2.2 I guess. f. From montanaro at tttech.com Thu Nov 8 09:23:58 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Thu, 08 Nov 2001 15:23:58 +0100 Subject: complex() bug or feature? In-Reply-To: <7bwG7.6335$%g7.277586@atlpnn01.usenetserver.com> References: <3BEA6446.8D8B4012@snakefarm.org> <3BEA8B0F.E594BE84@snakefarm.org> <7bwG7.6335$%g7.277586@atlpnn01.usenetserver.com> Message-ID: Steve> Well the documentation should really make it clear that the Steve> single string argument case is completely different from Steve> the single numeric argument case. The former uses an Steve> implied zero as the imaginary component, whereas the latter Steve> extracts the imaginary component from the string. Steve> And yes, the implementation *should* raise an exception Steve> with a string first argument and any second argument. But Steve> the docs could use clarification. I've got a patch for the code I need to test and will generate a patch for the doc, then submit both later today. I suspect this will make it into 2.2. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From carmstro at twistedmatrix.com Mon Nov 5 12:56:49 2001 From: carmstro at twistedmatrix.com (Chris Armstrong) Date: 5 Nov 2001 09:56:49 -0800 Subject: ANN: Twisted 0.12.0 released Message-ID: Twisted, version 0.12.0, was released yesterday (November 4, 2001). This was a major feature/bugfix release, which went rather smoothly. It is available at http://twistedmatrix.com/. The new things going on since 0.11.0: Unified the twisted.internet main loop approach to thread dispatching. This involved merging internet.threadtask into internet.task, and making a new threadtask - a threadpool subclass that integrates with twisted's event loop. Many minor refactorings. This included cleanup to move generic 'thread ownership' code to 'log ownership' where it really belongs. Many major bugfixes, most notably to twisted.spread and Instance Messenger, twisted's IM client. Added XML-RPC web resource, and fixed a few issues in twisted.web. Major speed improvement to twisted on jython, and some speed improvements to threaded twisted. Updates to twisted.python.usage. Beginning to revitalize twisted.enterprise: in this release, twisted.enterprise.adbapi, an asynchronous wrapper for python's DB-API 2.0. What is Twisted? Twisted is an event-based framework for internet applications. It includes a web server, a telnet server, a multiplayer RPG engine, a generic client and server for remote object access, and APIs for creating new protocols and services. Twisted supports integration of the Tk or GTK event loop with it's main event loop. It also has basic support for running servers on top of jython. Twisted currently supports the following protocols, all implemented in pure python, most of them as both servers and clients: - FTP - HTTP - SMTP - irc - telnet - POP3 - AOL's instant messaging TOC - DNS (client only) - LDAP (client only) - finger - Echo, discard, chargen and friends - Perspective Broker For more information, visit http://www.twistedmatrix.com. From mgerrans at ix.netcom.com Tue Nov 13 01:28:05 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Mon, 12 Nov 2001 22:28:05 -0800 Subject: IsPython really O-O? References: <9sl891$eik$1@slb7.atl.mindspring.net> Message-ID: <9sqeq6$qu5$1@slb1.atl.mindspring.net> Tim Hammerquist wrote > If you really need to raise a discussion, the posters > comp.lang.smalltalk... Okay, I'm off to the smalltalk group to declare that "Python is more OO than Smalltalk!" Who will ensure that I get a decent burial? > $ cat debate > #!/usr/local/bin/python > > assert time is infinite > steve = Zealot(SmallTalk) > matt = Advocate(Python) > > while isinstance(steve, Zealot): > try: > matt.argue() > if isconvinced(steve): > break > pigs.fly() > steve.say("I'm not convinced.") > except: > steve.say("Hah! You can't prove it!") > > $ chmod 700 debate > $ debate and echo "They all lived happily ever after." Cute, I like it! (although I don't claim to be a Python Advocate -- I advocate using the best tool for the job, which means the more tools you know how to use, the better your odds are). - mfg From buzzard at urubu.freeserve.co.uk Wed Nov 7 13:51:41 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Wed, 7 Nov 2001 18:51:41 -0000 Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) References: <9sacsk$r82$1@bugstomper.ihug.com.au> <8_dG7.4760$R43.760797@newsb.telia.net> Message-ID: <9sbvsa$925$1@newsg2.svr.pol.co.uk> "Fredrik Lundh" wrote in message news:8_dG7.4760$R43.760797 at newsb.telia.net... > Gary Stephenson wrote: > > Umm, I'm not really sure this is a claim we should be making! Next thing > > you'll have us claiming responsibility for making disco popular - and then > > they'll just have to shoot us! ;-) > > but Steve Irwin is your fault, right? And Rolf Harris. > > > > From rdsteph at earthlink.net Fri Nov 16 14:08:15 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Fri, 16 Nov 2001 19:08:15 GMT Subject: python vs ecmascript References: Message-ID: <3BF5657F.802474EE@earthlink.net> Hello !! ;-))) JavaScript is nice because you can embed it in web browsers and use it to do input/putupt interfaces over the web. JavaScript and its cousins (ecmascript et al) are somewhat unique in working almost all the time in almost all web browsers in this regards. The above is an advantage of JavaScript over Python. In my experience, Python has the following advantages over JavaScript: 1. Python is more versatile in that it can be used more easily on a much wider set of jobs. Python can be used to do very large programming jobs such as Zope. I do not believe anyone has ever tried to use JavaScript for such large and complex jobs. Why is Python so much more useful for such large jobs? I think others on this list can answer that question better than I can, but certainly Python's robust and complete object orientation features come into play in this. 2. Python has a much larger and more powerful set of tools. The Python Libraries, for instance, offer powerful yet easy capabilities in string processing, numerical processing, Internet and web processing etc. etc. etc. that JavaScript simply doesn't have. 3. Python has many good graphics libraries. I believe JavaScript can not do graphics programming at all, except for simple web based GUI's for user interaction and also display of JPEgs, GIF's etc.; but as far as actually processing images and graphics themselves, JavaScript is not the right tool. 4. Python has several really good IDE's, including IDLE which is part of the actual Python download. This feature, for me, is one of the most important strengths of Python. It makes debugging Python code so much easier for me than debugging JavaScript programs. If you haven't used the Python debugging tools in IDLE, PythonWin etc. etc. etc., then you have a real treat in store for you. Saves time! Makes life easier! 5. Python has a really good exception and error handling capability. 6. Python code is really easy to read and maintain. A page of Python code is clean, simple, and easy to understand. 7. Python can easily be extended using C or C++. Alternately, Python can easily be embedded in C or C++ code. These facts dramatically extend Python's usefulness and power. 8. There exists a fine Java implementation of Python, called Jython. Jython allows you to use Python's easy to learn and use scripting language features, while allowing the code to run on JVM's. Also Jython allows you to call and use any Java classes. Also allows Java programmers to call and use Jython classes. 9. Python is Fun! and it has an incredibly good, knowledgeable, and friendly user community. The value of this feature alone is more than enough to sell me on using Python !!! ;-)))) Ron Stephens Http://www.awaretek.com/python.html From junkster at rochester.rr.com Thu Nov 1 18:45:37 2001 From: junkster at rochester.rr.com (Benjamin Schollnick) Date: Thu, 01 Nov 2001 23:45:37 GMT Subject: Help? Tkinter problem (Menu ID 256 already in use!) Message-ID: Folks, I'm running into a problem, that I can't solve.... I have no idea what's really wrong.... This only occurs on the Macintosh version of Python (specifically, v2.0, I haven't tried 2.1 yet)..... "Menu ID 256 is already in use! Fatal Python Error: TCL/TK Panic" To me, this implies there is something wrong with Tkinter, but it maybe in the calling system from python.... This occurs when I try to use PMW, or "Wizard" (Tkinter "ms-wizard" system).... I've tried the MacPython list, with little luck.... - Benjamin From stuart at bmsi.com Fri Nov 16 11:16:42 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Fri, 16 Nov 2001 11:16:42 -0500 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> <9t1uce$5d8$1@nntp1-cm.news.eni.net> Message-ID: <9t3e5a$7cb$1@nntp1-cm.news.eni.net> In article , "Skip Montanaro" wrote: > John> Didn't we discuss this a month or two ago? There was quite a bit > John> of talk about speeding up access to module level names and so > John> forth, even going into the changes needed in the bytecode set, > and John> possibly even an implementation. > > Go to http://python.sourceforge.net/peps/ and check out PEPs 266 and > 267. There will possibly be a Developer's Day session on optimization. PEP 267 is very similar to my modest proposal. Apparently, functions are permanently bound to the module they are defined in, so my call site caching scheme isn't necessary. I vote for PEP 267. But what about my suggestion of applying the Dlict concept to classes? Using the call site caching scheme works for methods that may execute with instances created by arbitrary multiple inheritance. Keeping only the slot array with each instance and the symbol table with the class saves memory. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - Mozart background song for the Microsoft "Where do you want to go from here?" commercial. From plakal at yumpee.org Wed Nov 28 03:58:13 2001 From: plakal at yumpee.org (Manoj Plakal) Date: Wed, 28 Nov 2001 08:58:13 GMT Subject: rxvt + python problem: script output buffered and interactive output missing Message-ID: <3C04A742.50700@yumpee.org> Hi, I'm encountering a strange problem when I run Python scripts and the Python interpreter in an rxvt window (with tcsh) on the latest Cygwin. This is with Win98/BeOpen Python 2.0/Cygwin 1.3.5/rxvt-2.7.2. The scripts print some messages to stdout but these gets buffered and appear only when the app exits (it runs for a while). If I add calls to flush stdout, then the messages appear as they are printed. If I run the Python interpreter itself, I get no output at all, the shell just hangs, I get the hourglass icon and I can eventually break out with Ctrl-C's. Things work fine with bash in a DOS box. Makes me think that something is wrong with rxvt's handling of stdout/stderr. But it seems to work with some other console apps (like sftp). Manoj From grey at despair.dmiyu.org Fri Nov 30 19:20:56 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Sat, 01 Dec 2001 00:20:56 -0000 Subject: A modest indentation proposal References: Message-ID: On Fri, 30 Nov 2001 14:35:41 -0800, Erann Gat wrote: > In article , > wrote: >> But as you agreed earlier, their objection is a nit-pick and their >> reasoning (based on the fact that it's an "underdog") is irrational. >> Those are two very bad reasons to change a language. ;-) > That depends on one's goal. My goal is to convince the Powers that Be > here to let me write flight software in Python instead of C++. If a tiny, > inconsequential change to the language lets me accomplish that then I > think it's an excellent reason to change the language. That is understood. However, your goal is not automatically the language's and those who use and design the language's goal. As he said an irrattional nit-pick is not a reason to change a language. It is far better for you to change your tactics on addressing that irrational nit-pick or have then understand that it is indeed irrational and a nit-pick than to presume to change the language on a bad reasoning. > Now from here on how the story goes is up to you. If you simply insist > that the problem doesn't exist you will lose, at least in the short run, No, "we" do not lose. Not in the short run, not in the long run. "We" are not the ones pitching this and asking for the change. *You* are. As joe developer off doing my own thing with Python, or working on a SourceForge project in Python, or doing professional work in Python I have lost nothing. Nothing. That was a very bad attempt at an emotional ploy there knowing that people don't want to lose. However, we have to acknowledge and actively participate in a contest to lose. Now, IANAP. Guido and others who are involved in making this wonderful language may very well disagree with me on that point. Maybe they will feel they would have lost something. I just don't see it because I see no contest. Sure it would be nice if I could say "NASA/JPL uses Python" when I want to push it for one of my projects. But I would rather that be true because it is Python for what it is, not what NASA/JPL wants it to be for their requirements. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From philh at comuno.freeserve.co.uk Wed Nov 14 15:36:00 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 14 Nov 2001 20:36:00 +0000 Subject: Parser Generators: which is best? References: <3BF297E2.4D900A75@divalsim.it> Message-ID: On Wed, 14 Nov 2001 17:12:18 +0100, Nicola Musatti wrote: >Hallo. >While searching for parser generators in Python I came across Aaron >Watters's kw(j)Parsing and John Aycock's SPARK. Before I make my choice >I'd like to know about experiences with these or other tools. I've used SPARK (in my Parrot tool(1)) and am pleased with it. it works and is reasonably easy to use. (1) http://www.vision25.demon.co.uk/oss/parrot/intro.html -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From en at enlightened.de Mon Nov 26 09:42:21 2001 From: en at enlightened.de (Nicolai Ehemann) Date: 26 Nov 2001 06:42:21 -0800 Subject: popen3 stdin problem Message-ID: <57c2c2f1.0111260642.22b4cf30@posting.google.com> I have a strange problem using popen3() on a linux machine with python 2.1.1: I use inf, outf, erff os.popen3("cmd ....") to start a process which makes a lot of output to stdout and awaits user input on stdin. Capturing the output with outf.readline() works perfectly, but as far as I can see sending input to the process via inf.write("command") or inf.write("command\n") does not get through to the child process. When called interactively, cmd reacts to input from stdin with some status output, and there is a /QUIT-Command which should stop the program. Nothing of this happens (outf.readline() never gets EOF). Any ideas what the problem could be? Nico From max at alcyone.com Thu Nov 22 13:56:43 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 22 Nov 2001 10:56:43 -0800 Subject: RogueLike Games in Python References: <3BFC9160.24AFA11A@alcyone.com> Message-ID: <3BFD4A6B.900782F4@alcyone.com> Stefan Antoni wrote: > Anybody who's working at this kind of game in pure python? > I'm highly interested in this, too. Here's the one I've heard of most recently: http://kuoi.asui.uidaho.edu/~kamikaze/Umbra/ It looks to be sort of a Roguelike/Wizardy hybrid. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From logiplexsoftware at earthlink.net Thu Nov 8 20:00:28 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 8 Nov 2001 17:00:28 -0800 Subject: Gratuitous post In-Reply-To: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> References: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> Message-ID: <01110817002802.03352@logiplex1.logiplex.net> On Thursday 08 November 2001 15:49, Steve Holden wrote: > Free software. What do you mean, "software"? -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From slinkp23 at yahoo.com Fri Nov 9 23:26:16 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sat, 10 Nov 2001 04:26:16 GMT Subject: Teaching python (programming) to children References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> <3BEC9577.93682746@engcorp.com> Message-ID: On Fri, 09 Nov 2001 21:48:23 -0500, Peter Hansen wrote: >I wouldn't think one needs to understand classes to be able >to use exceptions effectively. They just look like a simple >name for a type of problem that could occur in a block of >code, and one only needs to learn a little syntax to be >able to use them to great effect. That's exactly how I experienced them when I first learned python. I didn't even know I *could* define my own exceptions for a while. I got a lot of work done just by thinking of them as "errors you can catch and / or deliberately raise." - Paul Winkler From martin.franklin at westgeo.com Mon Nov 19 04:16:03 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Mon, 19 Nov 2001 09:16:03 +0000 Subject: Regex and Tkinter References: <9t3b7g$t69$1@testinfo.cs.uoguelph.ca> Message-ID: <9taijb$1ob8$1@mail1.wg.waii.com> Jeffrey Dunnett wrote: > What I am trying to do is implement a find, find next option on a > Tkinter\Python program usings reg. expressions what I am not sure about > how to do is how to A) Get the information location in the string where > the regex was found B) Hightlight the text in the text box on scree. > > So far I have a created text box with some text in it and am doing this > > def findregegx(self): > > #Gets the regex from a entry widget created earlier in the class > self.expression = self.regexp_entry.get() > > #Gets the text from the text field created earlier, self. index = 1.0 > self.search_text = self.display.articleArea.listbox.get(self.index, > END) > > #Searching for the regex > found = re.search(self.expression, self.search_text) > > print found.group() > > > I figure that I can hightlight the text by using tags in some way but I > am not quite certain how to go about finding where the regext is in the > text field. Any help would be appreciated. > > Jeff Dunnett > > Jeff, The Tkinter Text widget has a search method..... i'm just not sure if it will take a re as it's argument, however this is the simplest way of 'finding' some text inside the text widget as it returns the position of the 'found' text so you can set the selection tag..... here is a quick example but you should also consider looking at the IDLE source code for a different aproach - in fact (i've just taken another look) and they don't use the Text widget search method so you should really take a look.... # textarea is a Pmw.ScrolledTextBox # pattern is an Entry box def find_text(self): self.parent.textarea.tag_delete("found") pat=self.pattern.get() if not pat: return self.found=self.parent.textarea.search(pat, "insert") if self.found: self.show() def show(self): line, start = map(int, self.found.split('.')) end=start+len(self.pattern.get()) self.parent.textarea.tag_add("found", "%d.%d" %(line, start "%d.%d" %(line, end)) self.parent.textarea.tag_config("found", background='navy', foreground='white') self.parent.textarea.mark_set("insert", "%d.%d" %(line, end+1)) self.parent.textarea.see("%d.%d" %(line, start)) self.parent.textarea.update() HTH Martin From mwh at python.net Fri Nov 16 05:36:51 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 16 Nov 2001 10:36:51 GMT Subject: initializing private members via exec References: <3BF40A4E.CC498C2D@bioeng.ucsd.edu> Message-ID: Curtis Jensen writes: > Why session below give me an error? Because name mangling is done by the compiler, basically. > Is there some rule against initializing private data members inside > an exec function? (aside: "inside an exec function" suggests confusion) Well, it doesn't work, does it? So probably, yes. > Is there an equivalant way of initializing private members? exec 'self._Foo__monty = 1'? Note the parentheses are an anachronism wrt exec. Not using double underscores? Cheers, M. -- This is the fixed point problem again; since all some implementors do is implement the compiler and libraries for compiler writing, the language becomes good at writing compilers and not much else! -- Brian Rogoff, comp.lang.functional From simonmartin at mail105.com Fri Nov 16 04:32:31 2001 From: simonmartin at mail105.com (Simon Martin) Date: Fri, 16 Nov 2001 09:32:31 +0000 Subject: UK Zope developer needed Message-ID: <3BF4DD2F.8135572C@mail105.com> Dear List, Please forgive me if this is inappropriate... I need a really good London/Herts based Zope developer for a very unusual open source project. You'll need good skills along with a real commitment to open source. Solo people only please, no companies and definitely no agencies. More or less immediate start for the right person. Sincerely Simon -- Simon Martin London Uk 020 8386 5828 PGP KEY ID <0xFA69D420> @ *Please note my e-mail address is now 'simonmartin at mail105.com'* From sill at optonline.net Tue Nov 13 21:41:29 2001 From: sill at optonline.net (Andrei Kulakov) Date: Wed, 14 Nov 2001 02:41:29 GMT Subject: Request for Validation of Python as Development Language References: Message-ID: On Mon, 12 Nov 2001 23:19:35 -0500, A. Keyton Weissinger wrote: > Does anyone have a more recent list of commercial products out there that > use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima > Online. I'd like more. > > The information in the books and the python.org site is a bit dated. > > I'm pretty new to the language and I'd like to use it for more stuff at > work. I'm beginning to feel some of the stigma of it being a "scripting > language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for > those who care) and I'd like to introduce Python into the mix. But I say > "scripting language" and people head to the hills yelling "PERL!" which is a > bit disconcerting (especially since I like Perl too, though not as much as > Python). They need to hear "object oriented application development > language" or I need to buck up and realize I'm barking up the wrong tree. > > Thank you! > > Keyton Well, other than the stuff others mentioned already, I think it's impressive that NASA uses python, and it's used in computer animated graphics in movie industry, and widely used in biochemistry, and other sciences. Yahoo and google use it, too. > > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From jmiller at stsci.edu Sat Nov 3 11:02:38 2001 From: jmiller at stsci.edu (Jay Todd Miller) Date: Sat, 03 Nov 2001 11:02:38 -0500 Subject: MMap "access" keyword, choice of exception class Message-ID: <3BE4151E.DE5E96B1@stsci.edu> Hi, I have written (and submitted) a patch which adds a new keyword parameter to mmap: "access". One dubious kind of access which I added for the sake of completeness is "readonly". A readonly mmap maps true OS protected readonly memory and does not update the underlying file. When python detects and attempt to write a readonly mmap, an exception is raised; Is there an obvious choice for what the exception class should be? I need to re-submit the patch for a few stylistic issues anyway, and would like to fix this while I'm at it. Right now, the patch raises ValueError. SystemError and RuntimeError also come to mind. Thanks, Todd From husalwan at sci.kun.nl Wed Nov 14 11:32:19 2001 From: husalwan at sci.kun.nl (husam) Date: Wed, 14 Nov 2001 17:32:19 +0100 Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> <3BED54C2.1010608@sci.kun.nl> <3BEFD59B.9000709@sci.kun.nl> <3BF1163C.9000502@student.kun.nl> <23891c90.0111140819.754d5a51@posting.google.com> Message-ID: <3BF29C93.3070602@sci.kun.nl> Paul Boddie wrote: > husam wrote in message news:<3BF1163C.9000502 at student.kun.nl>... > >>ok, now it's clear. >>thank you all for your contributions. >> > > But we wanted the half hour argument! ;-) > > I'd distinguish between databases and data structures as follows: > > A database is a collection of information stored in a structured > fashion, possibly along with a description of how elements of that > information are related to each other (although that description is > really the database meta-data). An example of a database would be > "software packages registered at The Vaults of Parnassus". > > A data structure is a mechanism for storing information. It dictates > the interface which lets you add, search for, investigate or remove > items of information from the structure. Examples of a data structure > are dictionaries, lists, stacks, trees and so on. > > One might start to argue whether or not a relational database > management system (RDBMS) such as Oracle, PostgreSQL, etc. is an > implementation of a data structure. Therefore, one could add the > following definition: > > A database (management) system is a system which implements data > structures to store information, typically restricting access to those > data structures by providing an abstract interface to the information. > > Therefore, one could regard a database system as being something which > potentially implements a number of data structures (in the case of an > RDBMS, we could consider a "table" as a data structure) with each of > these potentially incorporating other data structures (for an RDBMS > table, this might well involve various kinds of tree data structures). > > Of course, this is a vague discussion of the nomenclature, and out > there on the Internet, there's probably somewhere which lists the > "official" definitions from the "gods of Computer Science and database > theory". > > Paul > ok, lets start talk about which system is faster? imaging that we have 1000000 books. We want to make an interface that allow the user to add a book, its location in the library, author, publishing agent and year of publishing. Imagin that we make to programs, one that stores these informations in a data base system, while the other stores the information in simple dictionary. When two users search for the same query in these programs, which program will retrieve the information faster? From prabhu at aero.iitm.ernet.in Wed Nov 7 22:30:05 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Thu, 8 Nov 2001 09:00:05 +0530 Subject: A smarter(?) package importer. In-Reply-To: References: Message-ID: <15337.64573.258627.582066@monster.linux.in> >>>>> "GMcM" == Gordon McMillan writes: >> Well, I'm not sure it does 3/4 opens but yes it does do 3/4 >> imp.find_modules which will be more expensive than a >> sys.modules[mod_name]. GMcM> It really does do all those opens. If Windows had strace, it GMcM> would be easy to verify. Yes, you are right. find_module does use open underneath. Thanks for the information. write(1, "Importing foo (pkg/sub1/foo.pyc)"..., 37Importing foo (pkg/sub1/foo.pyc)... ) = 37 stat("pkg/sub1/a", 0xbfffe08c) = -1 ENOENT (No such file or directory) open("pkg/sub1/a.so", O_RDONLY) = -1 ENOENT (No such file or directory) open("pkg/sub1/amodule.so", O_RDONLY) = -1 ENOENT (No such file or directory) open("pkg/sub1/a.py", O_RDONLY) = -1 ENOENT (No such file or directory) [snip] GMcM> [back to recursive-relative imports] >> So, I'll ask again, how about making this behaviour standard? >> :) GMcM> I think not. I'd rather see import get less magical than GMcM> more magical. GMcM> If "import" meant "absolute import", and "rimport" meant GMcM> "relative import" (and maybe "rrimport" meant "recursive GMcM> relative import") then all name- masking problems would GMcM> disappear. That sounds ok but this adds 2 more keywords to Python. Anyway, so long as something that handles rr/rimport is added I'm happy. Should I make a request on python-dev about this? prabhu From James_Althoff at i2.com Wed Nov 14 14:40:39 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 14 Nov 2001 11:40:39 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: [mertz at gnosis.cx/Lulu] >Well... here's how Haskell does it: > > [1 .. 4] --> [1,2,3,4] > [4,3 .. 0] --> [4,3,2,1,0] > [2,4 .. 10] --> [2,4,6,8,10] > [0.0,0.3 .. 1.0] --> [0.0,0.3,0.6,0.9] > >It's hard to think of a better syntax for Python to use. [Skip Montanaro] >Though after reading the remainder of the thread, I like the Haskell syntax >best. [Rainer Deyke] >for i in [g() + 0, g() + 1, ... g() + 13]: pass > >How often is 'g' called? Once? 3 times? 14 times? [David Eppstein] My assumption would be that the syntax [x, y, ... z] is equivalent to range(x,z+y-x,y-x). This answers all of your questions: [Tim Hochberg] >So you can use it in your own class if you want. In particular, one could >make > >int[1,3,...,53] act like range(1,53,2) if one wanted. [Gareth McCaughan] > - I agree that Python needs a better way of doing > simple iterations over sequences of numbers. I'm > concerned that if this PEP is accepted then it may > discourage the implementation of something clearer. > > - For all that, the proposal *is* quite elegant, and > the syntax it offers is certainly concise. And if > numbers are going to provide iterators, James has > chosen the right ones. [Jim] The Haskell syntax does seem a nice way to specify some sequences of integers. Rainer points out some possible issues when one uses functions rather than literals in conjunction with said syntax (and David suggests answers). A couple of points: it appears that the Haskell syntax mentioned above assumes a closed interval. This means that in the common case of indexing a sequence, one must remember to subtract 1 from the ending value. E.g., for i in [0 .. len(mysequence)-1]: mysequence[i] Also, it appears that this syntax creates an actual list, not an iterator. So presumably, that leaves unresolved the range/xrange problem (i.e., I have a huge set of indices that I want to iterate through without first having to create a huge list). Getting back to the motivating example of PEP 276 -- as stated in the PEP, adding an iterator to types.IntType would allow one to write: for rowcount in table.getRowCount(): Summarizing some of the other possibilities, one might write: for rowcount in range(table.getRowCount()): # valid in current Python for rowcount in xrange(table.getRowCount()): # valid in current Python for rowcount in [0 .. table.getRowCount()-1]: # new Haskell-esque syntax for rowcount in 0...table.getRowCount(): # new syntax using elipsis for rowcount in [0:table.getRowCount()]: # new syntax proposed in PEP 204 for rowcount in int[0:table.getRowCount()]: # __getslice__ as class method in types.IntType (no new syntax) Stating again that PEP 276 does not propose any new syntax for Python, it should be noted that adding an iterator to types.IntType as proposed in PEP 276 does *not* preclude one from inventing some new syntax for specifying sequences of integers (such as the examples above). (It might lessen the motivation to do so as noted by Gareth. OTOH, decreasing the motivation for adding new syntax might not be such a bad thing ;-) And again, with any proposal for creating sequences of integers, there is the issue of how one specifies the creation of an *iterator* (which is what one actually wants in a for-loop as of Python 2.1) versus the creation of an actualized *list*. PEP 276 addresses this issue specifically. Jim From wurmy at earthlink.net Tue Nov 27 19:28:19 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 28 Nov 2001 00:28:19 GMT Subject: Regular expression References: <6039af6a.0111262123.54806bb7@posting.google.com> <3C032B29.A77DE30@earthlink.net> <9tvbv4$2uo$1@peabody.colorado.edu> <6039af6a.0111271523.38a21fa2@posting.google.com> Message-ID: <3C042F98.E4233C9A@earthlink.net> Sang DeSibtis wrote: > > Fernando P?rez wrote in message news:<9tvbv4$2uo$1 at peabody.colorado.edu>... > > > Sang DeSibtis wrote: > > >> > > >> > > >> Questions: how do I make a global replacements in the 'line' that > > >> read from the file object (buffer in memory? ). > > > > The key thing to understand is that in Python, strings are immutable, so you > > can never do *anything* in place to a string. All string operations return a > > new string, which if you want to work 'in place' you can just reassign to > > your original string: > > > > string = do_whatever(string) > > > > Even string methods don't work in-place: > > > > In [1]: s='abc' > > In [2]: s.replace('a','A') > > Out[2]= 'Abc' > > In [3]: s > > Out[3]= 'abc' > > > > Cheers, > > > > f > > Thanks! It solves my problem and also leads to another one. Isn't the > 'line' on both side of the assingment are using the same memory > address? No no... Python "variables" (they aren't really) do not work in the same way as variables in more traditional languages like C, Pascal or Basic. What looks like assignment in other languages, is in Python the binding of a name to an object: x = 2 creates an object of type integer, with value 2, and binds it to the name "x". It does *not* change the value of a typed variable at a certain memory address. Read this excellent guide for more information: http://w1.132.telia.com/~u13212494/guides/python-objects.htm --Hans From phd at phd.pp.ru Wed Nov 28 04:32:50 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 12:32:50 +0300 Subject: windows to linux pickled objects? In-Reply-To: ; from stephen@theboulets.net on Tue, Nov 27, 2001 at 11:05:08PM -0600 References: Message-ID: <20011128123250.H4239@phd.pp.ru> On Tue, Nov 27, 2001 at 11:05:08PM -0600, Stephen Boulet wrote: > I pickled a list in windows but couldn't open it in linux without first > running the handy dos2unix program on it. Always write binary data to binary files: outfile = open(filename, 'wb') outfile.write(pickle) outfile.close() Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From emile at fenx.com Thu Nov 8 15:15:21 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 12:15:21 -0800 Subject: What does *x mean? References: Message-ID: <9sepe2$13irce$1@ID-11957.news.dfncis.de> "Erann Gat" wrote in message news:gat-0811011133410001 at jansma-mac.jpl.nasa.gov... > I've heard people mention "the new *x syntax". Does Python have a prefix > * operator now? What does it do? (It's not mentioned in the online > language reference at python.org.) Email replies preferred. Thanks! > > Erann gat > gat at jpl.nasa.gov These are references to the ability to pass on function arguments to other functions. For example: ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> def showargs(*args, **kwargs): ... print "args: %s\nkwargs:%s" % (args, kwargs) ... >>> def passargs(*args, **kwargs): ... showargs(*args, **kwargs) ... >>> passargs(1,2,3,a=5,b=6,c=7) args: (1, 2, 3) kwargs:{'b': 6, 'c': 7, 'a': 5} >>> HTH, -- Emile van Sebille emile at fenx.com --------- From sholden at holdenweb.com Thu Nov 29 10:13:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 10:13:00 -0500 Subject: Should I use threads here? References: <83bshmv8yf.fsf@panacea.canonical.org> <6749bb94.0111290612.45c060ac@posting.google.com> Message-ID: "Era Akost" wrote in message news:6749bb94.0111290612.45c060ac at posting.google.com... > Hi again, > > Reading now a new email on the group "Strange Tkinter behaviour" > I realized that probably my problem has to do with the Tkinger widget. > So, I just inserted a > self.text.update() > and the output starts imediately apparing, as I wanted. > The widget is sort of "frized" while the .exe program is still > running (cannot scroll), but perhaps I can arrange that later. > > Anyway, pointing out the difference between readline() and readlines() was > absolutely right from your side. Now that I added .update(), I checked both and > only readline() does what I exptected. > > So, really thanks and sorry for bringing out the question of threads. > I just have to understand better some os stuff. > The usual Python rules apply: don't use [X] unless you need to, where [X] is any complex facility. As the eXtreme Programming community says: do the simplest thing that can possibly work ;-) But as far as being sorry, no need at all. Happy to help. It's these trolls and spam merchants we don't like: honest enquiries always welcome. The mroe you learn, the more c.l.py questions you can answer! regards Steve -- http://www.holdenweb.com/ From geert at cs.uu.nl Thu Nov 8 08:30:38 2001 From: geert at cs.uu.nl (Geert-Jan Giezeman) Date: 8 Nov 2001 13:30:38 GMT Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: <9se1du$6eg$1@samos.cs.uu.nl> >"Oleg Broytmann" wrote in message >news:mailman.1005218719.27461.python-list at python.org... >> On Thu, Nov 08, 2001 at 11:00:52AM +0000, Geert-Jan Giezeman wrote: >> > I am trying to create a shelve from a table of 1100 by 1100 floating >> > point numbers, which I want to store as 1100 lists of length 1100, >> > indexed by a key. Unfortunately, I get an error when I try to create >> > this: >> > bsddb.error; (22, Invalid argument) >> >> http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.099.htp >> This FAQ advises to move to a newer version of the Berkeley DB library. How do I know which version I use? How do I replace it with a newer? (I installed the standard Python 2.1 distribution for Windows). In "Thomas Weholt" writes: >I've experienced this problem if I don't close the db-connection after using >it. Be sure that you call close before ending the script/program. I did that, so that was not the cause of the trouble. From dek at cgl.ucsf.edu Fri Nov 16 01:00:32 2001 From: dek at cgl.ucsf.edu (David Konerding) Date: 16 Nov 2001 06:00:32 GMT Subject: Scientific Libraries in Python References: <9t1iqq$es0$2@peabody.colorado.edu> <3BF45CAF.9983E26A@home.net> <9t1pfj$k1s$1@peabody.colorado.edu> Message-ID: Y'all shoudl take a look at "PyML" which I wrote to interface to mathematica. You can write Mathematica expressions using Python, submit them to the math kernel to be evaluated, and plot results. http://www.mathsource.com/Content/Enhancements/Interfacing/Other/0209-292 It's in sore need of updates, but the basic structure of the tool is good. Dave From rtrocca at libero.it Sun Nov 4 04:12:09 2001 From: rtrocca at libero.it (Riccardo Trocca) Date: Sun, 04 Nov 2001 09:12:09 GMT Subject: COM objects and Python Message-ID: <3BE3F6F5.1020605@libero.it> Hello, just a simple question. I've just started learning some COM and Com under Python concepts. I'd like to know, before going on with Pure Python, if it is possible to create a DirectShow Graph with Python or not. I've made some attempts, but they were fruitless. Do I need to spend more time studying the problem, or switch to writing some extension to Python? Riccardo From justin at iago.org Thu Nov 29 23:09:08 2001 From: justin at iago.org (Justin Sheehy) Date: Thu, 29 Nov 2001 23:09:08 -0500 Subject: Python 2.2: socket.ssl documentation? References: <200111291746.fATHkeY24178@lap1.mtg.at> Message-ID: Andreas Kostyrka writes: > Is there any documentation about the ssl support in the socket module? Yes. > If so where? http://python.sourceforge.net/devel-docs/lib/module-socket.html http://python.sourceforge.net/devel-docs/lib/ssl-objects.html > Does it support writing servers? Sadly, no. As far as I can tell, none of the proposed patches to provide useful SSL server support to Python have yet been accepted. A standard library module capable of being used to build simple SSL servers would be an excellent addition, if done well. -Justin From mertz at gnosis.cx Sun Nov 25 23:01:23 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Sun, 25 Nov 2001 23:01:23 -0500 Subject: 11-15 new Python Books on the way! (fwd) Message-ID: Ron Stephens wrote: |Truly a surfeit of books. But, for what it is worth, I have listed all I |could find out about them all at http://www.awaretek.com/plf.html Ron seems to have done a more complete job than I have (or than I have really tried). But Pythonistas might enjoy looking at my reviews of many Python books for IBM developerWorks (quite a few overlaps with those Ron looked at): http://www-106.ibm.com/developerworks/linux/library/l-pbook2.html http://www-106.ibm.com/developerworks/linux/library/l-cp12.html Yours, David... From huaiyu at gauss.almadan.ibm.com Mon Nov 19 19:48:09 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Tue, 20 Nov 2001 00:48:09 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> <3BF47762.4322913A@engcorp.com> Message-ID: On Mon, 19 Nov 2001 21:58:20 +0000 (UTC), Marcin 'Qrczak' Kowalczyk wrote: >Mon, 19 Nov 2001 20:07:42 +0000 (UTC), Huaiyu Zhu pisze: > >> What would such examples look like? I can only think of cases where the >> problems are caused exactly by (a is b) and (a!=b) both being true. They >> would dissappear if (a is b) implies (a==b). > >They would be hidden, but the buggy implementation of == is still there. >It probably incorrectly says "inequal" also for some a,b where a is not b >but they should be equal. > I see the point now. Interesting debugging technique. Huaiyu From marcoxa at cs.nyu.edu Sun Nov 11 16:44:54 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 11 Nov 2001 16:44:54 -0500 Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: "Morten W. Petersen" writes: > Hello, > > I'm currently doing some research, to see if it could be an advantage to > use Common Lisp instead of Python (currently Python and Zope [1] are used > to build web applications). > > While doing this, Google has provided two interesting documents (search > for 'lisp vs python'): > > http://www.strout.net/python/pythonvslisp.html The above page contains several factual errors about Common Lisp. It is not a good summary and it is misleading, especially about Common Lisp. As such it must be disregarded. > http://www.norvig.com/python-lisp.html This is a very good document, by a person with a very good reputation and who knows what he is talking about. > First off, to save everyone some time, I'm wondering if there are more > papers documenting the difference between the two; if there aren't any, > I'd like to continue the discussion and summarize the findings in a paper > accessible on the net. There are a number of (maybe obscure) advantages to Common Lisp w.r.t. Python. Apart from the existence of very good native compilers, there are a number of nice features - all standard - that allow you to use Common Lisp as a "language kit": something very few other language are good at. Take for example one of the latest additions to Python: list comprehension. This is essentially incorporating regular set-theoretic notation in the language. I.e. to have notation that allows you to say things like {x | even(x) /\ x >= 0 /\ x <= 100} (the set of "numbers" between 0 and 100 - assuming integers or rational, this is a finite, enumerable set). To get this kind of notation into Python (alas a similar one), AFAIU, the (1) parser had to be modified, and (2) the interpreter had to be modified as well. This are not things that (AFAIK) where done in Python itself. In Common Lisp you just changed the "readtable" to recognize the special nature of the characters #\{, #\}, #\[, and #\] (think of Emacs and what it does with characters) and you write a couple of macros. The code is all written in CL and the above example may be rendered as {x / x in (range 0 100) / (evenp x)} This effectively constructs a list of the even integers. All of this is all CL and it is all compiled down to native code. (The above expression "expands" into a LOOP, which is happily compiled by the CL system. The code runs on all CL implementations and it can be used to shorten your programs. Here is a better example of legal CL code constructing a list of the prime numbers from 3 up to `max'. (defun primes (max) [n in (range 3 max 2) / (not (exist m in (range 3 (min (1- n) (+ 2 (sqrt n))) 2) / (= (mod n m) 0)))]) (Note the optional indentation! Of course you can use the INFIX package to write the customary 2 + sqrt(n), but that is just another trick you can do with Common Lisp). Again the above is legal CL (once you load the appropriate 300 lines of code) and it gets compiled to native code. Of course the underlying data structure for "set" is naive, but that is a different problem. Given time you could implement spme hash-indexed B-tree representation for sets and replace with that the guts of the notation rendering. All of that can easily be done in CL. Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From guy.theisen at isp.lu Thu Nov 15 07:46:04 2001 From: guy.theisen at isp.lu (GT) Date: 15 Nov 2001 04:46:04 -0800 Subject: Fork a SocketServer on NT Message-ID: Hi, I'm trying to fork a SocketServer on NT. But I don't know how to do this. The os.fork doesn't work on NT. I have this example from the Echo_server.py in O'Reilly book "Python for Win32". serversock = socket(AF_INET, SOCK_STREAM) serversock.bind((HOST, PORT)) serversock.listen(5) print 'socket listening for connections...' while 1: handlersock, addr = serversock.accept() #now do something with the handler socket print 'SocketServer connected by', addr data = handlersock.recv(1024) handlersock.send(data) handlersock.close() print 'SocketServer closed ...' Can anyone show me how to solve this ..... thanks for any help, GT From mwh at python.net Fri Nov 9 06:56:11 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 9 Nov 2001 11:56:11 GMT Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: "harry" writes: > if you put data into dictionary, how do we calculate the data size? Why do you want to know? It's not usually an interesting question to ask in Python. > key:data > > example: > > dict = {"key1":1,2,3,4; "key2": "hello", [1,2,3]} > how much is the data structure will cost? Err, lets see, a (small) dict is about 9*4 + 8*(3*4) = 124 bytes the four character strings will be about 5*4 + 4 = 24 bytes the list object will be about 30 bytes I think, similar for the tuple. Small integers are preallocated and so cost nothing. So the total for the above object is probably a couple of hundred bytes. I'm not sure how accurate the above is -- and I don't really care -- but it should give you an idea. > how to calculate it? Don't :) Memory is cheap. Cheers, M. -- Never meddle in the affairs of NT. It is slow to boot and quick to crash. -- Stephen Harris -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From peter at engcorp.com Thu Nov 29 00:38:11 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 29 Nov 2001 00:38:11 -0500 Subject: which is best for a singleton, module or class? References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C045C07.BA7B3FE6@engcorp.com> <3C05AE56.E2261313@engcorp.com> <3c05b472$1@207.229.64.20> Message-ID: <3C05C9C3.ADC96FB5@engcorp.com> Peter Bismuti wrote: > > What is best for a singleton, making it a module or a class within a module? > I guess the reason why having a class within a module undesirable is that it > adds to the namespace of the object mymodule.mclass.property instead of > mymodule.property, and so fourth. I know you can import it in a way to > reduce the path length of the object, but still, it seems like a cleaner > coding style to just use the module itself. Opinions? THanks. See http://www.google.com/search?q=python+singleton , especially the second item (Alex's Borg pattern). -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From walter at livinglogic.de Mon Nov 19 12:15:21 2001 From: walter at livinglogic.de (Walter =?ISO-8859-1?Q?D=F6rwald?=) Date: Mon, 19 Nov 2001 18:15:21 +0100 Subject: [Q] Printing color strings on stdout without using escape sequences ? References: <3BF4F588.9010500@edf.fr> <3BF92485.70801@edf.fr> Message-ID: <3BF93E29.3090008@livinglogic.de> Ivan DUTKA-MALEN wrote: > Walter D?rwald wrote: > > >> >> You might want to take a look at ANSIStyle: >> http://www.livinglogic.de/Python/ansistyle/ >> >> HTH, >> Walter D?rwald >> >> > > Yes this package does exactly what I want. Moreover, it is very simple > to use. Thanks! > But it doesn't work on 'old' version of Python (I mean 1.5.2). I tried > to make some change in the source code (not too dificult to understand) > but I've stopped on some internal Python functions (PyObject_DEL or > PyUnicode_check) I think they're only valid in recent release of Python. > I must say that I've never made any C extension to Python The simplest solution would be to upgrade to a newer version of Python. I'm not planning to maintain a 1.5.2 compatible version of ANSIStyle. In fact in the near future ANSIStyle might be ported to Python2.2 and use new style classes. > Do you think it would be a challenge to make it work on version 1.5.2 ? I have a patch that makes it work with Python 1.5.2. Unfortunately your emails bounce (dutka at edf.fr: User unknown) and I don't want to send the patch to the newsgroup. Give me a valid email address and I'll send you the patch. Bye, Walter D?rwald From dale at riverhall.NOTHANKS.co.uk Wed Nov 7 08:59:06 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Wed, 07 Nov 2001 13:59:06 +0000 Subject: Exception holes, again. References: <9s6spi$ksk$1@newsreaderm1.core.theplanet.net> Message-ID: Thanks that looks promising. This whole area is still a dogs breakfast, though. The fact that I have to spend 2 hours hunting around to find out how to catch an exception is a nonsense. -- Dale Strickland-Clark Riverhall Systems Ltd From maj64 at hotmail.com Sun Nov 4 00:32:01 2001 From: maj64 at hotmail.com (Mark J) Date: 3 Nov 2001 21:32:01 -0800 Subject: PEP 237; isinstance(i, integer) Message-ID: In PEP 237, Rationale, point 2, it mentions being able to use "isinstance(i, integer)" which returns true if i is either type int or long. Does anyone know if this is planned for v2.2? I see that it is not yet implemented in v2.2b1. Thanks, Mark From phd at phd.pp.ru Thu Nov 1 03:54:30 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 11:54:30 +0300 Subject: Python.NET, MONO and Visual Studio etc. In-Reply-To: <3BE098FF.4FD7341E@engcorp.com>; from peter@engcorp.com on Wed, Oct 31, 2001 at 07:36:15PM -0500 References: <3BE098FF.4FD7341E@engcorp.com> Message-ID: <20011101115430.D30403@phd.pp.ru> On Wed, Oct 31, 2001 at 07:36:15PM -0500, Peter Hansen wrote: > Oleg Broytmann wrote: > > > > On Wed, Oct 31, 2001 at 12:03:16PM +0100, Xavier Defrang wrote: > > > This is almost off-topic but since you guys are talking about that .NET > > > thing, I'd like just to ask anyone in here : WHAT THE HELL IS .NET??? > > > > > > I don't want any fancy buzzwords or corpspeak crap. I just want a clear, > > > > Among all the bullshit M$ invented there is one good thing: reusable > > components. This is really good. > > You weren't actually suggesting that MS *invented* the concept > of reusable components, were you? > > (I think you must have been referring to the specific reusable > components they invented.) No, I meant they invented far too many buzzwords. And among those buzzwords, and despite those buzzwords - there are good ideas in the .NET. Let us implement those ideas. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From laurent.pointal at laposte.net Wed Nov 21 15:09:36 2001 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 21 Nov 2001 20:09:36 GMT Subject: Still on python GUI toolkit References: <20011120221358.3e520125.use-net@schabi.de> Message-ID: Markus Schaber wrote in news:20011120221358.3e520125.use-net at schabi.de: > Hi, > > Am 20 Nov 2001 18:20:50 GMT schrieb Laurent Pointal: > >> For our futur projects (I work at on beamlines at LURE, Orsay-France), >> we may go to the following architecture (still to be tested and >> evaluated): >> >> >> GUI in Java >> | CORBA ORB for Java (OpenORB or other) >> | >> | >> | CORBA ORB for Python (omniORBpy) >> | >> scripting and processing in Python > > Did you thing about using Jython? You could click the gui objects > together using your favourite RAD tool, and then use this gui out of a > Jython program. I know about Jython, but we need to access C extension module (to interface with libraries dealing with hardware & Co), and I dont think C extension modules are usable with Jython. I've seen a thing named JPE (if I remember), which may be better for our need (a Java VM in Python and a Python VM in Java). But using CORBA is if interest for us (remote control). A+ Laurent. From gbreed at cix.compulink.co.uk Thu Nov 15 09:31:52 2001 From: gbreed at cix.compulink.co.uk (gbreed at cix.compulink.co.uk) Date: Thu, 15 Nov 2001 14:31:52 +0000 (UTC) Subject: PEP 276 Simple Iterator for ints (fwd) References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> Message-ID: <9t0jko$14b$1@thorium.cix.co.uk> Paul Rubin wrote: > 0..5 = 0,1,2,3,4 would be awful. Better would be introduce a new > function, say maxindex(sequence), equal to len(sequence)-1. Then > you'd say > > for i in 0..maxindex(sequence): If you're going to define a new function, how about for i in indices(sequence): or somesuch? Graham From tyler at tylereaves.com Sat Nov 24 20:32:11 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Sun, 25 Nov 2001 01:32:11 GMT Subject: Win98 PySol problem References: Message-ID: > I have commented out these lines in the module but now I have to deal with > the creation of tkutil.pyc and pysol_21.pyc -- I think! > Naw, we got dis new fangled language that does all the hard stuff for us ;) The Python interpreter will create those on the fly. Tyler From sholden at holdenweb.com Fri Nov 9 10:11:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Nov 2001 10:11:47 -0500 Subject: Open a windows database file with a path name? References: Message-ID: "Nomad" wrote ... > Hi, > > Is there anyway that I can open a database (MSAccess in this case) > using the path and file name rather than a DSN? I can't seem to get > it to work. > You can do this with ADO in the win32all extensions, but for ODBC access you have to go through the registered DSNs. Is this what you were asking? regards Steve -- http://www.holdenweb.com/ From fdrake at acm.org Wed Nov 28 02:57:33 2001 From: fdrake at acm.org (Fred L. Drake) Date: Wed, 28 Nov 2001 02:57:33 -0500 (EST) Subject: [development doc updates] Message-ID: <20011128075733.9558928696@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Minor updates; mostly changed organization of the "Internet Data Handling" chapter. From claird at starbase.neosoft.com Tue Nov 13 16:28:51 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Nov 2001 15:28:51 -0600 Subject: Web Services and Python articles References: Message-ID: In article , dW wrote: >Below are some IBM developerWorks article on Web Services developement >with Python. . . . While we're on the subject, is a SOAP-for-Python introduction that's particularly "hands-on". -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From tdelaney at avaya.com Thu Nov 29 17:49:36 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 30 Nov 2001 09:49:36 +1100 Subject: If UR brand spanking new to programming (like me)... Message-ID: > From: Syver Enstad [mailto:syver-en at online.no] > ophiel_magick at yahoo.com (Ophiel Magic) writes: > > > I just started working with Python last week. I have had NO > > programming experience, other than writing macros for Access. > > >I was > > fortunate to find this group and found, through the group, > MANY online > > resources. > > I think very fortunate, this is the best newsgroup I've been to. Very > knowledgeable AND nice people, and no trolls. True, but you need to watch out for vikings and lumberjacks ... Tim Delaney From logiplexsoftware at earthlink.net Wed Nov 7 17:59:51 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 7 Nov 2001 14:59:51 -0800 Subject: identify x,y coordinates in an image In-Reply-To: References: Message-ID: <01110714595100.01343@logiplex1.logiplex.net> On Wednesday 07 November 2001 14:35, Steve Holden wrote: > "Cliff Wells" wrote ... > Well, in my case that should now read "were tab-indentations": see what OE > does to your beautiful tabs -- completely lost, along with the sense of the > code: Ouch. Okay, let's try with spaces: def PILToWX(image): "convert a PIL image to a wxImage" if (image.mode != 'RGB'): image = image.convert('RGB') imageData = image.tostring('raw', 'RGB') imageWx = wxEmptyImage(image.size[0], image.size[1]) imageWx.SetData(imageData) return imageWx def WXToPIL(image, mode = 'RGBA'): "convert a wxImage to a PIL image" imageData = image.GetData() size = (image.GetWidth(), image.GetHeight()) imagePIL = Image.fromstring('RGB', size, imageData) if mode != 'RGB': imagePIL = imagePIL.convert(mode) return imagePIL Good luck, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From antoni3 at otenet.gr Thu Nov 1 05:01:08 2001 From: antoni3 at otenet.gr (Antonios B. Kaklis) Date: Thu, 1 Nov 2001 12:01:08 +0200 Subject: Dictionaries, popitem() method example Message-ID: <9rr6p5$psi$1@usenet.otenet.gr> Hello to everybody... There is something that i' don't understand. In the Python Library Reference, Section 2.1.6 "Mapping Types" It says: "a.popitem( )" --->Note 6: Is useful to destructively iterate over a dictionary as often used in set algorithms! I don't understand 1) what is "Destructively iteration over a dictionary" 2) Set Algotithms Any examples? Thanks Antonis Greece From tatebll at aol.com Mon Nov 5 09:37:53 2001 From: tatebll at aol.com (Bill Tate) Date: 5 Nov 2001 06:37:53 -0800 Subject: Solving Partial Differential equation in Python References: Message-ID: teg at redhat.com (Trond Eivind Glomsr?d wrote in message news:... > Roman Suzi writes: > > > Probably, if you could find library like LAPACK for linear algebra > > and use SWIG to make bindings to C for Python, you will have > > PDE solving functionality in Python. > > LAPACK doesn't do PDEs? Doesn't IMSL? available for C and Fortran. From mwh at python.net Fri Nov 23 05:31:46 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 23 Nov 2001 10:31:46 GMT Subject: Is curses.wrapper standard? References: <3BFE0AE6.8C78E6B@alcyone.com> Message-ID: Erik Max Francis writes: > Is curses.wrapper standard? I've seen it in a few scripts but don't > see any mention of it in the Python library documentation. Well, it's in the standard library if that's what you mean. It seems to have been written by someone who didn't know what finally: statements were for (or indeed argless raise), but I don't think it's going anywhere... Cheers, M. -- People think I'm a nice guy, and the fact is that I'm a scheming, conniving bastard who doesn't care for any hurt feelings or lost hours of work if it just results in what I consider to be a better system. -- Linus Torvalds From logiplexsoftware at earthlink.net Fri Nov 2 15:39:41 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 12:39:41 -0800 Subject: Freeware Python editor In-Reply-To: <9ruu6l09ah@drn.newsguy.com> References: <9ruu6l09ah@drn.newsguy.com> Message-ID: <01110212394103.09296@logiplex1.logiplex.net> On Friday 02 November 2001 12:03, Grant Griffin wrote: [snip] free [snip] free [snip] .... [snip] Since you mentioned the word "free", I'd like to take this moment to disagree with you. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From chinaguide at lycosasia.com Thu Nov 15 16:45:09 2001 From: chinaguide at lycosasia.com (China Financial Guide) Date: Fri, 16 Nov 2001 05:45:09 +0800 Subject: To : python-list@python.org, China Financial Guide 2002 Message-ID: <130519-220011141521459930@lycosasia.com> China Financial Guide 2002 has been published! ======================================= We are glad to inform that we have published "China Financial Guide 2002", which lists down all financial institutions (local and foreign) operating in China. China has emerged as the most important market in Asia. The attractiveness of China market is further enhanced with China joining the World Trade Organization. No organization can afford to ignore this important market in Asia. The vast and untapped China economy provides the best business opportunity and growth engine for your organization. China Financial Guide 2002 gives you the timely and comprehensive directory containing a complete listing of all the local and foreign financial institutions in China. This directory is the key reference guide for both financial and non-financial organizations worldwide that are interested in capturing market shares in China. Organizations, government authorities, financial institutions, multinational companies or any companies that are interested in China will find this guide useful. Whether your organization is searching for local financial partners for tie-up or locating the nearest financial institutions in China for your financing needs, this directory is a must that provides you with all the relevant information. Who needs this directory: ===================== Financial Institutions Key master and reference guide for all your important financial contacts in China. Search for the right local partners in the financial industry. Know who and where other market players have established operations in China. Government / International Bodies Must have directory to guide all your governmental missions and business related assignments. Associations Relevant information for all your members to assist their business development efforts in China Multinational Companies Important contacts and decision makers for marketing your products and services. Key contacts for your financial requirements in China. Libraries / Embassies Key reference materials for users, members and for general enquiries. Exporters, Traders and Manufacturing Companies Assist your company to sell to potential buyers in the financial industry in China. Key contacts for your financial requirements in China. Features of China Financial Guide 2002: ================================ 1200 pages of handy and useful information. 1500 financial institutions. More than 1500 financial institutions covered in the guide. 5000 key contacts. More than 5000 decision makers in the financial industry in China. This bilingual directory consists of useful information on: ? Addresses ? Telephone numbers ? Fax numbers ? Email addresses ? Website / URL ? Key management personnel ? Financial and other information Of all (local and foreign) financial players in China namely: ? Banks ? Exchanges ? Insurance Companies ? Fund Management Companies ? Trust and Securities Companies ? Private Equity and Venture Capital Companies Book Specifications: ================ Title : China Financial Guide 2002, Directory of Local and Foreign Financial Institutions in China ISBN : 981-04-4115-0 CIP/LC : HG3333, 332.102551-dc21, SLS2001026603 Edition : First Edition, 2002 Print Size : A5 Pages : 1,184 pages Cover : Softcopy Binding : Perfect String Binding Selling Price [Total : USD138 per copy] =============================== Selling price of the China Financial Guide 2002: United States Dollar, USD98 per copy + USD40 per copy for global priority shipping and handling charges. [Total: USD138 per copy] Email Enquiry =========== Email : chinaguide at lycosasia.com Order ===== Name:________________________________ Company:_____________________________ Delivery Address:_______________________ Postal Code:___________________________ Telephone:____________________________ Facsimile:_____________________________ Country:______________________________ Email:________________________________ Quantity:______________________________ Total Amount:__________________________ Each copy costs USD98 plus USD40 delivery charges (total USD138). Please email us if your organization is keen to purchase a copy of this guide. Many thanks and regards Raymond From schmidp at o000o.org Wed Nov 14 09:44:06 2001 From: schmidp at o000o.org (Philipp Schmid) Date: Wed, 14 Nov 2001 15:44:06 +0100 Subject: memory leak in python script Message-ID: <1005749457.219815@newsmaster-04.atnet.at> hi, my python2.0.1 script allocates slowly the whole system memory, how can i find out if it's a python bug or if my script is buggy? if its my script, how can i find the cause of the leak? thx philipp From phr-n2001d at nightsong.com Sat Nov 10 01:16:53 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 22:16:53 -0800 Subject: Teaching python (programming) to children References: Message-ID: <7xk7wzb162.fsf@ruckus.brouhaha.com> "Arthur Siegel" writes: > That's great for the folks who don't happen to think Piaget is > at some level horseshit. Happily, a programming language > need not take a position - unless it for some reason chooses to. Piaget's work is considered mainstream and valid these days. I suppose there are people who think it's horseshit, but there are also some who think the earth is flat. > My deepest objection - and why I'm consistently nasty when > getting near this subject - is that it always seems to be the tool in play > < LOGO/MindStorm/Alice, etc and etc> and its creators/advocates > that are hogging center stage. And off in the corner somewhere is > the happy student, and somewhere backstage, a subject matter. I don't think Papert had any particular agenda to use Logo. Logo was just a vehicle that he had available. He could just as happily have used something else if he had it. From mail at andreas-penzel.de Fri Nov 9 04:33:06 2001 From: mail at andreas-penzel.de (Andreas Penzel) Date: Fri, 9 Nov 2001 10:33:06 +0100 Subject: Example for using MySQL Message-ID: <9sg7t8$12a85q$1@ID-69142.news.dfncis.de> Hello NG! Where can I find an example for using MySQL in Python (specially how to connect to the DB)? Thanks, Andreas From tanzer at swing.co.at Tue Nov 13 02:19:09 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Tue, 13 Nov 2001 08:19:09 +0100 Subject: Is this considered black magic? In-Reply-To: Your message of "Mon, 12 Nov 2001 13:33:59 EST." Message-ID: "Scherer, Bill" wrote: > > > UML refers to methods as 'operations', and the uncallable > > > attributes as 'attributes'... > > > > I don't know UML, but I suspect this is a different distinction. Consider: > > > > class Widget: > > def __init__(self, callback): self.callback = callback > > def go(self): return self.callback() > > > > Would a Widget's 'callback' attribute really be considered an 'operation' in > > this context? > > Good point. No, I suspect it wouldn't. It would probably be > indicated on a class diagram via an association to the class > that implements the callback, where it would be an operation. I > don't know what they call that, but I suppose it's a 'delegated > operation' or 'aggregated operation' Too bad that there isn't any class to point at. The very reason for the callback is that you don't want to know which classes implement it. Just another reason why UML sucks <0.1 wink> -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From skip at pobox.com Fri Nov 16 18:10:28 2001 From: skip at pobox.com (Skip Montanaro) Date: 16 Nov 2001 17:10:28 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 16) Message-ID: <44389EABBB991A46.B5ABFFBAB7CF6C0D.99368A29FBB0C368@lp.airnews.net> Two new PEPs hit the streets this week: PEP 275 - Switching on Multiple Values http://python.sourceforge.net/peps/pep-0275.html PEP 276 - Simple Iterator for ints http://python.sourceforge.net/peps/pep-0276.html PEP 275 (Marc-Andre Lemburg) has been a hot topic on python-dev while PEP 276 (James Althoff) has been burning up the wires on comp.lang.python: http://mail.python.org/pipermail/python-dev/2001-November/018526.html http://groups.google.com/groups?th=4834c317087da840 For those of you who know hedgehogs aren't funny looking animals on which you clean your boots before entering the house, Prabhu Ramachandran wraps up an easy-to-install version of VTK-Python: http://groups.google.com/groups?start=25&group=comp.lang.python&selm=mailman.1005849327.21238.python-list%40python.org Whoa! Armin Rego's Psyco reaches version 0.3.2 and he can now double the speed of the pystone benchmark. I think he's onto something folks... http://groups.google.com/groups?th=6bada99c5930c8fa Jonathan Gardner has a VIM module, so you can programmatically control VIM from Python: http://groups.google.com/groups?th=13f2f28c95b560be That old black magic that you weave so well... Laura Creighton asks about introspecting random (food) objects to get an equivalent to map() for methods. She gets several answers. Maybe one is what you've been looking for. http://groups.google.com/groups?th=1644fb0da6d7d0f1 IPC10 is coming, with prestigious keynoters. Mark your calendars. Guido, can you book me into the Lincoln Bedroom? http://groups.google.com/groups?start=125&group=comp.lang.python&selm=mailman.1005681918.28766.python-list%40python.org ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continued Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week, into July 2001. Any volunteers to re-start this valuable series? 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/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html 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 Tenth International Python Conference http://www.python10.org 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://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) 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 dutka at edf.fr Fri Nov 16 06:16:24 2001 From: dutka at edf.fr (Ivan DUTKA-MALEN) Date: Fri, 16 Nov 2001 12:16:24 +0100 Subject: [Q] Printing color strings on stdout without using escape sequences ? Message-ID: <3BF4F588.9010500@edf.fr> Hello, for my application to be a bit more friendly, I want to show some colored strings on the standard output but I don't want to use ugly escape sequence like '\033[1m;' or so... I'd prefer use a module (if one exists) that encapsulate all those things and that allows me to be portable on various Unix-like systems (especialy Linux, Solaris, HP-UX, IRIX). Does anyone know such a module ? For information, I tried to use curses but I think it doesn't make what I want in the sense that it uses the full screen and I just want to use the standard output stream. I may be wrong and I surely misuse it. Some help will be much appreciated :-)). Thanks Ivan -- Ivan DUTKA-MALEN EDF R&D mailto: dutka at cli76al.der.edf.fr mailto: ivan.dutka-malen at edf.fr From max at alcyone.com Thu Nov 1 17:04:25 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 01 Nov 2001 14:04:25 -0800 Subject: Freeware Python editor References: <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> <3BE11391.BF044772@alcyone.com> <3BE18A02.76FE1AB@alcyone.com> Message-ID: <3BE1C6E9.89BCDE7F@alcyone.com> Oleg Broytmann wrote: > I m saying this third or fourth time - it was not a complain, just > a > clarification: the editor is "freeware", but not "free". Look at the Subject of this thread. The original poster _said_ it was freeware. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From headroom02 at gmx.de Wed Nov 14 19:28:47 2001 From: headroom02 at gmx.de (Gernot) Date: Thu, 15 Nov 2001 01:28:47 +0100 Subject: programming logical functions: myand, myor and mynot Message-ID: <9sv2c7$6qa$06$1@news.t-online.com> Hi, I want to implement the functions myand, myor and mynot. They should have the same effect as the known boolean operators and, or and not. The trick is that I am not allowed to use the boolean operators and, or and not. This is what I tried: ----------- x = raw_input("Type something (x): ") y = raw_input("Type something (y): ") def myand(x,y): if bool(x) == 1: if bool(y) == 1: return 1 return 0 if und(x,y) ==1: print "true" else: print "false" -------------- I think, the idea is not that wrong, but anyway, it doesn?t work! It has something to do with "bool (x)", I think. Maybe this is something like a module which i have to "activate" first?? Please give me some hints, I would be very grateful Good Night Gernot From nhodgson at bigpond.net.au Mon Nov 26 16:55:37 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 26 Nov 2001 21:55:37 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> Message-ID: Bill Melcher: > Unfortunately, Python seems to mess up the DOS redirection so that in the > command line above, the '>python.txt' fragment creates the .txt file in C:\ > but the output is not redirected to that file. The ability to specify "| > more" is also crippled by python. I caught the console output by using the > Pause key and typing what I saw into an editor. > > This 'failure' to allow redirection is the reason why I have problems > capturing the stdout and errout using redirection. If I use the Pause key > often enough, maybe I can see at least some of the error messages. :-) Standard error can be captured on Windows 2000 with 2>: python --help 2> p.txt and should be passable through more with 2|: python --help 2| more although the output is too short to see it happen. This worked on some earlier versions of Windows but unsure which or how well. One of the more recent features of my SciTE editor (http://www.scintilla.org/SciTE.html) is to allow typing command lines into the output pane making it easy to retrieve the combined text from the output and error streams. It can't handle running interactive scripts, though. Yet. Neil From richardSPAM at geotek.co.uk Thu Nov 29 04:56:47 2001 From: richardSPAM at geotek.co.uk (Richard Chamberlain) Date: Thu, 29 Nov 2001 09:56:47 -0000 Subject: Does Tk in Python support drog and drop? References: <9u42cv$649h5$1@ID-12869.news.dfncis.de> Message-ID: <7u55u9.4n4.ln@servant.geotek.co.uk> Look for a file called Tkdnd.py in your distribution. It has a fairly basic example of how to implement drag and drop. Richard "Kick" wrote in message news:9u42cv$649h5$1 at ID-12869.news.dfncis.de... > Can anyone give some advice? > > Thank you! > > From barry at zope.com Mon Nov 12 17:32:27 2001 From: barry at zope.com (Barry A. Warsaw) Date: Mon, 12 Nov 2001 17:32:27 -0500 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> Message-ID: <15344.19963.181812.444906@anthem.wooz.org> >>>>> "JH" == Jeremy Hylton writes: JH> I'd rather see the imports be explicit "import root.a.b.c" JH> than "import b.c". Then re-nesting requires all the import JH> statements to be edited. It's more typing and might even JH> require a simple script to do search-and-replace, but it JH> doesn't sound like a prohibitive burden. Note that applications can achieve the same thing without editing code by doing sys.path manipulations. JH> I expect there is more to the issue than just wanting to avoid JH> some extra typing. A short PEP that describes the specific JH> problems being solved and discussing alternatives would help. Indeed. We've been here before (perhaps, several "befores" :). Every time this comes up I get the feeling like there are easy ways to accomplish what you want if you think of the problem differently, or I'm missing something fundamental about the problem, and/or the problem has never been specified identified, or people are trying to solve too many problems at once. Are the needs of application authors different than library authors? -Barry From kathy at airotaxi.net Thu Nov 8 18:20:08 2001 From: kathy at airotaxi.net (kathy) Date: Thu, 08 Nov 2001 18:20:08 -0500 Subject: www.Aerotaxi.net Message-ID: www.Aerotaxi.net From owen at astrono.junkwashington.emu Mon Nov 12 14:06:29 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Mon, 12 Nov 2001 11:06:29 -0800 Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: <9sp6od$17de$1@nntp6.u.washington.edu> I'm not sure about Windows, but in the case of unix and Mac, the IDE is not suitable for Tkinter scripts (due to colliding event loops or similar problems) and you have to use the command-line version instead. If that's your problem, it should be pretty clearly stated in the release notes or some similar documentation. -- Russell In article <4OTH7.461273$ME2.55093623 at typhoon.kc.rr.com>, "Dave Butler" wrote: >I recently began exploring Tkinter programming. I built the following >program based on similar code in a book:... >This simple "app" opens fine and closes when run from a command prompt >(under Win2000). However, when run from PythonWin (win32all build 140) the >app does not close and a few clicks later PythonWin crashes with a MS Visual >C++ runtime error ("abnormal program termination")... From max at alcyone.com Thu Nov 29 13:49:47 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 29 Nov 2001 10:49:47 -0800 Subject: Mass mailing module for Python References: <3c0632ee$0$25408$edfadb0f@dspool01.news.tele.dk> Message-ID: <3C06834B.801A9173@alcyone.com> Max M wrote: > Without having tried it I guess that using a regular mailserver and > then > just sending tons of mails from that, one at a time, wont work either. > Though it would be very easy. Here I am thinking about bouncing mail > and > unavailable mailservers, but I could be wrong. > > Doest anybody have an idea as to how I should approach this in Python? > Has > anybody tried it? If each individual email needs to be personalized, then you're going to have to deliver each individually. If there are 25-40 000 recipients, that means 25-40 000 emails, and so you're going to need a heavy duty mail transfer agent like sendmail to do the job. It's trivial to write a program to generate the personalized emails, but if you want to get anything like reasonable performance you're best off letting sendmail handle the bulk deliveries. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From terabaap at yumpee.org Mon Nov 12 20:46:57 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Tue, 13 Nov 2001 01:46:57 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> Message-ID: <3BF07BC8.3090405@yumpee.org> Cimarron Taylor wrote: > shriek at gmx.co.uk (Stephen) wrote in message news:<97ae44ee.0111111912.14006c7f at posting.google.com>... >>I'm developing a program which sends messages back and forth >>between two servers using sockets. The message format I've >>been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" >> > > Why not save yourself a little coding and just use netstrings? > more info: http://itamarst.org/multiplex > advogato copy: http://www.advogato.org/article/212.html > python code: http://itamarst.org/downloads/multiplex-0.2.tgz > description: http://cr.yp.to/proto/netstrings.txt On a somewhat related note, consider the problem of a cross-platform way of communicating between applications on the same machine (this is in the context of applications exposing some functionality so that they can be scripted in some way). What's a good portable way of doing this? With the added constraint of being general, i.e., a general way of querying and calling methods exposed by arbitrary applications ... - Unix has all kinds of IPC mechanisms, but these won't work on Windows. And vice versa. Dunno about MacOS (X). - I could stick to BSD sockets and cook up my own protocol over UDP/TCP, but then each application has their own protocol which must be learnt. - Using XML-RPC, SOAP or CORBA in some form. These seem very heavyweight for simple inter-application messaging. They also require some sort of registration server/broker to hook up the communicating parties. Gnome and KDE are using CORBA-style protocols for their inter-app messaging, but this is not portable to Windows and I don't want to rely on Gnome/KDE or having a broker running. Basically, we need a portable, light-weight messaging protocol with a simple way of finding out how to connect to an application and calling some of the methods it exposes. Without having to do HTTP and XML and all that stuff that comes with XML-RPC and SOAP. I came across Scarab at http://casbah.org/Scarab/ This is interesting though the project's been abandoned. Any comments? Manoj From emile at fenx.com Wed Nov 14 10:32:07 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 14 Nov 2001 07:32:07 -0800 Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: <9su33o$14kfp9$1@ID-11957.news.dfncis.de> "Huaiyu Zhu" wrote in message news:slrn9v2qc7.1ss.huaiyu at gauss.almadan.ibm.com... > On 12 Nov 2001 23:45:51 -0500, David Bolen wrote: > > >On the non-empirical front, I peeked at the listobject.c source for > >its list_richcompare function and no, there doesn't appear to be any > >shortcut check for having both lists refer to the same object (at > >least in the latest CVS source). It does do the length check (for == > >and !=), but otherwise it's the full recursion with the generic > >comparison applied to each element. > > > >It would be an easy optimization to add, although I'm wondering how > >much benefit typical real-life code would see. > > > > class A: > def __cmp__(a,b): return -1 > > a = [A()]*3 > a == a # returns 0 > a is a # returns 1 > > > Is this intended? Yes, as decreed by the author of class A. I would think that mandating > a is b implies a == b > would make programs easier to read. > Because it's in the class that way, you'd have to assume the author knew what was intended. -- Emile van Sebille emile at fenx.com --------- From prabhu at aero.iitm.ernet.in Tue Nov 13 00:20:03 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 13 Nov 2001 10:50:03 +0530 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <15344.19963.181812.444906@anthem.wooz.org> References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> <15344.19963.181812.444906@anthem.wooz.org> Message-ID: <15344.44419.359241.47222@monster.linux.in> >>>>> "BAW" == Barry A Warsaw writes: JH> I'd rather see the imports be explicit "import root.a.b.c" JH> than "import b.c". Then re-nesting requires all the import JH> statements to be edited. It's more typing and might even JH> require a simple script to do search-and-replace, but it JH> doesn't sound like a prohibitive burden. BAW> Note that applications can achieve the same thing without BAW> editing code by doing sys.path manipulations. Its not the application that I'm concerned about - an application is typically a single/few file(s) and editing them to suit things is certainly not an issue. But editing 100 files inside a package each time the parent changes is nuts. There is another way to get around this by manipulating __path__ inside a sub package. But this leads to the same module being imported several times. This is what I use currently and its evil. :( JH> I expect there is more to the issue than just wanting to avoid JH> some extra typing. A short PEP that describes the specific JH> problems being solved and discussing alternatives would help. BAW> Indeed. We've been here before (perhaps, several "befores" BAW> :). Every time this comes up I get the feeling like there BAW> are easy ways to accomplish what you want if you think of the So do I need to write a PEP? Is there some special formality/format I need to keep in mind? BAW> problem differently, or I'm missing something fundamental BAW> about the problem, and/or the problem has never been BAW> specified identified, or people are trying to solve too many BAW> problems at once. BAW> Are the needs of application authors different than library BAW> authors? I would think so. prabhu From chris.gonnerman at newcenturycomputers.net Thu Nov 1 08:02:42 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 1 Nov 2001 07:02:42 -0600 Subject: starting externel program (win32) References: <3be121cb.89811609@news.easynews.net> Message-ID: <003d01c162d5$7f34b000$0101010a@local> ----- Original Message ----- From: "Marcus Stojek" > Hi, > > from a script I want to start an external program (win32). This should > be done in a way that is equivalent to typing the name and options at > the dos prompt. The program must not be influenced by exiting the > script. > > Do I have to use system(), spawnv() or spawnve() or something else? > Any traps? If it's a non-console Win32 app (i.e. NOTEPAD.EXE) you can do this: os.system("start notepad.exe") Add any parameters to the end of the string. This uses the Win9x/NT4/2K/XP START.EXE program, which in effect is the same as Start, Run. os.spawnv() would be the other way. Read the options; you want to use the no-wait option so the script resumes immediately. > Tanks Yo wecome. From tatebll at aol.com Thu Nov 8 08:42:06 2001 From: tatebll at aol.com (Bill Tate) Date: 8 Nov 2001 05:42:06 -0800 Subject: odbc: how to call a stored function in Oracle References: <25c120d1.0111071216.1947ca09@posting.google.com> Message-ID: Tim Roberts wrote in message news:... > tom.hines at usa.net (Tom Hines) wrote: > > > >Hi. I'm using ActivePython 2.1.212 and MS ODBC driver for Oracle. I > >am able to call a stored procedure that returns a cursor, but I > >haven't been able to figure out how to call a stored function or a > >procedure that has an output parameter. > > I don't think ODBC supports stored procedures returning a value directly. > Only as part of a cursor. > > I also don't know Oracle; it is possible for you to restate that as a > SELECT statement with a constant, one-row result, as in: > > SELECT Call MYPKG.MYFUNC (?) AS result; Tom, I've run into the identical problem in the past. DCOracle is frequently used to accessing stored procedures in Oracle using ZOPE - while I've never used it for this particular problem, it appears to support essentially what amounts to a function call. Someone else perhaps can speak to this directly. In any event, suggest checking out http://www.zope.org/Products/DCOracle/DCOracle.txt - Now if there one for postgre as well - time for google. From sag at hydrosphere.com Tue Nov 27 15:58:10 2001 From: sag at hydrosphere.com (Sue Giller) Date: Tue, 27 Nov 2001 13:58:10 -0700 Subject: sys.prefix in COM Message-ID: <20011127205644562.AAA244@mail.climatedata.com@SUEW2000> Awhile ago I posted a question about why my path was changing when I use a python COM object from VB vs using the object from python. Steve Holden replied that it looked like COM interface wasn't using site.py. I have finally looked into this, and I wonder if there might be a problem in sys.prefix in COM. I am a python wannabe, so I am not sure if the following is expected or what. I created a simple COM object in python that returns the state of sys.prefix, and sys.path. def GetPath(self): import sys prefix = sys.prefix line = "Prefix: " + prefix + ":" for path in sys.path: path = path.replace("\n","") if path != "": line = line + "\n" + path return line If I run a test case in python that makes the COM object using win32com.server.dispatch, it nicely prints out a good sys.prefix and a path. from win32com.client import Dispatch ds = Dispatch("PythonDemos.Utilities") p = ds.GetPath() print p Prefix: C:\Python21: C:\Python21\Pythonwin etc..... However, if I create the COM object in VB6, I get a blank string back for sys.prefix. Set objTester = CreateObject("PythonDemos.Utilities") results = objTester.GetPath ss = "Results are " & results Prefix: : C:\Python21\scripts\com etc..... With the blank prefix, the path has dropped any items that are located via *.pth files in my base python directory, thus loosing things like Numeric that is installed in my c:\python21 directory. I am unsure what exactly sys.prefix should be pointing to (I am assuming it is where my python 'stuff' is installed to; c:\python21 in my case), but I can't believe the string should be blank. Does anyone have any insights into this? I don't want to have to hardwire my base python directory into my various com objects to get them to find these other libraries, etc. I have done that up to now, but I need to make these objects more general so they will work on any python site. Thanks sue From era_akost at yahoo.de Thu Nov 29 04:55:58 2001 From: era_akost at yahoo.de (Era Akost) Date: 29 Nov 2001 01:55:58 -0800 Subject: Should I use threads here? References: <83bshmv8yf.fsf@panacea.canonical.org> Message-ID: <6749bb94.0111290155.5deb0e2c@posting.google.com> > This may be true. But the readline() solution *can't* be any worse, and > might be better. Readlines() will definitely not return until the called > program closes its standard output. Of course, if Era has no access to the > program's source he has no possibility of adjusting its output behavior. > > regards > Steve Hi all, Steve, I tried your suggestion, but that didn't change the situation. Let me explain it again. I have a simple GUI with a button and a text widget. When I click the button, the following fuction is called: def execute(self, command): #command is a string containing the .exe program and its file arguments i, o = os.popen2(command) while 1: line = o.readline() if not line: break self.text.insert(END, line) i.close(), o.close() Now, the button on the GUI remaines clicked for a while (it seems to me all the time that the .exe program is running). And only after that, its output is displayed in the text widget. But this is not the way the .exe program behaves when it runs on its own. During the execution it keeps displaying the results on the console. And this is exactly the behaviour that I'd like for my GUI. Thus, I asked if threads can do something in this case. Only that I don't yet understand how threads work, and so on - therefore I need some help. Again, many thanks Era From peter at engcorp.com Sun Nov 18 02:11:12 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 18 Nov 2001 02:11:12 -0500 Subject: Speed Comparisons: Python vs Java References: Message-ID: <3BF75F10.B049F3E2@engcorp.com> "A. Keyton Weissinger" wrote: > > I've seen some Java/Python comparisons, but none that show side by side > performance tests of any real depth. Has anyone seen any? If so, where? Readily found from a search with - http://www.google.com/search?hl=en&q=comparing+python+java+performance was the following: - http://twistedmatrix.com/users/glyph/rant/python-vs-java.html (most humorous in the relative lengths of the samples) and: - http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf which compares Python, Java, C, C++ and others for a particular string-processing program. Of course, speed of execution usually gets too much attention, and you should probably be more concerned about speed of development, ease of maintenance, and fun, which are all areas where Python wins hands down... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From horatio at qpsf.edu.au Sun Nov 11 20:32:34 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Mon, 12 Nov 2001 11:32:34 +1000 (EST) Subject: Scientific Libraries in Python Message-ID: G'day, I've been looking at SciPy and ScientificPython, and a question occurs: Would it be possible for one to absorb the other so we have a single standard scientific library for Python? There's good stuff in both of them that would be nice to have in _one_ place, and it just seems more Pythonic. Comments about redundant functionality, conflicting philosophies, license incompatibility, and other potential victims^H^H^H^H^H^H^H scientific libraries to be assimilated are welcome. Cheers, AHD From donod at home.com Thu Nov 1 23:20:09 2001 From: donod at home.com (Don O'Donnell) Date: Fri, 02 Nov 2001 04:20:09 GMT Subject: List transpose method References: <3BE1DD41.C58238FE@home.com> <9rsn3s$vjpde$1@ID-11957.news.dfncis.de> Message-ID: <3BE21EED.AD3A150A@home.com> Emile van Sebille wrote: > > "Don O'Donnell" wrote in message > news:3BE1DD41.C58238FE at home.com... > > Tom Harris wrote: > > > > > > Hi, > > > > > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional > guru > > > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I > can > > > only come up with an ugly multiliner. > > > > > >>> lst = [(1,2), (3,4), (5,6)] > > >>> trn = apply(zip, lst) > > >>> trn > > [(1, 3, 5), (2, 4, 6)] > > > > Cheers, > > Don > > Cool. I hadn't realized that zip could be used for more than two sequences. > > -- Yep. Although the zipper metaphor gets a bit streched. -Don From annedemedts at yahoo.com Tue Nov 27 10:19:08 2001 From: annedemedts at yahoo.com (Demedts Anne) Date: Tue, 27 Nov 2001 07:19:08 -0800 (PST) Subject: Python course around Boston Message-ID: <20011127151908.56356.qmail@web12003.mail.yahoo.com> Hi: We are several people in the Boston area interested in taking a course in Python. We are not looking for a one or several days training, but rather an evening course over several months with assignements and practice besides weekly classes. Any pointers appreciated. Anne __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From nicbar at mail.com Tue Nov 13 02:45:43 2001 From: nicbar at mail.com (Nic) Date: 12 Nov 2001 23:45:43 -0800 Subject: Python kernel32 exception on Win9x while using DDE extensions References: <9s85bf$5qd$1@odysseus.uci.kun.nl> Message-ID: "Patrick Vrijlandt" wrote in message news:<9s85bf$5qd$1 at odysseus.uci.kun.nl>... > > I am running on Win98 SE with the latest DCOM installed. > > When I try to run the following script fragment from python.exe or > > pythonw.exe I get a “page fault exception” in > > kernel32.dll > > > > import win32ui > > import dde > > import sys > > > > def send_string(str): > > # ….. > > pass > > > > print "Starting DDE v1.02" > > cESC = chr(27) > > cF11 = cESC + '[23~' > > > > server = dde.CreateServer() > > > > # The problem is in the following line > > server.Create("ERTestClient") > > should be: > server.Create('') > > > conv = dde.CreateConversation(server) > > then: > conv.ConnectTo("ERTestClient", service) # service might be "System" > > > > > while 1: > > str = raw_input("Enter String: ") > > if str == "EXIT": break > > str_all = cF11 + str > > ## send_string(str_all) > > > > print "DONE" > > > > > > > > Thanks > > Nic > > I'm afraid dde leaks memory, but Mark H hasn't confirmed this yet. Think of > this if your app fails after a few thousand dde calls. Thanks for your help. I tried the corrections you suggested but I still get an exception while running the script from python.exe from the command line. The same script works fine inside the pythonwin environment. The problem only occurred on Win9X, on NT and 2000 it works OK. Do anybody know if this a general problem with the windows extensions or only with the DDE? Thanks Nic. From darnold02 at sprynet.com Tue Nov 20 21:46:15 2001 From: darnold02 at sprynet.com (Don Arnold) Date: Wed, 21 Nov 2001 02:46:15 GMT Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> <3bf9f33a.5900599@24.0.228.33> Message-ID: <9tf4fo$fb5$1@nntp9.atl.mindspring.net> Here's the simple code I was trying to run (from 'Programming Python', 2nd ed): from Tkinter import * def quit(): print "Hello, I must be going" # import sys # sys.exit() root.quit() root = Tk() widget = Button(root, text="Hello, event world", command = quit) widget.pack() root.mainloop() When I run it in IDLE, the tk window pops fine. Clicking the button once outputs the message to the interactive window as expected, but doesn't shutdown the tk window. Clicking the button a second time shuts down the tk window, and IDLE along with it. I just found that if I delete(root) in the interactive window before the 2nd click, the tk window closes and I raise a NameError exception on 'root', but at least IDLE stays up and running. If I replace root.quit() with sys.exit(), clicking on the button prompts me with a dialog box that asks if I want to exit altogether. If I answer 'yes', both the tk window and IDLE close (not too surprising). If I answer 'no', the tk window remains up, this traceback is generated: Traceback (most recent call last): File "C:\Python21\mystuff\gui3.py", line 13, in ? root.mainloop() File "j:\idi\windows-x86\ActivePython-2.1.0-210\lib\lib-tk\Tkinter.py", line 933, in mainloop self.tk.quit() File "j:\idi\windows-x86\ActivePython-2.1.0-210\lib\lib-tk\Tkinter.py", line 1290, in __call__ SystemExit and the interactive window is responsive. Once again, clicking the button a second time (without first deleting root) shuts down the whole shooting match. Using either root.quit or sys.exit(), if I forego using my widget button to exit and instead click on the Windows close button, the tk window closes, but IDLE doesn't return to an interactive prompt and I can only exit it by killing it via Task Manager. If I click on my widget button first, and then Windows' close, the tk window closes and IDLE functions normally. I suppose this is an okay workaround, but it isn't very pretty. Sorry for being vague earlier. Hope this helps, Don On 20-Nov-2001, support @ internetdiscovery.com (Mike Clarkson) wrote: > > On Mon, 19 Nov 2001 16:54:51 -0800, "John Roth" > wrote: > > >"Don Arnold" wrote in message > >news:9t9qsb$4nd$1 at slb3.atl.mindspring.net... > >> I'm new to python and am interested in developing apps with Tkinter. > >> However, every IDE I've come across for the Win32 platform experiences > >> lockups/aborts when running Tkinter code. So far I've tried IDLE, > >PythonWin, > >> and WING with little luck. Does anyone know of an IDE that > >successfully > >> executes Tkinter code? > > Don: Can you describe the lockups/aborts when using IDLE? Do you > have a small test program that shows this? It would be very helpful. > > >There's a known problem with Tcl/tk that causes these lockups; > > John: he hasn't described the lockups enough to conclude that, > nor has he said he's running in Win9x using Idle from a console > window using python.exe instead of pythonw.exe (the default). > That's a different problem, that is neither a lockup nor an abort. > > >at least, I assume it's with tcl/tk since it's been discussed > >sporadically > >for quite a while, and the last time, someone said they had seen it in > >a pure tcl/tk environment. > > If anyone said that they were wrong, because in any Tcl <= Tcl 8.3.4 > it is not even possible to load Tk into a running Windows console Tcl. > There is no Tcl equivalent to 'import Tkinter' into a python.exe. > > >I suspect that the long term solution is going to be IBM's anygui > >project. > > If there are lockups and/or aborts using Idle to build Tkinter apps, > they should be diagnosed and solved. It is possible that there is a > problem in the C code for mainloop, and if so, you should be able to > work around this by running your own mainloop in Python: > > self.done = -1 > while self.done < 0: > self.tk.dooneevent(0) > > where your self.quit() method sets self.done to 1. > > Mike. From store_li at sina.com Wed Nov 21 22:41:16 2001 From: store_li at sina.com (Kick) Date: 21 Nov 2001 19:41:16 -0800 Subject: How can I distribute a python program References: <9tgd5i$2fjm5$1@ID-12869.news.dfncis.de> Message-ID: <235a79a1.0111211941.2f4d7083@posting.google.com> Thank you! I will have a look! "maxm" wrote in message news:... > You could probably find something here: > > http://www.google.com/search?q=standalone+python+distribution > > Regards Max M > > "Kick" wrote in message > news:9tgd5i$2fjm5$1 at ID-12869.news.dfncis.de... > > I write a python that import TK and some other packages. What shall I do > if > > I want to distribute this program to my friends who hasn't python > > environment? > > > > Thanks for any help! > > > > Kick > > > > From hungjunglu at yahoo.com Tue Nov 13 17:59:44 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 13 Nov 2001 14:59:44 -0800 Subject: dynamically generating a module Message-ID: <8ef9bea6.0111131459.38f96699@posting.google.com> Hi, Python does have good dynamic features. You can add/remove objects, classes, methods, etc. dynamically. Here is one more challenge: is it possible to create a module on the fly? Suppose I have the ASCII Python source code of a module-to-be, or even better, suppose that I have the compiled byte code of a module-to-be, stored in a Python string. Is there a simple way (meaning not tweaking at C++ level) of making the module-to-be into a real module, without hitting the harddrive? thanks, Hung Jung From frederic.giacometti at arakne.com Wed Nov 14 10:13:06 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Wed, 14 Nov 2001 15:13:06 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> Message-ID: <6SvI7.12665$Sx.4243655@news1.elcjn1.sdca.home.com> "Michael Hudson" wrote in message news:u8zdaodu4.fsf at python.net... > "Frederic Giacometti" writes: > > > "Michael Hudson" wrote in message > > news:uu1w0e0vo.fsf at python.net... > [...] > > > I must be missing something. Can you sketch how, say, socket.send() > > > would be implemented? Would you spawn a new OS thread for every C API > > > call? I'm afraid I don't understand you to this point... > > > > As I mentioned, two thread pools would be maintained. To the extent > > that send() is reentrant on the underlying OS, it would beexecuted > > in one of the threads of the reentrant thread pool. This is the > > 'thread pool' pattern; where threads are kept up (i.e. active) from > > one call to the next. It's a standard pattern and concurrent > > programming algorithm. > > So when Python code executes > > sock.recv(data) > > the interpreter would take a thread form the pool, and in effect say > "here, run this function". Then the interpreter thread would go off > and execute pending Python threads, and when the sock.recv call > returned, it would add the thread that called it back to the set of > pending interpreter threads? (I think this would be easier to discuss > with paper and pencil...) > > What does this buy us again? It still makes writing C code that calls > Python code a bit of a pain, doesn't it? Oh, maybe not. More > thinking required... A possible implementation would consist in using the method flag to mark C python methods/functions to run outside the interpreter thread. This way, the entire function runs in a separate thread. The programmer does not have to explicitely manipulate OS threads at any point; the continuation/OS thread correspondance would be taken care of automatically by the threaded stackless implementation. One would have parallel threads of execution through just continuations. C extensions would run entirely either in a parallel thread, or in the interpreter thread. There would be no more interpreter lock; and when a C thread needs some service by the interpreter, it would just post a continuation to the interpreter scheduler. This will simplify programming when using Python callbacks, too; since the currently active Python continuation would be the continuation active in the thread. From mlh at idi.ntnu.no Thu Nov 1 21:38:58 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 2 Nov 2001 03:38:58 +0100 Subject: doctest/pychecker "problem" Message-ID: <9rt102$n83$1@tyfon.itea.ntnu.no> When using the suggested self-importing mechanism of calling doctest (suggested in the docs), pychecker reacts: Module (foo) imports itself Is there another way to get the current module than to import it? If not, perhaps pychecker shouldn't see it as a problem? I guess there may be a config option for it... -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From sthiyaga at operamail.com Tue Nov 20 23:34:29 2001 From: sthiyaga at operamail.com (Senthilkumar Thiyagarajan) Date: Wed, 21 Nov 2001 04:34:29 GMT Subject: how to seek on remote file Message-ID: <20011120233014.5cf65e0f.sthiyaga@operamail.com> Hi, I was wondering how to seek() on remote files (when connected through ftp or http). The documentation says urllib doesn't support it and for FTP we could do use the REST command to restart at a position (provided the remote server supports restart). Is there a cleaner way to do this? Thanks, Senthil From michael at rcp.co.uk Tue Nov 6 03:17:18 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Tue, 6 Nov 2001 08:17:18 +0000 (UTC) Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Martin von Loewis wrote in news:j4d72xasx0.fsf at informatik.hu-berlin.de: > Michael Abbott writes: > >> Can you describe what you mean by "intrusive" in this context? > > The patches changes nearly everything in the core interpreter, and it > is not clear whether all these changes are really necessary and for > the better. > > It *is* clear that some things just cannot continue to work as they > did. Is just isn't clear (to me) that all the complexity that the > stackless patch adds is really necessary. > ... > > Regards, > Martin Hmm. Sounds tricky. It'd be interesting to find time to take a detailed look; after all, we're only talking about eight .c files and seven .h files, I think. Is there any dialogue with Christian Tismer (the original author) on this now? He seems to have kept quite a detailed commentary on his ideas in the heading to continuationmodule.c, so it may be possible to reconstruct what's going on from there. Umm. Well I for one need to go away and think about this, but let me end with the following question for Python kernel experts: Is the idea of "Stackless Python" fundamentally sound? From luruguaya at yahoo.com Wed Nov 14 12:37:28 2001 From: luruguaya at yahoo.com (Lu Ruguaya) Date: 14 Nov 2001 09:37:28 -0800 Subject: COM server created with py2exe fails if CLSCTX_INPROC_SERVER References: <30f17542.0111130925.713c2aa5@posting.google.com> <9ss1t7$15edub$1@ID-59885.news.dfncis.de> Message-ID: <30f17542.0111140937.74d96c8c@posting.google.com> > Currently you cannot create inproc COM servers with py2exe, point. > > Thomas Ok. Thanks Thomas. Happily I can resolve my problem with LOCAL_SERVERS. Lu. From grey at despair.dmiyu.org Fri Nov 30 16:41:07 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 30 Nov 2001 21:41:07 -0000 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: On Fri, 30 Nov 2001 14:34:34 -0600, Skip Montanaro wrote: > Cut-and-paste has been suggested as a source of problems in Python. I've > also found that not to be a problem, given good editor support for rigidly > moving chunks of code left and right. Python-mode uses C-c > and C-c < to > do this. Works like a champ in those situations where I do cut-and-paste. Vim being >> and << respectively. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From volucris at hotmail.com Tue Nov 20 00:49:16 2001 From: volucris at hotmail.com (Greg Krohn) Date: Mon, 19 Nov 2001 23:49:16 -0600 Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> <3bf9ec62$0$79563$6e49188b@news.goldengate.net> Message-ID: <3bf9ed8c$0$79555$6e49188b@news.goldengate.net> "Greg Krohn" wrote in message news:3bf9ec62$0$79563$6e49188b at news.goldengate.net... > "Brian Geddes" wrote in message > news:9tcobh$qql at news.or.intel.com... > > All - > > > > I've been trying to store/pass information in environment variables in > > Windows 2000, but things aren't working the way I expect them to. The > docs > > state that by making changes to the os.system dictionary, the changes > should > > be carried over in environment space automatically by os.putenv(). > However, > > the following which looks like it should work, does not: > > > > import os > > import sys > > os.system["HELLO"] = "Testing" > > sys.exit() > > > > # Run Python again > > import os > > print os.system["HELLO"] > > Mmm...there's something goofy with that. Are you sure that first one works? > Did you assign something to os.system itself? Try type(os.system). It should > be a function, not a dictionary. > > [Python 2.1.1] > > >>> import os > >>> type(os.system) > > >>> print os.system.__doc__ > system(command) -> exit_status > Execute the command (a string) in a subshell. I think you're looking for os.getenv() and os.putenv(). greg From loewis at informatik.hu-berlin.de Sun Nov 25 07:58:06 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Nov 2001 13:58:06 +0100 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> Message-ID: "Duncan Smith" writes: > I have a lot of code written for a particular application I'm > working on and I've got to the point where I need to access data > from XML files. I will also need to save to XML files. There's > almost too much information available and I'd appreciate any advice. > SAX? DOM? You don't specify what you mean by "accessing", most likely, you will need a tree representation of the document, i.e. the DOM. The only reason *not* to use the DOM would be if the document is too large to fit into memory. > I have the proposed DTD and examples of supposedly valid XML files. The XML > files are apparently well-formed, but (according to XML Spy) not valid. > 'Invalid value for datatype NMTOKENS in attribute INDEXES'. I think the > following are the relevant lines from the DTD and XML respectively. Can > anyone tell me what's wrong? Thanks in advance. Looks like a bug in XML Spy. According to the XML recommendation, an attribute of type NMTOKENS must follow the production Nmtokens ::= Nmtoken (S Nmtoken)* Nmtoken ::= (NameChar)+ NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender S ::= (#x20 | #x9 | #xD | #xA)+ On a shallow glance, the attribute value " 0 0 " does not match this production, since it begins with a space, whereas nmtokens must begin with NameChar. However, this ignores attribute normalization: # Before the value of an attribute is passed to the application or # checked for validity, the XML processor must normalize the attribute # value by applying the algorithm below ... # If the attribute type is not CDATA, then the XML processor must # further process the normalized attribute value by discarding any # leading and trailing space (#x20) characters, and by replacing # sequences of space (#x20) characters by a single space (#x20) # character. HTH, Martin From prabhu at aero.iitm.ernet.in Sun Nov 4 03:30:41 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 4 Nov 2001 14:00:41 +0530 Subject: newbie Tkinter Text widget question In-Reply-To: <3be4f80b$0$432$6e49188b@news.goldengate.net> References: <1103_1004849705@t4q4p0> <3be4f80b$0$432$6e49188b@news.goldengate.net> Message-ID: <15332.64689.598425.959279@monster.linux.in> >>>>> "GK" == Greg Krohn writes: >> I understand that the Text widget has a built in tag called >> 'sel' or >> SEL. The question is how do I find the start and end >> of this (or any other) tags range. The Text class does not >> seem to define GK> Yes, in fact, it does. It's tag_ranges as in GK> Text.tag_ranges(SEL). It returns a tuple like ('row.col', GK> 'row.col'). Sorry I'm not 'exhalted', but I hope this helps. Aaron, just in case you aren't aware of this: http://www.pythonware.com/library/an-introduction-to-tkinter.htm Its an extremely useful guide. Specifically, look at The Text Widget->Methods->Methods for tags. prabhu From peter at engcorp.com Mon Nov 19 20:36:24 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 19 Nov 2001 20:36:24 -0500 Subject: Newbie Q: efficiency of list -> string conversion References: <3BF9A7C9.6D425D0B@earthlink.net> Message-ID: <3BF9B398.FAAD07AF@engcorp.com> Erik Johnson wrote: > > s = "string" > l = list(s) > l.reverse() > > rv = "" > for i in xrange(len(s)): > rv += l[i] > > print rv Assuming the question is "is this the best way to do this?" the answer is a definite "no". First improvement would be to note that the 'for' statement in Python can directly iterate over the items in a sequence. for i in l: rv += i No need for all that 'unpythonic' indexing. Next improvement would be to understand that strings are immutable, which means that rather than *modifying* the string rv each time you 'add' something to it, you are actually creating a new string consisting of the previous contents of rv plus the new character, and deleting the old string, then reassigning the name rv to reference the new string. This sucks. Don't do it. :) Instead, and rather than the more complicated approach of using a special "growable" array to build the string, the simplest approach is simply use the built-in join method which operates on strings: ''.join(l) which takes the string '' (i.e. empty, nothing) and uses it repeatedly between the items in the sequence 'l' resulting in: >>> print ''.join(l) gnirts (which, by the way, is a great name for another GNU project, if there's not already one. 'Gnirts': a good name waiting for reverse engineering to make it an acronym...) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jedi at group6.net Thu Nov 1 12:26:13 2001 From: jedi at group6.net (jedi) Date: Thu, 1 Nov 2001 09:26:13 -0800 Subject: email module In-Reply-To: ; from david@dataovation.com on Thu, Nov 01, 2001 at 03:59:36PM -0800 References: Message-ID: <20011101092612.H96229@group6.net> haven't had much look yet at it myself, but here's the docs for it: http://python.sourceforge.net/devel-docs/lib/module-email.html On Thu, Nov 01, 2001 at 03:59:36PM -0800, David A McInnis wrote: > I am looking for sample code using the new email module for Python 2.2. > Does anyone have some sample code, I am newish to the world of Python. > > Also, I am looking for a phpbuilder.com equivilant for python. Does one > exist? > > Thanks, > David McInnis > > > -- > http://mail.python.org/mailman/listinfo/python-list -- j3di jedi at group6.net http://jedi.group6.net/ Stolen Tag: Linux is Luke FreeBSD is Yoda From emile at fenx.com Sat Nov 3 12:12:17 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 3 Nov 2001 09:12:17 -0800 Subject: String argument -> name of list? References: Message-ID: <9s18r9$v43ie$1@ID-11957.news.dfncis.de> "Gustaf Liljegren" wrote in message news:Xns914EB6E8E8EB7gustaflalgonetse at 195.100.94.182... > I'm making a program for training musical scales. It should for example be > able to ask things like: "What is the name of the sixth chord in the F# > Phrygian scale?". > > I have a list of scale names that looks like this: How about: scales = { 'ionian' :[0, 2, 2, 1, 2, 2, 2], 'dorian' :[0, 2, 1, 2, 2, 2, 1], 'phrygian' :[0, 1, 2, 2, 2, 1, 2], 'lydian' :[0, 2, 2, 2, 1, 2, 2], 'mixolydian' :[0, 2, 2, 1, 2, 2, 1], 'aeolian' :[0, 2, 1, 2, 2, 1, 2], 'locrian' :[0, 1, 2, 2, 1, 2, 2] } > > The program chooses one of the scales randomly, so I may get for example > the string 'dorian' in one session and the string 'locrian' in the next. > import random scale = random.choice(scales.keys()) > Finally, there's a function that should take any of the lists of scale > structures as an argument. Or perhaps it's better if it takes a string > value, but it's currently taking the list. Anyway I choose, the problem is > to make the conversion from a string ('ionian') to the list name (ionian) > to get the scale structure. structure = scales[scale] > > I wonder if it is any simple syntax for converting a string to the name of > a list? Or should I use another structure instead, like a dictionary with > strings + lists, or a list with strings + lists? > > Gustaf HTH, -- Emile van Sebille emile at fenx.com --------- From guy.theisen at isp.lu Fri Nov 16 02:22:32 2001 From: guy.theisen at isp.lu (GT) Date: 15 Nov 2001 23:22:32 -0800 Subject: MultiThread Socket on NT Message-ID: Hi, I have a Simple Thread Socket Server. But if I lunch the Socket Server, and many clients connect to this server, I must wait a long time for an answer. I use in this case a simple Thread. while 1: conn, addr = s.accept() if fail: thread = threading.Thread(target=burp, args=(conn,addr)) thread.start() else: burp(conn,addr) But how can I set up a multithread Socket ? Thanks for any help, GT From peter at engcorp.com Sat Nov 24 21:25:22 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 24 Nov 2001 21:25:22 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> Message-ID: <3C005692.173907B3@engcorp.com> Dave Cinege wrote: > > On Saturday 24 November 2001 9:21, Peter Hansen wrote: > > > Unfortunately, since the definition of a tab is ambiguous and > > inconsistent, > > # ascii tab > ASCII 0/9 is decimal 009, hex 09, octal 011, bits 00001001: called ^I, HT, TAB > Official name: Character Tabulation > Other names: Horizontal Tab, \t > > It's what it's always been for at least 30 years... You really don't actually understand the point everyone is making here, do you? I thought you were just being "in your face" for effect, but now I see you're lost. Yes, the above is what people call a tab. That doesn't say anything about the uses to which people (and software) put it. It is *that* which is ambiguous and inconsistent. Didn't that get through in the dozen other messages on the subject? Or are you currently in a mode where you jump on perhaps-sloppy use of words instead of concentrating on the intended meaning? > > Unfortunately, some people insist on using tabs with tabstop > > sizes other than 8, > > # ascii tabstop > ? > > Do relize this WHOLE TIME you are arguing a term that is only > relevent for a particular (set of) ascii editor? There is no such > thing as a 'tabstop' in the binary world. Tab, tabstop, whatever. There's no "tab" in the binary world either. Just ones and zeros. Once again, the point you missed is that tabs are sometimes treated (by software) in such a way as to advance the cursor other than to the next multiple of 8 (which effect I was calling the tabstop, so I wouldn't get jumped on by people like you for saying tabs represented a fixed 8 spaces). > > In the end, if people mixed tabs which were not the typical > > size > > A tab is a byte == 9. If you have a 'different sized' tab, it's called > a different character, and not a tab! You're quite tiresome. I could have said "if people mixed tabs when their editor was configured to treat them as though they caused the cursor to advance to a position which was not a multiple of the conventional number of spaces", but then that would have confused people. As it is, it seems only you are confused. I strongly suspect, based on your other postings, you are just trolling here, trying in a really obscure way to say that you think discussion of tab "sizes" is just a religious discussion. If that's all you're contributing, consider your point made and please stop the ranting. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From wtanksle at dolphin.openprojects.net Tue Nov 13 18:47:46 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Tue, 13 Nov 2001 23:47:46 GMT Subject: PEP 276 Simple Iterator for ints References: Message-ID: On Tue, 13 Nov 2001 13:31:21 -0800, James_Althoff at i2.com wrote: >PEP: 276 >Title: Simple Iterator for ints It's good to see someone doing useful work here. PEPs are cool. >Issues: > Based on some preliminary discussion on the Python interest > mailing list, the following concerns have been voiced: > - Is it obvious that iter(5) maps to the sequence 0,1,2,3,4? > Response: Given, as noted above, that Python has a strong > convention for indexing sequences starting at 0 and stopping at > (inclusively) the index whose value is one less than the length > of the sequence, it is argued that the proposed sequence is > reasonably intuitive to a Python programmer while being useful > and practical. Strike the part about intuition. Perhaps "consistent" would be strong enough. I'm not sure I like this aspect anyhow. "5" just doesn't seem similar to "0,1,2,3,4". A single integer isn't a range. > - Possible ambiguity > for i in 10: print i > might be mistaken for > for i in (10,): print i > Response: The predicted ambiguity was not readily apparent to > several of the posters. You'll have to do better than that. This is the same problem as issue 1 (immediately above). > - It would be better to reuse the ellipsis literal syntax (...) > Response: Shares disadvantages of other proposals that require > changes to the syntax. Needs more design to determine how it > would handle the general case of start,stop,step, > open/closed/half-closed intervals, etc. Needs a PEP. The last sentance is the only one that matters here. However, I'm curious: what do you mean "reuse"? I've never seen an "ellipsis literal" in Python. Reading through the Python documentation, I see an ellipsis notation for extended slicing, but I'm in the dark as to what it means. (I can guess, but I'd rather see it in print.) I've never seen it in Python code, and the documentation doesn't seem to mention it. > - It would be better to reuse the slicing literal syntax attached > to the int class, e.g., int[0:10] No. I said that would be better to implement __getslice__ as a sequence-returning class method of the int class, e.g. int[0:10]. I'm not interested in proposing syntax changes. I claim that it's better because your method because your method doesn't _look_ like a range and doesn't act like other Python usages. In essence, it makes Python integers behave differently in scalar context versus array context -- and we can't have people comparing us to that OTHER P*** language <0.4 wink>. > Response: Same as previous response. In addition, design > consideration needs to be given to what it would mean if one > uses slicing syntax after some arbitrary class other than class > int. Needs a PEP. Last sentance is still the most important one. The second sentance is nonsense; I don't have to define all possible class reactions to slicing simply because I'm defining one! This is equivalent to someone saying that your PEP is bad because you don't define iter() for all classes. I do, however, fail to define start, stop, and step behavior. For this reason I would propose that the PEP someone else writes for this suggest 'range' behavior, and require a start. -- -William "Billy" Tanksley From loewis at informatik.hu-berlin.de Tue Nov 27 03:33:05 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Tue, 27 Nov 2001 09:33:05 +0100 (MET) Subject: bugs in `gc.get_referents()' In-Reply-To: (message from Zooko on Mon, 26 Nov 2001 18:19:30 -0800) References: Message-ID: <200111270833.fAR8X5Z23184@paros.informatik.hu-berlin.de> > One thing I've figured out is that `gc.get_refer{ent,rer}s()' is > using equality rather than identity testing. I've opened a bug > report on this: [1] Good spotting. This is indeed a serious bug, which could explain a lot of things. I recommend that you try the patch first to see whether any of your observed problems go away with ot. > That does not by itself explain the "wrong referrers reported" > behaviour. It might. What if the "wrong referrers" do indeed refer to objects that compare equal to the referee? If they refer to an object that compares equal to everything, then it is no surprise they show up in every get_referrers result. > Martin von Loewis suggested that "there is a bug in the C type of > the tp_traverse function of [the bogus referrer] object", but this > example shows that this must not be the explanation: > > >>> refs = gc.get_referents([1,[2.3,4,],5,6,[7,8,],[9,]]) > >>> len(refs) > 8 > >>> refs[1] > [, ] > > (I'm pretty sure there is no list anywhere in memory that equals > that argument to `get_referents()'.) If you get this result, it would indicate that the TCPCommsHandler is indeed == to the list of odd numbers. Can you please try whether it is? > And by the way, the following two lines consistently segfault when > used interactively in my running Mojo Nation app (although sometimes > it takes a while to segfault): > > > >>> for i in xrange(2**20): > >>> refs = gc.get_referents({}) Again, this might go away with the patch. get_referents isn't supposed to trigger a garbage collection. However, since we are invoking ==, anything might happen. If a collection happens, and the object being inspected gets collected (or if the generations get re-organized in another funny way), then bad things may happen. > Waiatasecond: if my native code forgets to DECREF, this can't > possibly screw up the gcmodule! There's absolutely no different > between my native code forgetting to DECREF and my native code > actually keeping a live reference (perhaps the only live reference) > to an object. Indeed. If you are saying that only a decref may be missing, and all increfs are placed properly, then this would be no problem > By the way I had a look at the implementation of `get_referrers()' > and I agree that it is simple and looks right. Except for the apparently-not-so-obvious bug that SequenceContains will test for equality, not identity. For the moment, I'm willing to blame everything on that bug :-) Regards, Martin From tim.one at home.com Sun Nov 11 12:59:11 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Nov 2001 12:59:11 -0500 Subject: Is this considered black magic? In-Reply-To: <200111111337.fABDb7eR012232@ratthing-b246.strakt.com> Message-ID: [Laura Creighton] > ... > def foreach(name_key, object_list, *args): > print 'foreach: args are ' + `args` > for object in object_list: > try: > object.__class__.__dict__[name_key](object, *args) > except KeyError: > pass > ... > But is it white, grey, or black magic? Playing with __dict__ is black magic. Playing with getattr() is white magic. Putting too much inside a "try" clause is merely suicidal . From tim.one at home.com Mon Nov 5 19:49:43 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 5 Nov 2001 19:49:43 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message-ID: [John Roth] > The basic sign rules for multiplication are so clear that I don't > really need to repeat them here. If division is the inverse of > multiplication, then the sign rules follow directly. Any definition > of division which does not do that isn't an inverse of multiplication, > but some other operation masquerading under the same name. Are you serious? In a world where 3/4 == 0, how long could any programmer survive believing that integer division and multiplcation are "inverses"? The antecedent is dead on arrival. > This might be a much more useful operation in practice, but > it is confusing to someone who expects the system to behave > the way he was taught in grammer school. I can enumerate a hundred ways in which computer arithmetic confuses beginners, and I bet you could too. It even confuses beginners that, say, 4.00 - 1.00 gets displayed as 3 or 3. instead of 3.00. > In other words, (-i)/j should -(i/j). Newbies "know" too that if i < 0 and j > 0, then i/j < 0 (isn't that one of the "basic sign rules" you're defending?). But-- oops! --*that* one happens to be true of floor division, but not of truncating division. Integer division (whether truncating, flooring, rounding, or what have you) is an information-losing process, and the loss of information kills identities without prejudice. I'm not in favor of crippling a language for real-life use just to save a newbie a few seconds' initial confusion. Besides, newbies are sooooo easy to confuse no matter what you do <0.5 wink>: i j i/j (C99 style) -8 3 -2 -7 3 -2 -6 3 -2 -5 3 -1 -4 3 -1 -3 3 -1 -2 3 0 -1 3 0 0 3 0 1 3 0 2 3 0 3 3 1 4 3 1 5 3 1 6 3 2 7 3 2 8 3 2 Ask your favorite newbie why the quotients -2, -1, 1 and 2 show up 3 times each, but 0 shows up 5 times. I have asked newbies this. The usual reaction is paralysis -- and rote memorization without understanding is a recipe for disaster in programming work. The table for floor division is much more comforting, even to a newbie: i j i/j (Python style) -9 3 -3 -8 3 -3 -7 3 -3 -6 3 -2 -5 3 -2 -4 3 -2 -3 3 -1 -2 3 -1 -1 3 -1 0 3 0 1 3 0 2 3 0 3 3 1 4 3 1 5 3 1 6 3 2 7 3 2 8 3 2 BTW, the "exactly 3 of each quotient" goes a long way toward explaining why floor division is less error-prone in practice (for newbies and experts): the "weird lump" around 0 doesn't exist. Definitions Have Consequences, and that's a vital lesson for computer newbies to learn. too. confusion-isn't-to-be-feared-when-it's-a-sign-of-learning-ly y'rs - tim From johnp at reportlab.com Tue Nov 6 10:42:31 2001 From: johnp at reportlab.com (John Precedo) Date: Tue, 6 Nov 2001 15:42:31 -0000 Subject: [ANNOUNCE] Version 1.10 of the Reportlab toolkit released Message-ID: <1005061365.29602.0.nnrp-14.c29f0489@news.demon.co.uk> Version 1.10 of the Reportlab toolkit has been released. Reportlab is a cross-platform library for generating PDF files from Python, without relying on any third-party tools from Adobe or other vendors. The main feature of this release is the addition of support for Asian fonts, embedding your own Type-1 fonts and using custom encodings. These have been available in our developer CVS snapshots in the past, but are now robust enough to be considered non-experimental. While stable, they will continue to be improved and expanded in the future. Other features include improvements to the graphics/charts subpackage (our growing library of business charting diagrams) including improvements to the shading options for barcharts, and improvements to flags and symbols under graphics/widgets (our reusable widget libraries). The Reportlab library is Open Source (under a FreeBSD-like license), and comes with full documentation (which now covers font embedding in detail and using the new Asian fonts capabilities). Reportlab now allows you to create professional, portable and _international_ documents. Download it from: http://www.reportlab.com/download.html or using anonymous FTP from: ftp://ftp.reportlab.com/ The discussion group for the project is http://www.egroups.com/group/reportlab-users ; subscribe on the web, or send an email to reportlab-users-subscribe at egroups.com with 'Subscribe' in the subject line. -- John Precedo (johnp at reportlab.com) Developer Reportlab Europe Ltd (http://www.reportlab.com) From fperez528 at yahoo.com Wed Nov 28 13:10:23 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 29 Nov 2001 17:38:23 +2328 Subject: Whatever happened to String Interpolation? References: <9u6dbn$nsj$1@peabody.colorado.edu> Message-ID: <9u6kft$5b$1@peabody.colorado.edu> Skip Montanaro wrote: > > fp> I'm a big fan of Ka-Ping Yee's Itpl module (which allows > strings of fp> the form 'the value of x is $x', but I often find > myself not using fp> it so as not to add an extra dependency to > a program I want to keep fp> small. > > I know it's a little more verbose, but what's wrong with > > 'the value of x is %(x)s' % locals() > > (or something similar? As has been demonstrated recently on the > list, you can easily create a dict-like object that allows you to > interpolate complex expressions as well. > Too much to type and visually parse, for one. I've seen the neat tricks to evaluate more complex things, but they're not standard nor obvious (so I bet you 95% of people just create temps with what they need right before the evaluation). A more serious one: dynamic code generation. Just today I had to jump through some annoying hoops (like defining x="'%s'" and y='%' and use those in a string) to generate code that would include % characters but which would first have to be parsed by a %. I know this isn't exactly common, though. I am a big defender of not extending things unless truly needed, and with time I've learned to do things the 'python way', without saying at every corner 'but language_x has this feature!'. But string handling is the one that *constantly* feels kludgy in an otherwise stunningly clean and elegant language. I felt that pep215 had a clean argument, the extension is very orthogonal to the existing features, and can make a lot of code simply a lot cleaner. I feel those are strong arguments. Well, I can keep dreaming... Cheers, f From fardal at coral.phys.uvic.ca Thu Nov 29 19:15:24 2001 From: fardal at coral.phys.uvic.ca (Mark Fardal) Date: 29 Nov 2001 16:15:24 -0800 Subject: Copy operator (was list.remove for Noivces) References: <3C054C58.9961A62@home.net> <3C0694D6.2F143D59@home.net> Message-ID: Chris Barker writes: > A slice of an array is a reference. This is different than a list. Use: > > b = a.copy() Not available in Python 1.5.2, as you feared. Does it behave differently than b = copy.copy(a) ? > If you want a copy. This is, in fact, alluded to in the docs (although > the copy method is not well documented either), but not made very clear. > In the 7th paragraph of "Array Basics" in my copy of the docs, it says: > "functions which return arrays which are simply differnt views of the > same data will in fact share their data" This applies to slices, but I > agree that that is not made clear AT ALL in that section of the docs. Hm, the quoted criterion seems more than slightly circular to me. How does it tell you that copy.copy(a) makes a copy of the data, but a[:] does not? > I would > suggest posting a note to the NumPy list, suggesting an enhancment to > the slicing section of the docs. Will do. > > Also, it is not necessarily clear to me when assignment creates a new > > object (freeing the reference to the old object), and when it modifies > > the old object. > > Assignment always creates a new binding. > ... > What's important here is that assignment always creates a new binding. > Whether a new object is created depends on the operation. It is the "*" > in the previous example that created the new list, not the "=". Okay. Again I think this could be stressed more in the docs. Especially since "augmented assignment" is the official name for operators like *= , and... > Note that *= (and kin) generally does not create a new object for a > mutable type: > >>> a = [1,2,3,4] > >>> b = a > >>> a *= 2 > >>> a > [1, 2, 3, 4, 1, 2, 3, 4] > >>> b > [1, 2, 3, 4, 1, 2, 3, 4] > > This is particularly usefull for Numeric Arrays, and is the reason that > adding the *= operators was not just syntactic sugar. thanks Mark From bvdpoel at uniserve.com Mon Nov 19 13:11:14 2001 From: bvdpoel at uniserve.com (bvdpoel at uniserve.com) Date: Mon, 19 Nov 2001 11:11:14 -0700 Subject: list to list of pairs Message-ID: <3BF94B42.346E96EF@uniserve.com> I've sure I've seen this somewhere...but I can't today... I need to convert a list like [1,2,3,4,5,6] to a list of pairs [[1,2], [3,4], [5,6]]. Isn't there a way to do this with map() or zip()??? -- Bob van der Poel ** Wynndel, British Columbia, CANADA ** EMAIL: bvdpoel at uniserve.com WWW: http://users.uniserve.com/~bvdpoel From James_Althoff at i2.com Wed Nov 28 21:18:43 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 18:18:43 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Peter Hansen wrote: >Or just: > >if not 0 <= index < len(mylist): > print 'index out of range' Right. Which has the added advantage of not repeating index. Or just, just: if not index in len(mylist): # I know, I'm going around in circles Jim From James_Althoff at i2.com Thu Nov 15 15:58:39 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 15 Nov 2001 12:58:39 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: David Eppstein wrote: >Jeff Shannon wrote: > >> Which is exactly why I think that the Haskell-ish syntax is a bad idea. This >> syntax cries out to be a closed interval, and it would be very confusing if >> used as a half-open interval. But that would make it the *only* case of >> Python using a closed interval. I find that inconsistency to be *far* more >> jarring than the use of range(). > >I don't buy this argument. Currently AFAIK the *only* cases of Python >using intervals at all are range() and xrange(), which I've argued are Slicing (when using positive indices) is "half-open interval"-like, also. >unsatisfactory -- what's the point of changing to something better if you >require it to be consistent with the bad solution currently in place? >Don't tell me it's for consistency with C, either -- in C, closed and open >intervals are equally easy. > >Let me see if I can list some likely uses of ranges: > >- Loops over the elements of a sequence. Better handled by "for item in >sequence" or, as someone recently suggested, "for index in >indices(sequence)". With the expansion of Python into new realms -- I'm thinking specifically of Jython here -- I think one must broaden one's view a bit. Jython, for example, makes it seamless to use Java classes and APIs while programming in Python. It is not uncommon in Jython programming to encounter objects that don't follow the conventions of Python's builtins. Neither "for item in sequence:" nor "for index in indices(sequence):", for example, will work with DefaultTableModel. And yet DefaultTableModel follows the convention of indexing -- both for row and column indicies -- using a half-open interval starting at 0. Jim From chasm at galileo.rift Tue Nov 13 16:13:31 2001 From: chasm at galileo.rift (Julian Tibble) Date: 13 Nov 2001 21:13:31 GMT Subject: Just installed wxPython Message-ID: Having played around with Tkinter and not liked it very much, I installed wxPython to see what that was like. This program from the tutorial works fine if I run it as root, and seems to work if I run it as a normal user, but I get an error message on the console: Gtk-WARNING **: Unable to locate loadable module in module_path: "libmac2.so", I have found the file, and the user has read permissions to it. How do I change the path so this module can be found? Thanks, Julian From sholden at holdenweb.com Tue Nov 13 15:24:01 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 15:24:01 -0500 Subject: bool() or similar References: <9srjeu$ijn$1@isp-m-srv06.izb.net> <9srrfr$b3v$1@slb6.atl.mindspring.net> Message-ID: "Andrew Dalke" wrote ... > > Oliver Fromme: > >However, I wonder if there is a good way to convert some- > >thing to a boolean value (0 or 1), given any type of object? > >Such as a bool() function, which works in the same way as > >int() or str(). I.e. it would return 0 when given either > >0, "", an empty sequence or an empty mapping, and 1 other- > >wise. > > >>> for x in (0, 1, 2, (), (1,), ((),), [], ["Q"], "hello", ""): > ... print repr(x), operator.truth(x) > ... > 0 0 > 1 1 > 2 1 > () 0 > (1,) 1 > ((),) 1 > [] 0 > ['Q'] 1 > 'hello' 1 > '' 0 > >>> Oliver: AS a beginner you *might* not spot the need to import the "operator" module to use this code. But I think "not not x" is a very commendable attempt, guaranteed to return the same as operator.truth(). regards Steve -- http://www.holdenweb.com/ From db3l at fitlinxx.com Mon Nov 12 23:34:29 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Nov 2001 23:34:29 -0500 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <97ae44ee.0111121735.ebbca1@posting.google.com> Message-ID: shriek at gmx.co.uk (Stephen) writes: > Just read Dan Bernstein's description. Interesting note about > security considerations using CRLF, which follows on from an > earlier post in this thread. Well, but of course the bug here wasn't really using the CRLF terminator, but the laziness of the programmer in handling the general case of a buffer overflow. And a lazy programmer can cause a security problem in oh so many ways. It's just as easy to discard overflows while watching for a terminator when you run out of buffer space as it is to discard invalid length messages after you've received a length that is too long. And in fact, they have more in common than not, since even in the length counted case, it's going to be up to the receiver to "absorb" the data in the stream that it will be ignoring. So it's really just a question as to when you decide that the message is invalid and needs to be skipped. One could even argue that the delimited case is also a touch more robust in the presence of data corruption. If corruption in the stream affects the delimiter than the receiver (assuming no timeout) will wait indefinitely, but any eventual retransmission from the client will eventually trigger a new recognition of the retransmitted terminator. And then probably throwing away the mess of two packets :-) Whereas, in the length case, corruption of the length field will not only affect the receivers proper reception of the data but will also complicate its ability to resynchronize with the sender for any retransmissions, since it has to "find" the length field again. So in custom protocol formats it can also be helpful to have a magic marker for start of packets that, if present, is quoted in the stream, to aid in any resynchronization. Adding a CRC can't hurt either. Of course, this assumes you aren't opening and tearing down connections for each packet, which in most cases is a lot of overhead. -- -- 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 philh at comuno.freeserve.co.uk Tue Nov 13 11:07:56 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 13 Nov 2001 16:07:56 +0000 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <2b326e2e.0111130531.7a85a0b8@posting.google.com> Message-ID: On 13 Nov 2001 05:31:35 -0800, Steven Rumbalski wrote: >Michael 'Mickey' Lauer wrote in message news:<3beedf26 at nntp.server.uni-frankfurt.de>... >> Given this approach, the main question I'm currently trying to >> figure out is: What application shall I present? It must be complicated >> enough to show some advanced topics (not only presenting a tour of >> the widgets and voila...) but at the same time small enough to cover >> it within 50 pages or so (remember: for each toolkit!). >> >> I first thought of some contact application - in outlook style - or >> some kind of presentation program - powerpoint style - ... here's a plea >> for your input. >> >> What do you think would be a good application to show the basics and a few >> more sophisticated topics in programming GUI applications with Python? > >My $.02: > >How about a simple text editor? Most widget sets have a text editor widget, so this wouldn't be a particularly useful example. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From chris.gonnerman at newcenturycomputers.net Wed Nov 14 08:27:34 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Wed, 14 Nov 2001 07:27:34 -0600 Subject: Configure Python CGI failed References: <9st2pt$158u4s$1@ID-12869.news.dfncis.de> Message-ID: <005001c16d10$2429ad60$0101010a@local> ----- Original Message ----- From: "Kick" > I use the follwing envioment to run pythin CGI: > > Windows 98 > Apache 1.3.22 > Active Python 2.11 > > I change the document root setting to my own directory. And add ExecCGI > option to that directory description. finally I changed AddHandle statement > to .cgi .py. So far, so good... > When I try to execute a program located in my document root, the IE said > "Internel Error" First of all, you should REALLY post the entire error message (cut and paste is marvelous). I suspect I know which message you are referring to, though... You need to find out where Apache is keeping it's error log (httpd.error_log to be precise) and read it. Most likely your Python script is dumping a traceback and it's going into the error log. From jonathan.gilligan at vanderbilt.edu Tue Nov 13 16:28:29 2001 From: jonathan.gilligan at vanderbilt.edu (Jonathan M. Gilligan) Date: Tue, 13 Nov 2001 15:28:29 -0600 Subject: Tracking memory leaks References: <9srvk5$e8o$1@news.vanderbilt.edu> Message-ID: <9ss39u$eo8$1@news.vanderbilt.edu> Thanks. gc.garbage is empty, but gc.collect with set_debug(DEBUG_STATS) reports tens of thousands of items in generation 3. Sounds like a reference-counting bug, but I am only using Numpy 20.1 and calldll, both of which are widely used, so I would be surprised if there were a reference-counting bug in one of them. I instrumented calldll's membuf object and rebuilt it to trace object creation and destruction and to maintain a linked list of all membuf objects currently extant, and I find no leaks there. Perhaps the calldll part or else Numpy, but as I say, too many people use Numpy for me to believe that it really leaks megabytes per minute from internal flaws (as opposed to me being too ignorant to use it properly). "Neil Schemenauer" wrote in message news:mailman.1005684557.2452.python-list at python.org... > Jonathan M. Gilligan wrote: > Make sure there are no objects in the gc.garbage list. If there are > then you have objects with __del__ methods that are involved in a > reference cycle. If there are not, then you've most likely got a > reference counting bug somewhere. From google at thegoldensun.com Sun Nov 18 06:14:46 2001 From: google at thegoldensun.com (HW) Date: 18 Nov 2001 03:14:46 -0800 Subject: MySQLdb undefined symbol Message-ID: <62e69c0c.0111180314.37cc1486@posting.google.com> Hello, I get the following error when I try to import MySQLdb: >>> import MySQLdb Traceback (most recent call last): File "", line 1, in ? File "/home/clairvision/local/lib/python2.1/site-packages/MySQLdb/__init__.py", line 27, in ? import _mysql ImportError: /home/clairvision/local/lib/python2.1/site-packages/_mysql.so: undefined symbol: mysql_field_count >>> Red Hat 6.2, python 2.1.1, MySQLdb 0.9.1 Any ideas? Cheers, Harlan From fredrik at pythonware.com Thu Nov 22 14:31:19 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 22 Nov 2001 19:31:19 GMT Subject: Newbie needs "interface" References: <3BFD2536.7B4AFFC6@irisa.fr> Message-ID: Roberto Bonato wrote: > I'm writing a function that implements an algorithm and that > prints intermediate results all along the (usually very long) > computation. Sometimes I want the results to be written on the stdout, > sometimes on a Tkinter Text widget, sometimes to a file. I feel the need > of something like a Java Interface with a method "write" to wrap all > such devices into. in python, interfaces are informal, so all you have to do is to create something with a "write" method. for example: import Tkinter class TextWithWrite(Tkinter.Text): def write(self, string): self.insert(Tkinter.END, string) self.see(Tkinter.END) self.update_idletasks() # redraw me if print_to_file: outfile = open(myfile, "w") else: w = TextWithWrite(master) w.pack() outfile = w print >>outfile, "something" print >>outfile, "something else" From LLoeffler at home.com Wed Nov 28 13:26:26 2001 From: LLoeffler at home.com (Luke) Date: Wed, 28 Nov 2001 12:26:26 -0600 Subject: Super-newbie needs help! References: <70c31206.0111280950.7ebe06ae@posting.google.com> Message-ID: <3C052C52.7070802@home.com> > total = 100 > sum = input ("Enter your number.") > while sum < total: > print "You haven't reached 100 yet!" > sum = input ("give me another number") + sum Worked for me! Your version shouldn't matter. Restart the python console to clean out any gunk from past sessions that may be messing up your variables without you knowing it. Good luck. From phr-n2001d at nightsong.com Fri Nov 2 15:55:13 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 12:55:13 -0800 Subject: simple eval question References: <1f5252d4.0111021241.643efe1e@posting.google.com> Message-ID: <7xlmhoc2q6.fsf@ruckus.brouhaha.com> nbecker at fred.net (N Becker) writes: > What is wrong with this? > > eval ("print \"hello\"') Unbalanced quotes. You began the string with a double quote and ended it with a single quote. Did you mean eval ('print \"hello\"') ? From aeoo at myspamrealbox.com Fri Nov 2 01:48:57 2001 From: aeoo at myspamrealbox.com (Leo Lipelis) Date: Fri, 02 Nov 2001 01:48:57 -0500 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> Message-ID: On Thu, 01 Nov 2001 22:03:42 -0500, Paul Rubin wrote: > "Leo Lipelis" writes: >> I'd like some help with an issue I have with Python. Simply put, I >> think having an exception mechanism is a waste if there is no tool that >> will let you know which unhandled exceptions exist at point foo.... >> >> Considering that in Python exceptions are matched by identity instead >> of equivalence, it's possible to track all the exception flows, right? > > Of course not. Since you can execute arbitrary strings, you can create > new exception classes at runtime and throw them. This is a non-argument. It's like saying, you can access anything with a pointer in C, thus you shouldn't use any tools that can warn you about possible segfaults. It's nonsense. Just because you can dynamically execute dynamically created strings with unknown exceptions doesn't mean it's good to do so. In 99.99% of Python code, the exceptions that are thrown are well known in advance. Even dynamically executed strings are really not so dynamic, because, for example, they are often scripts that could be exception-checked prior to execution. > >> I agree with whoever said that a race horse doesn't belong in the glue >> factory. It seems like Python is being used for serious programming, >> and it seems to me, if it supports exceptions, it should support them >> all the way. It's fairly pointless to provide exceptions if you really >> never know whether you handle all the relevant exceptions or not, >> without the ugly, bad, and stupid except: foo() statements to catch >> *all* exceptions. > > I don't understand the problem. The whole idea of an exception is it's > something you don't have to know how to deal with. You catch the This is simply wrong. That's not the idea. The whole idea of exceptions is that you will know 99.99% of the time which exceptions you should handle, so that you can intelligently decide where to handle them, or whether to handle them at all, and how to handle them. This decision is impossible if you don't know what is being thrown at a certain point. In reality, there is no reason why you shouldn't know it. Then, you can deal with various exceptions differently. For some, you can just log them and keep going. For others, you may request the user to try again. For yet others you can attempt automatic recovery. All this is impossible if you don't know what exceptions you're dealing with. > exceptions you can handle, and leave the rest for higher levels of the > program. You can always catch all the exceptions, and then if you get > something you can't deal with, re-raise it. This is also nonsense. Sure you can catch all exceptions and examine them. But in order to code anything intelligent, you again have to know ahead of time what these exceptions might be. At the very *LEAST* you need a list of *all possible* exceptions in an entire Python code base, including Python standard module library! But how much better would it be if you could narrow the scope to the most likely exceptions. except: # foo is not bound here... because I am catching ALL exceptions if (not self.__canHandleException(foo)): # what is foo? raise foo # and how can you re-raise it here? what is foo? ... def __canHandleException(foo): if type(foo) == BlahType: # ahh, but you have to know about BlahType! return 1 elif type(foo) == BuzType: # again, you have to know about BuzType! return 1 elif type(foo) == OtherType: # and how do you know about OtherType? return 1 else: return 0 The above is not very smart and in fact, I don't even know how to reference the exception object when you use catch-all "except:". Even if it can be done, it doesn't accomplish anything. I'd much rather read this: except BlahType: self.__handleBlahError() except BuzType: self.__handleBuzError() except OtherType: self.__handleOtherError() But, no matter how you write it, you *still have to know* what exceptions you need to handle. You can't magically decide it at run time, nor do you need to, nor should you. The dynamic nature of Python is absolutely not a reason for such a lucklaster handling of exceptions in Python. Let's get this argument out of the way, because I don't think it's even worth discussing further, unless someone can demonstrate that in 99.99% of cases you really can't possibly know what exceptions you should handle anyway. Again, just because it's possible to use the language in a twisted way, doesn't mean that the other 99.99% of exceptions should be penalized by not having a tool that automatically warns you about unhandled exceptions. The very uncommon case where someone decides to create and throw random exceptions, just for fun, should not be protected or used as an excuse to deny us the very useful service of warning about unhandled exceptions. Nor should this excuse be used to diminish the importance of such a tool. I say that without such a tool, exceptions in Python are pointless at worst, and are very awkward to use at best. Documentation is *not* the answer, and I already explained why not in my original post. From peter at engcorp.com Wed Nov 28 02:05:48 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 02:05:48 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> Message-ID: <3C048CCC.6A8C3743@engcorp.com> David Eppstein wrote: > > Peter Hansen wrote: > > > But range() can be looked up. You can type range(5) at the interactive > > prompt (where a newbie would live) and see [0, 1, 2, 3, 4] and infer > > immediately that you are stepping through the items one at a time. > > Typing 0 <= i < 5 at the prompt gives you either 0 or 1, or NameError: > > name 'i' is not defined. Not helpful for a newbie. > > How would the newbie know to type "range(5)" instead of "i in range(5)"? Try both. One works... > > (Note: I'm not exactly interested in dumbing a language down to the > > point where anyone can understand it without learning something from a > > tutorial or the reference. > > When you phrase it that way, I'm not either -- what does it mean to dumb > down a language? I thought someone might object to my continued reference to newbies. The "dumbing down" part comes from guessing that if there was an objection to focusing on newbies when it comes to evaluating a suggested feature like this, the accusation would likely include those terms. Didn't refer to anything specific in this case... either yours or mine might be considered more "dumbed down" by this hypothetical objector. :) > -- but I would be interested in changes that allow > non-Python-literate programmers to understand my code without having to > dig through a manual. I agree that sounds like a worthy goal. I disagree that your suggestion is any more likely to be understood by anyone, other than perhaps a mathematician. As a very experienced programmer, I found it quite obscure and am unsure I would have figured it out were it not for the context of recent threads on the subject. Maybe we should look back to BASIC (for i = 1 to 5: next) or one of the suggestions for something which looks more explicitly like a list of items (for i in [0..5]) or (for i in [0, 1, .. 5] ). Especially this latter would definitely be understandable to anyone, IMHO. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From barry at zope.com Fri Nov 16 14:38:44 2001 From: barry at zope.com (Barry A. Warsaw) Date: 16 Nov 2001 14:38:44 -0500 Subject: How much is set in stone? References: Message-ID: >>>>> "TP" == Tim Peters writes: TP> On the bright side of darkness , not all of cPickle got TP> documented. We'll try to repair that for 2.2. In particular, TP> you can set a find_global attribute on a cPickle Unpickler to TP> supply your own function for resolving names, and of special TP> interest is that if you set it to None, the Unpickler won't TP> import modules or unpickle class instances at all. You could, TP> of course, also supply a function that accetps only a set of TP> blessed names (etc). And pickle users can override the load_global() method on the Unpickler to do something similar, although it's a bit more painful. All documented in the freshly minted pickle docs for 2.2b2. :) -Barry From shalehperry at home.com Fri Nov 16 22:32:20 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 16 Nov 2001 19:32:20 -0800 (PST) Subject: html rendering question In-Reply-To: <1005963048.324574@ferrari.mikka.net.au> Message-ID: On 16-Nov-2001 Mark Hatherly wrote: > Hi, in my html variable 'playerhtml' I am trying to set the width attribute > of a table to width="80%". However, my call to that variable results in the > interpreter not recognizing what it sees as %". Is there a way setting my > table to 80% of the browsr window without taking away the double quotes? > if you place a 'r' before a string, python does not look at the contents at all. so width = r"80%" or even thing = r"\\\\\\\\" # you get 8 backslashes From peter at engcorp.com Fri Nov 16 22:24:19 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 16 Nov 2001 22:24:19 -0500 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> <9t1uce$5d8$1@nntp1-cm.news.eni.net> <9t2ija$qtl$1@slb5.atl.mindspring.net> Message-ID: <3BF5D863.52B0389C@engcorp.com> Christopher Barber wrote: > > "Matt Gerrans" writes: > > > Well, one simple solution is to continue to discuss it here for another 17 > > months or so and we'll have doubled the performance without a single change > > to the interpreter, via Moore's Law (unless it is repealed by then). :-) > > My computer is already over 17 months old and it doesn't appear to be running > any faster. ;-) If you haven't already performed the common Windows->Linux optimization procedure, you're in luck! You can catch up to Moore's Law, and probably pass it for a while! :-) -reduce-windows-reuse-old-486s-recycle-with-linux-ly yr's ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fardal at coral.phys.uvic.ca Wed Nov 28 03:14:29 2001 From: fardal at coral.phys.uvic.ca (Mark Fardal) Date: 28 Nov 2001 00:14:29 -0800 Subject: reading tabular data Message-ID: Hi, what do people use when they want to read in long tabular files into a (NumPy) array? I have only tried Scientific.IO.readArray and read_ascii from Nick Bower's PYDL. read_ascii is very simple and needs some work to be robust, but it was much faster than readArray for the example I tried. Is there something else I should know about? I can imagine there are tradeoffs between speed and generality. (I.e., do you want to preserve types of the columns, control over comment characters, are strings read in as well, etc.) Usually I would prefer speed over generality, as my input files are usually very simple. thanks, Mark Fardal University of Victoria From m.faassen at vet.uu.nl Fri Nov 23 14:31:00 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Nov 2001 19:31:00 GMT Subject: Python execution speed References: Message-ID: <9tm85k$atu$2@newshost.accu.uu.nl> Martin von Loewis wrote: > "Morten W. Petersen" writes: >> 1. What is the plan for psyco (inclusion in the standard >> distribution, etc) ? > Here is what I think should/will happen: > * Psyco needs more help. Poor Armin is trying to get people > interested, but nothing happens. I guess this is *also* an aspect of > free software: Even if you follow the rules (publish early, publish > often), success is not guaranteed. Does he have a mailing list? I looked for one briefly but could find nothing obvious. He needs a mailing list. :) > However, it may be that he'll give up one day if there isn't more > interest in his work beyond people posting "looks cool" in a > newsgroup... Agreed, which would be a major shame. So far I'm one of the 'looks cool' folks, I'm afraid. [snip other good points] Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From carole_valentin at yahoo.fr Thu Nov 1 12:36:18 2001 From: carole_valentin at yahoo.fr (=?iso-8859-1?q?carole=20valentin?=) Date: Thu, 1 Nov 2001 18:36:18 +0100 (CET) Subject: Problem with imported variable Message-ID: <20011101173618.50987.qmail@web14105.mail.yahoo.com> Hello! I have a little question: I have 2 classes "Class1" and "Class2" and several functions in each class. The Class1 is in the file "File1" and the Class2 is in another file "File2". At the beginning of the File1, I import the File2: from File2 import * In the Class2, I create a variable with a specific value. When the program is running, I modify the value of this variable in the other class (Class1) and then I want to read the new value of the variable farther in the code of the Class2. The problem is that the value does not change in the File2 (Class2). Moreover, as the 2 classes are not in the same files, the global statement does not change the problem. Does someone have an idea? Thanks for your help! Carole. ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran?ais ! Yahoo! Courrier : http://courrier.yahoo.fr From trafficnow-subscribe at topica.com Sat Nov 17 10:52:24 2001 From: trafficnow-subscribe at topica.com (welcome) Date: Sat, 17 Nov 2001 09:52:24 -0600 Subject: Your New Account Info Message-ID: Your E-mail Address Removal/Deletion Instructions at the end of this email: We visited your site and thought the following might benefit you. Dear Advertiser: VnetFind.Com is currently achieving over 1,000,000 hits a month! We had been a meta search engine for quite sometime and just recently went to paid rankings (pay per click)! Most of our search terms are still available for only $.01! And with our Amazing Bonuses of up to 800% you could get highly targeted search engine traffic for as little as $.001 per unique visitor! You have nothing to lose and everything to gain! You pay only for traffic you receive NO OTHER FEES, NO MONTHLY MINIMUMS! Check out what VnetFind.Com has to offer! List your site now and VnetFind.Com will give you: Traffic - We deliver hundreds of thousands of searches every month. Targeting - Directly connect with specific audiences through custom titles and descriptions. Cost effectiveness - Pay when targeted customers click through to your site. Control - Choose how much to pay for each visitor. Easy account management - Get 24 hours a day, 7 days a week account access at Vnetfind.Com Free Money- VnetFind.Com will match your deposit with up to an 800% bonus! When you put in the promo code MPT1310 YOU WILL get $10 free just for signing up plus the following bonuses on deposits! Deposit $10 USD into your account and receive a 100% Bonus ($20 in your account) Deposit $25 USD into your account and receive a 500% Bonus ($150 in your account) Deposit $50 USD into your account and receive a 600% Bonus ($350 in your account) Deposit $100 USD into your account and receive a 700% Bonus ($800 in your account) Deposit $200 USD into your account and receive a 800% Bonus($1800 in your account) Within minutes you can place your site in our top rated search engine and be receiving highly targeted traffic for only pennies a click. Here are the details: We are a bid-for-placement search engine. You bid a certain number of cents you are willing to pay to have people come to your site. The more you pay, the higher you appear in our search. The best part is that you only pay for traffic you receive ... there are no other fees! Register for an account it's easy and only takes a few minutes! Deposit funds into your VnetFind account via check order or by credit card. Select the keywords you wish to place your site under. For example, if you run a site that sells rare coins, you might choose the keywords "rare coins" or "shillings". Create a description of your site for the keywords you chose. Choose how much you wish to pay per click for your sites link. The more you are willing to pay, the higher you will appear in our search engine. You will only be charged for traffic you receive. If you are paying .01 cents per click and receive 8 unique clicks, your account will be debited .08 cents. If a visitor clicks on your entry multiple times in the same day, you will only be charged once. We have special systems in place to make sure that you are only charged for unique clicks and not overcharged. You can request any remaining funds be returned to you at any time and there are no membership fees to use our service! That's it! You will begin receiving highly targeted search engine traffic for as little as $.001 per visitor in no time! Remember this is a special offer and you MUST enter the promo code MPT1310 to receive your bonuses! Thanks and Good Luck! Jennifer C Account Manager $$$$$$$$$$$$$$$$$$$-REMOVAL INSTRUCTION-$$$$$$$$$$ This message is sent in compliance of the new email Bill HR 1910. Under Bill HR 1910 passed by the 106th US Congress on May 24, 1999, this message cannot be considered SPAM as long as I include a valid return address and the way to be removed. ONCE AGAIN THIS IS NOT SPAM. PLEASE IF YOU WANT TO BE REMOVED SEND AN E-MAIL WITH "REMOVE" IN THE SUBJECT TO THE FOLLOWING ADDRESS: removeme at vnetdirect.com From printers at sendme.cz Tue Nov 13 06:20:19 2001 From: printers at sendme.cz (A) Date: Tue, 13 Nov 2001 12:20:19 +0100 Subject: ISP with Python script hosting Message-ID: <3BF11003.20941.6D8133@localhost> Hi, Does anyone know about 1.an ISP who hosts Python scripts? 2.a service where I can upload a program (about 8MB) and people could download that program. Thank you for reply. Ladislav From justin at iago.org Thu Nov 29 21:40:19 2001 From: justin at iago.org (Justin Sheehy) Date: Thu, 29 Nov 2001 21:40:19 -0500 Subject: extracting a pattern using RE In-Reply-To: ("Peoter Veliki"'s message of "Thu, 29 Nov 2001 17:02:11 -0800") References: Message-ID: "Peoter Veliki" writes: > In perl you can use variables within regular expressions to extract > patterns, something like this: > > string ~= /\((.*)\)/g > > pattern = $1 > > Probably not correct, but it is attempting to extract text > surrounded by parenthes > > if string equals '(hello)', pattern would equal 'hello'. How can > this be done in Python? >>> matchobj = re.search('\((.*)\)', '(hello)') >>> res = matchobj.groups()[0] >>> res 'hello' > I also am having problems with recursive patterns, what if I want to > do the same thing with string = '(hello (there))' , I want to be > able to extract both 'hello (there)' and 'there'. Since regular expressions can't count, they aren't so handy when trying to analyze nested structure. However, if your only need is extracting from parentheses, writing a little parser that would return the strings you want would be quite straightforward. -Justin From Bill.Scherer at VerizonWireless.com Mon Nov 12 13:33:59 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Mon, 12 Nov 2001 13:33:59 -0500 (EST) Subject: Is this considered black magic? In-Reply-To: Message-ID: On Mon, 12 Nov 2001, Rainer Deyke wrote: > "Scherer, Bill" wrote in message > news:mailman.1005585556.28492.python-list at python.org... > > > > On Mon, 12 Nov 2001 17:02:38 +0100, Laura Creighton > wrote: > > (snip) > > >I have a new problem. I've just lost a major amount of precision in my > > >language usage. What is the collective noun for 'attributes that aren't > > >methods (you can't call them)'? > > > > UML refers to methods as 'operations', and the uncallable > > attributes as 'attributes'... > > I don't know UML, but I suspect this is a different distinction. Consider: > > class Widget: > def __init__(self, callback): self.callback = callback > def go(self): return self.callback() > > Would a Widget's 'callback' attribute really be considered an 'operation' in > this context? Good point. No, I suspect it wouldn't. It would probably be indicated on a class diagram via an association to the class that implements the callback, where it would be an operation. I don't know what they call that, but I suppose it's a 'delegated operation' or 'aggregated operation' > -- > Rainer Deyke (root at rainerdeyke.com) > Shareware computer games - http://rainerdeyke.com > "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor > > > -- Bill.Scherer at Verizon Wireless RHCE 807101044903581 From eyal at hyperroll.com Wed Nov 28 17:04:11 2001 From: eyal at hyperroll.com (Eyal Lotem) Date: Thu, 29 Nov 2001 00:04:11 +0200 Subject: Perl to Python References: Message-ID: <3c055e44@news.bezeqint.net> > #!/usr/bin/perl #!/usr/bin/python > #Setting some environment variables. > $ENV{UDBCINI}="~openlinksw/bin/udbc.ini"; > $ENV{ODBCINI}="~openlinksw/bin/odbc.ini"; > $ENV{ODBCINSTINI}="~openlinksw/bin/odbcinst.ini"; > $ENV{LD_LIBRARY_PATH}="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib"; > $ENV{SHLIB_PATH}="$ENV{SHLIB_PATH}:~openlinksw/lib"; > $ENV{PATH}="$ENV{PATH}:~openlinksw/bin:~openlinksw/samples/ODBC"; #Setting some environment variables. os.environ["UDBCINI"]="~openlinksw/bin/udbc.ini" os.environ["ODBCINI"]="~openlinksw/bin/odbc.ini" os.environ["ODBCINSTINI"]="~openlinksw/bin/odbcinst.ini" os.environ["LD_LIBRARY_PATH"]="$ENV{LD_LIBRARY_PATH}:~openlinksw/lib" os.environ["SHLIB_PATH"]="$ENV{SHLIB_PATH}:~openlinksw/lib" os.environ["PATH"]="$ENV{PATH}:~openlinksw/bin:~openlinksw/samples/ODBC" > #SQL query that runs qryModelSNforWeb in the warranty Access database. > $sql = "echo \"select * from ;\" | > odbctest DSN="; > #SQL query that runs qryModelSNforWeb in the warranty Access database. import odbc # isntead of running odbctest, use the odbc Python module result = odbc.odbc().cursor().exec() > if (open(SQL, "$sql |")) { > chomp(@rawdata = ); > } # instead of chomping the reuslt, just print it as a tuple print result # should be a tuple of the reuslts, iirc You will need to get the odbc module, but I'm pretty sure this is how I recall it works. Hope it helps. From phr-n2001d at nightsong.com Thu Nov 22 12:02:54 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 22 Nov 2001 09:02:54 -0800 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: <7xbshuivr5.fsf@ruckus.brouhaha.com> "the Spinning Spider" writes: > I notice there doesn't seem to be much mention about PHP by Python people > whenever they mention other languages, > e.g.,see http://www.python.org/doc/Comparisons.html. > > Or is it because PHP is incomparable against Python? > ... PHP is generally thought of as a web page template system rather than a general purpose programming language. It's quite simple to learn and use--simpler than Python in my opinion, especially if you're already used to some languages with a C-like syntax. However, PHP doesn't do as much as Python. Python tries to make difficult things easy while making easy things stay fairly easy. PHP isn't so great for difficult things but makes easy things very very easy. Java isn't so bad for difficult things, but it makes easy things difficult ;-). Anyway, yes, PHP is great if you're trying to write dynamic web pages that fit a certain implementation style. Python has a slightly steeper learning curve but is more flexible. From cjw at sympatico.ca Sat Nov 17 20:03:11 2001 From: cjw at sympatico.ca (Colin J. Williams) Date: Sat, 17 Nov 2001 20:03:11 -0500 Subject: Module dbi Message-ID: <3BF708CF.B43D32F2@sympatico.ca> An HTML attachment was scrubbed... URL: From tim.leeuwvander at nl.unisys.com Mon Nov 5 16:58:15 2001 From: tim.leeuwvander at nl.unisys.com (Leeuw van der, Tim) Date: Mon, 5 Nov 2001 16:58:15 -0500 Subject: no setuid for CGI scripts? Message-ID: SETUID - scripts are usually disallowed for security - reasons. If there's a script, be it python, perl, shell or whatever, that can be run setuid, the interpreter can generally be coaxed into running arbitrary code. Not something you want. Therefore, a lot of unices disallow it. I believe that there is a special setuid - perl. Do you really *need* setuid? Is there no other way to achieve what you need to do? --Tim -----Original Message----- From: NOSpawnPAM at lightspawn.org [mailto:NOSpawnPAM at lightspawn.org] Sent: maandag 5 november 2001 12:49 To: python-list at python.org Subject: no setuid for CGI scripts? I'm trying to convert a few simple CGI scripts from Perl to Python, and was shocked to learn that the Python interpreter silently ignores the setuid bit. I really don't know how to get around this. Since the server is hosted remotely I can't recompile python to allow setuid, and I can't make my files world read/writable - I need my python CGIs to run with MY uid. I read somewhere about using a wrapper C program but it seems really convoluted, as well as requiring a different wrapper for each CGI. Is there any solution, or should I stick to / am I stuck with Perl? -- http://mail.python.org/mailman/listinfo/python-list From thomas.heller at ion-tof.com Thu Nov 29 08:10:49 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 29 Nov 2001 14:10:49 +0100 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <9u5d00$6aald$1@ID-59885.news.dfncis.de> "Laura Creighton" wrote in message news:mailman.1007037345.11725.python-list at python.org... > Does anybody have any favourite alternatives to CVS? I'm constantly > looking for something which is not file oriented, or which is better > able to handle multiple people editing the same file on the same day. > Just a way to insist 'I just moved that class into its own file. > Nobody gets to reinsert their old hacked versions of this class _back_ > into this file -- if you are changing this class you now need _that file_' > would be incredibly useful. Sometimes I hear some rumour about Perforce, but I never tried it. Thomas From emile at fenx.com Thu Nov 8 20:51:00 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 17:51:00 -0800 Subject: Gratuitous post References: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> Message-ID: <9sfd3g$12j0d7$1@ID-11957.news.dfncis.de> Hitler! -- Emile van Sebille emile at fenx.com --------- "Steve Holden" wrote in message news:_OEG7.910$Yh.66599 at atlpnn01.usenetserver.com... > Free software. > > missing-oleg-ly y'rs - steve > -- > http://www.holdenweb.com/ > > > > From thomas at gatsoft.no Tue Nov 6 09:43:08 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Tue, 06 Nov 2001 14:43:08 GMT Subject: PDF->Text converter/extractor References: <3be6fa21$1@sol.wohnheim.uni-ulm.de> <3be70a38$0$15115$626a54ce@news.free.fr> Message-ID: <0GSF7.115$Gm2.179080192@news.telia.no> Please put that script on Parnassus or somewhere similar. It would be very helpful to alot of people it seems. "Bruno Li?nard" wrote in message news:3be70a38$0$15115$626a54ce at news.free.fr... > I had written a script some time ago to extract directly from PDF file, it's > quite easy . As I had a very large volume of text to extract (some giga of > text), I now use PDFTOTEXT which comes with XPDF. I slighly modify for my > needs. If you are interested, I will look for the script in my archives > > Bruno Lienard > > "Igor Stroh" a ?crit dans le message news: > 3be6fa21$1 at sol.wohnheim.uni-ulm.de... > > Hi there, > > > > has someone ever tried to extract text from a PDF with python? > > So far, there are 2 alternatives, but none of them satisfies my needs > > (GPL license (or the like), speed and reliability): > > 1) Using pdftotext (Xpdf) with usual files > > 2) Using commerical PageCatcher from reportlab.com (1000 bucks per > > license lol) directly in a python script (no files opened) > > > > though I didnt find anything yet, perhaps there is someone who already > > had the same problem and solved it by writing an own PDF parser? :) I'm > > too lazy to start reading the specs of PDF and try to write the thingy by > > myself :) > > > > TIA, > > Igor > > From david at dataovation.com Mon Nov 5 11:45:04 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 5 Nov 2001 08:45:04 -0800 Subject: MySQLdb Question In-Reply-To: Message-ID: Great. That was it. Thanks, David -----Original Message----- From: Skip Montanaro [mailto:montanaro at tttech.com] Sent: Monday, November 05, 2001 8:22 AM To: david at dataovation.com Cc: Python Subject: Re: MySQLdb Question David> Can anyone tell me why I need to connect twice in order to set David> cursorclass=MySQLdb.cursors.DictCursor? David> If I try to include this argument the first time, I get an error. David> The only way I can get it to work without the error is to David> recreate the connection object a second time like this. It works for me. Is it perhaps because you didn't import MySQLdb.cursors in your code before creating the connection (and that the first connection you created did that import for you)? Try this: import MySQLdb, MySQLdb.cursors db1 = MySQLdb.connect(user = config.user, passwd=config.passwd, host=config.host, db = "prweb", cursorclass=MySQLdb.cursors.DictCursor) -- Skip Montanaro (skip at pobox.com) From piers at cs.su.oz.au Tue Nov 27 20:04:52 2001 From: piers at cs.su.oz.au (Piers Lauder) Date: Wed, 28 Nov 2001 12:04:52 +1100 Subject: imaplib send problem on BSD-style OSs References: <200111272151.AKM05515@mail.mirapoint.com> Message-ID: <1006909495.43.127677440@cs.usyd.edu.au> On Tue, 27 Nov 2001 13:50:47 -0800, Douglas Wiegley wrote: > > Hello. I'm not sure if this is the right place to address > this email, so please let me know if I should be sending this > elsewhere (found your email address at the top of imaplib.py). > > Having a slight problem with the imaplib.append() function > with large messages. Basically, this line: > > 636: self.sock.send('%s%s' % (data, CRLF)) > > doesn't always write all of the data and instead returns a > number of bytes that is less than what you give it (similar > to unix send()). I ended up needing a small while loop that > calls send multiple times to ensure that all the data is > sent... > > This is on FreeBSD 4.3. Please let me know if I'm doing > something wrong... > > doug No, it's a bug/feature in the socket module - hopefully fixed in a future release. For an immediate work-around, sub-class IMAP4 and override with the following version of send: import imaplib class IMAP4(imaplib.IMAP4): def send(self, data): """Send data to remote.""" bytes = len(data) while bytes > 0: sent = self.sock.send(data) if sent == bytes: break # avoid copy data = data[sent:] bytes = bytes - sent Hope that helps... From cliechti at gmx.net Fri Nov 9 15:32:13 2001 From: cliechti at gmx.net (Chris Liechti) Date: 9 Nov 2001 22:32:13 +0200 Subject: Strange __str__ behavior References: Message-ID: [posted and mailed] brucehapman at hotmail.com (brucehapman at hotmail.com) wrote in news:baf2f841.0111091141.7a104b10 at posting.google.com: > I am defining a class w/ method __str__. If I put a print statement > inside __str__, and if I then use the print statement to display an > instance of the class, I get an extra space in the output. > ... > I would think that case 1 applies here. Am I wrong? Does the print > statement in __str__ somehow know that the print statement in the main > program has or will print characters to stdout? Perhaps the "output > system" knows that one print statement (the outer print statement) has > executed or is executing, so the second (inner) print statement causes > the output system to print a space.... sounds logic for me > > Is this the expected behavior? I was surprised by this. > > TIA, > b. > > P.S. I want to include a print statement in __str__ not for practical > purposes, but for mostly didactic purposes when teaching someone > inheritance. workaround 1: print to sys.stderr workaround 2: use a log class: >>> class Log: ... def __init__(self, file): ... self.file = file ... def msg(self, s): ... self.file.write('MESSY %s\n'%s) ... def warning(self, s): ... self.file.write('WARNING %s\n'%s) ... def error(self, s): ... self.file.write('ERROR %s\n'%s) ... >>> log = Log(sys.stderr) >>> class Test: ... def __str__(self): ... log.msg("Hello") ... return "Value" ... >>> t = Test() >>> print t MESSY Hello Value you can also print to a file (or TCP port, or Window, or ...). You can also add priorities to the messages, or write them to NIL in the final version. This aproach is more powerful and saved me a lot of time on debugging (i have a more complete log class, if you're interested) writing to files has also the advantage of not to obfuscate the console output. (add a flush() after each write() so that you can look at the file while ist still open) -- Chris From mwh at python.net Fri Nov 9 11:04:11 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 9 Nov 2001 16:04:11 GMT Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin writes: > Really the ellipsis should make an iterator: for i in 0...10. It's probably worth reading the rejected pep on range literals: http://python.sourceforge.net/peps/pep-0204.html Cheers, M. -- I would hereby duly point you at the website for the current pedal powered submarine world underwater speed record, except I've lost the URL. -- Callas, cam.misc From tatebll at aol.com Tue Nov 13 07:33:01 2001 From: tatebll at aol.com (Bill Tate) Date: 13 Nov 2001 04:33:01 -0800 Subject: C-extension in Python -- returning results References: Message-ID: deoradh at yahoo.com (Keith Farmer) wrote in message news:... > "Delaney, Timothy" wrote in message news:... > > > Don't even think about it ... the braces are *always* there by the time I > > start writing the enclosed code, properly indented. > > I used to be that way, too. Hell, I just finished (not long ago) > converting an atrocious amount of Tcl to J2EE. You'd think I'd have > noticed it. > > ... Bless Python ... > > Now to test that the numbers actually match what they should be. Keith - now that was an interesting problem. Since you've found the source of your problem this may be moot but I would definitely second Jive's suggestion to consider using a neural network for this problem - I suspect you would find it works pretty well. As someone who was trained in classical Newtonian mechanics, I'm reluctant to admit it but these adaptive techniques (including genetic algorithms) seem to work pretty well. From huaiyu at gauss.almadan.ibm.com Tue Nov 20 19:22:11 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 21 Nov 2001 00:22:11 +0000 (UTC) Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> <9tdhon$aht52$1@hades.rz.uni-sb.de> Message-ID: On 20 Nov 2001 12:19:35 GMT, Uwe Schmitt wrote: >I'd prefer indexing from one, because it's the notion used in >mathematics, most existing algorithms are formulated this way. Mathematicians do not really care about whether the index starts with zero or one. They just need some index, which could start from 42 if you want. But when they do care, such as defining the axioms of natural numbers, they seem to prefer starting from zero as well. In programming, the indices are not just labels, because you actually loop over them. If you do not do indexing explicitly, it really does not matter to you. If you do a lot of index calculations, you'll find starting from zero is much easier. My experience is that translating algorithms to start indexing at zero is not a big deal, and it helps a lot when debugging code. I initially learned programming in Fortran, but when I learned C later it felt much more natural. I guess some other people might feel the same way too. Huaiyu From dswegen at allstor-sw.co.uk Wed Nov 14 12:38:22 2001 From: dswegen at allstor-sw.co.uk (Dave Swegen) Date: Wed, 14 Nov 2001 17:38:22 +0000 Subject: File Permission in Unix In-Reply-To: <00e601c16d2e$5fef0e30$6192003e@rashome> References: <00e601c16d2e$5fef0e30$6192003e@rashome> Message-ID: <20011114173822.E29464@software.plasmon> On Wed, Nov 14, 2001 at 07:04:07PM +0200, Amit Weisman wrote: > Hi > How do one creates a file with specified permissions (e.g. , 777) within > Python ? os.chmod is your friend. Use os.chown to change ownership of a file. Cheers Dave From graeme at saebex.com Thu Nov 29 07:11:27 2001 From: graeme at saebex.com (Graeme Longman) Date: Thu, 29 Nov 2001 14:11:27 +0200 Subject: HOWTO: Programming S/MIME in Python with M2Crypto In-Reply-To: <200111272204.fARM4h336438@bigboy.bizarsoftware.com.au> Message-ID: Hi, Please could you let me know exactly how you got this working. Is the sendsmime() method you refer to the same one that is given in the HOWTO ? Or is there another smime method which is part of the python package ? I've been trying to get the examples in the HOWTO to work with Netscape Messenger and haven't been able to. Your help is appreciated. Graeme -----Original Message----- From: Richard Jones [mailto:richard at bizarsoftware.com.au] Sent: 28 November 2001 00:05 To: Ng Pheng Siong; Graeme Longman Cc: python Subject: Re: HOWTO: Programming S/MIME in Python with M2Crypto On Wednesday 28 November 2001 03:02, Ng Pheng Siong wrote: > On Tue, Nov 27, 2001 at 08:48:44AM +0200, Graeme Longman wrote: > > I know that in the HOWTO you don't actually send the example in 'Sign' > > but have you managed to send and receive this example. If you have > > successfully then maybe it is the 'Outlook' issue. > > The function sendsmime() in sendsmime.py works: I've used this to send to > Netscape Messenger successfully. sendsmime() sends plain, signed, encrypted > or signed-and-encrypted mail. I remember being quite pleased with myself > when I got that done. ;-) The only caveat that we've found is that you can send a multipart e-mail with an encrypted part to Netscape, but not to Outlook. Outlook _only_ handles the entire message, one part, being encrypted. Richard From mgerrans at ix.netcom.com Wed Nov 14 21:01:54 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Wed, 14 Nov 2001 18:01:54 -0800 Subject: How program a particilar algorithm ? References: <9sua59$3lh$1@wanadoo.fr> Message-ID: <9sv7pd$5hl$1@slb5.atl.mindspring.net> > > I want to generate all possible lists with elements from another one. For > > example, from a list like [1,2,3,4] i want to program an algorithm which > > will give this result > > > [[1,2],[1,3],[1,4],[1,2,3],[1,2,4],[1,3,4],[1,2,3,4],[2,3],[2,4],[2,3,4],[3, > > 4]] > > Haven't you forgotten [1], [2], [3] and [4]? And don't forget poor little [ ]. - mfg From rwest at opti.cgi.net Thu Nov 15 13:56:49 2001 From: rwest at opti.cgi.net (Richard West) Date: Thu, 15 Nov 2001 18:56:49 GMT Subject: PIDDLE/SPING?? Message-ID: <7d38vt0br1abnvg30j9lettstbq6lh5k89@4ax.com> I was looking into PIDDLE today and it seems the only web address I could find is a little out dated: http://piddle.sourceforge.net/ Under the status section it reads, "with the 1.0 stable release coming soon (4th quarter 2000 is the current best guess)". And the link to the PIDDLE mailing list doesn't appear to work any longer. Is this a dead project? Are there any alternative competing projects? Does anyone know if this will work bug free under Python 2.1 or 2.2, and the latest version of PIL? Or do I just not have the latest web address? -Rich From bernie at pacific.net.hk Fri Nov 30 06:54:42 2001 From: bernie at pacific.net.hk (Bernie) Date: Fri, 30 Nov 2001 11:54:42 GMT Subject: A modest indentation proposal References: Message-ID: <3C0773C2.A12D0BAC@pacific.net.hk> Hi All, The indentation rule employed by Python is actually, IMO, one of the main reason why Python code are so readable. The first time I saw this type of indentation technique was in Miranda, back in my school days. Have not seen it used anywhere else since then, until I found Python. Erann, I think you find the indentation annoying because you choose 2 spaces as your tab size, hence making the block not as apparent as it could be. Try four spaces, or use Tools/Scripts/pindent.py if you really cannot stand it. Bernie Erann Gat wrote: > > The subject of syntactically-significant indentation seems to dominate a > lot of discussions on Python. Personally I've found it to be less of a > problem than I thought it would be, but annoying nonetheless. It also IMO > makes the language unsuitable for mission-critical applications. It's > just too easy to screw up indentation (particularly when cutting and > pasting large blocks of code) without realizing it. > > I have a suggestion for how to make people like me who are uneasy with > syntactically significant indentation feel more comfortable while at the > same time not alienating those who thing that it's a really cool feature. > The proposal is based on the observation that Python already has the > equivalent of an open-brace for code blocks. It's the colon. To see that > this is so you have only to observe that a good editor can automatically > indent code properly at the beginnings of blocks, but not at the end. The > solution to the problem is to add an optional end-of-block identifier. > > I propose to use a semicolon at the end of a line to denote the end of a > block, e.g.: > > for i in l: # Colon signals beginning of block > foo() > baz(); boff() # Semicolon separating statements works as usual > bar(); # Semicolon at end of line signals end of block > biff() > > This convention is 100% backwards-compatible with current practice, that > is, code written using this convention runs with no problems in Python as > it currently stands. > > What I would like to see in terms of support for this convention from the > Python community is two things: > > 1) Editor support for this convention so that a semicolon at the end of a > line causes the editor to unindent, and > > 2) Parser support. It would be enough to simply give a warning if there > is a discrepancy between the block structure defined by indentation and > that defined by the semicolon-at-end-of-line convention (i.e. "Warning: > end of block detected without trailing semicolon"). Making this optional > so that die-hard indentation fans could turn it off would also be fine. > > Comments? > > Erann Gat > gat at jpl.nasa.gov From jdavis at empires.org Sat Nov 3 02:17:51 2001 From: jdavis at empires.org (Jeff Davis) Date: Fri, 02 Nov 2001 23:17:51 -0800 Subject: http session module Message-ID: <9s05ru$br7$1@news1.ucsd.edu> Can someone reccommend a good http session module? I would prefer a stable, fairly scalable session module (one I downloaded just used pickle, which seems like it wouldn't work for concurrent access). I know there are a couple out there, but the "Vaults of Parnassus" didn't have many such modules. I am planning to use mod_python, so if there is some trick I can do with persistant memory, that would also be helpful. Thanks, Jeff From huaiyu at gauss.almadan.ibm.com Mon Nov 19 19:43:10 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Tue, 20 Nov 2001 00:43:10 +0000 (UTC) Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> Message-ID: On 19 Nov 2001 15:31:13 GMT, Uwe Schmitt wrote: >I uses MatPy today and think it' quite useful. But there is one >incompatibility to matlab: in MatPy indices start at zero, in >Matlab they start at one. Is there a solution to adapt MatPy to >the Matlab style ? Although it is possible with some hacking, I don't think you would want to do that, because in Python all sequences are indexed this way, including NumPy arrays. If that's changed there would be a lot of confusion when you transform between plain Python and numerical objects. Besides, there are many good reasons to start indexing from zero. The open source Matlab-compatible language Octave allows both indexing from zero and one. It defaults to start from zero, but if you choose an option (called "braindead" or something like that) it can start with one. Braindead is not an easy option here. :-) Huaiyu From loewis at informatik.hu-berlin.de Thu Nov 1 06:42:35 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Nov 2001 12:42:35 +0100 Subject: XML can't read Unicode shock horror. News at 11. References: Message-ID: Walter =?ISO-8859-1?Q?D=F6rwald?= writes: > But xml.sax.xmlreader.InputSource provides methods setCharacterStream > and getCharacterStream, to be able to parse something which is already a > decoded unicode character stream. > > Does any of the available parsers support this? I believe the xmlproc driver supports that. Regards, Martin From sholden at holdenweb.com Wed Nov 14 12:33:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 12:33:32 -0500 Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: "Huaiyu Zhu" wrote in ... [ ... ] > > class A: > def __cmp__(a,b): return -1 > > a = [A()]*3 > a == a # returns 0 > a is a # returns 1 > > > Is this intended? I would think that mandating > a is b implies a == b > would make programs easier to read. > Once you create a class where instances are not equal to themselves then common sense goes out of the window, and readability is no longer your major problem. If two lists contain items that compare unequal, then surely by definition the lists are unequal, and so *not* short-circuiting the comparison gives correct behavior. Ask any mathematician, and they will tell you that (a != b ) => ({a} != {b}) using the nearest ASCII approximation to set theoretical notation I can produce. Oddly enough, this makes sense to me. but-then-sense!=brains-ly y'rs - steve From dgrisby at uk.research.att.com Thu Nov 15 07:54:33 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 15 Nov 2001 12:54:33 GMT Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: Message-ID: <9t0du9$f2t$1@pea.uk.research.att.com> In article , Gordon McMillan wrote: >So 1000 / sec is quite possible, but you'll never get there with blocking >sockets. This isn't a direct comparison, but I've done some experiments with CORBA calls using omniORBpy. I did some tests with two 500MHz Pentium 3 machines running RedHat 6.2 Linux, connected by 100Mbit/s switched Ethernet. With client and server on the same machine, communicating via TCP loopback, I get: Threads in client Calls per second 1 3122 5 3145 10 2825 / 2096 20 2801 / 2988 50 2739 / 2820 100 2625 / 2342 between the two machines, the results are: Threads in client Calls per second 1 2314 5 5033 10 5035 / 5068 20 4861 / 5001 50 4570 / 4632 100 4125 / 4258 There are two results for each test with > 5 threads, since by default omniORB limits the number of TCP connections a client will open to a particular server to 5. There are therefore only ever 5 threads active in the server. The second figure in each test is the result of telling the clients to open an unlimited number of TCP connections. Each invocation is a request/reply, so a single threaded client across the network is bound by the network latency; clients with more threads allow there to be multiple calls in flight at once, so throughput is better. Anyway, as you can see, a target of 1000 calls per second is easy to meet :-) Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From jdadson at ix.netcom.com Mon Nov 5 16:59:55 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 21:59:55 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> Message-ID: <3BE70BB6.A2D0FCEC@ix.netcom.com> Chris Barker wrote: > > While nothing is actually set in stone, some things are pretty well > cemented in. > > Jive Dadson wrote: > > Thanks. Before I submit a formal proposal, let me run it by you guys. > > That is a good idea, most PEPs start as a discussion here. AN a whle lot > more start that way and nver make it to a PEP. > > > I've looked through all the PEPS and I was surprised that my suggestion > > is not already there. So, here it is. Please comment. > > You can bet that this has been proposed by people new to Python again > and again and again ... What does that tell you? > ... and I can promise you that this is one thing that > is very well cemented in. If there is one thing that makes Python > Python, is that it is a highly dynamic language. THat is not going to > change. You must have misunderstood what I wrote. I'm not proposing anything that would make it "lowly dynamic". > > > option explicit > > > > def initialized = 0 > > def init_everything(): > > blah() > > blah() > > blah() > > initialized = 1 > > > > The above code would work as anticipated. No pesky "global" qualifier. > > Actually, no it wouldn't. The second initialized here is a local > variable, and it should remain so. Having a variable in a function be > either local or global depending on something that is outside of the > funciton is asking for trouble. I didn't propose anything like that. The compiler will know that "initialized" is not local to init_everything because it is not declared there with a "def". That has absolutely nothing to do with anything outside the function init_everything. > If you start changing that too, you > really won't have Python anymore!! > The changes I've proposed do not conflict in any way with the "Python-ness" of the language. If you don't put "option explicit" at the top of your module, it will behave exactly the same as it did before. What we are discussing is not uniquely "Python". Other languages have had the dubious feature that the first assignment to a variable is its declaration. Invariably, people discover that it was a lousy idea. The people who USE it discover that. They misspell a variable name and in doing so they introduce a bug. The bug may not manifest itself until the code is already shipped. Even if they do notice the bug before it's too late, it may be very difficult to track down. I've been down that road a lot of times. There's a pragmatic reason I'm asking for this feature. One of our customers has suggested that we implement scripting using Python. I've looked into Python, and I am very impressed with what I see. But I would have grave misgivings giving it to customers with variable declarations the way they are now. I'm not sure I could sell the boss on it, and don't know if I would want to. The situation is quite different from writing code on ones own computer to be used in-house. These programs will run equipment, often in foreign countries, that can break literally a million dollars worth of merchandise, and could even hurt somebody. It is very important to find bugs BEFORE a program goes into production use. I won't have any say over who writes these programs, but bugs that appear to be compiler bugs ("Why doesn't that variable change when I assign to it?") will get bounced right to me. Of course, since the source code is freely available, I could implement it on our copy only. But that would be inefficient. By your own account, lots of other people want the feature also. Jive From m.faassen at vet.uu.nl Fri Nov 23 14:19:52 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 23 Nov 2001 19:19:52 GMT Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <3BFC0365.21FB6AA1@alcyone.com> Message-ID: <9tm7go$atu$1@newshost.accu.uu.nl> Erik Max Francis wrote: [snip] > I myself in the past have used stack-based languages which are promising > since even the constraint on program legality is dropped, provided you > make certain concessions such as allowing a bottomless operand stack, > having the key variables of the simulation available by means of special > operators, etc. With a suitable choice for environment, every sequence > of legal operators is itself a legal program. Cool; I've recently been thinking about that. Any results, info, etc, you have on your experiments? I've worked with a simple virtual machine designed to the same constraints too (every sequence of instructions is a legal program), but this VM didn't have a stack *or* a set of registers; instead there were some instructions to move read/insert/delete heads onto their own instruction set. This allowed me to write an ancestor replicator would copy itself. That's different from genetic programming though, moving more towards artificial life. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From rdsteph at earthlink.net Fri Nov 23 13:48:50 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Fri, 23 Nov 2001 18:48:50 GMT Subject: Indenting with tabs vs spaces References: <3BFDB593.39AFC7FD@earthlink.net> <3BFDC564.691550FB@earthlink.net> Message-ID: <3BFE9B6A.4F116067@earthlink.net> Thanks! Ron Stephens Hans Nowak wrote: > Ron Stephens wrote: > > > > OK, now you all have got me worrying about a new thing. All my code so far is > > indeented with single tabs (four spaces I think). Since I use IDLE or sometimes > > PythonWin when I code, will my tabs screw up anyone else trying to run my code? > > H9ow about if I use Windows Notepad? > > > > I hate spaces, like tabs. > > Single tabs are alright. So are spaces. It's the mixing of the two that > causes > indentation errors. > > --Hans From fperez528 at yahoo.com Sun Nov 11 09:44:21 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 12 Nov 2001 14:12:21 +2328 Subject: Scientific Libraries in Python References: <9snfbh$dt3$1@peabody.colorado.edu> Message-ID: <9spe1f$nq$1@peabody.colorado.edu> >>>> s = ShamelessPlug() >>>> s.start() > > VTK is library and some folks have trouble using it because it does > take some effort to get the hang of it. There is one tool/application > out there that helps such folks out by attempting to make data > visualization very easy. Its written in 100% pure Python and uses VTK > and Tkinter. Its available here: > > http://mayavi.sf.net > > To see specific examples in action look here: > http://mayavi.sf.net/screenshots/ > YES! That's *exactly* what I had in mind. The problem I see with most other systems out there is that at some point, your problem gets ugly enough that they fail you. And you're stuck learning a new syntax from scratch. The reason why I'm so interested in python is because, being such a clean language, I think it's a great base layer for a lot of scientific work. I'm sick and tired of having a project made up of: shell scripts/sed/awk/perl/Fortran/C/C++/IDL/Mathematica... In the end I end up spending more time switching mentally from syntax to syntax than getting work done! I don't mind that VTK is a complex toolkit: for something to scale well to really serious tasks, it better be. Otherwise it will crack open beyond a certain point. I think the challenge is writing a tool that: 1) can be easily used from the interactive python command line for 'basic' 2d and 3d plotting. 2) has itself a gui for fine tuning of things. 3) is scriptable from python with access to the mid and low-level routines. The gracePlot module to me is an excellent illustration of the model I have in mind, even thought the plotting tool itself is very limited (only 2d, though good at what it does). You can quickly fire it up from the command line to plot some data, then fine-tune it from the gui and save to eps the finished plots. Quick, efficient and clean. So best of luck with mayavi. I'll be keeping a close eye on this, it seems like you're well on your way to putting together a truly first-rate visualization environment for python. I just posted an announcement I found about the Gnu Scientific Library. Using that as a basis for SciPy/Scientific and your system, we're well on our way to a kick-ass scientific working environment: useful for things from interactive data exploration to job scripting/control, all the way up to full-scale simulation writing (with appropriate use of C/C++ components when needed). Cheers, f. From mkelly2002NOSPAM at earthlink.net Sat Nov 24 14:03:28 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Sat, 24 Nov 2001 19:03:28 GMT Subject: Windows Scripting Host Python Engine not registered/installed?? Message-ID: <1drvvtc91jnbmfoqpn2qdrg37km6ggk9sl@4ax.com> Hi. I'm trying out the Windows Scripting Host and even though PyScript.py runs with no error any python scripting attempt reports that it cannot find the Python engine. Also in all the demo IE pages with scripts the Python scripted portions don't work while the VB script ones do. I think they changed around the subdirectory structure as some of the docs say win32com folder when the stuff is in win32comext folder. Anyway, WScript.exe seems to work since any text file with a .vbs extention will invoke it such as a file with .vbs extention and the single line: WScript.Echo("Hello World") pops up a message box. Anyone have a tip? I'm a bit bewildered as it seems this should be an easy one. TIA Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From nicolasvandyck at hotmail.com Tue Nov 13 11:34:45 2001 From: nicolasvandyck at hotmail.com (Nicolas) Date: Tue, 13 Nov 2001 17:34:45 +0100 Subject: How to install Zope ? Message-ID: <9sri5l$p4l$1@rivage.news.be.easynet.net> A very quick question. We currently have shared webhosting at a provider (hostme.com). How do i install Zope there ? Is it something i can do, or is it up to our hoster to do this ? Thanks for the info ! Greetings Nicolas From fperez528 at yahoo.com Mon Nov 26 07:41:23 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 12:09:23 +2328 Subject: Integer Overflow References: <9u0m3l$447$2@peabody.colorado.edu> Message-ID: <9u0oek$64q$1@peabody.colorado.edu> Ursus Horibilis wrote: > > Thanks very much. I did not realize that a Python long was not > simply a 64-bit number. Just pure ignorance on my part. Is it > legal to mask a long and assign it to an int? For example: > > (a) is an (int), (b) is a (long) > > b = 6*sys.maxint > > a = b & (0xFFFFFFFF) That's just what I suggested in another post, though I've never played with bit-operators in python. (but remember to use 6L when assigning to b, not 6: that will make b a long). Cheers, f From g_will at cyberus.ca Thu Nov 8 21:30:20 2001 From: g_will at cyberus.ca (Gordon Williams) Date: Thu, 8 Nov 2001 21:30:20 -0500 Subject: Numerical Bug in Numpy V19.0 Message-ID: <004901c168c6$7ac13420$ea55c3d1@wnt20337> Hi, I have just changed to Numpy V19 from V17. I get the following output in V19: >>> a=array([1,2,3,4], Int16) >>> a array([1, 2, 3, 4],'s') >>> a/2 array([0, 1, 1, 2],'i') >>> a/=2 Traceback (innermost last): File "", line 1, in ? TypeError: return array has incorrect type >>> a.savespace(1) >>> a/2 array([0, 1, 1, 2],'s') >>> a/=2 Traceback (innermost last): File "", line 1, in ? TypeError: return array has incorrect type >>> In V17 it acts as expected and I don't get the "return array has incorrect type" error. This must be a new bug that was put into V19. Running Python 2.0 on W2000 if that makes any difference. Regards, Gordon Williams From loewis at informatik.hu-berlin.de Sat Nov 3 08:32:58 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 03 Nov 2001 14:32:58 +0100 Subject: search path References: <3BE33EB9.F7A9F629@ix.netcom.com> Message-ID: Jive Dadson writes: > I R'd the FM, but I can't figure it out: How do I set the search path > Python uses to find modules? The search path is always in sys.path. How sys.path is initialized varies with platform and Python version. If you need the full story, you best study the Python source code. > The documentation that came with Python says it uses an enviornment > variable named PYTHONPATH. What kind of environment variable? I'm > running this under Windows (spit!). There are environment variables on Windows, and PYTHONPATH is honored there, also. However, on any system, sys.path will include directories even if PYTHONPATH is not set. On Windows, these directories include: - directories relative to the Python installation. Those are usually retrieved from the registry, since Python, at installation time, adds a few registry entries - directories for other packages that added the registry - individual paths for modules, also found in the registry. - directories listed in .pth files on sys.path, if site.py is imported. Regards, Martin From grante at visi.com Wed Nov 21 14:25:11 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 21 Nov 2001 19:25:11 GMT Subject: Sending EOF (CTRL-D) to a subprocess References: Message-ID: In article , Holger Fuessler wrote: > Can anybody tell me how to send a C-D to a subprocess opened with > os.popen()? If you want to send ctrl-D, then just write ctrl-D to the pipe. However, mapping ctrl-D to EOF is something done by the tty driver (which isn't involved in a pipe). If what you want to do is cause an EOF, then close the pipe. -- Grant Edwards grante Yow! Now that we're at in LOVE, you can BUY visi.com this GOLDFISH for a 48% DISCOUNT. From martin.franklin at westgeo.com Fri Nov 23 04:43:54 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Fri, 23 Nov 2001 09:43:54 +0000 Subject: Problems with Getting Tkinter to Work References: Message-ID: <9tl5nq$280i$1@mail1.wg.waii.com> Ben Ocean wrote: > Hi; > I just configured Tcl--itworks--and I went to configure tk (both latest > stable distros) on my RH71 box and ran into all sorts of errors on *make*. > Both installations are in /usr/lib and I'm in as root. It exits with Error > 1. Here's how the errors start: > > [root at hermes unix]# make > gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall > -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix > -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps > -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 > -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 > -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED > /usr/lib/tk8.4a3/unix/../generic/tk3d.c > In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or > directory In file included from I am not an expert but this sounds like you have not got X11 headers do you need to install these from some sort of X11 rpm??? I have RH7.1 and did a full install when I installed RH and have no such problems. > /usr/lib/tk8.4a3/unix/../generic/tkPort.h:32, > from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:27, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/../unix/tkUnixPort.h:77: X11/Xlib.h: No > such file or directory > etc. etc. etc. etc. etc. etc. etc. etc. etc. > > Any ideas? > TIA, > BenO > > > > From no at spam.net Fri Nov 2 19:55:19 2001 From: no at spam.net (anonymous) Date: Fri, 02 Nov 2001 19:55:19 -0500 Subject: Q: Feature Wish: "%" Extension Message-ID: <3BE34077.8EA553CB@spam.net> I've been using python for file format translations and test/interface hardware control applications for a few years. I frequently have to perform conversions between ASCII representations of numbers and, well, numbers. Python thoughtfully provides the atoi()/int() functions for string->number conversions for the radices I use most: 2, 8, 10, 16. And since many of the fields I have to manipulate are 32 bits and wider, I'm very grateful for the merge of the int and long types. For number->string conversion (see it coming yet?), the handy overloaded "%" operator handles radices 8, 10, and 16 -- with padding, zero-filling, prefixing (e.g. "0x"). But every time I need to convert a number to _binary_, I have to call a function of my own to produce the string, and then intermingle that string with other numbers in the final "%" format I originally intended. It's awkward and slow. Here it comes: Am I the only Python user that needs to format numbers to and from binary, or has anyone else ever wished for a %b format to be added to the "%" operator? Pushed into C it'd be much faster, and could handle all the implicit type conversions and formatting flags similar to those of %d and friends. Treat negative and float numbers under the same convention as for %x and %o. I've resisted asking for this core language enhancement before, but with the recent additions of rawstrings (quietly preferred to see a distinction between ' and " handle this, but understand the trade-off), unicode strings, and floor division, I think this proposal seems comparatively pretty tame in impact to the aesthetics of Python :-). If this has been shot down before, I'm not aware of it; not trying to be a pain. twv PS: I'm still dumbfounded why Python's division operator must behave differently than that in php, js, java, perl, awk, and C/C++ -- colleges do not teach BASIC anymore -- as I worry about all of my hardware interface code and auto-comment-wrapping editor :-) From wpmelcher at snet.net Tue Nov 27 16:24:13 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Tue, 27 Nov 2001 21:24:13 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> Message-ID: "Neil Hodgson" wrote in message news:tfTM7.380397$bY5.1637507 at news-server.bigpond.net.au... > Bill Melcher: > It is not certain yet whether this can be done as I'm having trouble with > bugs. Will probably turn up but may only work with some programs. > Worry not. I've got SciTE up and running. It does capture both stdout and stderr. I love it! I also joined scite-announce so that I can keep up with new releases. -- Cheers, Bill TANSTAAFL! From gs at styrax.com Wed Nov 7 18:37:48 2001 From: gs at styrax.com (Garry Steedman) Date: Wed, 7 Nov 2001 23:37:48 +0000 Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) In-Reply-To: <9scc8a$g8b$1@bugstomper.ihug.com.au> Message-ID: <3BE9C5CC.26920.60589DC@localhost> Gary, you'll be chuffed to know that Rolf's autobiography, "Can You Guess What It Is Yet", is now available on www.rolfharris.com: "In his long-overdue autobiography, Rolf Harris charts his rise from the dusty streets of Bassendean in Western Australia to becoming a household name on both sides of the world... A limited number of signed copies are available at ?19.99. Unsigned copies are ?17.99." if you're quick you might still get a signed copy... tying-your-kangaroo-down-sportingly-y'rs, garry On 8 Nov 2001, at 9:34, Gary Stephenson wrote: From: "Gary Stephenson" Subject: Re: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) Organization: The Internet Group (Sydney) To: python-list at python.org Date sent: Thu, 8 Nov 2001 09:34:33 +1100 > It should to totally apparent to all and sundry that Steve Irwin comes > from an entirely different planet! Classifying him as Australian > would be equally as fallacious as classifying him human. > > Rolf, otoh, is a national treasure. I mean anybody who could give us > such classic masterpieces as "Jake the Fake" (with my extra leg, > deedle-ee deedle-um) and "Tie me Kangaroo down, sport", not to > mention a squillion others of similar calibre, deserves to be > permanently lodged in the pantheon of stars. Surely any country on > Earch would be proud to count Rolf as one of their own, .. surely.. > for sure... without a doubt... > > gary > > > > "Duncan Smith" wrote in message > news:9sbvsa$925$1 at newsg2.svr.pol.co.uk... > > > > "Fredrik Lundh" wrote in message > > news:8_dG7.4760$R43.760797 at newsb.telia.net... > > > Gary Stephenson wrote: > > > > Umm, I'm not really sure this is a claim we should be making! > > > > Next > > thing > > > > you'll have us claiming responsibility for making disco popular > > > > - and > > then > > > > they'll just have to shoot us! ;-) > > > > > > but Steve Irwin is your fault, right? > > > > And Rolf Harris. > > > > > > > > > > > > > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list +-------------------------------------------+ Garry Steedman mailto:gs at styrax.com Styrax Associates http://www.styrax.com/ "The Good Man has no shape." +-------------------------------------------+ From loewis at informatik.hu-berlin.de Wed Nov 21 09:39:44 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 21 Nov 2001 15:39:44 +0100 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> <3BF9D791.BEA22D61@engcorp.com> <3bfab7ae_3@mk-nntp-1.news.uk.worldonline.com> Message-ID: "Morten W. Petersen" writes: > In Python, there is: > > def multiply(argument): > return argument * argument > > Or (using anonymous functions): > > multiply = lambda argument: argument * argument > > Where the lambda has the implicit return-of-last-expression (no return > needed), while functions do not. It is really a little different. In lambdas, there is only a single expression, and that is the result. Functions, OTOH, are sequences of statements, not of expressions. Regards, Martin From ngreco at softhome.net Mon Nov 12 14:48:06 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Mon, 12 Nov 2001 16:48:06 -0300 Subject: IsPython really O-O? In-Reply-To: <91acf731.0111121115.30f5142a@posting.google.com> References: <91acf731.0111121115.30f5142a@posting.google.com> Message-ID: <20011112164806.6f78c59c.ngreco@softhome.net> On 12 Nov 2001 11:15:19 -0800 jason at jvoegele.com (Jason Voegele) wrote: > wrote in message news:... > > A Smalltalk guru in our organization looked at Python last weekend (after I > > had made a big scene saying that it may be a solution to some of our > > cross-platform issues) and came away saying that it was no more > > object-oriented than Java. I sputtered around a bit but could hardly make a > > decent argument, as I'm a mere designer. We do very large-scale industrial > > work here, all O-O, with object databases (I thought the ZODB business > > looked great). Is my friend right? Is Python not "really" appropriate for > > true O-O applications, in the sense that Viz-Age Smalltalk and Eifel and so > > on are??? > > Unfortunately, everybody has their own opinion on what "is OO", and > what is "pure OO". Personally, I don't consider Python to be a pure > OO language. I consider it a hybrid language with support for OO, but > that doesn't mean it's not useful. I've formulated my own opinion > about what makes a language "Pure OO", which you can read here: > > http://www.jvoegele.com/software/langcomp.html > I share that opinion and the ones in your page, but you are making a common mistake, you must view ST as a language/syntax, but also as an "Object Ambient", or "Box with objects to play". The language really doesnt matter too much, you can make other parsers in the Ambient (i know Lisp & Prolog in ST, but not python). By now, the unique "Objects Ambients" that i know are ST and Self, and i think that CLOS classifies also, but without tools (browsers, etc, or yes?). And ZOPE a little, but i dont like it too much :) The really revolutionary thing is the concept of "Objects Box", where you program / use manipulating objects. I think that is the future, if you see the trend in the OS camp, you see that for example, OLE, COM, and .NET or any component model is trying to reach that. Also the inclusion of metadata in the filesystems. Or the uniformity of device access / file access in Unix. In the end of the road, your computer will be full of objects, not "documents" and "binaries", all visually manipulable in a Gibson way :) - Nahuel Greco Web Development - Open Source - - http://www.codelarvs.com.ar Game Programming - Research - - Freelance coding / sysadmin Networking. The answer is 42. - From modman at altavista.com Wed Nov 14 11:59:39 2001 From: modman at altavista.com (Modman) Date: 14 Nov 2001 08:59:39 -0800 Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: Tim Hammerquist wrote in message news:... > Roy Smith graced us by uttering: > > ianb at colorstudy.com (Ian Bicking) wrote: > >> If you look under the hood, Python is much more like Smalltalk than > >> Java. > > > > I'm having trouble parsing that. Which of the following did you mean? > > > > 1) Python is more like Smalltalk that Python is like Java > > 2) Python is more like Smalltalk than Java is like Smalltalk > > I grokked it as meaning case 2. > > That's what we get for using English. Now if we used Latin, we wouldn't > have to rely on the relative location of words in a sentence to > determine meaning... ;) why is that bad? Python uses position to determine meaning (i.e. Spaces are significant) :-) just thought I could try to tie this back into the main topic :-) From stuart at bmsi.com Sun Nov 4 18:11:15 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Sun, 04 Nov 2001 18:11:15 -0500 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> <3BE5A1A7.75C7EC9C@attglobal.net> <9s4f79$8b3$1@nntp2-cm.news.eni.net> <87ady25fdf.fsf@lisboa.ifm.uni-kiel.de> Message-ID: <9s4huk$a5v$1@nntp2-cm.news.eni.net> In article <87ady25fdf.fsf at lisboa.ifm.uni-kiel.de>, "Janko Hauser" wrote: > AFAIK this is not right, as for the os.system() call first a shell is > started and then the process (ls) is started in this shell. Oops, you are right. I am a long way from a python guru... > A better way is to use the commands module. It wraps os.popen and I'm > not sure if this also didn't open a shell beforehand. I checked, and the "commands" module also creates a shell process to parse the command. > Pure ways to start a new process are wrapped in the os module as > os.exe?? os.fork and os.spawn??. But using these is more complicated (io > handling, finding the path of the executable etc.) It looks like os.spawn* is the way to go: import os def cmd(s): "I do not handle shell style I/O redirections or substitutions" sv = s.split() return os.spawnvp(os.P_WAIT,sv[0],sv) error = cmd('make myproject') if error == 0: cmd('ls') cmd('pj ci makefile') -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From root at rainerdeyke.com Mon Nov 12 13:07:07 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 12 Nov 2001 18:07:07 GMT Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: "Laura Creighton" wrote in message news:mailman.1005580996.11004.python-list at python.org... > I have a new problem. I've just lost a major amount of precision in my > language usage. What is the collective noun for 'attributes that aren't > methods (you can't call them)'? A non-callable attribute is just that, a non-callable attribute. Note that this includes things that you might not think of as methods: class C: def __init__(self, something) self.something = something class nested_class: pass c = C(abs) assert callable(c.__class__) assert callable(c.nested_class) assert callable(c.something) In general I use the terms "instance attribute" to refer to object attributes that are carried around by the actual object, "class attribute" to refer to attributes that an object inherits from its class, and "method" to refer to objects that are actually of a method type ('instance method' or 'builtin_function_or_method', where an iunstance if the latter is only a method if it indentifies itself as such in it's repr). -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From amk at localhost.debian.org Sat Nov 3 08:35:20 2001 From: amk at localhost.debian.org (A.M. Kuchling) Date: 3 Nov 2001 13:35:20 GMT Subject: [ #456742 ] Failing test case for .*? References: Message-ID: <9s0rqo$rrg$1@bob.news.rcn.net> On Sat, 3 Nov 2001 04:50:38 -0600, Skip Montanaro wrote: >Maybe there's some kind of operator precedence issue (the "?" binds more >tightly than the "+") that means you have to wrap the first part of the >pattern in a group. +? is a non-greedy +, and it's not equivalent to (...+)?. Here's a test program: import sre s = "a\nb\na1" # Original, buggy pattern p = sre.compile(r" [^\n]+? \d", sre.DEBUG | sre.VERBOSE) m = p.search(s) print (m and m.groups()) # Add a group p = sre.compile(r" ([^\n]+?) \d", sre.DEBUG | sre.VERBOSE) m = p.search(s) print (m and m.groups()) When I run with the current CVS Python, two different results are produced, even though the only difference is adding a pair of parentheses: amk at glass:~/src/python$ ./python t.py min_repeat 1 65535 not_literal 10 in category category_digit () subpattern 1 min_repeat 1 65535 not_literal 10 in category category_digit ('a\nb\na',) amk at glass:~/src/python$ There's definitely a bug here. --amk From david.abrahams at rcn.com Thu Nov 1 22:58:19 2001 From: david.abrahams at rcn.com (David Abrahams) Date: Thu, 1 Nov 2001 22:58:19 -0500 Subject: [ANN] Python and C++ - Support Available Message-ID: It was just pointed out to me that my purported description of the license terms for Boost.Python was actually a description of the Boost license requirements, of which the Boost.Python license is only an example. Boost.Python is free for any use, commercial or otherwise. The copyright notice reads: (C) Copyright David Abrahams 2001. Permission to copy, use, modify, sell and distribute this software is granted provided this copyright notice appears in all copies. This software is provided "as is" without express or implied warranty, and with no claim as to its suitability for any purpose. Sorry for any confusion, =================================================== David Abrahams, C++ library designer for hire resume: http://users.rcn.com/abrahams/resume.html C++ Booster (http://www.boost.org) email: david.abrahams at rcn.com =================================================== From peter at engcorp.com Fri Nov 30 00:10:45 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 30 Nov 2001 00:10:45 -0500 Subject: floating Pt. Division errors in Windows 2000 References: <05DN7.34897$H7.4336901@ruti.visi.com> Message-ID: <3C0714D5.32FA1FCF@engcorp.com> Leon Webster wrote: > > I am just learning Python using the book Learning Python. Here's a sample > problem from the book: > >>>a = 3 > >>>b =4 > >>>b/(2.0 + a) > 0.80000000000000004 > > Does anyone know why this happens? Is this a problem with Python on Windows > or Win 2k? Neither. See the FAQ, and observe also: >>> a = 3 >>> b = 4 >>> print b / (2.0 + a) 0.8 -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From donn at u.washington.edu Mon Nov 5 16:35:13 2001 From: donn at u.washington.edu (Donn Cave) Date: 5 Nov 2001 21:35:13 GMT Subject: Is Stackless Python DEAD? References: Message-ID: <9s70mh$qbq$1@nntp6.u.washington.edu> Quoth "Mike C. Fletcher" : | I'm not sure I understand this argument. The current version is | drop-in-compatible with the standard Python 2.0 DLL. You don't re-compile | anything in extension modules, they just work the same as with the standard | distribution. | | The patch is (apparently, haven't looked at it) intrusive in it's re-design | of the core loop of the interpreter (it is re-writing some pretty basic | mechanisms, after all), but for user-land (as distinct from | interpreter-implementer-land) code, it's pretty much transparent in my | experience. | | With that said, there are likely to be systems that don't work well under | (for instance) micro-threading. Modules that need locks and expect | micro-threads to look like real threads will be disappointed (1000s of them | can be running in a single OS-level thread, so regular thread locks don't | block the micro-threads). However, that's a problem only for those users | actually using the Stackless-specific stuff (in essence if there are no | micro-threads running, then the thread-assuming extensions work fine). And that doesn't apply to continuations, they are compatible with OS threads. That may be obvious, but FYI. In my experiment, I used lots of C++ modules, some of which create OS threads that branch into the interpreter and execute most of the program. Donn Cave, donn at u.washington.edu From oliphant at ee.byu.edu Mon Nov 26 16:27:46 2001 From: oliphant at ee.byu.edu (Travis Oliphant) Date: Mon, 26 Nov 2001 16:27:46 -0500 Subject: Scientific Libraries in Python In-Reply-To: <375ad208.0111261037.5a591853@posting.google.com> References: <375ad208.0111261037.5a591853@posting.google.com> Message-ID: > > Now... licensing. While the top two projects are both less...restrictive, > > I reluctantly have to concede that these lists have an awful lot of GPL > > code that would be difficult or impossible to do without. The eventual > > license, therefore, looks like GPL or (if we're lucky) LGPL. I can even > > live with that if it'll get me a coherent scientific library, but others > > might have a different viewpoint. What would those viewpoints be? > > As regards the MayaVi license, MayaVi was developed for the community > so I didn't want someone to take the MayaVi codebase, use it for their > own purposes and not give back anything in terms of code to the > community. That is why I chose the GPL. However, the GPL does force > everyone else who links to it to be GPL. I guess LGPL might also work > but I really don't know. I'll try to give it some thought. Anyway, I > am not sure you want to put all packages into one huge super package. > It would be a nightmare to package/distribute! I'd really pity the > person who'd have to maintain such a beast. > prabhu The LGPL does what it seems like you want you want (doesn't allow people to take your particular code, alter it slightly and make it proprietary), but it also allows people to release a larger application which only links to your code under a non-GPL license. My understanding is that if you keep the GPL, then folks could build an interface, but they could not distribute mayavi with the interface under anything but the GPL. That's why I much prefer the LGPL to the GPL for tools which could be "hooked together." As to the packaging issue, it is true that maintainance can be a problem to set up intially. While a "distribution" could be considered that includes all of the important programs, I think the right solution is to define a set of interfaces in various problem domains which other packages can use. SciPy is aiming to be as complete as possible --- but this really means, a complete set of interfaces and defined user-interactions, with reference implementations, and tests, and a packaging structure that allows other packages to be inserted in and potentially maintained by other people. Enthought is also interested in distributing an "everything included" distribution which contains many of the above packages you mentioned, but to distribute such a beast which all worked together dynamically, my understanding is that none of the included packages could be GPL (LGPL would be O.K.) THE GSL ============= Many of the GSL routines are already in SciPy. Here is a detailed list: The outline parallels the GSL reference. Mathematical Functions: * Constants: Constants are easily defined, but presently pi, e, inf, nan, are defined. * Elementary Functions: from Numeric * Small integer powers: from Numeric * Testing the sign of numbers: sign * Testing for odd and even numbers: x % 2 == 0 * Maximum and minimum functions: max, min, amax, amin Complex Numbers: all handled by Numeric including inverse hyperbolic functions Roots of Polynomials: polynomials are represented by sequences of coefficients * Polynomial Evaluations: polyval, polyder * Quadratic Equations: (not specifically) --- see roots * Cubic equations: (not specificially) --- see roots * General polynomial: roots Special Functions: (all defined over arrays for Numeric). (using special.general_function any function which returns a scalar can be converted to broadcast over arrays). * Airy functions: yes (no zeros) * Bessel functions: yes (no zeros, or spherical bessel) * Clausen functions: not specifically (but dilogarithm is there -- not for complex numbers though, spence.) * Coulomb functions: no * Coupling Coefficients: no * Dawson function: dawsn * Debye Functions: no * Dilogarithm: spence (no complex argument) * Elliptic integrals: yes * Elliptic functions: yes * Error functions: yes * Exponential functions: yes * Exponential integrals: yes * Fermi-Dirac integrals: don't think so * Gamma functions: yes * Gegenbauer functions: yes (through scipy.integrate.orthogonal) * Hypergeometric functions: yes * Laguerre functions: yes (through scipy.integrate.orthogonal) * Lambert W Functions: no * Legendre Functions: yes * Spherical Harmonics: (not directly) * Logarithm: yes * Power functions: yes * Psi (digamma): yes * Synchrotron: no * Transport: no * Trigonometric: yes * Zeta: yes Vectors and Matrices: Numeric (Matrix) Permutations: Not specifically Sorting: sort, argsort BLAS interface: linalg.cblas, linalg.fblas Linear Algebra: (linalg) --- interface to LAPACK * LU: yes * QR: yes * SVD: yes * Cholesky: yes * Tridiagonal decomposition (Schur): yes * Bidiaonlization: not sure (is this in LAPACK?) * Householder solve (through lapack) * tridiagonal systems: no Eigensystems: yes Fast Fourier Transforms: yes Numerical Integration: yes (all) Random Number Generation: yes (RandomArray) Quasi-Random Sequences: (random in standard library?) Random Number Distributions: many (RandomArray) -- not all Statistics: most of these and more Histograms: yes (not 2-D though) N-tuples: yes, from Python Monte-Carlo Integration: no Simulated Annealing: no Ordinary Differential equations: yes Interpolation: yes Numerical Differentition: yes Chebyshev Approximations: no Series Accelerations: no Discrete Hankel Transforms: no Root-Finding: yes (multi-dimensional) Optimization: yes (multi-dimensional) Least-squares fitting: yes Nonlinear least-squares fitting: yes Physical constants: no (easily defined) IEEE floating-point arithmetic: relies on platform So, asided from a few specialized applications, most everything in the GSL is already included in SciPy. It wouldn't take long to add the extra functionality if there were a demand for it. Any takers? -Travis From khirmint at hotmail.com Mon Nov 19 16:16:57 2001 From: khirmint at hotmail.com (Ken) Date: Mon, 19 Nov 2001 13:16:57 -0800 Subject: Can python do this? Message-ID: <3BF976C9.49AE31AB@hotmail.com> Is it possible to have a program running (either C or Python) and have that program dynamically load Python functions while its executing? The idea is to have a server running that users can connect to, and be able to change functionality without having to restart the executable. Objects/variables loaded into memory (ie. who's connected) would also need to be saved. If it is possible, would it be terribly difficult? From pinard at iro.umontreal.ca Tue Nov 20 18:12:46 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 20 Nov 2001 18:12:46 -0500 Subject: How to marshal a function? In-Reply-To: <01112013065003.01362@logiplex1.logiplex.net> References: <83itc5mawu.fsf@panacea.canonical.org> <01112013065003.01362@logiplex1.logiplex.net> Message-ID: [Cliff Wells] > As far as whether this will provide sufficient security, that's obviously > more difficult to say. It was merely my original intention to point out > the possibility of a security hole (there was no information regarding how > he was using this application in the first few posts), it seeming likely > to me that more information regarding his particular application would be > forthcoming, but the discussion didn't continue in this vein, so this was > never addressed. OK. I just translated the doc-strings and comments to English, so I can share the little tool with you. That should allow you people to evaluate this module's security, or lack thereof, and advise me! Besides, I think the tool may be useful in itself, to some of you. For one, I use this module within a bigger setup meant for administrating systems and user accounts for many machines at once, and in parallel. -------------- next part -------------- #!/usr/bin/env python # Copyright ? 2001 Progiciels Bourbeau-Pinard inc. # Fran?ois Pinard , 2001. """\ Python services on a remote machine. To each Server instance is associated an `ssh' link towards a remote server program. That remote server, which gets automatically installed, is able to evaluate Python expressions, apply functions or execute Python statements, on demand, within in a special evaluation context held within that server. The `pickle' module is used for all transit to or from the server, so the programmer should restrain him/herself to Python values that can be pickled. Here is a simplistic example. Suppose `cliff' is an Internet host for which we already have immediate SSH access through the proper key setup. To get `cliff' to compute `2 + 3', a Python expression, one uses this: import remote server = remote.Server('cliff') print server.eval('2 + 3') server.complete() If the host name is missing or None, the current host is directly used, without installing nor using a remote server. The server is installed as `~/.python-remote-VERSION' on the remote host (VERSION identifies the protocol) and left there afterwards. If the server already exists, it is merely reused if it identifies itself correctly. Typically, the link is kept opened to service many requests which depend on the remote machine, either for its computing power, its file system, or other idiosyncrasies, and closed once the overall task is completed. """ import string, sys error = 'Remote error' APPLY_CODE, EVAL_CODE, EXECUTE_CODE = range(3) NORMAL_RETURN, ERROR_RETURN = range(2) class run: version = 1 header = "Python `remote' server, protocol version %d" % version script = '.python-remote-%d' % version def main(*arguments): import getopt options, arguments = getopt.getopt(arguments, '') for option, value in options: pass execute_server() class Server: def __init__(self, host=None): if host is None: self.child = None self.context = {} return import os, popen2 self.host = host name = __file__ if name[-4:] == '.pyc': name = name[:-4] + '.py' command = 'ssh -x %s python %s' % (host, run.script) for counter in range(2): self.child = popen2.Popen3(command) text = self.receive_text() if text == '%s\n' % run.header: return if text is None: sys.stderr.write("Oops! Installing Python server on `%s'\n" % host) os.system('scp -pq %s %s:%s' % (name, host, run.script)) assert 0, "Unable to install `%s' on `%s'." % (name, host) def complete(self): if self.child is not None: self.send_text('') text = self.receive_text() assert text == '', text self.child = None def apply(self, text, arguments): """\ Evaluate TEXT, which should yield a function on the remote server. Then apply this function over ARGUMENTS, and return the function value. """ if self.child is None: return apply(eval(text, globals(), self.context), arguments) return self.round_trip((APPLY_CODE, (text, arguments))) def eval(self, text): """\ Get the remote server to evaluate TEXT as an expression, and return its value. """ if self.child is None: return eval(text, globals(), self.context) return self.round_trip((EVAL_CODE, text)) def execute(self, text): """\ Execute TEXT as Python statements on the remote server. Return None. """ if self.child is None: exec text in globals(), self.context return return self.round_trip((EXECUTE_CODE, text)) def round_trip(self, request): import base64, pickle, zlib text = base64.encodestring(zlib.compress(pickle.dumps(request))) self.send_text(text) text = self.receive_text() if text is None: return None code, value = pickle.loads(zlib.decompress(base64.decodestring(text))) if code == ERROR_RETURN: raise error, value return value def send_text(self, text): assert self.child.poll() == -1, \ "%s: Python server has been interrupted." % self.host self.child.tochild.write(text + '\n') self.child.tochild.flush() def receive_text(self): assert self.child.poll() == -1, \ "%s: Python server has been interrupted." % self.host lines = [] while 1: line = self.child.fromchild.readline() if not line: break if line == '\n': return string.join(lines, '') lines.append(line) def execute_server(): """\ Python remote server proper. Here is a description of the communication protocol. The server identifies itself on a single stdout line, followed by an empty line. It then enters a loop reading one request on stdin terminated by an empty line, and writing the reply on stdout, followed by an empty line. Requests and replies are compressed pickles which are Base64-coded over possibly multiple lines. All requests are processed within a same single context for local variables. An empty request produces an empty reply and the termination of this server. """ import StringIO, base64, pickle, traceback, zlib context = {} readline = sys.stdin.readline write = sys.stdout.write flush = sys.stdout.flush write('%s\n\n' % run.header) flush() lines = [] while 1: line = readline() if line != '\n': lines.append(line) continue text = string.join(lines, '') if text == '': write('\n') break lines = [] request = pickle.loads(zlib.decompress(base64.decodestring(text))) code, text = request try: if code == APPLY_CODE: text, arguments = text code = NORMAL_RETURN value = apply(eval(text, globals(), context), arguments) elif code == EVAL_CODE: code = NORMAL_RETURN value = eval(text, globals(), context) else: exec text in globals(), context code = NORMAL_RETURN value = None except: message = StringIO.StringIO() traceback.print_exc(file=message) code = ERROR_RETURN value = message.getvalue() write(base64.encodestring(zlib.compress(pickle.dumps((code, value))))) write('\n') flush() if __name__ == '__main__': apply(main, sys.argv[1:]) -------------- next part -------------- -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From DeepBlue at DeepBlue.org Tue Nov 6 11:24:06 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Tue, 6 Nov 2001 10:24:06 -0600 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> <9s8u5d$11feke$1@ID-11957.news.dfncis.de> Message-ID: "Oleg Broytmann" wrote in message news:mailman.1005060010.32722.python-list at python.org... > On Tue, Nov 06, 2001 at 06:59:31AM -0800, Emile van Sebille wrote: > > > > Let me add to this that in such a boring predictable world, I have > > always > > > > appreciated Oleg's Pushkin-Lermentov-like sensibility and idealism :) > > > > > > Always? Did I really show it *so* many times? :) > > oh yes! :) Nothing to be ashamed of anyway! Would Pierre be ashamed of his noble feelings to Natasha! Would Malakhov have abandoned Aksenia? Would Oleg turn away from what makes the world tick :) > > ;-)) > > About as predictable as waiting for Martijn to jump in about the PS > > Hmm. Something funny is in the Russian air if even me (neither Russian, > nor even born in Russia, though I live in Moscow now) behave like that :))) > hehehehehe! But I totally understand. It just grows on you. I am not even close to Russia. It is a state of mind. Would you program using Python? If yes, then you must be an avid reader of Turginev and Tolstoy :) DeepBlue > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > From James_Althoff at i2.com Mon Nov 12 14:17:44 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Mon, 12 Nov 2001 11:17:44 -0800 Subject: IsPython really O-O? Message-ID: Kent Smith wrote: >A Smalltalk guru in our organization looked at Python last weekend (after I >had made a big scene saying that it may be a solution to some of our >cross-platform issues) and came away saying that it was no more >object-oriented than Java. I sputtered around a bit but could hardly make a I worked in the LRG group (Learning Research Group, aka the Smalltalk team) at Xerox PARC in the late seventies / early eighties under Alan Kay and Adele Goldberg and helped design and implement the original Smalltalk-80. Therefore, by the powers vested in me by no one in particular, I hereby proclaim Python to be "Plenty-good OO!" Helpfully yours, Jim From warren-postma at home.com Fri Nov 16 23:30:51 2001 From: warren-postma at home.com (Warren Postma) Date: Sat, 17 Nov 2001 04:30:51 GMT Subject: Option Explicit: Yuck. References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> Message-ID: <%JlJ7.552378$j65.135625324@news4.rdc1.on.home.com> I felt the same way when I first encountered Python. After I had spent a little more time with it, and had read the C code implementing the various types, I realized the Necessity and Completeness of Python, which in a certain way, is the most harmonious convergence of theoretical Perfection and practical Usability of any language I have yet encountered. Option Explicit would wreck all that. Now, I've always hated VB, but I had not thought of why, until I started using Python. Now that I have decided I really like Python, I explain my choices of Language as follows: (1) C is a great language, because its the only language Python could have been implemented in, and be both portable to a wide set of platforms, yet provide acceptably high performance, and acceptable levels of OS-specific integration. Nevertheless, without Python, I wouldn't want to try to manipulate polymorphic hierachical data sets in bare C or C++. The object model of C and C++ is Insufficient. Obviously a layer on top is necessary for that. That layer is Python. (2) Python is a great language, but I wouldn't want to write a C compiler using it. Well, not just yet, anyways. (3) Visual Basic, at least until Visual Studio.NET is not capable of either #1 or #2, and it remains to be seen if .NET can reverse that. (VB.net will be the first truly Object Oriented version of VB, but will probably still not be fully dynamic like Python.) Warren Postma From peter at engcorp.com Thu Nov 29 21:14:13 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 29 Nov 2001 21:14:13 -0500 Subject: questions about of writing python scripts References: Message-ID: <3C06EB75.15904574@engcorp.com> ed wrote: > > I am writing a program in python, but I find that in using the python > interpreter in writing program I am not able to find errors in the > erliaest stage. I need to run the program a lot of timee just to find > out errors like: > simple syntax errors that are embedded in the functions that I called > in other modules.... > > Is there a way to force the python interpretter to kind of doing > "compilation" of the python scripts, so that I do not need to > rerunning the progrma a lot of times just to find out they are errors > like varibles not defined; functions name not found, variables not > found? Consider using PyChecker. (See http://pychecker.sourceforge.net, although that was offline a moment ago.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From nospam at bigfoot.com Tue Nov 27 09:22:55 2001 From: nospam at bigfoot.com (Gillou) Date: Tue, 27 Nov 2001 15:22:55 +0100 Subject: ActivePython Installation problem References: Message-ID: <9u077t$28dm$1@norfair.nerim.net> Did you doanloaded the latest MS installer from Microsoft ? If you're running Win 95, 98 or NT4, you need it ! The link to this Microsoft installer in dowload page of ActiveState. It worked for me (Win 98). Please post your next questions in plain text. HTH --Gillou "Alves, Carlos Alberto - Coelce" a ?crit dans le message news: mailman.1006867365.26491.python-list at python.org... > Hi all, > I downloaded and try to install the ActivePython-2_1_1.msi program, but it > failed. It seems not be a valid windows package installer. > Anybody could help resolve it?! > I'm using Wndows(hit) 95 > > Carlos Alberto > COELCE/DPRON-Departamento de Projetos e Obras Norte > Fone: 677- 2228 > e-mail: calves at coelce.com.br > \|||/ > (o o) > --ooo0-(_)-0ooo-- > > > From tim at vegeta.ath.cx Sun Nov 11 23:24:24 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 12 Nov 2001 04:24:24 GMT Subject: IsPython really O-O? References: <9sl891$eik$1@slb7.atl.mindspring.net> Message-ID: [ followups set to comp.lang.smalltalk ] Matt Gerrans graced us by uttering: > Roy, I really would like to know why, specifically, your Smalltalk guru (snob, > dare I say) thinks Java (especially) and Python are not OO. [ snipped throwing down of gauntlet ] Them 're fightin' w'rds. If you really need to raise a discussion, the posters comp.lang.smalltalk will be more than happy to tell you why it is that you and hundreds of programming langauges are brain-dead for even dreaming they could get to OO from where they started. I, for one, have had this discussion a dozen times and have not progressed any further in the latter 11 than I did in the first. $ cat debate #!/usr/local/bin/python assert time is infinite steve = Zealot(SmallTalk) matt = Advocate(Python) while isinstance(steve, Zealot): try: matt.argue() if isconvinced(steve): break pigs.fly() steve.say("I'm not convinced.") except: steve.say("Hah! You can't prove it!") $ chmod 700 debate $ debate and echo "They all lived happily ever after." Tim Hammerquist -- As someone pointed out, you could have an attribute that says "optimize the heck out of this routine", and your definition of heck would be a parameter to the optimizer. -- Larry Wall in <199709081854.LAA20830 at wall.org> From gordon.scott at peregrine.com Tue Nov 27 12:14:11 2001 From: gordon.scott at peregrine.com (Gordon Scott) Date: Tue, 27 Nov 2001 09:14:11 -0800 Subject: newbie question - object from a string? Message-ID: Thanks for the reply. Didn't get this until this morning. I have a file named MyHandlers.py in which I have the class MyHandler. when I use __import__('MyHandlers', globals(), locals(), ['MyHandler']) or . . . eval('MyHandler()', globals(), locals()) or eval('MyHandlers.MyHandler()', globals(), locals()) I get a NameError: name 'MyHandler' is not defined. -----Original Message----- From: Chris Liechti [mailto:cliechti at gmx.net] Sent: Monday, November 26, 2001 12:50 PM To: Gordon Scott Subject: Re: newbie question - object from a string? [posted and mailed] Gordon Scott wrote in news:mailman.1006800222.5110.python-list at python.org: [...] > Is there a way to dynamically import the class? Or is there entirely > different approach I should be > using to accomplish this? try the builtin function "__import__" (not the keyword) chris -- Chris From lac at strakt.com Thu Nov 29 08:25:57 2001 From: lac at strakt.com (Laura Creighton) Date: Thu, 29 Nov 2001 14:25:57 +0100 Subject: Strange Tkinter behaviour In-Reply-To: Your message of "Thu, 29 Nov 2001 07:28:00 +0100." <9u4kf5$ran$1@news.onet.pl> References: <9u4kf5$ran$1@news.onet.pl> Message-ID: <200111291326.fATDPvua008396@ratthing-b246.strakt.com> Try calling update_idletasks(). On occasion I have had that work when update() didn't. Laura Creighton From ssthapa at classes.cs.uchicago.edu Fri Nov 30 16:08:55 2001 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Fri, 30 Nov 2001 21:08:55 GMT Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> <20011129.151831.971899228.1845@hp.com> Message-ID: Bill Anderson wrote: >> Actually, there are template based packages for php, and it isn't >> too difficult to create a new template handling class if you don't like >> the existing ones. To be fairly, a standard python cgi will also force >> you to mix presentation and logic since all your html will be in print >> or stdout.write statements inside your script. > >Not true. There are likewise a number of templating packages for Python that >allowing you to "keep 'em separated". I was commenting on the standard python distribution in reference to the original comment about php forcing you to mix html and code. In both php and python the standard distribution doesn't have templating features, however it is fairly easy to get a module that implements it or to create one yourself. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From peter.milliken at gtech.com Wed Nov 7 15:42:25 2001 From: peter.milliken at gtech.com (Peter Milliken) Date: Thu, 8 Nov 2001 07:42:25 +1100 Subject: Announce: New version of Python Templates for Emacs Message-ID: <9sc6f1$ejs3@news1.gtech.com> This post is for programmers who use Emacs :-) A new version of ELSE (Emacs Language Sensitive Editor) has just been released recently. ELSE is a minor mode for Emacs that adds code templating, code abbreviations, code skeletons, whatever term you have for it :-). Basically it allows the user to create standard "forms" for text entry where the "fields" that require user input are easy to navigate to and change - programming is after all, just selection of a "form" and filling in the blanks :-). So ELSE is ideal for any repetitive text entry job where only a portion of the text requires modification/customisation. Examples of such situations are file/function headers, code structures etc etc Today, I have also uploaded a new version of the Python coding templates that can be used with it to generate Python code. These templates are more in keeping with the Python coding standards than the previous set (please point out any errors in my interpretation of that standard :-)). The Python-cust.lse file then contains examples on "overriding" those same standards i.e. you don't like an indentation of 4 spaces then the very first statement shows how to change it to 2 spaces :-) These packages (plus templates for other languages) can be found at http://www.zipworld.com.au/~peterm Full support is provided at no cost :-) Questions are welcomed. Peter From donod at home.com Thu Nov 1 18:39:58 2001 From: donod at home.com (Don O'Donnell) Date: Thu, 01 Nov 2001 23:39:58 GMT Subject: List transpose method References: Message-ID: <3BE1DD41.C58238FE@home.com> Tom Harris wrote: > > Hi, > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > only come up with an ugly multiliner. > >>> lst = [(1,2), (3,4), (5,6)] >>> trn = apply(zip, lst) >>> trn [(1, 3, 5), (2, 4, 6)] Cheers, Don From Gareth.McCaughan at pobox.com Tue Nov 27 17:21:03 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Tue, 27 Nov 2001 22:21:03 +0000 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> <9u0m3l$447$2@peabody.colorado.edu> Message-ID: "Ursus Horibilis" wrote: > Thanks very much. I did not realize that a Python long was not > simply a 64-bit number. Just pure ignorance on my part. Is it > legal to mask a long and assign it to an int? For example: > > (a) is an (int), (b) is a (long) > > b = 6*sys.maxint > > a = b & (0xFFFFFFFF) Yes, but the fact that you ask the question indicates that your model of the universe isn't quite the same as Python's. In Python, unlike C, *values* have types but *variables* don't. There's no such thing as a variable that can only hold "int"s in Python, for instance. So there's nothing illegal about the following (stupid) code fragment: x = 123 # now x contains a short integer x = "I am the walrus" # now x contains a string x = 123L**100 # now x contains a long integer x = None # now x contains None x = [1,2,3,4,5] # now x contains a list x = (1,2,3) # now x contains a tuple class X: pass # (preparing for next line) x = X() # now x contains a class instance x = X # now x contains a class object x = {1:"a", 2:-1} # now x contains a dictionary The same variable can hold all these different types of object: the type information lives with the object, the value, not with the variable. The nearest C equivalent (which isn't very near) would be having all your variables be "void *" pointers, and having enough information in the things pointed to to reconstruct everything. If you do Visual Basic then you might like to think in terms of the Variant type. But it's healthier to think of it on its own terms, rather than mentally trying to translate to C, or Java, or Forth, or whatever. Oh, by the way: sys.maxint is a short integer, not a long integer (NB that when I say "short" here I mean "the same length as a C long on your platform"!), so evaluating 6*sys.maxint will produce an exception. You could say "6L*sys.maxint", though. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From ajb at spkypc.demon.co.uk Tue Nov 27 09:07:49 2001 From: ajb at spkypc.demon.co.uk (ab) Date: Tue, 27 Nov 2001 14:07:49 +0000 Subject: poll() on a linux box always returns POLLIN Message-ID: <3C039E35.DD35CC02@spkypc.demon.co.uk> Hey, Just trying out some asynchronous socket operations in python, simple client server test code. Anyway so I get a queue of threads going waiting to be passed sockets. When they get a socket, I am using poll to implement timeouts. However poll() always seems to return data ready POLLIN, even when client has disconnected and finished. when reading the socket, 0 bytes of data is returned, as you would expect with the peer disconnected ??? any thoughts ??? sample code: while 1: result = poller.poll(5000) print result if result == []: break fd,event = result[0] if event == select.POLLIN: print 'receiving' str = conn.recv(1024) print len(str) print str else: break From printf at hongkong.com Wed Nov 21 18:37:16 2001 From: printf at hongkong.com (printf) Date: Wed, 21 Nov 2001 23:37:16 +0000 Subject: fail to grep the "Server:" string line in headers Message-ID: <3BFC3AAC.60307@hongkong.com> Help I would like to grep the string after "Server:" in the headers. Any one can help me? I think I need get the string of headers, then put to search in "re", and grep the ... And is there any way to "grep" words in python? class collectInfo: def __init__(self, _host): self.host = _host def getServerName(self): h = httplib.HTTP(self.host) h.putrequest('GET', '/') h.putheader('Accept', 'text/html') h.putheader('Accept', 'text/plain') h.endheaders() errcode, errmsg, headers = h.getreply() print headers p=re.compile('Server:') #wrong, why? print p.search(hearders).span()#wrong why? From db3l at fitlinxx.com Tue Nov 6 16:06:54 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Nov 2001 16:06:54 -0500 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> Message-ID: hungjunglu at yahoo.com (Hung Jung Lu) writes: > How soon does a beginner run into the following problem? (see also the > "How much is set in stone?" thread) > > #------------------ > flag = 0 > > def f(x): > flag = 1 > return 2*x > > y = f(3) > print y, flag > #------------------ > output: > 6 0 > > I'd say, most run into this problem soon after they learn to use > functions. It does not matter whether they have seen any other > programming language before or not. Hmm, I'd like to think that learning to use functions would involve local variables far more than globals. Thus, on the less common case where you (a) were using globals and (b) needed to overwrite the global within a local scope, it shouldn't be too hard to introduce the concept and the global keyword without causing overuse. -- -- 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 James_Althoff at i2.com Thu Nov 29 14:41:18 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 29 Nov 2001 11:41:18 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Bjorn Pettersen wrote: >> From: Kerim Borchaev [mailto:warkid at storm.ru] >> >> Hello James, >> Thursday, November 29, 2001, 5:18:43 AM, you wrote: >> Jic> Peter Hansen wrote: >> >>Or just: >> >> >> >>if not 0 <= index < len(mylist): >> >> print 'index out of range' >> >> Jic> Right. Which has the added advantage of not repeating index. >> >> Why not just _use_ that index on the list to check whether it's valid? >> >> try: >> mylist[index] >> except IndexError: >> print 'index out of range' > >Because a negative index doesn't give an IndexError, and presumably we >wanted to make sure the list was accessed through a positive index... > >-- bjorn Exactly. Python's builtin Lists and Tuples are conveniently designed to allow negative indexing. But DefaultTableModel in Jython, for example, can only be accessed using *positive* indicies. You *could* use the exception mechanism with DefaultTableModel, but it isn't quite so convenient, e.g., from java.lang import ArrayIndexOutOfBoundsException try: value = table.getValueAt(i,j) except ArraryIndexOutOfBoundsException: print 'invalid index' And with this approach we don't know which index, i or j, is invalid (without doing even more work). So there can be cases where one prefers to do a bounds check ahead of time. Jim From objectway at divalsim.it Mon Nov 26 08:18:01 2001 From: objectway at divalsim.it (Nicola Musatti) Date: Mon, 26 Nov 2001 14:18:01 +0100 Subject: Pls. help me recreate shell trick References: <3BFE4A90.1C0F1E0C@divalsim.it> <9tlmi5$s5d$1@news1.wdf.sap-ag.de> <9tmmeq$4e6$2@peabody.colorado.edu> Message-ID: <3C024109.389A43A@divalsim.it> Thanks to both Fernando and Daniel for your suggestions. However, I probably didn't explain myself very clearly. My aim is not only to provide display only, debug mode for external commands, but also for possibly disrupting Python statements. One example could be: import shutil shutil.copyfile(src,dest) Thanks for your help. Nicola Musatti From peoter_veliki at hotmail.com Fri Nov 16 17:03:27 2001 From: peoter_veliki at hotmail.com (Peoter Veliki) Date: Fri, 16 Nov 2001 14:03:27 -0800 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> Message-ID: > > also a bit annoyed at some things like having to wrap objects in a str() > > before > > printing, I don't see why this can't be automatic. > > Since when? The print statement automatically invokes str() on its arguments. > From the documentation: I'm using Python 2.0 at the moment (it is necessary as it is integrated into another product), perhaps this limitation was removed in later versions. If I try to do this: print "integer i = " + i it will barf on this and tell me that i is not a string, I must do this: print "integer i = " + str(i) From johnroth at ameritech.net Sun Nov 11 22:12:49 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 11 Nov 2001 19:12:49 -0800 Subject: Teaching python (programming) to children References: <9slmuc.3vuikrp.1@kserver.org> Message-ID: "Sheila King" wrote in message news:9slmuc.3vuikrp.1 at kserver.org... > A little bit ago, I was standing in the kitchen making my breakfast, > thinking about this discussion, and what I would write in reply to you. > And as I stood watching the water boil and the toast toast, my > 13-year-old daughter said to me, "What are you doing, Mom?". And after > giving an obvious reply, I said, "I'm thinking about this discussion I'm > having with someone on the Internet about the 'right way' to teach." And > she said, "There is no 'right way' to teach". So I asked her what she > meant by that, and she said, "Well, not everyone learns the same way. > Some people learn best by seeing things, and others learn best by > hearing things ..." and so on. (I do think that the public school she > attends is rather unusual, in that they do educate the students, even in > elementary school, about different learning modalities, and try to help > the students recognize their own learning strengths and how to find > methods to help them best learn.) Reminds me of my NLP teachers training many years ago, and how to put a lesson plan together so it appealed to all modalities. (Not how to teach NLP - how to use NLP in teaching.) John Roth From just at letterror.com Sun Nov 4 02:48:58 2001 From: just at letterror.com (Just van Rossum) Date: Sun, 04 Nov 2001 08:48:58 +0100 Subject: dictionaries and 'in' in 2.1 References: Message-ID: <3BE4F2E9.69ABF972@letterror.com> Sean 'Shaleh' Perry wrote: > > On 03-Nov-2001 John J. Lee wrote: > > > > The Python 2.1.1 manual, section 2.1.6, says: > > > > k in a 1 if a has a key k, else 0 > > k not in a 0 if a has a key k, else 1 > > > > > > Odd, I thought you had to do "key in dict.keys()". That's the *last* thing you had to do: it's a linear search. The pre-2.2 equivalent to "key in dict" is "dict.has_key(key)". Just From mikael at isy.liu.se Mon Nov 12 11:25:46 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 12 Nov 2001 17:25:46 +0100 (MET) Subject: Language change and code breaks In-Reply-To: Message-ID: On 12-Nov-2001 Mikael Olofsson wrote: > [snip really old stuff - like last summer] Please ignore that message. My mail client is doing it again, i.e. resending old messages. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 12-Nov-2001 Time: 17:24:04 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From joakley at solutioninc.com Tue Nov 27 11:25:48 2001 From: joakley at solutioninc.com (James Oakley) Date: Tue, 27 Nov 2001 12:25:48 -0400 Subject: ScanMail Message: To Recipient virus found and action taken. In-Reply-To: <02f901c1775e$21c62730$0e0fbb82@corp.es.com> References: <02f901c1775e$21c62730$0e0fbb82@corp.es.com> Message-ID: <200111271625.fARGPdQ31629@tesla.solutioninc.com> On November 27, 2001 12:11 pm, Administrator wrote: > ScanMail for Microsoft Exchange has detected virus-infected attachment(s). ...snip... As annoying as getting Windows viruses is, getting multiple copies of this is worse. Imagine if 200 people on the list were running this stupid Exchange thing... Yikes. -- James Oakley Engineering - SolutionInc Ltd. joakley at solutioninc.com http://www.solutioninc.com From skip at pobox.com Mon Nov 12 02:19:42 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 12 Nov 2001 08:19:42 +0100 Subject: Teaching python (programming) to children In-Reply-To: <3BEF7170.4E387A7D@mindspring.com> References: <3BEF7170.4E387A7D@mindspring.com> Message-ID: <15343.30734.530486.460027@beluga.mojam.com> David> I want to mention that the November 2001 American Journal of David> Physics has an interesting article "Physics Education David> Research--The Key to Student Learning" by Lillian Christie David> McDermott who won the Oersted Medal from the American Association David> of Physics Teachers (AAPT) for her research into the teaching of David> physics. For those people who don't subscribe to the AJP, the PDF slides from McDermott's Oersted Award Lecture (62 in all) are at http://www.psrc-online.org/classrooms/mcdermott.htm If you do subscribe to AJP, you can read the full article online at: http://ojps.aip.org/getabs/servlet/GetabsServlet?prog=normal&id=AJPIAS000069000011001127000001&idtype=cvips&gifs=Yes -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From robin at jessikat.fsnet.co.uk Sun Nov 11 07:35:57 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sun, 11 Nov 2001 12:35:57 +0000 Subject: multipack Message-ID: I'm looking for multipack the numPy extension, by Travis Oliphant. The old link http://oliphant.netpedia.net/ seems to require a password and the sf link http://pylab.sourceforge.net/packages/multipack-0.7.tar.gz gives a 404 (there are no files in the pylab project). Does multipack still exist? -- Robin Becker From martin.franklin at westgeo.com Wed Nov 21 03:46:56 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Wed, 21 Nov 2001 08:46:56 +0000 Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> Message-ID: <9tfpkk$2eu4$1@mail1.wg.waii.com> Don Arnold wrote: > I'm new to python and am interested in developing apps with Tkinter. > However, every IDE I've come across for the Win32 platform experiences > lockups/aborts when running Tkinter code. So far I've tried IDLE, > PythonWin, and WING with little luck. Does anyone know of an IDE that > successfully executes Tkinter code? > > Thanks, > Don Arnold > try SciTE http://www.scintilla.org/SciTE.html From pinard at iro.umontreal.ca Wed Nov 14 17:53:54 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 14 Nov 2001 17:53:54 -0500 Subject: How to marshal a function? In-Reply-To: <01111412544105.04702@logiplex1.logiplex.net> References: <01111412544105.04702@logiplex1.logiplex.net> Message-ID: [Cliff Wells] > > I quickly found out that, for a given `function f(...) ...' I should > > transmit marshal-ed `f.func_code' instead of `f'. > Try pickle (or cPickle) rather than marshal: I did not even try `pickle' for that, after the documentation (printed at 1.5.2 time) insists that `pickle' has no representation for code objects. > import pickle > def f(a, b, c): > return a + b + c > pc = pickle.dumps(f) > # transmit pc to another machine... > f = pickle.loads(pc) > print f(1, 2, 3) If you examine `pc', you will have some difficulty to believe that it actually conveys the function definition. It probably only holds a reference to the name. Oh, it does works if I do everything in a single Python session, because `f' is already defined. But if I save `pc' to disk and reload it in a fresh Python session, the `pickle.loads(pc)' yields: SystemError: Failed to import class f from module __main__ So, I would not think that `pickle' is a solution. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From mgerrans at ix.netcom.com Fri Nov 30 16:21:11 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Fri, 30 Nov 2001 13:21:11 -0800 Subject: string.join() syntax quirky? References: Message-ID: <9u8t76$nlv$1@nntp9.atl.mindspring.net> > Yep, this has been pounded before. I actually liked it better when it was > string.join(s, l), but oh well. You can still use string.join(), but it would be string.join(l,s). - mfg From bh at intevation.de Tue Nov 6 14:56:49 2001 From: bh at intevation.de (Bernhard Herzog) Date: 06 Nov 2001 20:56:49 +0100 Subject: Python packages - problems, pitfalls. References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: Prabhu Ramachandran writes: > >>>>> "BH" == Bernhard Herzog writes: > > >> pkg_root/ __init__.py app.py # app is the application that is > >> not part of the package > > BH> If it's not part of the package, why is it in pkg_root? Put it > BH> somewhere outside of pkg_root, make sure pkg_root is in a > BH> directory on Python's path and everything should be fine. > > Easier said than done. If I wanted to do this I'd have to re-nest > every blessed file in CVS. This is something I want to avoid. Do you mean that pkg_root is the CVS module? Ouch! Well, there's a way to achieve it without much renaming in CVS with CVS' modules file. If you create a new CVS module named app with app.py and a line like app app &pkg_root a cvs checkout app should create an app directory with pkg_root as subdirectory. Caveat: I'm not a CVS expert and I haven't used this feature myself yet, but it's used quite a bit in GNOME's CVS. [ni could refer to the parent module with __] > Yes, unfortunately, this way of referring to parent packages was > removed! From: http://python.org/doc/essays/packages.html > > "This feature was dropped because of its awkwardness; since most > packages will have a relative shallow substructure, this is no big > loss.)" > > If you ask me that is a bad assumption. "most packages will have a > relative shallow substructure" - where was that pulled out from?? Well, in your pkg_root example the packages were nested two deep. I'd count that as "relative shallow". > Let me try to be a little clearer. This is what Python does now: > > (1) Check if module is in same directory (sibling module). > > (2) If not found - look at the global level for modules in any > directories found in sys.path. Correct. > There is *absolutely* no in between here. Its either local or global. > What I suggest. > > (1) Check if module is available in the same directory, if available > - use it. > > (2) If not found walk up to parent dir. check there, if not there > go up until out of package. > > (3) If not found in (2) look at sys.path for module. I don't think that will help with your problem. At least not as far as the app.py part is concerned. If you execute app.py in pkg_root, all sub-packages are on the top-level, i.e. there is not parent package, because pkg_root is in sys.path. Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From cimarron+google at taylors.org Mon Nov 12 05:45:08 2001 From: cimarron+google at taylors.org (Cimarron Taylor) Date: 12 Nov 2001 02:45:08 -0800 Subject: Fw: Re: IsPython really O-O? References: Message-ID: <29e28c51.0111120245.3ecf070f@posting.google.com> Nahuel Greco wrote in message news:... > On Sat, 10 Nov 2001 20:13:47 -0500 > wrote: > All the objects created (in your "box", the ST) are "persistent" by default, > when you close the ambient/box, the next time that you open it, are there. > There isnt a distinction between "Create the program" and "Use it", you always > play with live objects. Yikes! How do you make this scale? Suppose you have a hundred developers. Suppose one of them changes a method. Do all the other developers immediately see the change? What do you do about changes in data formats? How do you ever maintain changes to a production system if anyone can change anything at any time? Cim From timo.savola at iki.fi Thu Nov 8 18:15:18 2001 From: timo.savola at iki.fi (Timo Savola) Date: 09 Nov 2001 01:15:18 +0200 Subject: Defining inheritance in C extensions Message-ID: <1005261318.4142.20.camel@whiz-bang> Hello. I'm new to this list, and relatively new to Python (played around with it every now and then, and used it as a calculator :). Now I'm doing an extension module, or rather a system that I want to control via Python. I have a C++ class hierarchy that I want to be accessible from Python. I can't figure out how to make a type object a subclass of another type object, so that I can do type checking in the Python wrappers of my methods. I've been browsing the Extending and Embedding section of the Python documentation (version 2.2). Is it just me, or has the Defining New Types section fallen short? It doesn't say anything about /* Attribute descriptor and subclassing stuff */... Is there a more extensive reference to extending Python, or maybe some comprehensive example code on the subject? Thanks in advance. :) Timo From phd at phd.pp.ru Thu Nov 1 03:42:19 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 11:42:19 +0300 Subject: Freeware Python editor In-Reply-To: ; from sholden@holdenweb.com on Wed, Oct 31, 2001 at 03:48:57PM -0500 References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> Message-ID: <20011101114219.C30403@phd.pp.ru> On Wed, Oct 31, 2001 at 03:48:57PM -0500, Steve Holden wrote: > "Oleg Broytmann" wrote in message > news:mailman.1004551447.32304.python-list at python.org... > > On Wed, Oct 31, 2001 at 09:45:25AM -0800, Erik Max Francis wrote: > > > You said you didn't want to start another GNU flamewar. But what do you > > > think you're doing? > > > > Trying to stop you arguing :) > > > I'm sorry, this is abuse. I have no problem abusing this in case people are trying to restrict my freedom. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From James_Althoff at i2.com Fri Nov 16 20:20:48 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 16 Nov 2001 17:20:48 -0800 Subject: Recap: PEP 276 Simple Iterator for ints Message-ID: William "Billy" Tanksley wrote: >It isn't even a tradeoff. > >You can provide both __getitem__ and __iter__, and you're set. Providing >__getitem__ doesn't mean you're a list or tuple; it just means you're a >sequence. If you do that the way range() has in the past, you're an >idiot. There's absolutely no reason to store all the integers in a range >which you could instead store start,stop,and step, and generate them as >needed. I don't see it as being quite that clear cut. Take the proposed Haskell-esque syntax, for example. If one were to see: list1 = [0, 1, 2, 3, 4] list2 = [1, 2 .. 5] it might be surprising that list1 is an actual list while list2 is a minimalist sequence. Since list1 is a real list, one can append to it, remove from it, replace items in it, slice it, etc. If list2 is a minimalist sequence as suggested, then such operations are not defined -- unless even move magic methods are implemented, which seems to be the *opposite* direction of PEP 260 "Simplify xrange()" (which is done and implemented). Like the new xrange, the proposed minimalist sequence might be designed to "have one idiomatic use", namely, as part of a for-loop. And perhaps one might propose even that said syntax is *invalid* except in a for-loop (or in conjunction with "in", say). But again, this might surprise users who might see the new Haskell-esque syntax as a nice extension of the current *list* literal syntax. Maybe this is ok. But it still seems to me that there are design tradeoffs that need to be addressed. Jim From fredrik at pythonware.com Wed Nov 28 02:58:38 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 28 Nov 2001 07:58:38 GMT Subject: Is selecting from multiple list boxes in Tk possible? References: <3C047207.8243CFE7@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote: > But it seems that making a selection in one > listbox causes any selections in any other listboxes > in the same window to be cleared. Is there any > way of preventing this from happening? set the exportselection option to 0. there's a brief discussion about this in the "listbox patterns" section in the tkinter introduction: http://www.pythonware.com/library/tkinter/introduction/listbox.htm => pattern From dsavitsk at e-coli.net Wed Nov 7 17:17:00 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Wed, 07 Nov 2001 22:17:00 GMT Subject: Python, FreeBSD, idle Message-ID: i installed a new FBSD 4.4 system. i installed Python 2.1.1 from the packages menu. i then installed idle (0.5) from the ports collection. this inturn installed python 1.5.2. from a terminal when i type "python" 1.5.2 is started. is there a trick to linking idle to 2.1.1, and easily resetting it (2.1.1) as the default? or better yet, i notice that idle is up to 0.8 on windows ... has anyone done any work to update the FreeBSD port? doug From stuart at bmsi.com Mon Nov 12 14:07:07 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Mon, 12 Nov 2001 14:07:07 -0500 Subject: Is ST really O-O? References: Message-ID: <9sp6ks$tnp$1@nntp1-cm.news.eni.net> In article , "Tim Hammerquist" wrote: > A major problem "pure" or "true" OO advocates have with Python et al. is > data hiding. Encapsulation (at least in the Python-intended sense) is > implemented, but with enough hacking, a coder _could_ access an object's > private data at runtime. This is a serious offense to many OO radicals, > esp. Smalltalkers. That is a silly objection. Smalltalk implements data hiding, but with enough hacking, a coder _could_ access an objects private data at runtime (via (ab)use of introspection, dynamic class modification, generic persistance mechanisms, etc. etc.). So I guess ST isn't O-O either by that criterion. In general, if a language provides for generic persistence or debuggers written in that language, then those features can be abused to violate encapsulation. This is why introspection and persistence are considered security sensitive in the Java system. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - Mozart background song for the Microsoft "Where do you want to go from here?" commercial. From ianb at colorstudy.com Tue Nov 13 14:58:31 2001 From: ianb at colorstudy.com (Ian Bicking) Date: 13 Nov 2001 11:58:31 -0800 Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> Message-ID: <359f85cd.0111131158.1520ea32@posting.google.com> Erik Max Francis wrote in message news:<3BEE09CD.FFC433CC at alcyone.com>... > Java _is_ object-oriented, so I don't see how this is a negative. Note > that object orientation looks a little different in message-oriented > languages (such as Smalltalk or Objective C) rather than in > call-oriented languages (like C++, Java, or Python). If you look under the hood, Python is much more like Smalltalk than Java. The message-passing of smalltalk is the same as a function call -- though the syntax obscures that. The (subtle) difference between message-passing and method-calling is that message passing *sends* something to the object, while calling *calls* something. Calling implies that the language pretty much knows what's being called before it calls it. Python is really sending, not calling. You don't (ever) know before runtime what function definition is going to be invoked. By overriding __getitem__ and other special methods, you can make the object fully dynamic -- just like you can do in Smalltalk, but can't do in Java. (There are some holes in Python with respect to this, but they are all being filled so they should be ignored for this argument) Maybe to explain this a bit more: in Smalltalk every method call is like sending a message to the object. So when you do (someObject moveTo: 10) you are actually sending (#moveTo:, 10) to the object, which it can interpret as it wants. It usually searches its class for a method definition named #moveTo:, but it does not have to. The exact same thing happens in Python. when you do (someObject.moveTo(10)) in python, you are sending ("moveTo", 10) to the object. Most of the time it searches the class for a method named "moveTo", but the object can really do anything it wants with it. This is why both Python and Smalltalk are message passing languages. Python starts out from somewhere different than Smalltalk -- particularly that it's default object model is much more concrete and not altogether as regular. But you can go to all the same places. And what makes Smalltalk so cool -- that you can have so much power over the language and objects, so that an object can pretend to be anything you want it to be -- is also true for Python. And it's getting truer all the time as 2.x progresses. From cs1spw at bath.ac.uk Mon Nov 26 05:03:02 2001 From: cs1spw at bath.ac.uk (Simon Willison) Date: 26 Nov 2001 02:03:02 -0800 Subject: (newbie) A very weird Python CGI problem, possibly related to os.system Message-ID: I have a very odd Python CGI problem. I'm writing a simple web script which queries Quake III game servers and displays the server name / map / number of players on a web page. The script works by executing a command line program called qstat (www.qstat.org). I'm very new to python, and I'm using this project as a learning excercise. Anyway, here's the problem: When I run the script I have written from the command line it works fine: bwaf $ qstat.py OMG!! ResNet Game Server Listing System

[{'maxplayers': '12', 'name': 'blueyonder Quake 3 Free For All #2', 'players': ' 0', 'ip': '62.30.30.160:27961', 'map': 'q3dm8'}, {'maxplayers': '12', 'name': 'b lueyonder Quake 3 Free For All #1', 'players': '0', 'ip': '62.30.30.160:27960', 'map': 'q3dm13'}] However, when I visit the script on the web the page displayed shows an empty list: ResNet Game Server Listing System [] The script is here: http://www.bath.ac.uk/~cs1spw/cgi/servers/qstat.py I'm completely baffled as to why the list is populated when I run the script myself, but appears empty when the script is executed via the web. Could this be a unix permissions problem? I doubt it, as a smaller test script which I wrote to display results from qstat shows information in the browser fine. Unfortunately the script is quite long so I'll only post a snippet here, I'm happy to post the rest (or place it on the web) if it will help solve the problem. Cheers, Simon import os, sys, string, tempfile, common from common import custom_die, servertypes qstat = '/u/cs/1/cs1spw/qstat24e/qstat' # Path to qstat tempdir = '/u/cs/1/cs1spw/public_html/cgi/servers' # Used by mktemp() badstatus = ['DOWN', 'TIMEOUT'] def gameservers(game): """ returns array of dictionaries of server details for game """ array = [] # Run qstat on the game file if (not servertypes.has_key(game)): custom_die('Invalid game specified!') tmp = tempfile.mktemp() run = qstat + " -raw ~@~@~ -f " + game + " > " + tmp os.system(run) file = open(tmp, 'r') lines = file.readlines() file.close() os.remove(tmp) for line in lines: if (string.strip(line)): try: bits = string.split(line, '~@~@~') except ValueError: continue if (string.strip(bits[2]) in badstatus): continue else: # Create a dictionary of details about the server dict = {} dict = { 'ip': bits[1], 'name': bits[2], 'map': bits[3], 'maxplayers': bits[4], 'players': bits[5] } # put the dictionary in the array array.append(dict) return array # test code common.output('OMG!!', gameservers('q3s')) And from common.py... servertypes = { 'q3s': 'Quake III', 'hls': 'Half-Life' } def output(title, html): """ outputs a page using header.txt with %title% replaced and footer.txt """ file = open('header.txt', 'r') lines = file.readlines() file.close() for line in lines: line = string.replace(line, '%title%', title) print line print html file = open('footer.txt', 'r') lines = file.readlines() file.close() for line in lines: print line sys.exit(0) def custom_die(message): """ Die with an error message """ output('Error!', message) From QnickQm at alum.mit.edu Mon Nov 12 15:25:20 2001 From: QnickQm at alum.mit.edu (Nick Mathewson) Date: Mon, 12 Nov 2001 20:25:20 GMT Subject: [Hack][2.2] One way to implement private variables Message-ID: Here's a neat way to hack up private methods and variables in Python 2.2. BUGS: -It's not terribly optimized, and there are probably better ways to do it. -It isn't very paranoid. For instance, you still circumvent access restrictions as easily as: Class.privatemember.basic_get(obj) This may be considered a feature. -It doesn't distinguish between readers and writers. ============================================================ import sys import types class ForbiddenAccess(TypeError): pass class private(object): __slots__ = ["permittedCode", "basic_get", "basic_set", "basic_del" ] def __init__(self, basic, permitted): self.basic_set = getattr(basic, "__set__", None) self.basic_get = getattr(basic, "__get__", None) self.basic_del = getattr(basic, "__del__", None) self.permittedCode = {} try: it = iter(permitted) except TypeError: permitted = [permitted] for v in permitted: self.__buildcodeset(v, self.permittedCode) def __get__(self, obj,type=None): if hash(sys._getframe().f_back.f_code) not in self.permittedCode: raise ForbiddenAccess() return self.basic_get(obj,type) def __set__(self, obj, val): if hash(sys._getframe().f_back.f_code) not in self.permittedCode: raise ForbiddenAccess() return self.basic_set(obj, val) def __del__(self, obj): if hash(sys._getframe().f_back.f_code) not in self.permittedCode: raise ForbiddenAccess() return self.basic_del(obj) def __buildcodeset(self, obj, codeset): if isinstance(obj, types.FunctionType): codeset[hash(obj.func_code)] = 1 elif isinstance(obj, types.UnboundMethodType): codeset[hash(obj.im_func.func_code)] = 1 elif isinstance(obj, (type, types.ClassType)): for v in obj.__dict__.values(): self.__buildcodeset(v, codeset) if __name__ == '__main__': class User(object): __slots__ = ["x","y"] def __init__(self): self.x = 0 def setX(self, val): self.x = val def getX(self): return self.x User.x = private(User.x, User) u = User() print u.getX() u.setX(99) print u.getX() try: print u.x, "This should never be reached" except ForbiddenAccess: pass try: u.x = 3 print "This should never be reached." except ForbiddenAccess: pass ============================================================ "Protected"-left-as-an-exercise-for-the-reader-ly y'rs, -- Nick Mathewson Remove Q's to respond. No spam. From bac at OCF.Berkeley.EDU Sun Nov 18 23:45:44 2001 From: bac at OCF.Berkeley.EDU (Brett Cannon) Date: Sun, 18 Nov 2001 20:45:44 -0800 Subject: Pulling out In-Reply-To: References: Message-ID: You could just read each page and use a regex to fetch it: title_value=re.search(r'(?P<title>.*?)',re.I) title_value.group('title') -Brett C. On Sun, 18 Nov 2001, David A McInnis wrote: > I am writing a script to catalog about 30,000 html pages on my site and need > to pull out the value of . > > I guess this is possible with htmllib, but I cannot figure it out. > > Thanks, > David > > > From olli at secnetix.de Wed Nov 14 08:14:09 2001 From: olli at secnetix.de (Oliver Fromme) Date: Wed, 14 Nov 2001 13:14:09 +0000 (UTC) Subject: PEP proposal: enhanced string functions References: <9stdc2$6abo$1@mail1.wg.waii.com> Message-ID: <9stqn1$gqo$1@isp-m-srv06.izb.net> Martin Franklin wrote: > Matthew Dixon Cowles wrote: >> On 13 Nov 2001 12:54:47 -0800, Stephen Ferg wrote: >>>Title: Optional pad character for string justification functions >> >> I like this. > > Me too. For the center() case, it might be useful to optionally allow another argument, so you can have different padding on the left and on the right. Example: >>> string.center(" Title ", 25, ">", "<") '>>>>>>>>> Title <<<<<<<<<' >>>Title: Optional argument for string strip functions > [...] >> This bothers me a bit for the same reason that the split() method >> does. It strikes me as weird that without arguments, split() splits on >> all whitespace but that it will only take one character as an >> argument. I'd prefer to be able to pass a sequence to strip() and have >> any of those characters stripped. > > how about adding new methods stripc(), rstripc(), lstripc(), (or > stripchar()) then maybe stripword() etc for what you want...... I'm not so convinced about that. Instead of adding a whole bunch of new functions, maybe better think about using re.sub and re.split, which already do what you want (and more). Just my 0.02 Euro. Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From altis at semi-retired.com Fri Nov 9 23:03:16 2001 From: altis at semi-retired.com (Kevin Altis) Date: Fri, 9 Nov 2001 20:03:16 -0800 Subject: Example for using MySQL References: <9sg7t8$12a85q$1@ID-69142.news.dfncis.de> Message-ID: "Andreas Penzel" wrote in message news:9sg7t8$12a85q$1 at ID-69142.news.dfncis.de... > Hello NG! > > Where can I find an example for using MySQL in Python (specially how to > connect to the DB)? There is a MySQL example included with PythonCard http://pythoncard.sourceforge.net/ You can download PythonCard at: http://sourceforge.net/project/showfiles.php?group_id=19015 ka ps. My first reply seems to have been eaten by my ISP, but apologies in advance for a double-post if it shows up (I posted the first reply over 8 hours ago). From sg_oneill at hotmail.com Tue Nov 13 01:17:05 2001 From: sg_oneill at hotmail.com (goonfist) Date: 12 Nov 2001 22:17:05 -0800 Subject: IsPython really O-O? References: Message-ID: <572d36a5.0111122217.62b80fa2@posting.google.com> Hee! Indeed by Smalltalks standards, many OO things , python included , aren't reeeeealy truly objecto-puro-oriento , but there we have it! Endorsement! That said , python doesnt encourage you to directly fiddle with 'properties', but rather fiddle with 'methods' , so it's pretty good like that. James_Althoff at i2.com wrote in message news:... > Kent Smith wrote: > >A Smalltalk guru in our organization looked at Python last weekend (after > I > >had made a big scene saying that it may be a solution to some of our > >cross-platform issues) and came away saying that it was no more > >object-oriented than Java. I sputtered around a bit but could hardly make > a > > I worked in the LRG group (Learning Research Group, aka the Smalltalk team) > at Xerox PARC in the late seventies / early eighties under Alan Kay and > Adele Goldberg and helped design and implement the original Smalltalk-80. > > Therefore, by the powers vested in me by no one in particular, I hereby > proclaim Python to be > > "Plenty-good OO!" > > Helpfully yours, > > Jim From lac at strakt.com Sat Nov 10 16:41:06 2001 From: lac at strakt.com (Laura Creighton) Date: Sat, 10 Nov 2001 22:41:06 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Sheila King of "Sat, 10 Nov 2001 19:00:58 GMT." Message-ID: <200111102141.fAALf6ua011230@ratthing-b246.strakt.com> > Sheila King > Well, in my opinion, the problem is in the way the previous teachers > have assessed the students, allowing them to get by with such a shallow > understanding of the topic. Whether or not the graphing calculators is > used in the course is really not the issue. The issue is: What type of > test questions was the student required to answer. The best scenario, > would be having the student take tests, at least half of the time, with > no calculator permitted, and having them answer meaty questions on the > topic. In other words: I'm not sure that the problem here is either > curriculum or method, but assessment. This is crazy. The problem is that the students didn't learn. Assessing the fact that they didn't learn may help educators, parents, and the students themselves realize that there is a huge problem, but the question remains: Is this a decent way to teach mathematics? > You admit, earlier, that the number of students you've encountered who > have this shallow understanding is small, and yet you say that you want > to dictate what "high school teachers" should do. Yes. The students I have met who have been exposed to this method has also been small, foreign students mostly. What I want to dictate to all teachers is that what they do actually promotes learning whatever subjects they are teaching. Assesment is good for this, as a way to evaluate the teachers, and their courses. Let us say, for argument, that a teacher who is using method A needs to spend 4 times as much time individually coaching students and gettting involved with them personally than a person using method B. Then only teachers who are also willing to make the commitment to spend the 4 times as much should be using method A. And if that is only, say 10% of the population of teachers as a whole, then method A, whatever its virtues when taught well, must be discouraged, unless we have a way to restrict its use to the 10% who are capable and willing to use it effectively. Its wholesale adoption means society as a whole suffers, and, in the aggregate, statistically speaking, students as a whole are being more poorly taught. This really stinks for the teachers in the 10%, and their students, but the alternative really stinks for everybody else. > In my experience, it doesn't matter what group you are dealing with, > whether it is teachers, doctors or plumbers, there will always be a > small part of that group that is "bad". And it really isn't reasonable > to form the policies for an entire groups based on a few "bad" ones. Yes. My suggestion was for the bottom third, not the handful of worsts. If somebody made me _God_ I think that I would ban the bottom half of teachers from the profession, on the grounds of our children deserving better. I'd do that every 10 years or so, and give teachers a huge increase in salary so that it would attract the best minds, and the best people in general in the profession, instead of what we have now. Until this happens, we have to design educational platforms so that the poorest third of our educators can educate with them. There is nothing pleasant about this at all. But I don't see being made God any day soon, so this is the harsh reality we are stuck with. > In any case, here is what I really think: [much snipped. I don't live in the United States. I have no idea if any of the mentioned programs are effective. If they are, I like them even if all the teachers hate them. If they aren't I hate them. What I hate worse is why you can't get rid of them already. This makes it political, which I understand gets in the way of stopping doing bad things because they are bad. Testing and assessing is only of use if we can make some hard conclusions here and stop doing foolish things.] > I agree with you completely about the current situation, with students > who have a very concrete understanding of math but are unable to make > the bridge to abstractness. This has always been one of my battles in > the classroom. Currently I'm teaching two sections of College Algebra, > and these students have NO abstract thinking ability nor any ability to > set up word problems. (OK, that's a sweeping generalization. Maybe I > have a few who do have these abilities.) But this course is supposed to > introduce some abstraction, and it is like pulling them kicking and > screaming. But, I try to take care to ask questions that get at the > abstract ideas, or to disallow calculators on some of the exams and > quizzes where they might be used as a crutch (i.e. design questions > where the calculator is no advantage, or band them from the test if they > are one). At least, they will not pass the course I am teaching without > some ability to think abstractly. This is the part that is under my > control, which I can do something about. What if its too late? How old are these students? If they are in college then it is way too late for them. You have to start developing a mathematical intuition in childhood, and really grow one through adolescence. You can't graft one on later, no matter how much you would like to. It is precisely the same sort of thing as a dietary deficiency. You correct that when you find it, but you can't undo the stunted growth that was supposed to happen and didn't. Why isn't this considered child abuse? Why can't we find the bad policies at every level that cause this and stop them? Whoever in the United States thinks that college level is the place to learn abstraction is either a fool or a very evil person and in any case I want him or her out of the education business. Now. angry as anything, though not at you, Laura Creighton From wurmy at earthlink.net Mon Nov 26 12:17:38 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Mon, 26 Nov 2001 17:17:38 GMT Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <83bshqtek2.fsf@panacea.canonical.org> <3c021cd7@brateggebdc5.br-automation.co.at> Message-ID: <3C02792B.3748A916@earthlink.net> Thanks to everyone who replied to my questions about licenses and CVS. Things are clearer now. I have a follow-up question though. The project I'm currently working on is well suited for third-party contributions; it makes sense for others to add modules if they want to. If my code is released under, say, the GPL, what happens when someone else wants to contribute to it? Does the new code have to be GPL too? Or GPL-compatible? TIA, --Hans From huaiyu at gauss.almadan.ibm.com Thu Nov 29 22:06:09 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Fri, 30 Nov 2001 03:06:09 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C053AA4.97246A72@ccvcorp.com> Message-ID: On Thu, 29 Nov 2001 15:15:09 -0500, Steve Holden wrote: >"Huaiyu Zhu" wrote... >[Jeff Shannon and Huaiyu go back and forth ...] >> >> So the ideal world is all spaces, no tabs. It is then not a big leap to >> allow tab as a shorthand to replace the number of spaces used as indent. >> >Just because I can hear Peter banging his head on the desk from here, let me >agree wholeheartedly with your first sentence, and point out that in your >second sentence you fall again into the error of assuming that a tab will >always represent a fixed number of spaces. It does not have to be the same size. Example: Consider A and B editing the same file with different editors: (1) There is no problem if: A sets indent=4spc. B sets indent=3spc. Both sets indent=tab. (2) The current problem is often caused by: A sets tab=8spc. B sets tab=4spc. Both sets indent=4spc. Why are these two different? Because - tab can change size with setting. space can't. - people want to change indent size or tab size. - changing indent level will mess up program. The link indent-tab-space works even when people use different sizes. The link indent-space-tab works only if everyone used the same size. But since Tim has spoken I'll stop right here. Huaiyu From wtanksle at dolphin.openprojects.net Mon Nov 12 18:25:12 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 12 Nov 2001 23:25:12 GMT Subject: Benefits of moving from Python to Common Lisp? References: <3BEFD773.3080204@cs.wisc.edu> Message-ID: On Mon, 12 Nov 2001 08:06:43 -0600, Manoj Plakal wrote: [macros] > I'm curious (I haven't done much programming in Lisp). > Doesn't this make CL programs harder to read? No. In the hands of a bad programmer, macro-laden source is a true horror, but this doesn't change anything: a bad programmer's source is a horror whether he uses macros or not. In the hands of a good programmer, though, macro allow you to grow the language closer to the solution domain, so that your solution can look natural and clear to people who understand the problem. So there's a lot to gain, and not much to lose. > Manoj -- -William "Billy" Tanksley From gmcm at hypernet.com Thu Nov 15 08:09:02 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 15 Nov 2001 13:09:02 GMT Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <97ae44ee.0111142345.5679aca4@posting.google.com> Message-ID: Stephen wrote: [Gordon] >> About 3 years ago, I wrote a Python message-slinger as a drop-in >> replacement for my client's C code. It did around 600 msgs / sec (vs >> <200 / sec for the client's code). That was Python 1.4 on 3 year old >> hardware. > > Thanks for the example, Gordon. Gives me the confidence knowing that > "it is possible" ~ now I just have to work out how. It's very > reassuring, rather than having doubts and asking myself "should I > be doing this directly in C/Java instead?" whenever I hit a problem. > >> So 1000 / sec is quite possible, but you'll never get there with >> blocking sockets. > > Even if they're threaded ? Even if they're threaded. Thread creation is high-overhead (allocating megs of memory, for one thing). If you do use threads, it's better to create a thread pool and reuse them. Depends on platform, but if you're using more than (say) a dozen threads, you're probably wasting resources. It's also vastly more efficient to use select than to have the OS cycle through a bunch of context-switches, testing for socket activity. Basically, the "one thread per socket" model sucks. > May I ask what you used for the 600 msgs/sec ? Select's and asyncore ? It was very similar to asyncore. - Gordon From dinceraydin at softhome.net Wed Nov 28 19:31:38 2001 From: dinceraydin at softhome.net (Dincer Aydin) Date: 28 Nov 2001 16:31:38 -0800 Subject: writing to parallel port? References: <55881dd4.0111280848.3d2b38ab@posting.google.com> Message-ID: <3112302e.0111281631.1c54a918@posting.google.com> > is it possible to write to the > parallel printer port from > Python? It is possible with the winioport module at www.geocities.com/dinceraydin/python/indexeng.html Regards, Dincer Aydin From printers at sendme.cz Tue Nov 20 10:03:37 2001 From: printers at sendme.cz (A) Date: Tue, 20 Nov 2001 16:03:37 +0100 Subject: Default DNS Message-ID: <3BFA7ED9.14355.557930@localhost> Hi, Is there any possibility in Python to find out my primary or secondary DNS when using Dial Up connection from Windows? Thank you for help. Ladislav I look forward to hearing from you soon. Best Regards, Ladislav Blazek( Mr.) BMA TRADING Ltd. email: export at sendme.cz email2: export at bmatrading.com Fax:/Tel +420 506 447921 Tel:+420 506 447920, +420 602 849309 From loewis at informatik.hu-berlin.de Thu Nov 1 08:51:25 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Nov 2001 14:51:25 +0100 Subject: Component model References: Message-ID: Rock VZ writes: > Does Python have support for the component model > followed by Bonobo or KPart. There is a number of wrapper libraries, PyQt/PyKDE and pygtk/gnome-python/bonobo-python. See http://www.daa.com.au/~james/gnome/ http://theta.lajnux.nu/bonobo-python/ http://www.xs4all.nl/~bsarempt/python/tutorial.html for details. Regards, Martin From fredrik at pythonware.com Fri Nov 23 19:20:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sat, 24 Nov 2001 00:20:41 GMT Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> <3bf9f33a.5900599@24.0.228.33> <9tf4fo$fb5$1@nntp9.atl.mindspring.net> <3bfec43c.2822417@nntp.ix.netcom.com> Message-ID: Mike Clarkson wrote: > This is unfortunately the cause of the problem in this case. > In Python, if you're having troubles, remove all the 'import *' > you can find and replace them with 'import' for safety. > > >def quit(): > > print "Hello, I must be going" > > root.quit() > > The problem here is that root is not your root - it's a default > root in Tkinter that came in with your 'import *'. What are you talking about? It's perfectly safe to use from-import with Tkinter. And there's no "root" variable in Tkinter: >>> from Tkinter import * >>> root Traceback (most recent call last): File "", line 1, in ? root NameError: name 'root' is not defined (if you think you see one, you've probably missed that IDLE doesn't reset the __main__ namespace between runs. the real default root is stored in a variable called _default_root, and isn't imported by from-import). And you don't seem to understand global variables either; even if Tkinter did provide a root variable, it would have been overwritten *before* the script created the button. There's no way you can end up in the quit function before that. And the global statement doesn't do what you think it does. Etc. All you've done is that you've made sure root.destroy is called when the script returns from the call to mainloop (this call isn't needed if you run the script outside IDLE, or in a real IDE that doesn't insist on running your program inside its own Python environment). Do the same thing to the original script, and you get exactly the same behaviour. From jason at tishler.net Wed Nov 28 10:10:29 2001 From: jason at tishler.net (Jason Tishler) Date: Wed, 28 Nov 2001 10:10:29 -0500 Subject: std. python from cygwin: the final word (?) In-Reply-To: Message-ID: <20011128101029.B2516@dothill.com> John, On Wed, Nov 28, 2001 at 12:22:05PM +0000, John J. Lee wrote: > After several, surprising long, threads, the collective brain power of > c.l.python and the cygwin mailing list has produced the following magical > shell incantations: > > #!/bin/sh > > python='/d/Program Files/Python21/python' > if [ "$1" = "" ]; then exec "$python"; fi > cp=`cygpath -w $1` > shift > exec "$python" "$cp" ${1+"$@"} If you are willing to use rxvt, then the following trigger is a simpler alternative: #!/usr/bin/env pythonw Jason From anthony at interlink.com.au Wed Nov 7 19:46:00 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 08 Nov 2001 11:46:00 +1100 Subject: Q: Fast searching Imap server, IMAP server (in Python) In-Reply-To: Message from Jan Kybic of "07 Nov 2001 13:44:44 BST." Message-ID: <200111080046.fA80k1E25332@mbuna.arbhome.com.au> >>> Jan Kybic wrote > > >> Would you know about an IMAP server which stores important information > > >> about messages (data, from, to, subject) in some sort of a database so > > >> that the searches are quicker? > > > > > > Cyrus. > > Are you sure Cyrus does it? I did not find anything about it in the > documentation. My first attempt to compile it failed, but I am willing > to try again if it solves my problem. Cyrus has a metadata cache in each folder. This makes many things much much much MUCH faster. > > > Or use UW, which uses flat files that are much faster to search. > > Courier beats UW when searching large mailboxes, on mid-sized hardware: UW is a nasty bit of code - it's too damn generalised, and it's just a pain to work with. [snip] > I do not require any artificial intelligence. The set of headers to > search on can be determined in advance, for example: from, to, cc, > bcc, date, subject. I am willing to accept the slow search in the > unlikely event of wanting to search on other criteria. I think you'll find that this is what you'll get from Cyrus. Anthony -- Anthony Baxter It's never too late to have a happy childhood. From dpetrac at yahoo.com Thu Nov 15 07:32:45 2001 From: dpetrac at yahoo.com (Danijel) Date: Thu, 15 Nov 2001 13:32:45 +0100 Subject: Default Icon Message-ID: <9t0cg8$caj$1@sunce.iskon.hr> (Win2k, PyWin2.1.1) How can I define defaut icon for all MDI child frames, on global level (not to define on each window)? Tnx, Danijel From James_Althoff at i2.com Tue Nov 13 20:00:29 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Tue, 13 Nov 2001 17:00:29 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: William Tanksley wrote: >On Tue, 13 Nov 2001 13:31:21 -0800, James_Althoff at i2.com wrote: >>PEP: 276 >>Title: Simple Iterator for ints > >It's good to see someone doing useful work here. PEPs are cool. Thanks! > >>Issues: >> Based on some preliminary discussion on the Python interest >> mailing list, the following concerns have been voiced: >> - Is it obvious that iter(5) maps to the sequence 0,1,2,3,4? >> Response: Given, as noted above, that Python has a strong >> convention for indexing sequences starting at 0 and stopping at >> (inclusively) the index whose value is one less than the length >> of the sequence, it is argued that the proposed sequence is >> reasonably intuitive to a Python programmer while being useful >> and practical. > >Strike the part about intuition. Perhaps "consistent" would be strong >enough. Reasonable consistency probably is the key point. > >I'm not sure I like this aspect anyhow. "5" just doesn't seem similar to >"0,1,2,3,4". A single integer isn't a range. > >> - Possible ambiguity >> for i in 10: print i >> might be mistaken for >> for i in (10,): print i >> Response: The predicted ambiguity was not readily apparent to >> several of the posters. > >You'll have to do better than that. This is the same problem as issue 1 >(immediately above). > >> - It would be better to reuse the ellipsis literal syntax (...) >> Response: Shares disadvantages of other proposals that require >> changes to the syntax. Needs more design to determine how it >> would handle the general case of start,stop,step, >> open/closed/half-closed intervals, etc. Needs a PEP. > >The last sentance is the only one that matters here. However, I'm >curious: what do you mean "reuse"? I've never seen an "ellipsis literal" >in Python. Reading through the Python documentation, I see an ellipsis >notation for extended slicing, but I'm in the dark as to what it means. >(I can guess, but I'd rather see it in print.) I've never seen it in >Python code, and the documentation doesn't seem to mention it. There are some concrete examples on page 36 of David Beazley's "Python Essential Reference", Second Edition. > >> - It would be better to reuse the slicing literal syntax attached >> to the int class, e.g., int[0:10] > >No. I said that would be better to implement __getslice__ as a >sequence-returning class method of the int class, e.g. int[0:10]. I'm not >interested in proposing syntax changes. Got it. But can __getslice__ be changed from an instance method to a class method for types.IntType and still work without special casing? I don't know about this. In any case, presumably the returned sequence would be auto-converted to a lightweight iterator in the for-loop (as lists are). Seems that PEP 276 has the advantage of directly creating an iterator without the need of first creating a sequence object. > >I claim that it's better because your method because your method doesn't >_look_ like a range and doesn't act like other Python usages. In essence, >it makes Python integers behave differently in scalar context versus array >context -- and we can't have people comparing us to that OTHER P*** >language <0.4 wink>. > >> Response: Same as previous response. In addition, design >> consideration needs to be given to what it would mean if one >> uses slicing syntax after some arbitrary class other than class >> int. Needs a PEP. > >Last sentance is still the most important one. The second sentance is >nonsense; I don't have to define all possible class reactions to slicing >simply because I'm defining one! This is equivalent to someone saying >that your PEP is bad because you don't define iter() for all classes. Yes, I misunderstood the suggestion. However, I'm still unclear on the notion of __getslice__ being sometimes an instance method and sometimes a class method. The code generated from the slicing syntax would have to try to call it both ways or something, I guess? Agree with you that a PEP would be good. ;-) > >I do, however, fail to define start, stop, and step behavior. For this >reason I would propose that the PEP someone else writes for this suggest >'range' behavior, and require a start. > Thanks for your comments and clarifications. Jim From glennfulford at bigpond.com Thu Nov 22 23:12:13 2001 From: glennfulford at bigpond.com (Glenn R Fulford) Date: Thu, 22 Nov 2001 20:12:13 -0800 Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> <9tdhon$aht52$1@hades.rz.uni-sb.de> Message-ID: "Huaiyu Zhu" wrote in message news:slrn9vntn4.5im.huaiyu at gauss.almadan.ibm.com... > On Wed, 21 Nov 2001 19:25:01 -0800, Glenn R Fulford > wrote: > > > If you have tried to solve differential equations with a difference method > in Fortran you'd have felt the pain of indexing from one. More > specifically, if you divide an interval into n, the nodes would be most > naturally labelled [0, 1, ..., n]. There are many other situations, but I > won't repeat them. > Good example. I have solved DEs with finite difference and found it a bit anoying. That is where Fortran900 is good, where you can declare where you want the arrays so start from. Glenn. > Huaiyu From chris.gonnerman at newcenturycomputers.net Thu Nov 22 09:54:33 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 22 Nov 2001 08:54:33 -0600 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: <006701c17365$aee949a0$0101010a@local> ----- Original Message ----- From: "jcrowe" > I think it all depends what you are going to be using the language for. In > my opinion PHP and Python are not really comparable. I see php as a step up > from cgi. I would not even concider using python for web scripts, it's just > doesn't make sense ( if you know php). I looked into php some, and was impressed, but frankly I still prefer Python. Can anyone compare the relative power and difficulty of Zope vs. PHP? (I'm not looking for a fight, just some comparative information). From logiplexsoftware at earthlink.net Mon Nov 12 15:19:12 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 12 Nov 2001 12:19:12 -0800 Subject: Teaching python (programming) to children In-Reply-To: <200111101633.fAAGXPua010988@ratthing-b246.strakt.com> References: <200111101633.fAAGXPua010988@ratthing-b246.strakt.com> Message-ID: <01111212191201.01611@logiplex1.logiplex.net> On Saturday 10 November 2001 08:33, Laura Creighton wrote: > > I have a problem. I can't pick the _students_ that come into my > classroom. And wherever I have come across a student that learned > calculus from the graphing-calculator school, I have found somebody > who does not understand, really understand, what 'this function is > increasing' _means_. They are incapable of doing their own visualization > of that. Fortunately for me, I don't run into these people that often. > But they are crippled, so much that it shows. It is evident in trying > to have the simplest of conversations with them. They have little or > no mathematical intuition at all. But this does not necessarily reflect bad teaching methods. It's simply a fact of life that some people will lack mathematical intuition, and it seems unlikely that any teacher will find a way to surmount this. In any class, you will have some students who excel, some who manage and some who fail to grasp the fundamental concepts. What does this say about the teaching methodology? Not much. > > So either a) the method is bad, and cripples minds (period) or > b) the method, if not taught according to some vigorous standard and > in conjunction with some other methods, cripples minds (or doesn't > allow them to expand properly). (For purpose of argument only I am > willing to believe that _somewhere_ it is working.) > > If the second is the case, then high school teachers must not be > allowed to pick and chose what to do, because with the best intentions > in the world they will produce a program that will produce people are > mathematically naive. Which is my experience. We have people who > never made the leap from arithmetic to mathematics. They are human > calculators, tied to machine calculators, but have no mathematical > intuition whatsoever, and a great difficulty in thinking abstractly. > It is frightening. They do get correct answers, as long as their > calculators have batteries, but they can't understand them. Not all students taking math classes /want/ to learn mathematics. They are taking them as a course requirement and only care about passing. If you rearrange class curriculum to cater to these students, you are going to inhibit the education of the few students who are sincerely interested in mathematics. IMO, there is a strong correlation between a student's desire to learn and his or her subsequent depth of understanding of a subject. If a student is unwilling to spend the energy to deeply understand a subject, why should educators be forced to alter their curriculum to assist them? > One must never design educational policy thinking only how the best > teachers will educate the most exceptional students (exceptionally > good or exceptionally poor.) The policy must instead focus on the > worst third of teachers. This is hard on the gifted teacher, indeed, > but the alternative is hard on _everybody_. Hm. Poor teachers are indeed a problem, but I fear the impact of such a "policy" upon the gifted teachers. My own interest in math and programming were inspired by a single teacher. Prior to that I had no clue that I would have ever been interested in such a subject (in fact, I dropped out of high school at 15 due to my total lack of interest - it wasn't until I went to college that I encountered this instructor). I think a major problem with teachers is that many of them are mostly interested in /teaching/ - not in the /subject/ they are teaching. The instructor who inspired me loved math and computer science and his enthusiasm for the subject was catching. His degree wasn't in education, but in mathematics. In fact, he revealed to me that he had a somewhat difficult time obtaining his degree because all he wanted to take was math classes and was slow in finishing some of the other required courses. I have serious doubts about programs designed by fiat. The problem hasn't been solved, it's simply been taken out of the hands of the teachers and put into the hands of a committee composed of... well, quite possibly mediocre teachers. So now we will be enforcing a curriculum designed by mediocre teachers onto brilliant teachers. Not so good. I agree that something needs to be done, but I think perhaps it should be done at the time of hiring teachers rather than trying to fix them after they've been hired. Think about this: if such a curriculum could be designed that it wouldn't matter if the teacher were excellent or mediocre, why couldn't that curriculum be issued as a software program that the students could follow without a teacher? Doesn't seem likely, does it? No curriculum will ever replace the need for good teachers, and no curriculum will ever make a poor teacher into a good one. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From philh at comuno.freeserve.co.uk Mon Nov 12 09:51:36 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 12 Nov 2001 14:51:36 +0000 Subject: importing a module Message-ID: I have a project that is split into 2 directories, one for the main source, and the other for testing. I have 2 files: ./src/utility.py ./test/test_herbrip.py My test program needs to import the utility.py module. At the moment I am doing this using this code (in test_herbrip.py): sys.path.append(os.path.abspath("../src")) import utility This works but looks a bit inelegant. Is there a better way of doing this? -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From logiplexsoftware at earthlink.net Fri Nov 9 19:13:59 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 16:13:59 -0800 Subject: Teaching python (programming) to children In-Reply-To: <000001c1697b$19b0de00$a9e1fea9@carol> References: <000001c1697b$19b0de00$a9e1fea9@carol> Message-ID: <0111091613590B.01414@logiplex1.logiplex.net> On Thursday 08 November 2001 22:50, Arthur Siegel wrote: > ear, it sounds like horeshit. Which is the point, because those of us > serious about seeing some progress made are not willing to wait > until the rest of the educational world happens to see the light > on this and similar points. Teaching Python to children? Sounds like you're working hand-in-glove with the PSU. You can't possib From starx at pacbell.net Mon Nov 26 22:43:14 2001 From: starx at pacbell.net (Philip Swartzleonard) Date: 27 Nov 2001 03:43:14 GMT Subject: Non-Indented python References: Message-ID: Lucio Torre || Thu 22 Nov 2001 09:38:12a: > On problem i had several times, is that while cut and pasting code from > one source (ie, mozilla) to a editor (ie, komodo), indentation will be > wrong. lines would be continued an there would be a real mess because to > 'beautify' the source, youd have to understand the code. > This is more of a problem of 'copying text out of a html display window and trying to do anything useful with it' problem... even if there were tabs the html output wouldn't show them because of the way html treats whitespace... You'd probably have better luck copying from the 'display source' window... -- Philip Sw "Starweaver" [rasx] :: From skip at pobox.com Wed Nov 14 06:14:30 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 12:14:30 +0100 Subject: Mimetools and how to use it In-Reply-To: <3BF25ABF.27201.B52A60@localhost> References: <3BF25ABF.27201.B52A60@localhost> Message-ID: <15346.21014.2141.219451@beluga.mojam.com> Ladislav> From a web server I receive headers that is an instance of the Ladislav> class MIMETOOLS.MESSAGE. How can decode it ... You need to call one of its header retrieval methods (there are several to choose from). For more detail, check the mimetools library reference page: http://www.python.org/doc/current/lib/module-mimetools.html and the libref page of rfc822, its base class: http://www.python.org/doc/current/lib/module-rfc822.html Ladislav> and how to extract cookies then? Assuming your mimetools.Message instance is referenced by the name "msg", you'd retrieve the Set-Cookie headers with something like: cookies = msg.getallmatchigheaders("Set-Cookie") Note that you may need to put the actual headers back together. This method returns the raw lines, including continuation lines, as separate list elements. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From cimarron+google at taylors.org Mon Nov 12 05:34:42 2001 From: cimarron+google at taylors.org (Cimarron Taylor) Date: 12 Nov 2001 02:34:42 -0800 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> Message-ID: <29e28c51.0111120234.35d10048@posting.google.com> shriek at gmx.co.uk (Stephen) wrote in message news:<97ae44ee.0111111912.14006c7f at posting.google.com>... > I'm developing a program which sends messages back and forth > between two servers using sockets. The message format I've > been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" Why not save yourself a little coding and just use netstrings? more info: http://itamarst.org/multiplex advogato copy: http://www.advogato.org/article/212.html python code: http://itamarst.org/downloads/multiplex-0.2.tgz description: http://cr.yp.to/proto/netstrings.txt Cim From mwh at python.net Fri Nov 30 05:38:48 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 30 Nov 2001 10:38:48 GMT Subject: A modest indentation proposal References: Message-ID: Steve Lamb writes: > On Thu, 29 Nov 2001 14:09:28 -0800, Erann Gat wrote: > > It also IMO makes the language unsuitable for mission-critical applications. > > It's just too easy to screw up indentation (particularly when cutting and > > pasting large blocks of code) without realizing it. > > Hogwash, plain and simple. Either you know it because it is visually > different or you know it when you test the application and it fails > spectacularly. You /do/ test your mission-critical applications, don't you? Erann works at NASA, so I'd hope so... Cheers, M. -- I never realized it before, but having looked that over I'm certain I'd rather have my eyes burned out by zombies with flaming dung sticks than work on a conscientious Unicode regex engine. -- Tim Peters, 3 Dec 1998 From peter at engcorp.com Mon Nov 12 00:08:23 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 12 Nov 2001 00:08:23 -0500 Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: <3BEF5947.47826862@engcorp.com> Just van Rossum wrote: > > def foreach(object_list, method_name, *args): > for object in object_list: > method = getattr(object, method_name, None) > if method is not None and callable(method): > method(*args) > > I think three-arg getattr() is faster than catching an exception. > > (I would leave out the callable() test, but then again, I don't > know your exact needs.) Good point with the default return from getattr(), but we differ on the latter point. *I* would leave out the check for None, since callable(None) returns false, but then again, maybe we should be leaving both of them out! If we are assuming the object has a method with the specified name, both tests are redundant. If we want to handle objects which don't even have such an attribute by silently ignoring them, I suppose we should also ignore objects which have an attribute with the right name but which are not callable... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From d_blade8 at hotmail.com Fri Nov 16 00:54:22 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 15 Nov 2001 21:54:22 -0800 Subject: Prob with Freeze.py Message-ID: <7396d2b2.0111152154.79f1dc6d@posting.google.com> I am having a problem converting a python script into an exe. The script works fine/great when run normally, but when I try to Freeze it I get the following error. Anybody have any recommendations? Thanks a bunch. Later. Chris PS- at the bottom of this script, I put the information that comes up during the build... C:\WINDOWS\Desktop\py2exe>UniLocString Traceback (most recent call last): File "", line 16, in ? File "C:\Python\support\imputil.py", line 98, in _import_hook top_module = self._import_top_module(parts[0]) File "C:\Python\support\imputil.py", line 182, in _import_top_module module = self.fs_imp.import_from_dir(item, name) File "C:\Python\support\imputil.py", line 533, in import_from_dir return self._process_result(result, fqname) File "C:\Python\support\imputil.py", line 295, in _process_result exec code in module.__dict__ File "C:\WINDOWS\DESKTOP\PY2EXE\EasyExcel.py", line 1, in ? import win32com.client File "C:\Python\support\imputil.py", line 98, in _import_hook top_module = self._import_top_module(parts[0]) File "C:\Python\support\imputil.py", line 184, in _import_top_module module = item.import_top(name) File "C:\Python\support\imputil.py", line 211, in import_top return self._import_one(None, name, name) File "C:\Python\support\imputil.py", line 266, in _import_one module = self._process_result(result, fqname) File "C:\Python\support\imputil.py", line 295, in _process_result exec code in module.__dict__ File "C:\Python21\win32com\__init__.py", line 5, in ? import win32api, sys File "C:\Python\support\imputil.py", line 101, in _import_hook raise ImportError, 'No module named ' + fqname ImportError: No module named win32api From kseehof at neuralintegrator.com Wed Nov 28 14:30:01 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Wed, 28 Nov 2001 11:30:01 -0800 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: <015601c17843$b306e500$4fc5fc9e@kens> > "DeepBlue" wrote in message > news:u0a0qpdf7npqa1 at corp.supernews.com... > > > > "Jonathan Gardner" wrote in message > > news:mailman.1006958441.30706.python-list at python.org... > > > Ken Seehof wrote: > > > > > > > > > > more. True, I think .NET is cool - but I'll only use it if MS keeps > it > > > > > promise and ports it too Linux and such. > > > > > > > > Odds of MS keeping any promises of this kind: 0.027% > > > > > > > > It has never been in MS's best interest to be compatible with the rest > > of > > > > the > > > > computing world. > > > > > > > > > > Look at Visual C++. Portability? Compatability? Ha. > > > > > > Look what they did to Java, HTTP, HTML, and JavaScript. > > > > > What did they do to Java, HTTP, HTML, and JavaScript? > > > > > Microsoft is in the business of making money, not software. > > > > > Is Sun and Netscape any different? > > Yes, in so far as they seem to feel that their best interests are served by > adhering to standards and interoperating with other peopple's > implementations. > > regards > Steve > -- > http://www.holdenweb.com/ It's not simply that MS is evil. If a corporation is attempting to defend or establish a monopoly (or near monopoly) it is not generally profitable to increase compatibility, since compatibility tends to create a level playing field. Since neither Sun nor Netscape have displaced Microsoft's lead position, they profit by creating a level playing field. As MS loses some market share perhaps they will start behaving nicer :-) Also, the Open Source community generally likes to maximize interoperability, because the utility of the software and size of the user base tend to be the most important design objectives, whereas creating leverage for operating system market dominance is not an issue. - Ken Seehof From tdelaney at avaya.com Thu Nov 29 18:05:42 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 30 Nov 2001 10:05:42 +1100 Subject: A modest indentation proposal Message-ID: > From: gat at jpl.nasa.gov [mailto:gat at jpl.nasa.gov] > > I propose to use a semicolon at the end of a line to denote > the end of a > block, e.g.: > > for i in l: # Colon signals beginning of block > foo() > baz(); boff() # Semicolon separating statements works as usual > bar(); # Semicolon at end of line signals end of block oops(); # Where does the block actually finish??? > biff() Tim Delaney From barry at zope.com Tue Nov 6 01:04:26 2001 From: barry at zope.com (Barry A. Warsaw) Date: 06 Nov 2001 01:04:26 -0500 Subject: How much is set in stone? References: Message-ID: >>>>> "BP" == Bjorn Pettersen writes: BP> Note that this happens *only* when your misspelling is on the BP> lhs of an assignment statement, in *all* other contexts the BP> compiler will complain at you. I've written several large BP> Python projects and I've never run into this problem -- BP> i.e. it's not high on my priority list. If it's important to BP> you I would suggest you run PyChecker BP> (http://pychecker.sourceforge.net/) on the code... One possible way to accomplish this is new with Python 2.2. With new-style classes, you could use a __slots__ attribute to cause any assignments to misspelled attributes to generate an error. Not exactly local variable assertions, but maybe close enough where it matters: Python 2.2b1+ (#1, Nov 1 2001, 02:06:16) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> class NotSoStrict: ... pass ... >>> n = NotSoStrict() >>> n.python = 1 >>> n.phyton = 2 >>> >>> class Strict(object): ... __slots__ = ('python',) ... >>> s = Strict() >>> s.python = 1 >>> s.phyton = 2 Traceback (most recent call last): File "", line 1, in ? AttributeError: 'Strict' object has no attribute 'phyton' guido-left-the-keys-to-his-time-machine-laying-on-his-desk-again-ly y'rs, -Barry From michel at zope.com Mon Nov 12 18:10:18 2001 From: michel at zope.com (Michel Pelletier) Date: Mon, 12 Nov 2001 15:10:18 -0800 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> <15344.19963.181812.444906@anthem.wooz.org> Message-ID: <3BF056DA.74724E5C@zope.com> "Barry A. Warsaw" wrote: > > Are the needs of application authors different than library authors? This is the best place to start, almost everyone on this list plays both roles to one degree or another. I've read Prabhu's emails and I understand his problem. He's explained it a couple of times, but in general users and their needs have been unclear which I think spawned most of this discussion. I'm actually sort of interested in more about the idea of 'looking up' for packages that Prabhu mentioned and think it could be very useful. In Zope we call this "acquisition" and we use this pattern many, many times to override general site policies and objects with more specific ones the farther "down" you go in the object heirarchy. This not only gives us a nice customization model, but it also gives us a nice delegation model, ie, those responsible on high (that's all of you) can dictate what is and is not the standard library "policy" and users below you (that's me and all the other lusers) can specificly override that mandate at a lower level without interfering with other users. -Michel From gdemmy at layton-graphics.com Thu Nov 1 12:17:49 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 01 Nov 2001 12:17:49 -0500 Subject: map, filter, reduce, zip, range, and.. slice? References: <3bdf39a6@news.bezeqint.net> <9rrp5f$37r$1@scotsman.ed.ac.uk> Message-ID: eddie at holyrood.ed.ac.uk (Eddie Corns) writes: > Eyal Lotem writes: > > >Hey. Recently, I've been heavily using functional-style programming in > >Python, doing almost all of my text processing and so with complex nested > >lambda clauses. I love those, as they are so short, and seem to work with > >a painless "debug" cycle, usually consisting of some missing reduce initial > >value or so. > > >To get to the point, I've almost always lacked a 'slice' function, that > >slices sequences into smaller chunks. For example: > > >divide("Hello world!", 2) => ["He", "ll", "o ", "wo", "rl", "d!"] > > It's a bit clumsy but how about: > > [x[i:i+2] for i in range(0,len(x),2)] > > Where x is your string. > > Eddie Eddie's solution in the lambda notation... divide = lambda x,s=1: [ x[i:i+s] for i in range(0,len(x),s) ] In action... >>> hi = 'hello, world' >>> for i in range(1,len(hi)+1): ... divide(hi,i) ... ['h', 'e', 'l', 'l', 'o', ',', ' ', 'w', 'o', 'r', 'l', 'd'] ['he', 'll', 'o,', ' w', 'or', 'ld'] ['hel', 'lo,', ' wo', 'rld'] ['hell', 'o, w', 'orld'] ['hello', ', wor', 'ld'] ['hello,', ' world'] ['hello, ', 'world'] ['hello, w', 'orld'] ['hello, wo', 'rld'] ['hello, wor', 'ld'] ['hello, worl', 'd'] ['hello, world'] Love them lambdas... G From joost_jacob at hotmail.com Fri Nov 30 11:32:17 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 30 Nov 2001 08:32:17 -0800 Subject: Why Python? References: <0nDN7.14999$WC1.1783701@newsread2.prod.itd.earthlink.net> Message-ID: <13285ea2.0111300832.6aff3c94@posting.google.com> Nice to see your Python promotion. But the font you use looks ugly here (netscape) and displays apostrophs as question marks. Maybe you can put something like in your html file, a font that looks more or less the same on all browsers. and you have in your html source, where replacing all the "0" with "10" often looks better. Oh i see you use frontpage (*ouch*)? The line with <9sacsk$r82$1@bugstomper.ihug.com.au> Message-ID: <9sb8u7$127p7o$1@ID-11957.news.dfncis.de> "Gary Stephenson" wrote in message news:9sacsk$r82$1 at bugstomper.ihug.com.au... > > "Delaney, Timothy" wrote in message > news:mailman.1005090308.3549.python-list at python.org... > > > From: Fredrik Lundh [mailto:fredrik at pythonware.com] > > > Gary Stephenson wrote: > > > > We here downunder have just always claimed him as one of our own > > > > > > like ABBA? > > > > We've never claimed ABBA. We merely claim to have made them popular and > > famous ... > > > > Tim Delaney > > Umm, I'm not really sure this is a claim we should be making! Next thing > you'll have us claiming responsibility for making disco popular - and then > they'll just have to shoot us! ;-) - senseless waste of human endeavour > and all that.. > What claim. That's true! ;-) We're talking-rattlesnakes-not-pythons-ly y'rs -- Emile van Sebille emile at fenx.com --------- From gh_pythonlist at gmx.de Thu Nov 1 16:59:48 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 1 Nov 2001 22:59:48 +0100 Subject: List transpose method In-Reply-To: <20011101224504.C7406@lilith.hqd-internal>; from gh_pythonlist@gmx.de on Thu, Nov 01, 2001 at 10:45:05PM +0100 References: <20011101205127.A4219@ibook.distro.conectiva> <20011101224504.C7406@lilith.hqd-internal> Message-ID: <20011101225947.A7619@lilith.hqd-internal> On Thu, Nov 01, 2001 at 10:45:05PM +0100, Gerhard H?ring wrote: > On Thu, Nov 01, 2001 at 08:51:27PM -0200, Gustavo Niemeyer wrote: > > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > > > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > > > only come up with an ugly multiliner. > > > > >>> zip((1,2),(3,4),(5,6)) > > [(1, 3, 5), (2, 4, 6)] > > Hmm. How would I apply zip if I have a variable already, like ^^^^^ With apply, stupid! > l = ((1,2),(3,4),(5,6)) apply(zip, l) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From mwh at python.net Tue Nov 13 11:06:39 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 13 Nov 2001 16:06:39 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> Message-ID: "Frederic Giacometti" writes: > "Michael Hudson" wrote in message > news:uu1w0e0vo.fsf at python.net... [...] > > I must be missing something. Can you sketch how, say, socket.send() > > would be implemented? Would you spawn a new OS thread for every C API > > call? I'm afraid I don't understand you to this point... > > As I mentioned, two thread pools would be maintained. To the extent > that send() is reentrant on the underlying OS, it would beexecuted > in one of the threads of the reentrant thread pool. This is the > 'thread pool' pattern; where threads are kept up (i.e. active) from > one call to the next. It's a standard pattern and concurrent > programming algorithm. So when Python code executes sock.recv(data) the interpreter would take a thread form the pool, and in effect say "here, run this function". Then the interpreter thread would go off and execute pending Python threads, and when the sock.recv call returned, it would add the thread that called it back to the set of pending interpreter threads? (I think this would be easier to discuss with paper and pencil...) What does this buy us again? It still makes writing C code that calls Python code a bit of a pain, doesn't it? Oh, maybe not. More thinking required... Cheers, M. -- The meaning of "brunch" is as yet undefined. -- Simon Booth, ucam.chat From jd at commandprompt.com Fri Nov 2 19:13:49 2001 From: jd at commandprompt.com (Joshua Drake) Date: 2 Nov 2001 16:13:49 -0800 Subject: Python/QT Book no in final edit Message-ID: Hello, The Py/QT book (which covers QT 2 and 3) is now in final edit and will be shipping before the end of the month. For those interested you may view the book online at: http://stage.linuxports.com/projects/pyqt There is a link to preorder on the site as well. J From cliechti at gmx.net Sat Nov 17 18:29:44 2001 From: cliechti at gmx.net (Chris Liechti) Date: 18 Nov 2001 00:29:44 +0100 Subject: drawing functionality References: Message-ID: [posted and mailed] jcrowe wrote in news:ouAJ7.1872$tg4.89012 at eagle.america.net: > I am concidering creating an app that would basicly be a database > frontend. But I would like to have the ability to make small (300 X 300 > dpi) drawings. This would be used to create a rough floorplan drawing > for each entry (real estate) in the database. I am planing on running > this on a linux server that is being accessed by window 98/95 client > machines. > > Thanks for any URL's or insites that you can provide. > > Jason Crowe well you don't say much about how you would exchange data between client and server. do you want to write a custom app or should the clients simply use a webbrowser? i would prefer the second as it limits the programming to the server side and a wide variety of clients can connect. you can either setup a webserver and use python scripts for CGI or write even the server in python (realy simple to do). for graphical data there are e.g.: - pdf: http://www.reportlab.com/ - jpg, png, ...: http://www.pythonware.com/downloads/index.htm#pil with both you can create data on the fly and embed it in dynamic webpages. chris -- Chris From BPettersen at NAREX.com Mon Nov 5 18:10:52 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 5 Nov 2001 16:10:52 -0700 Subject: How much is set in stone? Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192215107@admin56.narex.com> > From: Jive Dadson [mailto:jdadson at ix.netcom.com] > > Chris Barker wrote: > > > > While nothing is actually set in stone, some things are pretty well > > cemented in. > > > > Jive Dadson wrote: > > > Thanks. Before I submit a formal proposal, let me run it by you > > > guys. > > > > That is a good idea, most PEPs start as a discussion here. > AN a whle > > lot more start that way and nver make it to a PEP. > > > > > I've looked through all the PEPS and I was surprised that my > > > suggestion is not already there. So, here it is. Please comment. > > > > You can bet that this has been proposed by people new to > Python again > > and again and again ... > > What does that tell you? That more people (or more experienced Python programmers) don't see this as a problem? [snip] > > If you start changing that too, you > > really won't have Python anymore!! > > > > The changes I've proposed do not conflict in any way with the > "Python-ness" of the language. If you don't put "option > explicit" at the top of your module, it will behave exactly > the same as it did before. Not that I'm able to channel Guido, but historically he's been against adding switches to the compiler to make it behave in some domain specific way. I'm guessing he would be against "options" that would basically create two Python syntaxes too. I know I am. > What we are discussing is not uniquely "Python". Other > languages have had the dubious feature that the first > assignment to a variable is its declaration. Invariably, > people discover that it was a lousy idea. The people who USE > it discover that. They misspell a variable name and in doing > so they introduce a bug. The bug may not manifest itself > until the code is already shipped. Even if they do notice > the bug before it's too late, it may be very difficult to > track down. I've been down that road a lot of times. Note that this happens *only* when your misspelling is on the lhs of an assignment statement, in *all* other contexts the compiler will complain at you. I've written several large Python projects and I've never run into this problem -- i.e. it's not high on my priority list. If it's important to you I would suggest you run PyChecker (http://pychecker.sourceforge.net/) on the code... god-save-us-from-the-newly-converted'ly y'rs -- bjorn From gdemmy at layton-graphics.com Thu Nov 1 13:08:13 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 01 Nov 2001 13:08:13 -0500 Subject: map, filter, reduce, zip, range, and.. slice? References: <3bdf39a6@news.bezeqint.net> <9rrp5f$37r$1@scotsman.ed.ac.uk> Message-ID: Skip Montanaro writes: > George> Eddie's solution in the lambda notation... > > George> divide = lambda x,s=1: [ x[i:i+s] for i in range(0,len(x),s) ] > ... > George> Love them lambdas... > > Just out of curiosity, what's the advantage you perceive of lambda over > > def divide(x, s=1): > return [ x[i:i+s] for i in range(0,len(x),s) ] > > in this situation? > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ > Skip Montanaro writes: > > George> Eddie's solution in the lambda notation... > > George> divide = lambda x,s=1: [ x[i:i+s] for i in range(0,len(x),s) ] > ... > George> Love them lambdas... > > Just out of curiosity, what's the advantage you perceive of lambda over > > def divide(x, s=1): > return [ x[i:i+s] for i in range(0,len(x),s) ] > > in this situation? > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ Hi Skip, There is no "Pythonic" advantage to this representation of which I know -- I rather suspect there are some serious performance hits with the lambda form. The orginal poster had mentioned that he was doing a lot of hacking using nested lambda forms -- he obviously *not* interested in maximizing Python performance! I just thought it was interesting to generalize Eddie's "divide" pattern using a lambda form. Cheers! G -- George Demmy Layton Graphics, Inc From robin at jessikat.fsnet.co.uk Mon Nov 5 07:04:27 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Mon, 5 Nov 2001 12:04:27 +0000 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: In article <4b4c5d99.0111050348.6d7c9406 at posting.google.com>, pawn writes >I'm trying to convert a few simple CGI scripts from Perl to Python, >and was shocked to learn that the Python interpreter silently ignores >the setuid bit. > >I really don't know how to get around this. Since the server is hosted >remotely I can't recompile python to allow setuid, and I can't make my >files world read/writable - I need my python CGIs to run with MY uid. > >I read somewhere about using a wrapper C program but it seems really >convoluted, as well as requiring a different wrapper for each CGI. > >Is there any solution, or should I stick to / am I stuck with Perl? If you can get a wrapper program onto your machine it's as easy as this (at least for freeBSD) #!/usr/home/myhome/bin/wrapper /usr/local/bin/python here wrapper is a program that you create to be setuid in your name/group. my code for the wrapper looks like below. I only allow it to work for the owner and the nobody user. #include #include #define SRCUID 1234 /*our UID so we can do things ourselves*/ #define NOBID 65535 /*another possible ID (nobody*)/ #define TGTUID 1234 /*the desired run UID*/ #define TGTGID 7890 /*the desired run group*/ #define TGTUSER "myusername" #define TGTHOME "/usr/home/" TGTUSER int main(int argc, char**argv) { size_t i, n=0; char *buf; n = getuid(); if(n!=NOBID && n!=SRCUID) exit(-1); for(i=1;i1) strcat(buf," "); strcat(buf,argv[i]); } setuid(TGTUID); setgid(TGTGID); /*users*/ setenv("USER",TGTUSER,1); setenv("HOME",TGTHOME,1); system(buf); } -- Robin Becker From jeff at ccvcorp.com Wed Nov 28 14:27:32 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 28 Nov 2001 11:27:32 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> Message-ID: <3C053AA4.97246A72@ccvcorp.com> Huaiyu Zhu wrote: > Question: What should tab be default to in terms of other charactors, or > screen positions, or editor actions, or anything else that is not the tab > charactor? > > Answer: It shouldn't. So, then... how is someone to know whether there is a tab character in the file they are editing, if there is no standard way to represent that character? It seems to me that just about every *other* ascii character has *some* default action or symbol associated with it... Tab characters are useless if they cannot be represented on the screen. Standard usage since the dawn of typewriters has been that tab is roughly equivalent to spaces. Sure, you can define Tab to be its own thing, and this will clear up some confusion perhaps, but how are you going to display them? How are you going to indicate their existence? If you use a method that is visually distinct from spaces, then you're going to confuse and irritate everyone who has consistently used tabs and spaces as equivalent (in coding, tabulation, prose, etc...) If you use a method that is visually equivalent to spaces, but can be customized to however many spaces the current user wishes... well, then you've got our current mess, with people wanting to mix the two and getting unpredictable results. The only real solution to the problem, is to insist that using one or the other is an error. Of course, many people will, without thinking, use spaces to indent even when they "know" that they should use tabs. (As evidence, the Python docs specify that a tab is equal to two standard indent levels, and yet people insist on ignoring this specification...) Tab keys, on the other hand, are easy (and relatively painless) to reinterpret to insert spaces. Therefore, the easiest, least painful solution, is to disallow tab characters for indenting. I'd be happy to see *every* appearance of 0x09 for indenting become a syntax error. This would require a fair amount of fixing old code, but not too much--running TabNanny once over all old code. From that point on, there would be *no* confusion, as any reasonable editor would auto-convert tabs to spaces, and tab characters would disappear from code. Jeff Shannon Technician/Programmer Credit International From mwh at python.net Thu Nov 15 13:53:20 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 15 Nov 2001 18:53:20 GMT Subject: What is "marshal data"? References: <859c71be.0111151028.63227109@posting.google.com> Message-ID: soren at pobox.com (Soren Ragsdale) writes: > I'm testing some scripts with Python 2.1.1: we're upgrading from > 1.5.2. I've been noticing this error, and the REAL problem is that > I've never heard of "marshal data" before. This error is not > reproducible: this script is part of a distributed program which runs > on about 200 machines, and four of the scripts produced this error. > The problem isn't isolated to individual machines: > > > /tip/td/python2-irix64/bin/python -u ren_blade.py 44 > Traceback (most recent call last): > File "ren_blade.py", line 4, in ? > import uh,gh > ValueError: bad marshal data > > Possible sources of the problem: "uh.py" is imported from MANY > programs on our network. It's being imported by Linux and Irix > machines running 1.5.2 and 2.1.1 versions of Python. Could this be > some sort of race condition, where one platform or version produces a > .pyc file while the other platform or version is also writing the same > .pyc file? Yes, sounds likely. The problem is that .pycs aren't compatible between 1.5.2 and 2.1.1, so when Python 2.1.1 tries to load the file and finds a 1.5.2 .pyc it tries to write a new one, and vice versa. Can you set things up so the different versions see different copies of the file? Another approach would be to write protect the directory that uh.py is in, though this will impact the performance of imports. Cheers, M. -- [1] If you're lost in the woods, just bury some fibre in the ground carrying data. Fairly soon a JCB will be along to cut it for you - follow the JCB back to civilsation/hitch a lift. -- Simon Burr, cam.misc From edwardt at trillium.com Thu Nov 29 18:40:50 2001 From: edwardt at trillium.com (ed) Date: 29 Nov 2001 15:40:50 -0800 Subject: questions about of writing python scripts Message-ID: I am writing a program in python, but I find that in using the python interpreter in writing program I am not able to find errors in the erliaest stage. I need to run the program a lot of timee just to find out errors like: simple syntas errors that are embedded in the functions that I called in other modules.... Is there a way to force the python interpretter to kind of doing "compilation" of the python scripts, so that I do not need to rerunning the progrma a lot of times just to find out they are errors like varibles not defined; functions name not found, variables not found? From ungrzr2 at ubatxbat.pbz Wed Nov 28 22:58:21 2001 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 29 Nov 2001 03:58:21 GMT Subject: [2.2b2]: class variable and classmethod, subclass References: Message-ID: Andreas Kostyrka wrote in news:mailman.1006977818.13927.python-list at python.org: > #A: a=123(0812828c) [] (08122cd4) B: a=123(0812828c) [] > (08122cd4) #A: a=123(0812828c) [100] (08122cd4) B: a=100(08128298) > [100] (08122cd4) > > When you look at A.x, you can see, that it rebind klass.a to a new > object. (Very important: = just labels a reference in python. It's not > a classical assignment operator) > Because of this, when B.x is called, B.a is bound to a different object > then A.a. > > klass.b OTOH is not rebound, but modified in place. So it A.b and B.b > continue to be the same object. > Thanks for the explanation. The problem is that a new copy of the class variable is only created if it is changed in the child class. If the variable is not mutable, that is. I think it is more natural that the new copies of class variables are created at the time of subclass definition. Then subclass and parent class will not share the same class variable references, whether the variables are mutable or not. From fredrik at pythonware.com Wed Nov 7 16:36:31 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 21:36:31 GMT Subject: C-extension in Python -- returning results References: Message-ID: Keith Farmer wrote: > I don't understand what the '-1.#IND' returns indicate. IEEE indeterminates. the following site mentions things like (infinity - infinity) and (0 x infinity): http://www.research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html and -1.#IND is exactly what the following small program prints (if compiled under MSVC, at least): main() { double a = 1.0; double b = 0.0; double c = a / b; double d = c - c; printf("%g", d); } maybe you're dividing by zero somewhere in there? adding a few strategic printf statements to your code might help you figure out where things go wrong. (and I'm sure tim will correct me if I'm wrong) From keyton at weissinger.org Mon Nov 12 23:13:50 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Mon, 12 Nov 2001 23:13:50 -0500 Subject: WebLogic Server Calls In-Reply-To: Message-ID: Has anyone got any scripts to automate calls back and forth to WebLogic (or any other app server that uses cookie-based state management)? I need to set up an app that calls a security JSP page, logs in, and then calls a second page, sending the cookie it received. Surely someone has done this.... Any help would be MOST appreciated. Thank you. Keyton From jdavis at empires.org Sun Nov 4 05:38:21 2001 From: jdavis at empires.org (Jeff Davis) Date: Sun, 04 Nov 2001 02:38:21 -0800 Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: <9s35vp$ne$1@news1.ucsd.edu> Python covers a lot of ground. Since almost any language can be used for almost anything, I will qualify that statement: python covers the same ground as VB, except python will cover that ground much better (in my opinion). The primary reason you would not use python is if the application you were writing relies on excellent performance for many basic operations (for example, you would not write an operating system). Another reason might be that there is a more specific language for your particular task (i.e. the unix shell language is better suited for an interactive shell). The largest application that comes to mind is zope (zope.org). It is an entire application server. Larger applications can be written without a problem. I have also written many applications meant to be run only one time to solve one task once, that were only a few lines. I really recommend python. I have used VBScript, php, perl, c, c++ among others and I think python has a great language design. Jeff Davis Cliff Pruitt wrote: > Hello, I've just started looking into Python and am considering delving > into > it a bit. My main reason is that it seems to be pretty portable across > platforms. I work on a Mac for the most part but I do work on windows > machines durring the day and it would be fun (I think) to develop for > both. So far I've downloaded the Python files and flipped through a > little bit of > the documentation but haven't gone into much detail with it. I'm > wondering if anyone could sort of give me a good idea of what Python is > really capable > of and maybe more importantly what it's NOT capable of. The extent of my > programming experience involves VBScript for the web. If i had, say, a > microsoft access Database, is python capable of displaying records and > doing > searches on that database? Maybe more importantly is it capable of > adding > records? Out of curiousity, what are the nicest or most complex > applications you've seen done in Python? A lot of what I've read referrs > to Python as being useful as "glue" to hol dother languages like C++ and > others > together. I dont know any of those so I'm wondering if Puthon will > really be somethign useful to learn or not. > > Your insight is greatly appreciated. > Thanks. > > -- > C. Pruitt > mail at cliffpruitt.com > http://www.cliffpruitt.com From frederic.giacometti at arakne.com Sun Nov 4 21:18:10 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Mon, 05 Nov 2001 02:18:10 GMT Subject: Exception holes, again. References: <9s1sen$1sdd$1@feed.teaser.net> Message-ID: "Dale Strickland-Clark" wrote in message news:sj4autoi1lbtvsiccf5kaadabb6ru4nnoe at 4ax.com... > "Olivier Deckmyn" wrote: > > >Did you look in the C sources ? > > > I don't have the C source. I shouldn't need it. Tough luck. You can try to fix the English documentation, too. Meanwhile, "The documentation is the source code"... FG From weeang at hotmail.com Wed Nov 28 21:23:20 2001 From: weeang at hotmail.com (weeang) Date: 28 Nov 2001 18:23:20 -0800 Subject: how to call external functions from python References: <3C046A11.175B9FB5@engcorp.com> Message-ID: Peter Hansen wrote in message news:<3C046A11.175B9FB5 at engcorp.com>... > weeang wrote: > > > > i need help on the following: > > > > 1) find all files in inbox directory and zip them > > 2) move the zipped file to outbox > > 3) copy the zipped file to a remote directory > > What's an inbox? An outbox? There is no general > implementation of such things, so your question > must be platform and/or application-dependent. > Knowing you are on Windows doesn't actually help. > Do you mean Outlook? Probably not, since you mentioned > you'll move to Linux. I had meant for eg. an inbox local directory... and an outbox local directory.. and no, it's not platform or application-dependent... but rather.. being descriptive of the directories, rather than from 1st directory.. to 2nd directory, etc... Sorry for the confusion.. > > > i m using python 2.1, using windows for my initial testing. however, > > i will subsequently use the script on a linux box instead. > > Maybe describing what your general objectives are, > rather than the specific steps you think will get > you there, would help. *Why* are you trying to > do these things? There might be better options. My general objectives are: To zip all files in a directory and copy the zipped file to a remote directory. The design is as follows, i.e. simulating a ms outlook functionality: 1)Zip all the files in a local 'inbox' directory 2)Move the zipped file to local 'outbox' directory 3)Copy the zipped file to a remote directory 4)Moving the zipped file to a local 'sent' directory I hope I have made myself clear?? Thanks once again, & best regards. From mdlch at altavista.net Thu Nov 22 17:37:30 2001 From: mdlch at altavista.net (marco) Date: 22 Nov 2001 17:37:30 -0500 Subject: Python on AIX Message-ID: Hi all, We just recently compiled Python 2.2b2 under AIX 4.3.3 using gcc 2.8.1. I'll just post our experience in case anybody finds it helpful. The original configure command was: ./configure \ --prefix=/usr/local/python-2.2b2 This uses cc_r (v. 5), and while this more or less worked, there were many of the following warnings: cc_r: 1501-210 command option t contains an incorrect subargument Later there were other problems but these were not really compiler-related (I did not know this at the time, though). Furthermore cc_r did not seem to have the threads problem I later encountered with gcc (and which are documented in the README). So, in summary, cc_r would have probably worked -- perhaps better than with gcc -- but we didn't go down that road. Instead, we used the following: ./configure \ --prefix=/usr/local/python-2.2b2 \ --with-gcc and when trying to "make" got the following error: In file included from /usr/include/sys/thread.h:45, from /usr/include/sys/ptrace.h:28, from /usr/include/sys/proc.h:48, from /usr/include/sys/pri.h:29, from /usr/include/sys/sched.h:38, from /usr/include/sched.h:52, from /usr/include/pthread.h:43, from Python/thread_pthread.h:6, from Python/thread.c:117: /usr/include/sys/var.h:116: parse error before `__cptr64' . [snip a lot] . Python/thread_pthread.h:135: warning: implicit declaration of function `pthread_init' make: 1254-004 The error code from the last command is 1. As I mentioned above, this is documented in the README. We got around it by using: ./configure \ --prefix=/usr/local/python-2.2b2 \ --with-gcc \ --with-threads=no The "make" then died with the following error: ./Modules/makexp_aix Modules/python.exp "" libpython2.2.a; -Wl,-bE:Modules/python.exp -lld -o python Modules/python.o libpython2.2.a -ldl -lm /bin/sh: -Wl,-bE:Modules/python.exp: not found. make: 1254-004 The error code from the last command is 127. Notice the space after the ";". Indeed, looking at the results from the configure script we see: checking LINKCC... ./configure[1417]: LINKCC: not found $(srcdir)/Modules/makexp_aix Modules/python.exp "" $(LIBRARY); Lines 1415 to 1417 of "configure" are as follows: case $ac_sys_system in AIX*) LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $(LINKCC)";; The problem turned out to be extra parenthesis around $(LINKCC). It should read: AIX*) LINKCC="\$(srcdir)/Modules/makexp_aix Modules/python.exp \"\" \$(LIBRARY); $LINKCC";; The lines after that read: dgux*) LINKCC="LD_RUN_PATH=$libdir $(LINKCC)";; Monterey64*) LINKCC="$(LINKCC) -L/usr/lib/ia64l64";; esac Presumably these too have extra ()s. Once that was fixed there were further complaints along the following lines: WARNING: building of extension "fcntl" failed: command '/usr/local/python-2.2a4/lib/python2.2/ld_so_aix' failed with exit status 1 There seemed to be some confusion between the source directory and the installation directory (which was set with --prefix to be /usr/local/python-2.2b2). The file it was looking for was in fact under the "Modules" subdirectory within the Python source tree. The simplest workaround was to copy the files it wanted to the appropriate location. These were: ld_so_aix makexp_aix python.exp Once copied into /usr/local/python-2.2a4/lib/python2.2/ we re-ran the configure ; make ; make install. The following failed: /usr/local/src2/marco/Python-2.2b2/Modules/socketmodule.c: In function `PyH_Err': /usr/local/src2/marco/Python-2.2b2/Modules/socketmodule.c:432: warning: implicit declaration of function `hstrerror' WARNING: building of extension "_socket" failed: command 'gcc' failed with exit status 1 /usr/local/src2/marco/Python-2.2b2/Modules/_cursesmodule.c:2348: too few arguments to function `tparm' WARNING: building of extension "_curses" failed: command 'gcc' failed with exit status 1 /usr/local/src2/marco/Python-2.2b2/Modules/_curses_panel.c:17: panel.h: No such file or directory WARNING: building of extension "_curses_panel" failed: command 'gcc' failed with exit status 1 However, we can live for now without the socket and curses modules. Other than that Python seems to be OK. Note that precompiled Python binaries (in RPM form) are available for AIX at: http://www-1.ibm.com/servers/aix/products/aixos/linux/download.html We haven't tried those, though. Still, we hope this is helpful for people trying to perform the compilation on their own, and to the Python developers by letting them know about the glitches we encountered. Cheers! -- mdlch at altavista.net Gunnm: Broken Angel http://reimeika.ca/ From sight at ukr.net Tue Nov 27 06:17:20 2001 From: sight at ukr.net (Sight) Date: Tue, 27 Nov 2001 13:17:20 +0200 Subject: Welcome to new photogallery Message-ID: <9tvt12$fia$553@bn.utel.com.ua> Welcome to Sight photogallery http://www.sight.com.ua From prabhu at aero.iitm.ernet.in Sun Nov 4 13:01:59 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 4 Nov 2001 23:31:59 +0530 Subject: How can i retrieve a key from a dictionary? In-Reply-To: <3BE54A08.2AFF9A66@student.kun.nl> References: <3BE519E0.34312B48@student.kun.nl> <3BE52DBC.724B1C6F@student.kun.nl> <3BE54A08.2AFF9A66@student.kun.nl> Message-ID: <15333.33431.903922.851343@monster.linux.in> >>>>> "HJ" == Husam writes: HJ> thanks, now i understand. by the way, if you have time to HJ> satisfy my curuosity, what is the solution for the umbiquity HJ> in you'r second example? There is none. AFAIK, Python isn't psychic yet (apologies if I may be wrong ;) so it can't figure out which one of the keys you really asked for. OTOH, it is possible to return all the keys that have the same value. prabhu From graz at mindless.com Mon Nov 5 04:22:59 2001 From: graz at mindless.com (Graham Ashton) Date: Mon, 05 Nov 2001 09:22:59 GMT Subject: bg and fg References: <20011104112551.A14309@cruciatuz.de> <001101c1653f$3f9a33e0$0101010a@local> Message-ID: In article , "Stefan Antoni" wrote: > #!/usr/bin/env python > > import sys, os, time > > if os.fork() == 0: > os.setsid # what does THAT mean? it was in the example. > # i looked into "pydoc os" but i didn't understand > # find an explantation > sys.stdout = open("/dev/null", 'w') > sys.stdin = open("/dev/null", 'r') > > while 1: > pass > # daemon code: > > It works :) An alternative way to approach the stdout/stdin redirection is to create class whose write() method does nothing; that way you're not reliant on /dev/null existing (that may have no practical value whatsoever, I'm just thinking about portability). This is from O'Reilly's Python Standard Library: class NullDevice: def write(self, s): pass sys.stdin.close() sys.stdout = NullDevice() sys.stderr = NullDevice() I'm not sure why your example doesn't touch stderr and leaves stdin open. You should call os.umask(0) in there too so that child processes are able to set their own umasks correctly (again, a security related thing). In Python Standard Library, Fredrik Lundh also recommends calling os.setpgrp() to make the forked process a process group leader. He doesn't bother with os.setsid() though - does anybody know why? Stephens implies that os.setsid() has the same effect as os.setpgrp(), and more. The intricacies of this are probably UNIX dependent. Stephens also recommends setting the current working directory to / (or a chroot equivalent) incase it's launched from a mounted file system which goes away before the process dies. > ... but raises another question: > How can i send commands to a daemon to (let's say) get it's status or > terminate it without killing it? Do i need a local socket connection for > doing something like this? Or is there a more elegant way? There are many ways of skinning a cat. If you're running on a UNIX computer you could do a UNIX socket instead of a TCP/IP socket. Have a read about named pipes, and os.popen() stuff. If your requirements are really simple you could set up a signal handler in the daemon, and send the signal from some other process, or the shell (with kill -HUP 1234, for example). When the daemon receives the signal it could do any number of things, such as append a message to a log file, etc. It all depends how scalable your solution needs to be, and what kind of systems it needs to be able to interoperate with. -- Graham From weismann at netvision.net.il Tue Nov 6 04:20:53 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Tue, 06 Nov 2001 11:20:53 +0200 Subject: " When parsing an HTML page with SGMLParser ' I get an error when then parser meets a ! tag (' From karthikg at aztec.soft.net Sat Nov 10 06:45:07 2001 From: karthikg at aztec.soft.net (karthik Guru) Date: Sat, 10 Nov 2001 17:15:07 +0530 Subject: Simple Thread Program not working (Newbie: Python) In-Reply-To: Message-ID: hello all, Am not sure why am getting the errors at the specified place ( I have pasted the error on those lines) Can someone help. --------------- import threading, time class Test: def __init__(self): self.data = "start" def change(self,data): self.data = data def __str__(self): return self.data def __repr__(self): return self.data class ChangeThread(threading.Thread): def __init_(self,val,a): self.ref = a threading.Thread.__init__(None,self) def run(self): count = 1 while 1: self.ref.change(s,count) # AttributeError: ChangeThread instance has no attribute 'ref'..this is the error. count+=1 time.sleep(1) class WatchThread(threading.Thread): def __init_(self,val,a): self.ref = a threading.Thread.__init__(None,self) def run(self): while 1: print 'changed data : ' + self.ref.data # AttributeError: ChangeThread instance has no attribute 'ref' time.sleep(3) def execute(): print 'Start execute' t = Test() t1 = WatchThread(None,t) t2 = WatchThread(None,t) t3 = WatchThread(None,t) t1.start() t2.start() t3.start() time.sleep(2) t4 = ChangeThread(None,t) t4.start() if __name__ == '__main__': execute() This is the trace: Start execute Exception in thread Thread-1: Traceback (most recent call last): File "d:\python21\lib\threading.py", line 378, in __bootstrap self.run() File "thread1.py", line 30, in run print 'changed data : ' + self.ref.data AttributeError: WatchThread instance has no attribute 'ref' Exception in thread Thread-2: Traceback (most recent call last): File "d:\python21\lib\threading.py", line 378, in __bootstrap self.run() File "thread1.py", line 30, in run print 'changed data : ' + self.ref.data AttributeError: WatchThread instance has no attribute 'ref' Exception in thread Thread-3: Traceback (most recent call last): File "d:\python21\lib\threading.py", line 378, in __bootstrap self.run() File "thread1.py", line 30, in run print 'changed data : ' + self.ref.data AttributeError: WatchThread instance has no attribute 'ref' Exception in thread Thread-4: Traceback (most recent call last): File "d:\python21\lib\threading.py", line 378, in __bootstrap self.run() File "thread1.py", line 20, in run self.ref.change(s,count) AttributeError: ChangeThread instance has no attribute 'ref' From rdsteph at earthlink.net Wed Nov 28 20:30:48 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 29 Nov 2001 01:30:48 GMT Subject: Overheads from Lightweight Languages Conference. Message-ID: <3C05910F.B1740C45@earthlink.net> Since I attended this conference I have been included on a mailing list, and recently I recieved a list of links, which includes some, but not all, of the overhead presentations given at the conference Nov 17 at MIT. I am copying these links a the bottom of this post. Jeremy Hylton's presentation is included. Actually, to those of us already familiar with Python, some of the other presentations are the most interesting since they cover unfamiliar territory. There are some other interesting links. I hope this will help answer some of the emailed questions about the conference that I have received. By the way, my web site host seems to be down right now. I will post these LLC links and overheads on my site also for future reference. One last thing. I am going to slightly revise my review of Python 2.1 Bible. It is a good and thorough book, and I think I indicated that. However, since I read this book *after* so many others, I used the phrase "me-too" and I now think that was unwise and unfair; if I had read the Python Bible *first*, I would not have used that ill advised phrase. I am re-looking at this book (after reading an email from an admirer of the book who felt I missed a little of its virtues). It is good and thorough and deserves equal consideration, from new readers, with some of my favorites like "Core Python" I will revise the review as soon as I can log into my web hosting site again. Thanks to all the many folks who read some of the reviews and commented on them to me. rs There are a few updates to the LL1 web site, http://ll1.mit.edu/ with links to the following: * A number of the presenters have made their slides/notes available. They are available via the Agenda page or at: http://www.ai.mit.edu/projects/dynlangs/ll1/agenda.html * Eric Kidd has posted some pictures, http://www.pobox.com/~emk/photo/ll1/ * Simon Cozens has posted an article to perl.com, http://www.perl.com/pub/a/2001/11/21/lightweight.html * There is an archive of the ll1-discuss mailing list, http://www.ai.mit.edu/~gregs/ll1-discuss-archive-html/threads.html From sholden at holdenweb.com Wed Nov 14 18:17:21 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 18:17:21 -0500 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> <9nj5vto66nk83romuu3f40qrd72lmrjpui@4ax.com> <9sut89$b7v$1@slb7.atl.mindspring.net> Message-ID: "Andrew Dalke" wrote . > Me: > >>I wanted to add a new method, so I did > >> > >>class Spam: > >> def double(self): > >> self.x = self.x * 2 > > Daniel Klein: > >Just curious to know how it is that you expected this to work > > Because I didn't think that 'class Spam' always created a new > class. I thought it would reuse a definition of one already exists. > I believe this is similar to what Smalltalk does. > > > why you were 'annoyed'? > > Because it didn't fit my model of how the language worked, so > was more effort to learn. > > >I can't > >see what the problem is with the double() method. > > The problem was I wanted to add a method to an existing class. > The method definition was fine. > ISTR someone suggested some time ago that we might use def Spam.double(self): self.x *= 2 to add or redefine methods, but I don't remember why this was thought to be a bad idea. I suppose in all such cases it's bad that there's no way to reach out to existing instances and modify them. SmallTalk's introspection system has it over Python in that respect, but then (like me :) it's more mature. memory's-not-what-it-was-ly y'rs - steve -- http://www.holdenweb.com/ From ylee12 at uiuc.edu Mon Nov 12 23:41:59 2001 From: ylee12 at uiuc.edu (Young-Jin Lee) Date: Mon, 12 Nov 2001 22:41:59 -0600 Subject: [Q] wxPython from newbie Message-ID: Hi, all. I have a question on AddSimpleTool() method of tool bar. I was trying to create a simple application with a tool bar. I was reading wxToolBar.py and trying to copy and paste the code. While I was reading the code, I had problem understanding the following code. toolBar = self.CreateToolBar( wxTB_HORIZONTAL | wxNO_BORDER | wxTB_FLAT ) I checked the online help of wxPython (wxWindows) and I got the following information. virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER | wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = "toolBar") My problem is that I couldn't know the exact return type of CreateToolBar() method because it is a virtual function. But I decided to go further on wxToolBar.py. Then I got another problem in the following code. toolBar.AddSimpleTool( 10, images.getNewBitmap(), "New", "Long help for 'New'" ) I looked up the online help, but I couldn't find any method named AddSimpleTool in wxToolBar and I found nothing when I tried to search "AddSimpleTool" in the online help. In addition to this problem, I couldn't understand getNewBitmap() method in images.py (it is also in the demo directory of wxPython distribution.) def getNewBitmap(): return wxBitmapFromXPMData(getNewData()) def getNewData(): return cPickle.loads(zlib.decompress( 'x\332\323\310)0\344\012V74S04U0V0T\347J\014V\327SHVp\312IL\316\006\363"\200 \ Message-ID: Prabhu Ramachandran writes: > >>>>> "GMcM" == Gordon McMillan writes: > > GMcM> But sys.modules is a dictionary. It's hashed, not scanned. > > Indeed but doesn't the length of the table matter for performance? Not significantly, no. Cheers, M. -- That's why the smartest companies use Common Lisp, but lie about it so all their competitors think Lisp is slow and C++ is fast. (This rumor has, however, gotten a little out of hand. :) -- Erik Naggum, comp.lang.lisp From andreas at mtg.co.at Sun Nov 25 05:56:24 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Sun, 25 Nov 2001 11:56:24 +0100 Subject: PHP vs. Python/comp.lang.php? In-Reply-To: References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: <200111251056.fAPAuTm09724@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Freitag, 23. November 2001 06:08 schrieb stephen cox: > > 2. I also need something practical to get away from the borg; I made > > a big mistake during the 1990s and moved from Clipper to Visual Basic, > > MS's new .NET Framework is impressive. And believe it or not it works. And > you can use Python as you lang of choice if you prefer. Also supported are > J#, C#, C, Cobol, and of course VB (ASP w/VB. No more VBA). Another shocker > is that the Framework is available for free. And MS is porting it to Linux > and FreeBSD. Also you do not need Visual Studio (which is crap. Even the Are they also porting the Win32 API Frameworks to Unix? Why should I consider using such a huge base without source/rights to modify it? [snip] >-- >Stephen Cox >web.net geek for non-profits, political campaigns, and a few socially >conscious businesses. I see "a few socially conscious businesses" should use software from THE socially conscious business of the World ;) Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8AM5bHJdudm4KnO0RAkOZAJ9oslpp32H51AwqX2PSRubiSBJDtgCg0AuO T6QjNcjOuxZYwSPfZbtqyfc= =Er1P -----END PGP SIGNATURE----- From nde at comp.leeds.ac.uk Wed Nov 28 05:39:37 2001 From: nde at comp.leeds.ac.uk (N D Efford) Date: Wed, 28 Nov 2001 10:39:37 GMT Subject: lanching a "*.exe" from Python ? References: <9ts4o1$sd7$1@wanadoo.fr> Message-ID: stefff wrote: > Hello, > I am a new python user and I would like to know if it is possible to launch > an executable in python : ie I have a c compilled program (that I want run > as fast as it possible) and I intend using python for GUI and I/O managing. The second edition of "Programming in Python" has some very detailed explanation of the various ways of doing this on Unix and Windows platforms. Nick From stephen.boulet at motorola.com Fri Nov 30 13:29:01 2001 From: stephen.boulet at motorola.com (Stephen Boulet) Date: Fri, 30 Nov 2001 12:29:01 -0600 Subject: Converting an integer to base 2 Message-ID: <3C07CFED.C7F7CA38@motorola.com> I'm trying to convert integers to base 2. Can someone tell me why this doesn't work? >>> int('5', 2) Traceback (most recent call last): File "", line 1, in ? int('5', 2) ValueError: invalid literal for int(): 5 Thanks. -- Stephen From TomH at optiscan.com Thu Nov 1 16:42:23 2001 From: TomH at optiscan.com (Tom Harris) Date: Fri, 2 Nov 2001 08:42:23 +1100 Subject: List transpose method Message-ID: Hi, Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can only come up with an ugly multiliner. Tom Harris, Software Engineer Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, Australia email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 This email may contain confidential information. If you have received this email in error, please delete it immediately,and inform us of the mistake by return email. Any form of reproduction, or further dissemination of this email is strictly prohibited. Also, please note that opinions expressed in this email are those of the author, and are not necessarily those of Optiscan Pty Ltd. From sill at sill.silmarill.org Tue Nov 20 18:17:09 2001 From: sill at sill.silmarill.org (Andrei Kulakov) Date: Tue, 20 Nov 2001 23:17:09 GMT Subject: distutils for old pythons? Message-ID: Hello, I just found out that distutils were not included in python1.5 and 2.0. Since a lot of systems still have these installed, I thought of including distutils with distributed source. Is that a good idea? I checked the size and distutils dir is too large, did anyone make a "light" version for inclusion with small scripts? What do you people do? Don't use distutils, make your own, include it with your app, use something else? - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From david at dataovation.com Mon Nov 19 13:47:26 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 19 Nov 2001 10:47:26 -0800 Subject: Cookies Message-ID: I want to read the values of a cookie that was placed on my computer by a web site. I opened it up and it appears to be encoded. Is there anyway to decode the values? David From jerry at sky.net.ua Thu Nov 15 15:36:29 2001 From: jerry at sky.net.ua (Serg) Date: Thu, 15 Nov 2001 22:36:29 +0200 Subject: Can't add modules? Message-ID: <3bf428b9@skynet> I'm quite a newbie with setting python. I've downloaded sources, compiled for win32 platform and first thing I wanted to do is to add some library and test its work. The problem is: pythonpath is set for d:\python\lib; in that directory there is directory Optic. In it __init__.py and options.py. Ok I write thimple python program from optik import otion # or it was from optik import * option(100) I get Traceback (most recent call last): File "a.py", line 1, in ? from optik import * ImportError: No module named optik At the same time I create in the same lib directory my directory b and in it file bb.py def aa(some): print some I start the following program from optik import * aa(100) And it prints 100. What did I do wrong? >>> import sys >>> sys.path ['', 'D:\\', 'd:\\python\\lib', 'D:\\PYTHON\\lib\\lib-tk', 'D:\\PYTHON'] python 2.2b1 -- Keep in touch. Your partner Maltsev. From skip at pobox.com Tue Nov 27 14:55:48 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 27 Nov 2001 13:55:48 -0600 Subject: Integer Overflow In-Reply-To: <9u0oih$64q$2@peabody.colorado.edu> References: <3C03D04B.D89F97A2@earthlink.net> <9u0oih$64q$2@peabody.colorado.edu> Message-ID: <15363.61380.433572.159573@beluga.mojam.com> >> In the current 2.2 beta, int operations that would overflow silently >> return longs: >> >> >>> 3**100 >> 515377520732011331036461129765621272702107522001L fp> Just curious: how bad is the performance impact from this (if any)? Compared to what? ;-) Seriously, since I can't easily compute 3**100 without resorting to longs, there's not really anything to compare it to. Arithmetic with longs is substantially slower than with ints (looks like about 4x slower for multiplication where operands and results are <= sys.maxint), but may still be fast enough. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From fredp at mygale.org.nospam Mon Nov 26 04:39:35 2001 From: fredp at mygale.org.nospam (Fred Pacquier) Date: 26 Nov 2001 09:39:35 GMT Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: "MANUEL FERNANDEZ PEREZ" said : > Hello, > I'm looking for an editor for Python.I' m interested it works on > Windows.Can anybody help me? If all you want is an editor that treats Pythoncode well, not a full-blown IDE, then you might want to look at SciTe (http://www.scintilla.org). It's lightweight, effective, and the interface can be localized easily in the latest version. -- YAFAP : http://www.multimania.com/fredp/ From opengeometry at yahoo.ca Mon Nov 26 12:53:23 2001 From: opengeometry at yahoo.ca (William Park) Date: Mon, 26 Nov 2001 12:53:23 -0500 Subject: Programming Rayleigh-Ritz method In-Reply-To: <3BFD0E67.9080106@stu.ust.hk>; from ee_fhw@stu.ust.hk on Thu, Nov 22, 2001 at 10:40:39PM +0800 References: <3BFD0E67.9080106@stu.ust.hk> Message-ID: <20011126125323.A3795@node0.opengeometry.ca> On Thu, Nov 22, 2001 at 10:40:39PM +0800, Calvin wrote: > Greetings, > Did anyone have the experience of programming the Rayleigh-Ritz method > using Python. The Rayleigh-Ritz method is a numerical approximation for > solving energy minimizing problem. If you have program FEM in Python. > Could you teach me how to write the algorithm? Calvin, - if you have C source code, then it's easy to translate it to Python. - if you have the algorithm in pseudo-code, then it's even easier. In other words, write it your self. :-) -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From mjackson at wrc.xerox.com Fri Nov 9 07:40:42 2001 From: mjackson at wrc.xerox.com (Mark Jackson) Date: 9 Nov 2001 12:40:42 GMT Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <9sgisa$hgc$1@news.wrc.xerox.com> James_Althoff at i2.com writes: > So under the proposed scenario, if one looks at 10 and asks "if 10 were to > return an iterator, what would that iterator iterate over?", then it seems > that range(10) would be a more *useful* answer than a sequence of one > element 10. So "for i in 10:" wouldn't, actually, include 10. That's just Wrong, in a way that range(10) and [0:10] is not. Bad idea, IMO. also-opposed-to-the-"up_to_but_not_including"-keyword-ly yr's -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson After a recent trip to New York one French journalist remarked that leafing through a copy of /Forbes/ or /Fortune/ is like reading the operating manual of a strangely sanctimonious pirate ship. - Adam Gopnik From rdsteph at earthlink.net Wed Nov 21 14:33:17 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Wed, 21 Nov 2001 19:33:17 GMT Subject: using python with MS WSH? .NET? References: Message-ID: <3BFC02D8.F30513FF@earthlink.net> Peoter Veliki wrote: > Can Python be used with MS Windows Script Host (WSH)? What about for use > with .NET? What are the limitations of using Python in windows? I am very > new to the MS world, don't flame if these are silly questions. Thanks. Check out Mark Hammond's book, Python Programming on Win32. Mr. Hammond also created the excellent win 32 Python extensions and tools included in the ActiveState distribution of Python, which is highly recommended. H also has done some work creating a python prototype on .NET, but this is definitely not ready for prime time yet. Check out the ActiveState web site, I think it is www.activestate.com and try the win32 Python distribution. Look up Mark Hammond's web site. get his book if at all possible. Yes Python works very well with windows and COM. RS From ANTIGEN_NETSYS-NT-SERV at netsys.co.za Mon Nov 26 04:06:59 2001 From: ANTIGEN_NETSYS-NT-SERV at netsys.co.za (ANTIGEN_NETSYS-NT-SERV) Date: Mon, 26 Nov 2001 11:06:59 +0200 Subject: Antigen found Win32/PSW.Hooker 2.4.Trojan (CA(InoculateIT)) virus Message-ID: <41A321246CB6D511AE2600C0DFF8012E63A0@netsys-nt-serv.netsys.co.za> Antigen for Exchange found stuff.MP3.pif infected with Win32/PSW.Hooker 2.4.Trojan (CA(InoculateIT)) virus. The file is currently Removed. The message, "", was sent from Joanna and was discovered in Thys Meintjes\Inbox located at Netsys International/NETSYS/NETSYS-NT-SERV. From brueckd at tbye.com Fri Nov 30 10:57:37 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Fri, 30 Nov 2001 07:57:37 -0800 (PST) Subject: Python evangelists unite! In-Reply-To: <3C07884E.75E18DF7@engcorp.com> Message-ID: On Fri, 30 Nov 2001, Peter Hansen wrote: > brueckd at tbye.com wrote: > > On Fri, 30 Nov 2001, Peter Milliken wrote: > > > I use Python as a good, quick and dirty hacking language. For real (read > > > production) stuff that I expect a customer to run or will require more than > > > a single person working for a couple of hours, I look elsewhere :-). Sure [snip] > > > > I am *so* glad that there are people in the world that share your opinion > > because you hand me a competitive advantage on a silver platter. I don't > > even have to work for it! Keep up the good work; many, many thanks! > > Dave! :-( Sshhhhh! > > (Most of the people here are probably not in business themselves. > You're not supposed to leak the secret out to our competitors!) Doh! Sorry... I may have exceeded the MADCAP (Maximum Advocacy Degree for the Customer Acceptance of Python). It's a fine line - on the one hand Python needs to be evangelized so that software consumers (clients and/or bosses) realize it is "safe" to use and not a toy, and at the same time I don't want it to become *too* popular because the playing field becomes level again. OTOH, if my competitors were really smart, they'd already be using Python, so me spilling the beans isn't too damaging. ;-) -Dave From mwh at python.net Wed Nov 14 07:10:02 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 12:10:02 GMT Subject: Python .elc and /etc/magic References: Message-ID: Oleg Broytmann writes: > On Wed, Nov 14, 2001 at 11:35:00AM +0000, Michael Hudson wrote: > > [mwh at starship mwh]$ python1.5 get_magic.py > > 1.5 0xa0d4e99 > > > 0 belong 0x994e0d0a python compiled > > > > > Where did they get that number from? Doesn't seem to match anything I > > can find. > > This is just reverse byte order of your 0xa0d4e99 :) Oh yeah . And then they forgot to twiddle their magic file when they upgraded to Python 2.0. 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 srumbalski at prodigy.net Tue Nov 13 08:31:35 2001 From: srumbalski at prodigy.net (Steven Rumbalski) Date: 13 Nov 2001 05:31:35 -0800 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <2b326e2e.0111130531.7a85a0b8@posting.google.com> Michael 'Mickey' Lauer wrote in message news:<3beedf26 at nntp.server.uni-frankfurt.de>... > Given this approach, the main question I'm currently trying to > figure out is: What application shall I present? It must be complicated > enough to show some advanced topics (not only presenting a tour of > the widgets and voila...) but at the same time small enough to cover > it within 50 pages or so (remember: for each toolkit!). > > I first thought of some contact application - in outlook style - or > some kind of presentation program - powerpoint style - ... here's a plea > for your input. > > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? My $.02: How about a simple text editor? Whatever application you present you should probably have either an appendix or an early chapter explaining the code that will stay the same across each implementation. By the way, it would be nice if this were an online book. You may get a lot of good feedback if people can see it as you write it. Bruce Eckel has had some success with this model. Steven Rumbalski From BPettersen at NAREX.com Mon Nov 26 16:26:33 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 26 Nov 2001 14:26:33 -0700 Subject: string.join() syntax quirky? Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192215118@admin56.narex.com> > From: Chris Barker [mailto:chrishbarker at home.net] > > > > One way to look at it is that the various collection > classes do NOT > > > inherit from a single base class (which would be a > logical place to > > > define a join method). Hence to have all kinds of > collections learn > > > to "join" requires a lot of repeat coding. Making join a string > > > method solves this problem. > > > > So instead of doing what's right we're doing what's convenient? > > Doesn't sound very Pythonic > > Another way to look at is is that joining and splitting are > inherently string functionailty, and thus belong with the > string object. Or the string module, if you take the > procedural view of programming. I don't think join() belongs > with sequences at all, as sequences can hold anything,not > just strings. And here I thought I wanted to join the elements of a list with a string (not insert this string between them -- wouldn't I then call insert? ) And while it's true that sequences can hold anything, I fail to see what the relevance is in a dynamic language. I would expect to get something like: TypeError: sequence item 1: expected string, int found Which is what you get now if your list isn't of the right type... > "".join(list) is a little clunky, but it makes sense to me. Nah, it's just plain ugly -- bjorn From bill-bell at bill-bell.hamilton.on.ca Fri Nov 9 16:27:15 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Fri, 9 Nov 2001 16:27:15 -0500 Subject: Open a windows database file with a path name? In-Reply-To: <1005317748.433.44382.m12@yahoogroups.com> Message-ID: <3BEC03E3.29221.514038@localhost> Nomad wrote, in part: > Is there anyway that I can open a database (MSAccess in this case) > using the path and file name rather than a DSN? It goes something like this: conn = win32com.client.Dispatch ( r'ADODB.Connection' ) connString = 'PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE=;' conn.Open ( connString ) rs = win32com.client.Dispatch ( r'ADODB.Recordset' ) rs.Open ( SQL, conn, 1, 3 ) There's a good web page offering clues about working with ADODB and Python. (If I could remember where it is I'd even tell you!) Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From scott_hathaway at riskvision.com Wed Nov 14 15:32:09 2001 From: scott_hathaway at riskvision.com (Scott Hathaway) Date: Wed, 14 Nov 2001 14:32:09 -0600 Subject: reportlab question References: <0o+s9LA$ms87Ewxn@jessikat.demon.co.uk> Message-ID: Thanks, Robin. Sorry for misposting. Scott "Robin Becker" wrote in message news:0o+s9LA$ms87Ewxn at jessikat.demon.co.uk... > In article , Scott Hathaway haway at riskvision.com> writes > >Hello All, > > > >I have a simple script that I am using to create form letters from a text > >file with reportlab. > >It works ok until the text is longer than xx characters long. Then the text > >is just cut off, not > >word wrapped as I would like. How to I cause reportlab to word wrap the > >text? > > > ... > Hi Scott, you'll probably get better results from the users list at > reportlab-users at yahoogroups.com. > > Any how you'll either need to chop the words your self or use the > platypus framework to establish frames and handle wrapping. A relatively > simple example is in reportlab/platypus/doctemplate.py (just run and > look at the output). > -- > Robin Becker From hamish_lawson at yahoo.co.uk Wed Nov 7 10:31:58 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Wed, 07 Nov 2001 15:31:58 -0000 Subject: Special celebration event for Orlijn? Message-ID: <9sbk5e+igpo@eGroups.com> Maybe we should hold a special event in celebration of Guido's new baby boy, Orlijn Michiel - perhaps a New Orlijn's Jazz Festival? OK, I'm sorry :-) Hamish Lawson From vvainio at karhu.tp.spt.fi Tue Nov 27 03:08:31 2001 From: vvainio at karhu.tp.spt.fi (Ville Vainio) Date: 27 Nov 2001 10:08:31 +0200 Subject: Python IDE Opinion Request References: Message-ID: "A. Keyton Weissinger" writes: > 1) Do you use a code editor (SlickEdit, emacs, etc) or an IDE (IDLE, etc)? > Why? I use xemacs for all my editing (any language), but having PythonWin open for interactive stuff helps. It provides autocompletion, so there is less to write and remember. You can escape to a python interpreter from emacs by C-c !, but it does not provide all the fancy features of PythonWin (and probably IDLE also). IDE that ships w/ python is always valuable, for working in environments that only have crippled editors (that routinely consider tab a true character). -- Ville Vainio - http://www.tp.spt.fi/~vvainio - ICQ #115524762 Wild geese have no intention to cast a reflection Water has no mind to assume their form From sholden at holdenweb.com Wed Nov 28 17:41:52 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 17:41:52 -0500 Subject: Should I use threads here? References: <83bshmv8yf.fsf@panacea.canonical.org> Message-ID: "Kragen Sitaker" wrote in ... > "Steve Holden" writes: > > readlines() doesn't terminate until it knows (by seeing and end of file on > > its input stream) that it has read all the input. If you built a loop using > > readline() you might find you got better results. > > This is assuming that the program actually outputs stuff as it goes; > many programs buffer output in big blocks when they're talking down a > pipe instead of outputting line by line. > This may be true. But the readline() solution *can't* be any worse, and might be better. Readlines() will definitely not return until the called program closes its standard output. Of course, if Era has no access to the program's source he has no possibility of adjusting its output behavior. regards Steve -- http://www.holdenweb.com/ From roy at panix.com Thu Nov 29 21:15:43 2001 From: roy at panix.com (Roy Smith) Date: Thu, 29 Nov 2001 21:15:43 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> Message-ID: Jeff Shannon wrote: > My current place of employment does not use any significant form of version > control. How the heck do they have any idea which end is up? > Due to the nature of most of our codebase, using CVS for it would > be unrealistic anyhow. Could you expand on that? Are you saying that specifically CVS won't work for your codebase, or that version control in general won't work? Either way, I'm curious to hear why you think that. From olli at secnetix.de Tue Nov 6 13:43:51 2001 From: olli at secnetix.de (Oliver Fromme) Date: Tue, 6 Nov 2001 18:43:51 +0000 (UTC) Subject: split(None) References: <9s98o6$ilj$1@isp-m-srv06.izb.net> <9s9aii$121pt9$1@ID-11957.news.dfncis.de> Message-ID: <9s9b17$ilj$2@isp-m-srv06.izb.net> Emile van Sebille wrote: > I don't get the same results. > > F:\Python21>python > ActivePython 2.1, build 210 ActiveState) > based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on > win32 > Type "help", "copyright", "credits" or "license" for more information. >>>> "foo bar baz".split(None) > ['foo', 'bar', 'baz'] >>>> "foo bar baz".split(None, 1) > ['foo', 'bar baz'] >>>> > > It look to me like it works the way you would expect it to. Yes. I've just exited from the python interpreter, restarted it, and now it works fine, too. I guess I must have broken something during experimentation in my previous interpreter session. Don't ask me how I did that ... :-( I'm sorry for the confusion and the false alarm. However, the small error in string.split.__doc__ still exists. ;-) Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From r.vanwees at chello.nl Thu Nov 8 11:06:40 2001 From: r.vanwees at chello.nl (r.vanwees at chello.nl) Date: Thu, 08 Nov 2001 16:06:40 -0000 Subject: How to get two modules loaded into the same namespace? Message-ID: <9seaig+1hni@eGroups.com> I am trying to build a rule engine. I have two Python modules: RuleEngine.py and utilities.py. I want to keep the engine and the utility functions separated for reasons of maintainiability and cleannes. I am running into a few problems: 1) In RuleEngine.py I have defined a global, DEBUG_PRINT_LEVEL, which allows me to steer the amount of debug info I get at runtime (curently somewhere between 'nothing' and 'an awful lot'). When I try the following in RuleEngine.py: global DEBUG_PRINT_LEVEL DEBUG_PRINT_LEVEL = 0 from utilities import * class RuleEngine: someUtilityFuncThatReferencesDEBUG_PRINT_LEVEL() I get a NameError on DEBUG_PRINT_LEVEL (see stack trace below): File "D:\Dev\PyCharGen\utilities.py", line 120, in calcLevel if DEBUG_PRINT_LEVEL >= 4: NameError: global name 'DEBUG_PRINT_LEVEL' is not defined Process terminated with exit code 0 As far as I understand the docs, the 'from x import *' syntax should import stuff into the current namespace, but apparently this does not hold for globals. 2) Several functions in utilities.py refer back to functions in RuleEngine.py. They also return a NameError (see stacktrace below from an actual debug log) File "D:\Dev\PyCharGen\utilities.py", line 157, in calcSpells statLevel = find(stat, 'base') + find(stat, 'bonus') NameError: global name 'find' is not defined Process terminated with exit code 0 Again, it seems that the two modules are not in the same namespace. Both python 2.1.1 and 2.2beta show this behavior. Does anyone know a solution (other than putting the utility functions in RuleEngine.py) to this problem? I must admit that I got lost at the Python namespace rules before... Kind regards, Rob van Wees From prabhu at aero.iitm.ernet.in Tue Nov 6 11:00:13 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 21:30:13 +0530 Subject: Python packages - problems, pitfalls. In-Reply-To: References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: <15336.2317.28847.858357@monster.linux.in> >>>>> "BH" == Bernhard Herzog writes: >> pkg_root/ __init__.py app.py # app is the application that is >> not part of the package BH> If it's not part of the package, why is it in pkg_root? Put it BH> somewhere outside of pkg_root, make sure pkg_root is in a BH> directory on Python's path and everything should be fine. Easier said than done. If I wanted to do this I'd have to re-nest every blessed file in CVS. This is something I want to avoid. >> Also, irrespective of whether people have run into such >> problems or not, don't you think it makes sense for modules to >> be searched the way I had suggested earlier?? Or is there some >> serious issue with this. BH> The name search rules for packages are more or less the same BH> as for local variables in functions, at least when packages BH> were introduced. With nested scopes that similarity will be BH> gone, though. BH> Anyway, you may want to search a bit through Python's BH> history. Python 1.3 introduced the first stab a packages of BH> modules with a mechanism called "ni" which had a much more BH> elaborate name resolution scheme. One part of it was BH> "expanding search" which would automatically look in a BH> package's parent package and so forth and it had a way of BH> referring to a module's package (by the variable __) and to BH> package's parent (__.__). Yes, unfortunately, this way of referring to parent packages was removed! From: http://python.org/doc/essays/packages.html "This feature was dropped because of its awkwardness; since most packages will have a relative shallow substructure, this is no big loss.)" If you ask me that is a bad assumption. "most packages will have a relative shallow substructure" - where was that pulled out from?? BH> The ni module is still there, but it's deprecated since the BH> new builtin package support was added in 1.5 and therefore now BH> lives in lib-old. BH> Guido's essay about the builtin package support has some BH> comments on the reasons behind the differences between ni and BH> the current scheme: http://python.org/doc/essays/packages.html Yes I read that long before I posted to this list. Sorry if I may sound rude, but please understand that the problem is real and not theoretical. And I did do my homework and have my reasons and I'm not the only one looking for a solution. :) Maybe I was not clear. Let me try to be a little clearer. This is what Python does now: (1) Check if module is in same directory (sibling module). (2) If not found - look at the global level for modules in any directories found in sys.path. There is *absolutely* no in between here. Its either local or global. What I suggest. (1) Check if module is available in the same directory, if available - use it. (2) If not found walk up to parent dir. check there, if not there go up until out of package. (3) If not found in (2) look at sys.path for module. Here is pseudo code: def load_module(module): # do stufff def check_module_in_dir(module, dir): # do stuff def find_parent_package_dir(): # do stuff def walk_package(module, dir): if check_module_in_dir(module, dir): return load_module(module) else: par = find_parent_package_dir() if par: if walk_package(module, par) else: # search in sys.path and try to load module from there. dir = os.path.dirname(__file__) walk_package(module, dir) Now doesn't this make more sense than what is being done currently? Forget about my silly examples. :) Anyway, looks like I'm gonna have to look at knee.py and imputil and figure out a way to implement this. thanks, prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 From cliechti at gmx.net Tue Nov 20 17:29:13 2001 From: cliechti at gmx.net (Chris Liechti) Date: 20 Nov 2001 23:29:13 +0100 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> <3BFAAD1E.9E9AF618@alcyone.com> <3BFAC45B.9D246137@alcyone.com> <2SzK7.605$px5.156976@newsfeed.slurp.net> Message-ID: [posted and mailed] "Bruce Edge" wrote in news:2SzK7.605$px5.156976 at newsfeed.slurp.net: >> It wouldn't be hard to write a simple wrapping script that takes a >> printf format string, converts it to a regular expression, does a >> match against a string, then pulls out the arguments and converts them >> to types as appropriate. But one might just as well be using regular >> expressions directly in the first place. >> > > Here's what I did to convert the format string to a regex. > It's not pretty, and many types will break it, but it serves the > purpose, for now: > > def fmtstr2regex( str ): > regex = "" > while len(str): > if str[0] == '%': > x = re.match("%(?P\d*)(?P\w)(?P.*)$",str) you don't match "%6.3f" and similar and not "%-4f" > if not x: > exc = CommandException() > exc.reason = "Invalid print format specifier %s" % > str raise exc when you define an exception like this: class CommandException(Exception): pass you can simply call "raise CommandException("reason %s" % str) > length = int( x.group("len") ) needs an if here... if x.group("len"): length = int( x.group("len") ) else: length = None > type = x.group("type") > # Some types need to be changed from printf to regexp > world if type == 'x': > type = '['+string.hexdigits+']' > else: > type = "\\%s" % type type 's' should also be transformed to 'w' ('\s' are whitespaces) > regex += "(%s" % type > if length: > regex += "{%d,%d})" % ( length, length ) > else: > regex += "+)" > str = x.group('rest') > else: > regex += "\%s" % str[0] whats the intent of '\' here if you want to escape the character you should write two (ok "\%" -> '\\%' but writing it explicit is better, like you did above). but escaping produces wrong regexes here. >>> print fmtstr2regex("1.st %d") \1\.\s\t\ (\d+) '\s', '\t', '\1' are all special commands for regexes, you realy want is r'1\.st (\d+)' only reserved regex characters should be escaped. [](){}.+?*$^\ > str = str[1:] > return regex > just a sidenote: "type" is a builtin function, which you shadow with your variable but overall a nice idea.. chris -- Chris From a00tch00 at nchc.gov.tw Tue Nov 6 03:53:29 2001 From: a00tch00 at nchc.gov.tw (T. C. Huang) Date: Tue, 06 Nov 2001 16:53:29 +0800 Subject: win32print.Enumjobs Message-ID: <3BE7A509.A03DD6C9@nchc.gov.tw> Hi, How to use win32print.EnumJobs() function? The documention has too little information to be useful. Tsunagchi Huang From huaiyu at gauss.almadan.ibm.com Fri Nov 30 18:05:06 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Fri, 30 Nov 2001 23:05:06 +0000 (UTC) Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: Message-ID: On Fri, 30 Nov 2001 08:59:21 -0500, Steve Holden wrote: >"Michael Abbott" wrote in message >news:Xns91697EB73ACCmichaelrcpcouk at 194.238.50.13... >> Skip Montanaro wrote in >> news:mailman.1007090560.18985.python-list at python.org: >> >> > You were relying on undocumented behavior. There is no obvious ordering >> > between integers and None. >> > >> >> So why don't comparisons of this type generate an exception? > >Because comparisons are used in sorts, for example, and it wasn't considered >helpful for sorts of lists of arbitrary datatypes to raise errors. However, sort will fail if one of the objects is a complex number. The current order model is broken: the system can't make up its mind whether it wants a total order or partial order. Both kind of orders are used in practice. The only way to avoid unexpected results in all cases is to assign distinct semantics to distinct syntax. It cannot be fixed by pretending there is only one kind of order. One approach might be this: let sort use a total order defined by __cmp__, and let max and min use a partial order defined by __lt__, __gt__. The user is responsible for their compatibility if so desired, but it should not be required a priori. Huaiyu From tim.one at home.com Sun Nov 11 13:50:22 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Nov 2001 13:50:22 -0500 Subject: Tim Peters on speed! In-Reply-To: Message-ID: [Don Tuttle] > Ok, now that I have your attention ... Hmm -- I confess it worked. Good ploy! I hope to see a lot more of these . > In studing Tim' recipe "Remove duplicates from a sequence" > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/52560 > > Tim assigns the result back to the original list rather than a new list. > Was this done for performance or convenients? Is there a performance > penalty for using a second list? > > ... > try: > t = list(s) > t.sort() > except TypeError: > del t # move on to the next method > else: > assert n > 0 > last = t[0] > lasti = i = 1 > while i < n: > if t[i] != last: > t[lasti] = last = t[i] > lasti += 1 > i += 1 > return t[:lasti] It's primarily to save memory: the "t = list(s)" already allocated all the memory we could possibly need for the result, and the result *can* be computed in place, so why allocate more? Storing into a preallocated list is definitely quicker than .append()'ing elements, one at a time, to an initially empty list, if that's the alternative you have in mind. A comparatively minor consideration is that crawling over two lists is also less cache-friendly than crawling over one. Note that in no case does the unique() function actually overwrite *the* original list: the input sequence is s, not t, and s may not even be a list (before Python 2.2, it can be any sequence; in Python 2.2, any iterable object). In case you were confused about that, note too that list(s) makes a (shallow) copy of s when s is a list: nothing in unique() mutates s (although it's possible that a perverse user-defined __hash__ or __cmp__ method could mutate s as a side-effect of hashing or comparing s's elements). not-responsible-for-insane-user-methods-ly y'rs - tim From sabren at manifestation.com Mon Nov 26 14:08:24 2001 From: sabren at manifestation.com (Michal Wallace) Date: Mon, 26 Nov 2001 14:08:24 -0500 (EST) Subject: (newbie) A very weird Python CGI problem, possibly related to os.system In-Reply-To: Message-ID: On 26 Nov 2001, Simon Willison wrote: > I have a very odd Python CGI problem. I'm writing a simple > web script which queries Quake III game servers and > displays the server name / map / number of players on a > web page. The script works by executing a command line > program called qstat (www.qstat.org). I'm very new to > python, and I'm using this project as a learning > excercise. [snip] > qstat = '/u/cs/1/cs1spw/qstat24e/qstat' # Path to qstat > run = qstat + " -raw ~@~@~ -f " + game + " > " + tmp > os.system(run) I think perhaps that run fails. Possibly a permission issiue with the apache user. Have you verified that tmp does indeed contain the correct data? Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From LLoeffler at home.com Wed Nov 28 13:20:24 2001 From: LLoeffler at home.com (Luke) Date: Wed, 28 Nov 2001 12:20:24 -0600 Subject: 1st day newbie question. References: <_79N7.7778$Wd.2905531@news1.rdc1.az.home.com> Message-ID: <3C052AE8.7010600@home.com> The the code in a text file and save it as spam.py where spam is some meaningful name. You can then say python spam.py at the command prompt to run it, or if you are at the prompt you can do an import spam.py to run the code... If there is some main function, you can get it to run by adding: if __name__ == "__main__": somefunction() so somefunction() could be your main logic loop or something. In a unix enviornment add #!/path/to/python at the top From max at alcyone.com Thu Nov 8 13:13:43 2001 From: max at alcyone.com (Erik Max Francis) Date: Thu, 08 Nov 2001 10:13:43 -0800 Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> <3BEACB0E.DCB6E4C6@alcyone.com> Message-ID: <3BEACB57.B62C8A62@alcyone.com> Erik Max Francis wrote: > It works as expected in Python 2.1.1, so I'd say it's just a bug. No it doesn't, never mind. Not enough coffee this morning. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From jhauser at ifm.uni-kiel.de Sun Nov 11 10:48:49 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 11 Nov 2001 16:48:49 +0100 Subject: multipack References: Message-ID: <87n11tcnq6.fsf@lisboa.ifm.uni-kiel.de> it's now part of scipy at http://www.scipy.org If you do not want to download the hole thing, I have probably a version locally I can send you by email. __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From jdadson at ix.netcom.com Tue Nov 6 18:29:57 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 06 Nov 2001 23:29:57 GMT Subject: How much is set in stone? References: Message-ID: <3BE8724E.7482C881@ix.netcom.com> I expected better from this group. Jive From hfoffani at yahoo.com Fri Nov 30 13:37:18 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Fri, 30 Nov 2001 19:37:18 +0100 Subject: python documentation. was: Re: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> <2NPM7.568$_06.167730@newsb.telia.net> Message-ID: <20011130133759.283$nv@news.newsreader.com> "maxm" escribi? en el mensaje news:JsaN7.1178$K4.200702 at news010.worldonline.dk... > > The complaints that I have from a few of the people i religiously try to > convert to Python, is that they have a hard time finding information in the > docs. Not that it isn't in there, just that it's hard to find. You want the Python Docs in MS HTML Help format with full text search. Get them at: http://www.orgmf.com.ar/condor/pytstuff.html you'll also find there the Python Shelf (which is a collection of other serveral documents) Regards, -Hern?n. From morton at dennisinter.com Tue Nov 27 23:24:46 2001 From: morton at dennisinter.com (damien morton) Date: 27 Nov 2001 20:24:46 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <4abd9ce7.0111272024.79ec4e0b@posting.google.com> James_Althoff at i2.com wrote in message news:... > Greg Ewing wrote: > >While trying to think of a range syntax that looks > >unambiguously half-open without clashing with list > >or tuple constructors, the following blindingly > >obvious solution occurred to me: > > > > for 0 <= i < 5: > > ... > > Greg, > > Since this looks like a suggestion for replacing xrange in the general > case, did you have any thoughts on how one might specify a step value? > > Jim is a step value really necessary? I have very rarely used a step vale, except when programming in C, and even then only in ill-defined cases. Anyone else iterate in Python in steps larger than 1? From tim at vegeta.ath.cx Fri Nov 16 07:45:35 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 16 Nov 2001 12:45:35 GMT Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> <9svuli$lss$1@slb4.atl.mindspring.net> Message-ID: Matt Gerrans graced us by uttering: > Tim Hammerquist graced us by uttering: >> ...and someone posted regarding a cow orker who denounced Python's... > > Now let's not stoop to name-calling. He may be a SmallTalk bigot, but we > have no proof that he ever orked a cow... > > - mfg There you go, assuming orking cows is bad! Have you proof? Or even personal experience? ;) Now bigotry... _that_ I have experience with, and let me tell you...it can really be fun! Tim Hammerquist -- If Microsoft built cars, the oil, gas, and alternator warning lights would be replaced by a single "general car fault" warning light. From sholden at holdenweb.com Mon Nov 5 10:25:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Nov 2001 10:25:29 -0500 Subject: Question: Error or misconcept References: <3be65da4$1_3@corp-goliath.newsgroups.com> <9s62qa$11k821$1@ID-11957.news.dfncis.de> <3be69395_1@corp-goliath.newsgroups.com> Message-ID: "K?roly Ladv?nszky" wrote in ... > Thank you for your answer. > > > You've just created a class level shared object a1. > > Ok, but then I'd expect the same behaviour when a1 is a number. > Try this: > > class c: > a1=0 > def f1(self,a): > self.a1=a > > Now: > o1=c() > o1.f1(99) > o1.a1 ==> 99 > o2=c() > o2.a1 ==> 0 ! Shouldn't it reflect the change in the class level object's > value just like in the case a1 is a list? > In your original two examples you were comparing the results of self.a1.append(a) in your first example with self.a1 = (a) in your second example. The fundamental difference is that the first example modifies the mutable value bound to the name "self.a1", which is resolved as the class variable a1. Your second example *rebinds" the name "self.a1", which is therefore added to self's locals and becomes a separate variable from the class variable. The class variable can in both instances be accessed using "c.a1". regards Steve -- http://www.holdenweb.com/ From mgerrans at ix.netcom.com Wed Nov 14 15:28:09 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Wed, 14 Nov 2001 12:28:09 -0800 Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: <9suk42$lr6$1@nntp9.atl.mindspring.net> > 39. Re graphics: A picture is worth 10K words - but only those > to describe the picture. Hardly any sets of 10K words can be > adequately described with pictures. > -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html Hey, when did a picture's word-value get upgraded by an order of magnitude? (or was he referring to the Chinese version of that clich??) - mfg From ejohnso9 at earthlink.net Tue Nov 20 18:28:23 2001 From: ejohnso9 at earthlink.net (Erik Johnson) Date: Tue, 20 Nov 2001 23:28:23 GMT Subject: Conversion from tuple to argument list? References: Message-ID: <3BFAE47F.C014585B@earthlink.net> Chris Liechti wrote: > > > >>> args = range(3) > > newer python releases: > >>> struct.pack("bbb", *args) > '\x00\x01\x02' > Hmm, I am new to Python. ORA's "Learning Python" & "Programming Python" both document the use of '*' for variable argument lists in the function definition, but this is the first time I have seen it used in the function call. Does this sort of use have a name? Is this documented somewhere? Thanks, -ej From justin at iago.org Thu Nov 29 20:44:45 2001 From: justin at iago.org (Justin Sheehy) Date: Thu, 29 Nov 2001 20:44:45 -0500 Subject: A modest indentation proposal In-Reply-To: (gat@jpl.nasa.gov's message of "Thu, 29 Nov 2001 14:09:28 -0800") References: Message-ID: gat at jpl.nasa.gov (Erann Gat) writes: > syntactically-significant indentation > It also IMO makes the language unsuitable for mission-critical > applications. It's just too easy to screw up indentation > (particularly when cutting and pasting large blocks of code) without > realizing it. You are looking at the wrong cause of your problems. Cutting and pasting large blocks of code without adequate verification and testing makes the programmer unsuitable for mission-critical applications. Decent programming practice and an enforced indendation style will make this a complete non-issue. Any programming team that doesn't already enforce a specific internal coding style has no business writing mission-critical applications. > I have a suggestion > [snip] Your suggestion is unworkable as it would throw warnings on currently correct, well-formed code. Expecting everyone to add completely uneccessary semicolons at the end of blocks is not only unworkable in practice, it also wouldn't achieve your goal. A semicolon is already a valid character at the end of a line, and is essentially ignored. > Comments? Indentation is already significant to the programmer in nearly every common language. If the programmer or programming team is competent, making that whitespace similarly significant to the language does not cause any problems. -Justin From Bill.Scherer at VerizonWireless.com Mon Nov 12 12:17:36 2001 From: Bill.Scherer at VerizonWireless.com (Scherer, Bill) Date: Mon, 12 Nov 2001 12:17:36 -0500 (EST) Subject: Is this considered black magic? In-Reply-To: Message-ID: On Mon, 12 Nov 2001 17:02:38 +0100, Laura Creighton wrote: (snip) >I have a new problem. I've just lost a major amount of precision in my >language usage. What is the collective noun for 'attributes that aren't >methods (you can't call them)'? UML refers to methods as 'operations', and the uncallable attributes as 'attributes'... -- Bill.Scherer at Verizon Wireless RHCE 807101044903581 From dcinege at psychosis.com Wed Nov 21 03:10:17 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Wed, 21 Nov 2001 03:10:17 -0500 Subject: Python execution speed In-Reply-To: References: Message-ID: On Tuesday 20 November 2001 6:57, Martin von Loewis wrote: > * Psyco needs more help. Poor Armin is trying to get people > interested, but nothing happens. I guess this is *also* an aspect of > free software: Even if you follow the rules (publish early, publish > often), success is not guaranteed. IBM has been throwing large dollars at Linux and Python. They are/were puting large dollars into Java VM/JIT as well. Sound like this might be right up their alley to fund. Someone please mention it to the Psyco's author. (This is the first I've heard of the project.) I have some email addy's of people @ ibm to contact concerning things like this. Mail me off list.. I'd love to see it happen. If a side effect is a reduced process memory footprint, that would be a lesser dream come true. (How about just embedding python into the Linux Kernel? : > ) Dave -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From Gareth.McCaughan at pobox.com Tue Nov 27 16:41:48 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Tue, 27 Nov 2001 21:41:48 +0000 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> Message-ID: Greg Ewing wrote: > While trying to think of a range syntax that looks > unambiguously half-open without clashing with list > or tuple constructors, the following blindingly > obvious solution occurred to me: > > for 0 <= i < 5: > ... +1 if it also groks "for 0 < i <= 5" and so on. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From hfoffani at yahoo.com Sat Nov 10 13:00:34 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Sat, 10 Nov 2001 19:00:34 +0100 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> Message-ID: <20011110130113.274$u8@news.newsreader.com> "Amit Weisman" escribi? en el mensaje news:mailman.1005403215.5502.python-list at python.org... > I don't know what comes after the "<" . It's not " by handke_comment . > How can I parse (or even better - ignore) the "<" ?? Amit, I think it would be best if you tell us exactly what do you want to do giving us a sample input too. I'll promise you'll have a better answer from us. Regards, -Hernan From root at rainerdeyke.com Thu Nov 1 00:17:35 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 01 Nov 2001 05:17:35 GMT Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <9rp4d8$830$1@tyfon.itea.ntnu.no> <3BE0240A.A2CCAA83@alcyone.com> <3BE099F6.A9E0708F@alcyone.com> <9rq70r$ve8u6$1@ID-11957.news.dfncis.de> Message-ID: "Chris Gonnerman" wrote in message news:mailman.1004590322.31204.python-list at python.org... > FreeWare is a counterpoint to ShareWare. I was there... before > ShareWare was invented, we just called it free software (not > to be confused with Free Software ala GNU), but then ShareWare > came out, expecting payment, and those who didn't care to be > paid called their programs FreeWare. The trademarked term "freeware" was originally used to refer to sofware that is freely shared with a completely voluntary payment system. The term "shareware" was originally used as a non-trademarked term for the same concept. Later "freeware" was used to refer to free-as-in-free-beer software without voluntary payment systems, and later still the definition of "shareware" was extended to include time- and feature-limited demo software. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From phr-n2001d at nightsong.com Fri Nov 9 08:16:01 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 05:16:01 -0800 Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> <3BEBCE6F.3AAA5358@snakefarm.org> Message-ID: <7xd72sm6em.fsf@ruckus.brouhaha.com> Carsten Gaebler writes: > Paul Rubin wrote: > > > Really the ellipsis should make an iterator: for i in 0...10. > > Sounds pretty cool. However, the ellipsis seems to be poorly > documented. I guess the parser would have to change for the above to work. Right now you'd have to say for i in 0:...:10 and I'm not sure if that's syntactically valid. As far as I can tell, the only current use of ellipsis is in dictionary indexing. One can imagine mapping a database into a dictionary, so db[4:...:19] does a select on those elements. From zooko at zooko.com Mon Nov 26 21:19:30 2001 From: zooko at zooko.com (Zooko) Date: Mon, 26 Nov 2001 18:19:30 -0800 Subject: bugs in `gc.get_referents()' Message-ID: [Please Cc: zooko at zooko.com in follow-ups. Thanks!] Many thanks to Martin von Loewis and Michael Hudson for their prompt and informative responses. One thing I've figured out is that `gc.get_refer{ent,rer}s()' is using equality rather than identity testing. I've opened a bug report on this: [1] That does not by itself explain the "wrong referrers reported" behaviour. Martin von Loewis suggested that "there is a bug in the C type of the tp_traverse function of [the bogus referrer] object", but this example shows that this must not be the explanation: >>> refs = gc.get_referents([1,[2.3,4,],5,6,[7,8,],[9,]]) >>> len(refs) 8 >>> refs[1] [, ] (I'm pretty sure there is no list anywhere in memory that equals that argument to `get_referents()'.) So the bogus referrer object in this case is a list -- a builtin Python list. That particular list (containing those two particular objects of mine) shows up in about half of the bogus referrer lists I see. And by the way, the following two lines consistently segfault when used interactively in my running Mojo Nation app (although sometimes it takes a while to segfault): >>> for i in xrange(2**20): >>> refs = gc.get_referents({}) I wasn't able to get the same results with any test case simpler than a full running Mojo Nation app. If you want to try it in a full running Mojo Nation node then execute the "cvsinstall.txt" script[2] (which fetches the latest Mojo Nation source from CVS and builds it and launches the Mojo Nation node), but replace the call to "Broker" with a call to "Broker --interact" to enter an interactive Python interpreter where you can run the tests quoted above. I, Zooko, wrote the lines prepended with "> > > ": Michael Hudson wrote the lines prepended with "> > ": Martin von Loewis wrote the lines prepended with "> ": > > > Also some of those threads are using native code which might be > > > failing to DECREF properly. > > > > If that's the case, then you've got problems all your own, no? > > That is my suspicion. get_referrers accesses every object that claims > to be a container, without attempting a garbage collection. Some > extension types may not expect that, but they would be broken already. Waiatasecond: if my native code forgets to DECREF, this can't possibly screw up the gcmodule! There's absolutely no different between my native code forgetting to DECREF and my native code actually keeping a live reference (perhaps the only live reference) to an object. On the other hand, if my native code over-DECREFs (or under-INCREFs, etc.), then this could surely cause the kind of wackiness quoted above. If that's the problem then I'm surprised that I'm not getting segfaults in normal usage (i.e., I've never gotten a segfault except the one described above) nor any *other* unusual behavior in normal usage that I've noticed. Okay, so I'll go through all the native code that we use checking for correct reference counting. I've already seen some failure-to-DECREF in some of our native code (but code that is disabled for all the tests that I've described here) so I won't be surprised to find other refcount errors. By the way I had a look at the implementation of `get_referrers()' and I agree that it is simple and looks right. Regards, Zooko [1] http://sourceforge.net/tracker/index.php?func=detail&aid=485781&group_id=5470&atid=105470 [2] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mojonation/evil/hackerdocs/cvsinstall.txt?rev=HEAD&content-type=text/vnd.viewcvs-markup From mwh at python.net Tue Nov 20 08:05:00 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 20 Nov 2001 13:05:00 GMT Subject: how to access the _psyscho module ? References: <6e2dt9.43u.ln@adsl.bapnt> Message-ID: huber writes: > i have downloaded PSYCHO on linux and compiled it.... but now i > don't know what to do whith the library _psycomodule.so ! can > someone help me ( in detailed form ) how to access the _psycho > module ? It's spelt psyco, by the way. All you have to do is fire up python in the directory containing _pyscomodule.c (or put that directory on your $PYTHONPATH) and execute >>> import _pysco then you can do things like: >>> def f(a,b): ... return a + b ... >>> ff = _psyco.proxy(f) >>> ff(1,2) psyco: new code buffer 0xa061154 psyco: disassemble 0xa061154 0xa0611a0 (76 bytes) psyco: new code buffer 0xa0611ec psyco: disassemble 0xa0611ec 0xa061238 (76 bytes) psyco: new code buffer 0xa061284 psyco: new code buffer 0xa0691cc psyco: disassemble 0xa0691cc 0xa0691f4 (40 bytes) psyco: new code buffer 0xa06923c psyco: disassemble 0xa06923c 0xa069260 (36 bytes) psyco: disassemble 0xa061284 0xa0612a8 (36 bytes) 3 >>> I haven't got much further than this yet myself. Is this helping? 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 greg at cosc.canterbury.ac.nz Wed Nov 28 00:11:35 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Wed, 28 Nov 2001 18:11:35 +1300 Subject: Is selecting from multiple list boxes in Tk possible? Message-ID: <3C047207.8243CFE7@cosc.canterbury.ac.nz> I'm trying to make a Tk window containing three Listboxes, with the ability to select one item out of each list. But it seems that making a selection in one listbox causes any selections in any other listboxes in the same window to be cleared. Is there any way of preventing this from happening? This is using Tk8.3 with Python 2.1 on Windows 2000 Professional. -- 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 mikael at isy.liu.se Mon Nov 12 05:20:15 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 12 Nov 2001 11:20:15 +0100 (MET) Subject: long string constants In-Reply-To: Message-ID: On 12-Nov-2001 Holger Fuessler wrote: > Now my question. Is it possible to spread very long string constants > over multiple lines?. """Do you mean like this? """ ''' Or do you mean like this?''' Or are you asking about something completely different? /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 12-Nov-2001 Time: 11:18:25 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From skip at pobox.com Thu Nov 1 11:48:52 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 10:48:52 -0600 Subject: references ??? In-Reply-To: References: Message-ID: <15329.31988.85433.970231@beluga.mojam.com> Thomas> l=[1,2,3,4,5,6] Thomas> for i in l:i=0 Thomas> print l Thomas> l is still [1,2,3,4,5,6]. How to make changes made to i also Thomas> apply to l ? Everything in Python is a reference, so rebinding the name "i" won't have any effect on the list that is bound to the name "l". You need to change the elements of l: for i in range(len(l)): l[i] = 0 print l In the end you should have a list full of zeroes. P.S. For purposes of clarity, names like "l" and "i" are probably not the best choice. ;-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From skip at pobox.com Fri Nov 30 12:03:12 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 30 Nov 2001 11:03:12 -0600 Subject: xmlrpc tutorial? In-Reply-To: <3C07B7A3.2A6443C9@snakefarm.org> References: <3C063569.8230ADD0@snakefarm.org> <3C07961D.9A7970FA@snakefarm.org> <3C07B7A3.2A6443C9@snakefarm.org> Message-ID: <15367.48080.596899.491913@beluga.mojam.com> >> Use the setsockopt function on the socket objet, pass it the value >> SO_REUSEADDR (defined in the socket module). Carsten> Nope, doesn't help. My code is: ... In my server I override the server_bind method like so: def server_bind(self): self.socket.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1) self.socket.bind(self.server_address) Perhaps that will work for you. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From ykingma at accessforall.nl Wed Nov 7 14:17:59 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Wed, 07 Nov 2001 20:17:59 +0100 Subject: [Q] Python and expert system shell References: Message-ID: <3BE988E4.240BA98F@accessforall.nl> Young-Jin Lee wrote: > > Hi, all. > I'm a python newbie and I want to get some advice. > I have developed a Java application and I want to convert it to Python > application. > I think I can easily do most of the part except one module. In my Java > application, I used a JESS (Java Expert System Shell). JESS is a CLIPS > interpreter written in Java. Is there any CLIPS interpreter written in > Python? Or any expert system shell in Python? Did you consider using Jython? It is a python implementation written in Java that allows you to call almost any java code on the class path, including your own java code. It also allows you to write java classes in python. This means that you can get your program running in jython eg. by only rewriting the main program in jython, so you won't need to rewrite all of your code from java to python. You can also reuse the JESS as it is. See www.jython.org for more. Regards, Ype From rxg218 at psu.edu Thu Nov 1 15:43:03 2001 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 01 Nov 2001 15:43:03 -0500 Subject: accessing a web search engine References: <9rq340$1hfc@r02n01.cac.psu.edu> Message-ID: <9rsc34$23co@r02n01.cac.psu.edu> Thanks for the pointers - got it working now -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 152 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- A motion to adjourn is always in order. From loewis at informatik.hu-berlin.de Thu Nov 1 07:01:36 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Nov 2001 13:01:36 +0100 Subject: XML can't read Unicode shock horror. News at 11. References: Message-ID: Dale Strickland-Clark writes: > That's not much good if my XML document happens to start with: > > > > To quote from the O'Reilly book, "XML In A Nutshell" p71: "An XML > parser is required to handle the UTF-16 and UTF-8 encodings or > Unicode." And I expect similar is stated in the XML DOM spec if I had > time to look for it. This is getting interesting. Suppose you have a unicode string u'' How do you want your XML processor to process that? In particular, what do you think it is supposed to do with the encoding declaration? As for the XML spec, it merely says # All XML processors must accept the UTF-8 and UTF-16 encodings of # 10646; the mechanisms for signaling which of the two is in use, or # for bringing other encodings into play, are discussed later... So there is no mentioning of "or Unicode", or equivalent. The DOM specification does not recognize the existance of XML parsers (atleast not in DOM level 2 or earlier); so it doesn't say anything on the subject. Regards, Martin From skip at pobox.com Thu Nov 15 05:32:01 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 15 Nov 2001 11:32:01 +0100 Subject: PEP 276 Simple Iterator for ints In-Reply-To: References: Message-ID: <15347.39329.36697.773593@beluga.mojam.com> Jim> Getting back to the motivating example of PEP 276 -- as stated in Jim> the PEP, adding an iterator to types.IntType would allow one to Jim> write: Jim> for rowcount in table.getRowCount(): Jim> Summarizing some of the other possibilities, one might write: ... Jim> for rowcount in range(table.getRowCount()): Jim> for rowcount in xrange(table.getRowCount()): No need to even mention these two dinosaurs... ;-) Jim> for rowcount in [0 .. table.getRowCount()-1]: I think I would still write the above as for rowcount in [0, step, ... table.getRowCount()]: That would get you the sequence 0, 1*step, 2*step, ... (table.getRowCount()-1)*step and is more flexible than your proposal. There's no reason you couldn't have for f in [0.0, 1.0, ... sys.maxint]: to enumerate floats up to but not including sys.maxint (care needs to be taken to not to compound errors). You could also build character sequences I think: for c in ["a", "b", ... "z"]: which would use ord() and chr() internally. (You could probably extend to multi-character strings, but that would raise locale and string vs. unicode issues.) From lsmithso at NOhare.SPAM.demon.co.uk Wed Nov 21 17:33:04 2001 From: lsmithso at NOhare.SPAM.demon.co.uk (Les Smithson) Date: 21 Nov 2001 22:33:04 +0000 Subject: Tkinter without the window Message-ID: <6hu1vn92lb.fsf@hare.demon.co.uk> I have a working Tkinter application that uses a canvas to draw graphics in an X window. Is it possible for Tkinter to draw the same graphics straight to a PNG/JPG/whatever file without going through a windowing system? I have in mind using this application for an External script in a Zope server. This would be called to generate a img tag on the fly. I want to do this in the server, rather then in the browser. Any ideas how I can generate PNG/JPG directly from Python, other than Tkinter? From phr-n2001d at nightsong.com Sun Nov 11 12:27:56 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 11 Nov 2001 09:27:56 -0800 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> Message-ID: <7x8zddnroj.fsf@ruckus.brouhaha.com> Erno Kuusela writes: > | Basically if you unpickle a string that came from an untrusted source > | (say, a browser cookie from the Cookie module), the string can make > | pickle load arbitrary modules and call arbitrary object constructors > | in your application. The docs for the cookie module mention this and > | there's an bug open on sourceforge to fix the pickle docs. > > oh, that. but it is a deliberate design choice. if you want to take > python to task for these sorts of features, eval() or input() are much > "worse". or even marshal. i agree the pickle documentation should > mention this as the first thing in big friendly letters. In fact it does the opposite--both the documentation and the pickle implementation (look at the "security" check for pickled strings) appear written with the idea that unickling is intended to be safe for untrusted strings. If you look at docs for the Cookie module, you see that it originally used pickle in precisely this dangerous way. If that got past the maintainers who allowed the Cookie module to be shipped with the Python library, what chance do most ordinary users have? Re marhsal: is it dangerous to unmarshal an untrusted string? Yes, I know that marshalled strings can contain code objects, but unmarshalling the strings doesn't actually RUN such code objects, as far as I know. I haven't examined marshal super-carefully though. I think that input() evalling the stuff it reads is also a poor design choice, but at least it's documented. From lrl at ou.edu Fri Nov 23 02:00:26 2001 From: lrl at ou.edu (L) Date: 22 Nov 2001 23:00:26 -0800 Subject: python on handhelds References: <9tjsvr$90i$2@moonstone.imsb.nrc.ca> Message-ID: I haven't found pippy particularly useful yet. It is more of a toy at the moment IMO. Java support for palm is there, and better than python support, but still sketchy. You would probably want to use waba for java on the palm. Really, neither of these are desirable for use on the palm... Anything not written in C is probably going to be pretty sluggish. Luke From tdickenson at devmail.geminidataloggers.co.uk Mon Nov 12 07:29:21 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Mon, 12 Nov 2001 12:29:21 +0000 Subject: iters on ints? (reducing the need for range/xrange) References: <7xzo5v34pt.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin wrote: >"Tim Peters" writes: >> > for i in 10: >> > doSomething(i) >> >... >> This isn't even half as disgusting as most people will say it is . I >> rather like it! Write a PEP. > >The trouble is as someone else noted, "for i in 10" replaces "for i in >range(10)". But how do you handle range(1,10)? "for i in 1,10" does >precisely the wrong thing. for i in 10-1: ;-) Toby Dickenson tdickenson at geminidataloggers.com From tuttledon at hotmail.com Sun Nov 11 22:32:22 2001 From: tuttledon at hotmail.com (Don Tuttle) Date: Mon, 12 Nov 2001 03:32:22 GMT Subject: Tim Peters on speed! References: Message-ID: As always Tim, thanks for your help. Don From bvu01 at sprintspectrum.com Tue Nov 20 13:56:38 2001 From: bvu01 at sprintspectrum.com (Vu, Bao) Date: Tue, 20 Nov 2001 12:56:38 -0600 Subject: (no subject) Message-ID: <858C10943BCED511A6C40000D1ECDB1033BEEE@pkcexv006.sprintspectrum.com> From mwh at python.net Thu Nov 8 07:12:48 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 8 Nov 2001 12:12:48 GMT Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> Message-ID: Carsten Gaebler writes: > Hi there, > > is this the way complex() is supposed to work? I doubt it. > Python 2.2b1 (#2, Oct 22 2001, 10:47:30) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> complex('1', '1') > (1+0j) > >>> > > If complex() allows stings as arguments (like float()), what's > happened to the imaginary part? According to the docs, this is in error: ,--http://python.sourceforge.net/devel-docs/lib/built-in-funcs.html--- | complex(real[, imag]) | Create a complex number with the value real + imag*j or convert a | string or number to a complex number. Each argument may be any | numeric type (including complex). If imag is omitted, it defaults | to zero and the function serves as a numeric conversion function | like int(), long() and float(); in this case it also accepts a | string argument which should be a valid complex number. `--------------------------------------------------------------------- I read that to mean that if the first arg is a string, it should be the only arg. The code simply ignores imag if real is a string. Do you want to open a bug, or shall I? Cheers, M. -- > Look I don't know. Thankyou everyone for arguing me round in > circles. No need for thanks, ma'am; that's what we're here for. -- LNR & Michael M Mason, cam.misc From martin at tactilis.co.uk Tue Nov 13 17:58:00 2001 From: martin at tactilis.co.uk (Martin Armstrong) Date: Tue, 13 Nov 2001 22:58:00 +0000 Subject: Signed (and now seen) References: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> Message-ID: In article , Steve Holden writes >"Martin Armstrong" wrote in message >news:PhgUoNIqkE87Ew2Z at tactilis.demon.co.uk... >> In article , J?rgen A. >> Erhard writes >> >> >> It doesn't matter what you wrote. >> >> What matters is: >> >> Content-Type: multipart/signed; >> boundary="pgp-sign-Multipart_Sat_Nov_10_23:43:08_2001-1"; >micalg=pgp-sha1; >> protocol="application/pgp-signature" >> ^ ^ >> ^ ^ >> Colons are no longer broken :) -----------^--^ >Sadly, my wonderful Microsoft mail reader Steve, stop right there! Reflect on the error of your ways ;-) >still insists on showing the >message as empty, with a 448-byte text attachment and a 286-byte .dat >attachment. Well, that's obviously the optimum way to display a PGP signed message. Well done Microsoft. >Of course, it must a be problem with the posting, because >there's no chance Microsoft could wrong-headedly ignore well-established >Internet standards this way ;-) Perhaps you should have a word with J?rgen. Ask him to change his User Agent. It is must be broken beyond repair :) It must be pure co-incidence that my UA can now display J?rgen's signed messages perfectly. Nothing to do with: X-Mailman-Version: 2.0.7 (101270) > But I'm glad the mail gateway is fixed. Yes, thanks Barry W. -- Martin Armstrong From kalipygian at hotmail.com Thu Nov 22 06:00:04 2001 From: kalipygian at hotmail.com (Kali Kim) Date: 22 Nov 2001 03:00:04 -0800 Subject: Getting the class of a method in Python 2.2 (semantic change from 2.1) References: Message-ID: <64a28082.0111220300.23c665cf@posting.google.com> Martin von Loewis wrote in message news:... > "Kali Kim" writes: > > > Can anyone help me? > > I think this is not possible in 2.2. Why do you need that? > > Regards, > Martin In order to analyze class relationships and informations, for example, in a class browser or a code analyzer. From jeff at ccvcorp.com Fri Nov 16 13:21:02 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 16 Nov 2001 10:21:02 -0800 Subject: initializing private members via exec References: <3BF40A4E.CC498C2D@bioeng.ucsd.edu> Message-ID: <3BF5590E.37753221@ccvcorp.com> Curtis Jensen wrote: > Why session below give me an error? Is there some rule against > initializing private data members inside an exec function? Is there an > equivalant way of initializing private members? Thanks. Not using exec? Obviously what you've shown is a trivial example, intended to demonstrate what you see as the problem. But more likely, the real problem is your decision to use exec. ;) Exec and eval() are very powerful, but most of the time that someone tries to use them, there's a simpler, safer, easier way to do the same thing. Try finding that way. (Maybe post the problem that you're trying to solve by using exec?) Jeff Shannon Technician/Programmer Credit International From loewis at informatik.hu-berlin.de Sat Nov 17 06:15:18 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Nov 2001 12:15:18 +0100 Subject: Unicode and string conversions References: <9t3ijd$1lr$1@netnews.upenn.edu> <3bf558cb$1@brateggebdc5.br-automation.co.at> <9t41u9$7g6$1@netnews.upenn.edu> Message-ID: zayats at blue.seas.upenn.edu (Salim Zayat) writes: > For example, let's say I have a string > > >>>s = '\u0162' > > to begin with. Where did you get this string from? Why does it have to use \u escapes to denote non-ASCII characters? Couldn't the string use encodings that other people use as well (like Latin-1, UTF-8, KOI-8R, etc)? > >>>us = unicode(s, 'utf-8') > or even > >>>us = unicode('\u0162', 'utf-8') > > I get back : > > >>>u'\\u0162' > > Which is unfortunately not the same thing. It is exactly the same - in UTF-8. Every character (below 128) stands for itself in UTF-8, so the backslash stands for a backslash, the u stands for an u, etc - just as it does in the Unicode string. > I am just a whole lot of confused. It looks like this. If you absolutely *have* to use \u be treated as an escape in a byte string, you can use the 'unicode-escape' encoding: >>> unicode('\u0162','unicode-escape') u'\u0162' HTH, Martin From sheershion at mailexpire.com Sat Nov 10 11:33:12 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Sat, 10 Nov 2001 16:33:12 -0000 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> <3BEC1A81.6D8766B@ccvcorp.com> Message-ID: Jeff Shannon wrote: > Robert Amesz wrote: > >> I wrote: >> > [something] >> >> Ignore previous post: I read 'raw_input' where it actually said >> 'input'. My mistake. > > Though actually, the use of input() is generally not a very good > idea, and it would be safer to use raw_input() and then convert > from strings if needed. In this case, it's not needed, and the > raw_input result would be better off being compared as a string. Which is probably why I made that mistake. The use of 'raw_input' is not that uncommon, but 'input'? I've never seen 'input' being used in a real program. It's not very useful anyway, as input("Expression: ") seems to do exactly the same as eval(raw_input("Expression: ")). And if I'd need a number, I would use float() or int() on whatever 'raw_input' returns, and probably protect it with a try-except block to boot. You can't go far wrong by never trusting user input. Robert Amesz From jason-dated-1007772335.65c4ac at mastaler.com Thu Nov 29 19:45:34 2001 From: jason-dated-1007772335.65c4ac at mastaler.com (Jason R. Mastaler) Date: Thu, 29 Nov 2001 17:45:34 -0700 Subject: problems with DBM nonuniformity Message-ID: I'm having some trouble with one of my applications due to how DBM implementations vary across UNIX platforms. This app will read a DBM file when it finds a line such as this in its "filter file": from-dbm ~/.tmda/lists/whitelist.db ok It uses the anydbm module to open "whitelist.db" and goes from there. This works fine. However, I'd like to support an automatic DBM regeneration feature that works like this: Given the above filter line, if the user turns on this feature, the application will look for a textfile in the same directory called "whitelist" and compare its timestamp to that of "whitelist.db". If "whitelist.db" either doesn't exist or the modification date of "whitelist" is more recent, "whitelist.db" will be regenerated using anydbm, and then read. The idea is similar to how ".pyc" file auto-generation works. Here is the problem. Depending on the platform, the "whitelist.db" DBM may be composed of one or more files of different names. On Linux, "whitelist.db" = whitelist.db when the default module is dbhash, so there is no problem: % python -c "import anydbm;wl = anydbm.open('whitelist.db','c')" % ls -l whitelist* -rw------- 1 jasonrm acl 16384 Nov 29 17:15 whitelist.db However on Solaris for example (default module of dbm): % python -c "import anydbm;wl = anydbm.open('whitelist.db','c')" % ls -l whitelist* -rw------- 1 jason users 0 Nov 29 19:13 whitelist.db.dir -rw------- 1 jason users 0 Nov 29 19:13 whitelist.db.pag Under Linux, the dbm module acts differently, adding a '.db' suffix to the given filename: % python -c "import dbm;wl = dbm.open('whitelist.db','c')" % ls -l whitelist* -rw------- 1 jasonrm acl 16384 Nov 29 17:21 whitelist.db.db So, I can't rely on comparing "whitelist" with "whitelist.db" filename to filename since the latter might not exist. There are probably even more discrepancies that I haven't found, but I hope you can see my dilemma. There is no uniformity in file naming when using anydbm, or when using the same DBM module across different platforms. Does anyone have some suggestions on how I might support this feature in a cross-platform, and generic fashion? Thanks. -- (TMDA - http://tmda.sourceforge.net) (Python-based SPAM reduction system) From bokr at accessone.com Mon Nov 26 16:20:19 2001 From: bokr at accessone.com (Bengt Richter) Date: Mon, 26 Nov 2001 21:20:19 GMT Subject: postgresql triggers to update GUI? References: <20011126.145234.816620091.2222@localhost.localdomain> Message-ID: <3c02b086.304990102@wa.news.verio.net> On Mon, 26 Nov 2001 15:28:26 -0500, "Steve Holden" wrote: >"Robert Nikander" wrote ... >> Hi, >> >> I am writing a python program that uses a postgresql db backend. I would >> like to update the gui whenever a change in certain tables occurs, so it >> would be nice to use triggers rather than generating the 'events' when I >> update the db. That way I get cascading changes. Does anyone know of a >> python module that supports postresql triggers? ie: you can create a >> trigger that calls a python function? Is there another solution here >> that I am missing? >> >The purpose of a trigeer is to maintain the database's semantic integrity by >running stored procedures whenever particular changes take place. Because >triggers are specifically stored procedures, they run within the database >engine rather than inside a database client process. It therefore wouldn't >seem like a suitable mechanism for triggering updates of a GUI. Sorry... > Seems like someone must have invented a trigger process with a side effect of sending a message to a subscriber list, so that a GUI could have a thread that has subscribed and is listening for a message. The message wouldn't have to contain the data. That could be aquired by new DB query. From export at bmatrading.com Sat Nov 10 14:32:27 2001 From: export at bmatrading.com (A) Date: Sat, 10 Nov 2001 20:32:27 +0100 Subject: The Best solution? Message-ID: <3BED8EDB.24818.1F8E1C@localhost> Hello, I need from my program send an email and I would like to send it in a different thread or process. Can you please give me an example how I can start a new thread or process Under Win32 systems? Is it better to use a new thread or a new process? Thank you for help. Ladislav From pythonlist at zumnet.com.br Wed Nov 28 05:50:07 2001 From: pythonlist at zumnet.com.br (Rafael Mentz Aquino) Date: Wed, 28 Nov 2001 08:50:07 -0200 Subject: Database in a simple ascii file Message-ID: <3C04C15F.7E595F6C@zumnet.com.br> Hi, How many lines can I have in a simple ascii file before I start to loose performance when I open this file and put all the lines in a dict, turning the first column into the key and the rest of the line into a list associated to that key. (my file has just 100 lines, but that question starts to bother me ;-) Thanks! Rafael Mentz Aquino From SNeelakantan_C at zaplet.com Thu Nov 1 20:23:47 2001 From: SNeelakantan_C at zaplet.com (Shankar) Date: 1 Nov 2001 17:23:47 -0800 Subject: How to pass objects to a function? Message-ID: <4a0341c8.0111011723.53246ecd@posting.google.com> I am a python newbie. How do I pass a user defined object to a function? if I have something like def func(session, url): ... .... and session is supposed to be an object of httpsession class, how would the interpreter know about it? I suppose all arguments are treated as strings. so, if I invoke a method such as session.getreply() or something I would get an error. The httpsession class is expected to have derived classes too. (that should not matter to the problem in hand anyway). Also, if anybody has used the httplib.py module, can someone tell me how to do a request.redirect() if the replycode is 302. Kindly let me know ASAP. Thanks, Shanker From nhodgson at bigpond.net.au Wed Nov 7 17:37:40 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Wed, 07 Nov 2001 22:37:40 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: David Andreas Alderud: > I love Python, I advocate it a lot, but I believe that Ada95 > is the prime language for beginners. I was an Ada83 programmer (on a non-military project) and I don't think its a good language for beginners. Ada is too large to be fully understood within a reasonable time. Type based overloading is very complex to understand and predict. The task feature was particularly troublesome as it did not map onto other well established multi-tasking models. Ada95 looks even more complex with one core language and 10 optional annexes. Ada's strict typing goes too far adding much noise to basic operations if used to define all variables with appropriate constraints. Eventually programmers give up on this and start using the simple basic types instead. Use appears to have contracted to just military projects here, most commercial users dropping it for C/C++ to increase productivity. Neil From mikael at isy.liu.se Fri Nov 2 04:14:58 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 02 Nov 2001 10:14:58 +0100 (MET) Subject: Monty Python (was: Freeware Python editor) In-Reply-To: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> Message-ID: On 02-Nov-2001 Anthony Baxter wrote: > obofftopic: I seem to recall that when Life of Brian was banned in Norway, > it was advertised in Sweden with "This Film Is So Funny It Is Banned In > Norway". That's exactly what my memory tells me. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 02-Nov-2001 Time: 10:12:58 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From BPettersen at NAREX.com Thu Nov 15 16:47:32 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 15 Nov 2001 14:47:32 -0700 Subject: PEP 276 Simple Iterator for ints Message-ID: <60FB8BB7F0EFC7409B75EEEC13E2019221510F@admin56.narex.com> > From: Ken Seehof [mailto:kseehof at neuralintegrator.com] > > > Ken Seehof wrote: > > >Hey, what ever happened to the int[:10] iterator idea? > > > > > >>>> for i in int[2:10:2]: print i, > > >2 4 6 8 > > > > Nothing actually *happened* to it. ;-) > > > > It needs a PEP (or needs to be added to an existing PEP). [...] > 1. Integer slicing is better than iter(n), and accomplishes > the same objectives. 2. Integer slicing is just a different > spelling for xrange. So don't bother. 3. Therefore, might as > well just reject 276. 4. But wait, xrange and range are > really ugly in for loops. 5. So let's do integer slicing after all. Jim has been good enough to write up a PEP for his proposal, so if you have a counter proposal I suggest you do the same. Personally, I don't like the slice idea because the common usage would be: for i in int[:len(sequence)]: ... Which is hardly more readable than: for i in range(len(sequence)): ... Vs. the proposed: for i in len(sequence): ... +1 for PEP 276 from me. -- bjorn From stephen at stephencox.org Sun Nov 25 11:54:05 2001 From: stephen at stephencox.org (stephen cox) Date: Sun, 25 Nov 2001 16:54:05 GMT Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: > I see "a few socially conscious businesses" should use software from THE > socially conscious business of the World ;) Except for the webserver, they do. MySQL as the backend database, ASP and PHP are the scripting langs. I'm learning Python so I can use ZOPE more. True, I think .NET is cool - but I'll only use it if MS keeps it promise and ports it too Linux and such. -- Stephen Cox web.net geek for non-profits, political campaigns, and a few socially conscious businesses. stephen at stephencox.org From db3l at fitlinxx.com Tue Nov 13 13:16:39 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Nov 2001 13:16:39 -0500 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <97ae44ee.0111121735.ebbca1@posting.google.com> <_l9I7.9705$vQ1.375666@atlpnn01.usenetserver.com> Message-ID: "Steve Holden" writes: > While the above steps are useful in datagram-based application protocols > they should not be required over, say, TCP, when if communications take > place at all they will be error-free. Not quite true. TCP has a checksum, but it can be fooled by certain types of single bit errors occuring multiple times. No, it's not a high likelihood of corruption, but it's not guaranteed error free either. In a prior life, one of our backbone links exhibited just that sort of corruption and could be hell on TCP sessions. It isn't common, and for most uses there's no need to layer on additional verification, but for anyone needing true verification, adding your own CRC or data validation meta-data is advised, regardless of the underlying protocols. > But stream-based datagrame protocols > are tricky, and inevitably result in the re-implementation of some (or all!) > of TCP's complexity at the application level, as you describe above. That > was why the web accepted the overhead of a TCP connection per interaction > for HTTP 0.9, and then went on to design keep-alive workarounds in later > versions as an optimization. Of course, that's why when HTTP first started to see its use ramp up, most backbones absolutely _hated_ it. (probably still do for non-HTTP 1.1 connections) Here we had spent years tuning TCP slow start and congestion avoidance, all of which work best over an established stream that has some "history" of behavior, and HTTP came along and kept making and breaking short lived TCP sessions, giving the protocol no real time to tune or to avoid overloading things. In particular, many TCP streams over large pipes will settle on a very equitable sharing of the bandwidth - but not if they are all being created/destroyed constantly. Adding persistent connections back into HTTP 1.1 was a _major_ improvement over the earlier versions. The same problem is exhibited by various game protocols that are datagram oriented with their own higher level control mechanisms, most of which didn't play nice with other users of the stream. -- -- 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 jahs at jahs.org Tue Nov 27 20:10:42 2001 From: jahs at jahs.org (James A. H. Skillen) Date: Wed, 28 Nov 2001 01:10:42 +0000 Subject: function operators References: Message-ID: On Tue, 27 Nov 2001 01:43:34 +0000, James A. H. Skillen wrote: Thanks for the feedback from everyone. Perhaps I should have made it clear: yes, I realise that my suggestions can be done quite easily using classes and the magic methods. But any simplicity gained would be offset by the added hassle of wrapping the functions with instances. I was just suggesting that __add__ etc. should be implemented for the built-in "function" type. I can't see that it would make Python code that much harder to read, indeed it would simplify things in many cases. There would be no ambiguity with classes that define both __call__ and __add__, as f = a + b would *always* mean f = a.__add__(b). It would be up to the author whether to define __add__ to be equivalent to: f = lambda x: a(x) + b(x). -- James A. H. Skillen - jahs at jahs.org 4th year MMath Mathematics undergraduate, University of Warwick, UK. From gherman at darwin.in-berlin.de Thu Nov 29 03:47:49 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 29 Nov 2001 09:47:49 +0100 Subject: *args and **opts oddities (?) Message-ID: <3C05F634.6EAB5E1@darwin.in-berlin.de> Hi, I'm trying to transform *args and **opts parameters and pretend they were passed in some transformed way. What I find is an un- expected phenomenon that makes me use indices in the code below (in function transform1) to get the behaviour I want. Is there any good explanation for this? Thanks, Dinu # unexpected result: lines (1) and (2) are not equal def transform0(*args, **opts): print 't', args, opts return args, opts def call0(*args, **opts): print args, opts # (1) args, opts = transform0(args, opts) print args, opts # (2) # result as expected, but in an unexpected way def transform1(*args, **opts): print 't', args, opts return args[0], args[1] # ??? def call1(*args, **opts): print args, opts # (1) args, opts = transform1(args, opts) print args, opts # (2) ## >>> call0('foo', 'bar', foobar=0) ## ('foo', 'bar') {'foobar': 0} ## t (('foo', 'bar'), {'foobar': 0}) {} ## (('foo', 'bar'), {'foobar': 0}) {} ## >>> ## >>> call1('foo', 'bar', foobar=0) ## ('foo', 'bar') {'foobar': 0} ## t (('foo', 'bar'), {'foobar': 0}) {} ## ('foo', 'bar') {'foobar': 0} ## >>> From max at alcyone.com Sun Nov 25 14:14:49 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 25 Nov 2001 11:14:49 -0800 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> Message-ID: <3C014329.7B828AE8@alcyone.com> Fred Flintsone wrote: > Hi. I went to the Python.org page to pick up a copy of Python, and > was faced with a choice of which version I want to d/l. As a rank > beginner, does it matter? I'll be working on a Windows ME machine. In most cases when looking at fiddling with software for the first time, you want the latest stable release. Often software is maintained in two branches: a stable release and a development release. For Python the latest stable release is 2.1.1. > Between the O'Reilly book I just bought, and all those great looking > tutorials, I'm anxious to dig in. The tutorials on python.org are very good, but which O'Reilly book did you get? I have _Programming Python_ and don't think too highly of it. The other, _Learning Python_, is by comparison much better. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From export at bmatrading.com Mon Nov 5 16:59:16 2001 From: export at bmatrading.com (A) Date: Mon, 5 Nov 2001 22:59:16 +0100 Subject: How to ? Message-ID: <3BE719C4.26077.693A1B@localhost> Hi, I have a program that uses( reads) some data from a text file. How can I prevent users from seeing the content of this text file? Thank you for reply. Ladislav From syver-en at online.no Fri Nov 23 12:39:38 2001 From: syver-en at online.no (Syver Enstad) Date: 23 Nov 2001 18:39:38 +0100 Subject: (off-topic humor) While browsing google for python and turtle Message-ID: (I was intersted in turtle graphics for python) >From http://www.geocities.com/~chicagoturtle/tips.html: Elmer says, Attach the Python valve to your faucet, connect the plastic hose from the valve to your turtle tank. In the down position with the water faucet turned on, the Python generates a powerful suction which quickly drains the tank's water (and "vacuum" cleans any debris) into your sink's drain. By pushing the Python valve in the up position, water will flow from the faucet quickly filling the tank with clean water. Please be sure to adjust the water temperature to the proper temperature for your turtle before filling the tanks. With the Python, one can easily drain and refill over 150 gallons in less than an hour without lugging a bucket or sucking on a hose. *The Python siphon system with hose and connectors is available at most larger pet stores, $35 -$50 depending on hose length.* - Tip submitted by Dennis & Diane K. from the unpublished memoirs of Elmer, The Oldest Woolworth's Turtle. -- Vennlig hilsen Syver Enstad From bedge at troikanetworks.com Tue Nov 20 14:56:36 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 11:56:36 -0800 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> <3BFAAD1E.9E9AF618@alcyone.com> Message-ID: In <3BFAAD1E.9E9AF618 at alcyone.com>, Erik Max Francis wrote: > Bruce Edge wrote: > >> OK, that works for this case, I was looking for something more generic. > > There is no scanf-like parsing service in Python. Which is fine, since > scanf has problems. If you want general parsing, you should use regular > expressions; that's what they're there for. > > Yeah, I know that scanf is not an ideal tool, but in this case, I only have the format string and the data. A regexp str is an additional data item that I have to put in my class. Additionally, after parsing with re, I still need to convert to integers, which is a PITA when you consider the "%x" case. The format string "knows" that this is in hex, using re, I get back say a string which I still need to dtermine the number base and convert. I'm not arguing :) It's just that in this one tiny case, scanf would have been the perfect tool. -Bruce. From darnold02 at sprynet.com Sun Nov 18 21:31:54 2001 From: darnold02 at sprynet.com (Don Arnold) Date: Mon, 19 Nov 2001 02:31:54 GMT Subject: Tkinter and IDE's Message-ID: <9t9qsb$4nd$1@slb3.atl.mindspring.net> I'm new to python and am interested in developing apps with Tkinter. However, every IDE I've come across for the Win32 platform experiences lockups/aborts when running Tkinter code. So far I've tried IDLE, PythonWin, and WING with little luck. Does anyone know of an IDE that successfully executes Tkinter code? Thanks, Don Arnold From john at ecsc.co.uk Sat Nov 10 20:48:09 2001 From: john at ecsc.co.uk (John Leach) Date: 11 Nov 2001 01:48:09 +0000 Subject: Newbie: Using MySQL In-Reply-To: <200111110120.fAB1KCc02633@localhost.localdomain> References: <200111110056.fAB0u0V02578@localhost.localdomain> <1005440920.1023.2.camel@murdock> <200111110120.fAB1KCc02633@localhost.localdomain> Message-ID: <1005443289.3082.0.camel@murdock> On Sun, 2001-11-11 at 01:20, Jordan Elver wrote: > Hi, > I'm getting the following even though I know the password and username are > correct as I use them in all my PHP scripts. > > _mysql_exceptions.OperationalError: (1045, "Access denied for user: > 'root at localhost.localdomain' (Using password: YES)") > > Any ideas? > This sounds more of a mysql server config problem. If the php scripts run on the same server as the mysql daemon does, then it may not (and by default probably won't) actually be using tcp/ip to connect, it will be using a unix socket. I'm not so sure if the same applied to the mysqldb module (and I'm too tired to check :). Check your host based permissions on the mysql server. Make sure the user you are connecting as is able to connect from the host you are running the python script on. As a test you could try adding the host "%" on the mysql permissions as this will allow any host to connect, but this is bad practice, make sure to put it back after testing. John. goodnight :) -- ======================================================================== This email is intended solely for the addressee. When addressed to our clients any opinions or advice contained are subject to the terms and conditions expressed in the governing ECSC Conditions of Service. From mlh at idi.ntnu.no Wed Nov 14 17:12:41 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Wed, 14 Nov 2001 23:12:41 +0100 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <9suq8q$53g$1@tyfon.itea.ntnu.no> "Lulu of the Lotus-Eaters" wrote in message news:mailman.1005708499.16461.python-list at python.org... > David Eppstein wrote: > > for i in [n-1, n-2, ... 0]: > > for j in [i+1, i+2, ... n]: > > ...do something... > > James_Althoff at i2.com wrote: > |Thanks for your interesting example. I agree that your notation "[n-1, > |n-2, ... 0]" is a very nice way of showing a sequence of integers. I'm not > |sure how one would turn this into programming language syntax that would be > |as clear. > > Well... here's how Haskell does it: > > [1 .. 4] --> [1,2,3,4] > [4,3 .. 0] --> [4,3,2,1,0] > [2,4 .. 10] --> [2,4,6,8,10] > [0.0,0.3 .. 1.0] --> [0.0,0.3,0.6,0.9] > > It's hard to think of a better syntax for Python to use. IMO it's really a pity that we don't have this sort of thing in Python, including possibly a version without the brackets (for iterators, perhaps? Or I guess tuples would be more natural, although less suited for for loops): for i in 1 .. 10: print i or for i in 0, 2 .. 20: print i But I guess getting this in as part of the language isn't very realistic. -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From amitp at Xenon.Stanford.EDU Sat Nov 3 11:37:07 2001 From: amitp at Xenon.Stanford.EDU (Amit Patel) Date: 3 Nov 2001 16:37:07 GMT Subject: Q: Feature Wish: "%" Extension References: <3BE34077.8EA553CB@spam.net> Message-ID: <9s16fj$l7i$1@usenet.Stanford.EDU> anonymous wrote: | | PS: I'm still dumbfounded why Python's division operator must behave | differently than that in php, js, java, perl, awk, and C/C++ -- colleges | do not teach BASIC anymore -- as I worry about all of my hardware | interface code and auto-comment-wrapping editor :-) Doing the right thing is more important than doing whatever your friends do. ;) - Amit -- -- Amit J Patel, Computer Science Department, Stanford University http://www-cs-students.stanford.edu/~amitp/ From niemeyer at conectiva.com Thu Nov 1 18:28:16 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Thu, 1 Nov 2001 21:28:16 -0200 Subject: List transpose method In-Reply-To: <20011101225947.A7619@lilith.hqd-internal>; from gh_pythonlist@gmx.de on Thu, Nov 01, 2001 at 10:59:48PM +0100 References: <20011101205127.A4219@ibook.distro.conectiva> <20011101224504.C7406@lilith.hqd-internal> <20011101225947.A7619@lilith.hqd-internal> Message-ID: <20011101212816.A4654@ibook.distro.conectiva> > > Hmm. How would I apply zip if I have a variable already, like > ^^^^^ > With apply, stupid! > > > l = ((1,2),(3,4),(5,6)) > > apply(zip, l) ;-) You may also use the new zip(*l) syntax. Best regards! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From frederic.giacometti at arakne.com Wed Nov 14 10:22:26 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Wed, 14 Nov 2001 15:22:26 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> <9srknr$qe8$1@nntp6.u.washington.edu> Message-ID: > But while it requires OS thread support, it collides with support of > OS threads, doesn't it? For example, the threaded applications I write > use one thread per window, threads created by Window.Show(). Those > threads call back into the interpreter on window events, and the > interpreted code calls right back into the C level graphics library; > that library is built around this multi-threaded system and the calling > thread isn't something to select arbitrarily from a pool, it has to be > the thread that supports the Window object that noticed the event. The continuation in the Python interpreter has to keep a pointer to the C thread to which it is to return. Here, we would be in the case of non-rentrant threads (thread with a state memory, as opposed to stateless thread, to use the analogy with server processes/threads). The sending C thread would not be assigned another thread/continuation of control, and would remain idle. Thus, it could execute the callbacks from its Python continuation. FG From tdelaney at avaya.com Wed Nov 21 18:19:24 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Thu, 22 Nov 2001 10:19:24 +1100 Subject: Non-Indented python Message-ID: > From: Jeff Shannon [mailto:jeff at ccvcorp.com] > Dave Cinege wrote: > > > Rule of God: > > The punishment for non-tab based indentation is death. > > This is exactly backwards. > > Tabs are wrong, because different editors will treat them differently. > > Spaces are right, because a space is a space is a space, > everywhere you go. There are actually two things involved here. If you use tabs everywhere for indentation (i.e. tab *characters*, not tab *stops*) you are guaranteed that you can cut and paste from any other source code that uses tabs everywhere, even if it doesn't look right onscreen (because they used a different tab size). If you use spaces everywhere, you are at the mercy of other code that doesn't use the *same number* of spaces for indentation. For example, if you use four spaces for indentation, and you cut and paste code that uses two spaces per indentation, nothing will work. You will need to reformat one or the other before copying the code. And of course, any time you mix spaces and tabs for indentation you might as well forget it completely. The problem is simply that people use the tab key and character to mean different things. Originally the tab key was designed to do the same thing as on a typewriter - advance to the next tab stop (i.e. a certain number of spaces). Thus you end up with editors which distinguish between indentation and tab because a tab is too big for indentation. It would have been so much easier if it had originally been defined that the tab key always generated a tab *character*, and that the tab *character* had been defined as equivalent in size to four spaces (or 3 perhaps). This rule of course would be broken by applications which can set their own tab stops, but that's up to the application. The important thing is that there should *always* be a direct mapping between the tab key and the tab character. Tim Delaney From logiplexsoftware at earthlink.net Mon Nov 12 18:28:34 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 12 Nov 2001 15:28:34 -0800 Subject: Obfuscator for Python? In-Reply-To: References: Message-ID: <01111215283401.01958@logiplex1.logiplex.net> On Monday 12 November 2001 15:03, Amitabh wrote: > Hi, > > I wanted to know if there are any products which obfuscate the python > byte code so that it cant be reverse engineered easily? > Somehow, I doubt obfuscating the byte code would be a good idea... If you are really concerned about this, you could encrypt your modules and write a custom import routine. Obviously, you can't encrypt the encryption routine, so the only way to make it somewhat difficult would be to have the decryption routine either as a C module or modify the Python interpreter to use it. But really, none of these things will prevent a determined person from obtaining the byte-code (binaries can be reverse-engineered as well). BTW, this is what copyrights are for. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From mwh at python.net Wed Nov 28 12:22:13 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 28 Nov 2001 17:22:13 GMT Subject: Installing Python > 2.1: make fails in posixmodule.c References: <9u2g7u$5i5al$1@ID-113469.news.dfncis.de> <9u31it$60iuf$1@ID-113469.news.dfncis.de> Message-ID: Elmar H?fner writes: > Michael Hudson wrote: > > > Didn't look hard enough: > > > > > http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=440522 > > Oops, you're right. Although I spent quite a time searching, I oversaw it. > This link helped me, now it compiles. Do you mean to say the patch in the bug summary fixed the problem? That's very strange, seeing as that patch was applied before 2.1.1 was released. > > I'm pretty that fix went into 2.1.1 though. Which version are you > > compiling? 2.1.1 and current CVS don't have PRIO_PROCESS at line > > 1145. > > > > Try current CVS? Tell us which version you're compiling? > > I tried at first 2.1.1 [error in line 1102], 2.2a4 [line 1145], 2.0.1 > [which did compile, but gave me other problems] and at last > 2.2b2. None of the mentioned [exept 2.0.1] compiled without patching. > I didn't try CVS, though. I'm really confused now. Can you now do things that make 2.2b2 and 2.1.1 compile where they didn't beforehand? Can you submit relavent patches to sf? Cheers, M. -- For every complex problem, there is a solution that is simple, neat, and wrong. -- H. L. Mencken From db3l at fitlinxx.com Mon Nov 26 13:20:35 2001 From: db3l at fitlinxx.com (David Bolen) Date: 26 Nov 2001 13:20:35 -0500 Subject: Non-Indented python References: Message-ID: philh at comuno.freeserve.co.uk (phil hunt) writes: > On 22 Nov 2001 00:25:28 -0500, David Bolen wrote: > >Chris Liechti writes: > > > >> tabs are specified as 8 characters. only programmers that use tabs to > >> indent make them 4 or 3 characters... > > > >Well, you have to be a little careful how you phrase this. I'm not > >aware of any global document or specification that actually makes a > >pronouncement that tabs are 8 characters > > I am aware of one such document. It's called the "Python Reference > Manual": That only specifies how the Python parser treats tabs, not a global definition that covers more than Python. But as I noted later in my post, I do suggest that any visual display of hard tabs match what the parser is defined to use if only to avoid possible visual confusion. -- -- 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 bill-bell at bill-bell.hamilton.on.ca Wed Nov 28 07:39:03 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 28 Nov 2001 07:39:03 -0500 Subject: sys.prefix in COM In-Reply-To: <1006907305.735.14105.m11@yahoogroups.com> Message-ID: <3C049497.32625.260FE6B@localhost> David Bolen wrote, in part: > sag at hydrosphere.com (Sue Giller) writes, in part: > > I hate the registry - hassles abound. I would rather do anything > > else including hard coding the path and forcing other users to use > > my paths :) > > There's not much different from adding such a key to the registry > (just publish a .reg file for your users to use) and hardcoding a > path. Sue and David, I haven't been following this thread. However, I wonder what would make you use a .reg rather than just doing the registry manipulations in the Python? Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From peter at engcorp.com Tue Nov 27 22:32:26 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 27 Nov 2001 22:32:26 -0500 Subject: Two questions about Python.. References: <3BF99E55.2C300858@hotmail.com> <83r8qj6gi8.fsf@panacea.canonical.org> <124312AFE15AC2A7.3108D1F50CF59A6C.A4102B9233F78776@lp.airnews.net> Message-ID: <3C045ACA.C336DEFA@engcorp.com> Cameron Laird wrote: > > Kragen Sitaker wrote: > >Ville Vainio writes: > > > >> Ken writes: > >> > I'm looking into using Python for a project, and was wondering how does > >> > Python rank up against other scripting languages for speed? > > > >It's about as fast as Perl, much faster than Tcl or sh, and much > >slower than Lua, a good Scheme, FORTH, or GhostScript, in my > >experience. HTH. > > And it depends, of course, on the kind of project of interest. > Numeric makes Python a world-beater for many problems, for > example. Cameron, can you confirm that by this you mean that for intensively numeric-processing-bound programs, the Numeric package effectively makes Python a *higher* performance solution than most/all other solutions? Or were you talking more about features and ease-of-use, for example? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From tim at vegeta.ath.cx Tue Nov 27 20:18:48 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 28 Nov 2001 01:18:48 GMT Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: Ken Seehof graced us by uttering: [ snip ] > It has never been in MS's best interest to be compatible with the > rest of the computing world. More precisely, it's never been in Bill's pocketbook's best interest to be compatible with the rest of the world. It's _always_ been in MS's best interest to be compatible. There's more than enough money in the industry to support Microsoft and any other vendors. MS starts to lose market share. Then spends a lot of money convincing everyone they need _them_ and _only_them_, just to regain the market share they lost. This becomes a cycle which strongly resembles an addicts craving cycle. They spend more just to support their habit (of making more money), and over time their net profit approaches zero. If they became known as reliable, honest merchants in the industry, they lose a bit gross to begin with, but ultimately it would result in more net income. ;) "Of course, that's just my opinion. I could be wrong." (Dennis Miller) Tim Hammerquist -- Anyone who thinks that the act of programming is worth less than $50/hr should leave the industry. -- Randal L. Schwartz (clpm, 27 Jul 2000) From tundra at tundraware.com Sat Nov 24 14:10:06 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: Sat, 24 Nov 2001 19:10:06 GMT Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> Message-ID: <3BFFF06A.F7A3C69@tundraware.com> Tim Roberts wrote: > > "Brian Geddes" wrote: > > > >I've been trying to store/pass information in environment variables in > >Windows 2000, but things aren't working the way I expect them to. > > The short and rather unsatisfactory answer is that you just cannot do this > in a Win32 application. You cannot change an environment variable in a > Win32 program in a way that outlives the process (except for the registry > hack mentioned earlier, which affects ALL processes from that point > forward). You can affect the environment in your CHILD processes, but not > in your SIBLINGS. > -- > - Tim Roberts, timr at probo.com > Providenza & Boekelheide, Inc. I dunno why this is "unsatisfactory" - you cannot do this in Unix either - that is, you cannot modify an environment variable which persists to other login instances (and therefore, shell instances). The only way to get global environment settings is to change the appropriate shell global startup files. This is not a problem, but an intentional design point in both operating systems. You do not want a random user process to be able to fiddle with the runtime environments of other users. This is intentionally possible only by an act of system administration... It is a bit unclear exactly what the original poster was trying to accomplish, but both pipes and files are probably a more appropriate IPC mechanism for asynchronously invoked processes than environment variables, at least if those processes need to be started by different users and across different login instances. -- ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From mkelly2002NOSPAM at earthlink.net Wed Nov 21 17:41:02 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Wed, 21 Nov 2001 22:41:02 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> <3BF3378B.8030205@altavista.com> Message-ID: On 21 Nov 2001 01:31:22 -0800, sandskyfly at hotmail.com (Sandy Norton) wrote: >Here are some doc comments from pindent.py (located in Python\Tools\Scripts): Thanks for the tip Sandy. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From sill at optonline.net Tue Nov 13 21:36:40 2001 From: sill at optonline.net (Andrei Kulakov) Date: Wed, 14 Nov 2001 02:36:40 GMT Subject: Python Vim Module - works References: Message-ID: On Tue, 13 Nov 2001 02:00:26 +0900, Jonathan Gardner wrote: > I got it all to work. Thanks to a contribution by Tomas Zellerin, and a few > more hacks, I think it all looks good. > > I need some help to make it professional. > > It's 2:00 AM here in Seoul, so I won't be getting any answers out for a few > hours... =) > If you can get it to compile (just edit the Makefile to make it point to > the right place...) try this with Vim 6.0: > > $ gvim --servername TEST > $ python >>>> import vim >>>> vim.list() > ['TEST'] >>>> vim.send('TEST', 'iHello World!') > > You should see the string "Hello World!" neatly typed into the newly opened > vim window!!! > > Sorry, X11 only right now... > > Jonathan > > [ Note: This was cross-posted to vim-dev and python-list so I can go to bed > sooner... ] > I'm sorry if this is a dumb question, but what's the purpose of this? -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From ws-news at gmx.at Mon Nov 19 13:33:50 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 19 Nov 2001 19:33:50 +0100 Subject: object identity and equivalence References: Message-ID: <3bf95152$1@brateggebdc5.br-automation.co.at> Hi, Object identity (is) defines if two things refer to the same instance of an object. Equality (==) only informs you that two things refer two instances with the same value. For your own classes, you can define how equality should be defined. E. g. >>> class Test: ... def __init__(self, data): ... self._data = data ... def __cmp__(self, other): ... return cmp(self._data, other._data) ... >>> x = Test(17) >>> y = Test(17) >>> z = Test(20) >>> x is y 0 >>> x == y 1 >>> x is z 0 >>> x == z 0 >>> x and y in the above example are not the same instance, so is yields 0. But they have the same value, so == yields 1. >>> y = x >>> x is y 1 After assigning x to y, both variables refer to the same instance of the class. Now is yields 1. >>> a = 7 >>> b = 7 >>> >>> c = 273 >>> d = 273 >>> >>> a is b 1 >>> a == b 1 >>> c is d 0 >>> c == d 1 >>> c = d >>> c is d 1 When testing the same thing with integer values, it seems strange why a is b and c is d do not yield the same value. Integers are objects in Python, and they are created on demand (e. g. when you assign a literal value). However, small literal values are not created, but a reference to a cached object is handed out. Therefore, a and b refer to the same (cached) object, whereas a new object has been created for c and d. Since you used small integer numbers, you were biten by this optimization of Python. As a conclusion, you should use == when you are interested if two variables refer to the same value. Use is if you need to know that two variables actually refer to the same instance. hth Werner "Sandy Norton" wrote in message news:b03e80d.0111190954.ce015b8 at posting.google.com... > I apologize if this is a stupid question that has been asked before. > (I feel kinda stupid asking it :-) but I've searched the FAQ to no > avail and google is not really responsive to the keywords in question. > But this question is pestering me... > > I am a bit confused about when it is correct to use object identity > "is" for comparisons and when I should use the equals '==' operator. > > I always seem to get the same results with both: > > >>> class Person: pass > ... > >>> p1 = Person() > >>> p2 = Person() > >>> p1 is p1 > 1 > >>> p1 == p1 > 1 > >>> p1 is p2 > 0 > >>> p1 == p2 > 0 > >>> 1.0 is 1.0 > 1 > >>> 1.0 == 1.0 > 1 > >>> 1 is 2 > 0 > >>> 1 == 2 > 0 > >>> (2+3) is 5 > 1 > >>> (2+3) == 5 > 1 > > I haven't personally come across cases where these two operators don't > produce the same results with the same operands. Of course I am not > assuming the semantic equivalence of the operators, as it makes sense > that comparing object identity is the not the same as comparing object > value. But could someone offer me an example that uses the same two > operands with 'is' and '==' and produces 'different' results. > > Aside: I'm assuming you can overload the '==' operator but not the > 'is' operator? Is this true? > > There! I've announced my ignorance to the world. Feel better already! > > Sandy From mikael at isy.liu.se Fri Nov 23 02:18:35 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Fri, 23 Nov 2001 08:18:35 +0100 (MET) Subject: PLEASE OH PLEASE UNSUBSCRIBE ME! In-Reply-To: <3BFD6028.E43777E5@nrc.ca> Message-ID: On 22-Nov-2001 Alain D?silets wrote: > NO, I can't unsubsrcribe through the web or mail interface because I don't > know my stupid password. It doesn't seem to be any of the ones I typically > use. Yes, you can. Go to http://mail.python.org/mailman/roster/python-list There is a link to that page from http://mail.python.org/mailman/listinfo/python-list Then click on your mail address in the list. Then click on "Email My Password To Me" Wait for "bing" in your inbox. HTH /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 23-Nov-2001 Time: 08:15:00 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From printers at sendme.cz Sat Nov 10 14:32:27 2001 From: printers at sendme.cz (A) Date: Sat, 10 Nov 2001 20:32:27 +0100 Subject: The Best solution? Message-ID: <3BED8EDB.16670.1F8E02@localhost> Hello, I need from my program send an email and I would like to send it in a different thread or process. Can you please give me an example how I can start a new thread or process Under Win32 systems? Is it better to use a new thread or a new process? Thank you for help. Ladislav From James_Althoff at i2.com Wed Nov 28 18:45:10 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 15:45:10 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: Jeff Shannon wrote: >Um, maybe I've missed something, but what does this have to do with iterators? >An iterator will never return results to a constant (thus, your "3 in 5" example >is still a syntax error). PEP 276 does not make an integer equivalent to the >list of natural numbers ending below it; it simply provides a way to *iterate* >over those numbers, in the context of a for-loop. "if x in 5" would still be an >invalid construct, even after "for x in 5" became legal. (Unless I'm *severely* >misunderstanding the intent...) You are right in saying that PEP 276 calls for adding an iterator. If types.IntType has an iterator then places in Python that are "iterator-based" just work automatically without need for any further changes. So, for example: for rowindex in table.rowcount: works because for-loops are (2.1 and after) iterator-based. No changes are necessary in for-loops for this to happen. And, if I'm not mistaken, if index not in len(mylist): also works because "in" is iterator-based (in 2.1 or 2.2). No changes are necessary to "if" statements for this to work (assuming again that "in" has become iterator-based). Jim From loewis at informatik.hu-berlin.de Mon Nov 26 13:26:27 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Nov 2001 19:26:27 +0100 Subject: bugs in `gc.get_referents()' References: Message-ID: Michael Hudson writes: > Wild, wild stab in the dark: try running gc.collect() first. That shouldn't matter. Certainly, gc.get_referrers may return referrers that the next collection would eliminate. However, if one such object is found, it is added to the list that will be returned from get_referrers, so it won't be collected as it is still referenced from the result list. Also, AFAICT, the only thing that could trigger a collection is the allocation of the result list. However, that happens before the generations are being traversed, so that could not cause problems, either. > I *doubt* threads are running during the call to gc.get_referrers. > Could be wrong. You are right. As every other C function, get_referrers holds the interpreter lock. > > Also some of those threads are using native code which might be > > failing to DECREF properly. > > If that's the case, then you've got problems all your own, no? That is my suspicion. get_referrers accesses every object that claims to be a container, without attempting a garbage collection. Some extension types may not expect that, but they would be broken already. > > whether the code has been changed since 2.2b2, > > Only the name changes, I think. Correct. > > if there is any sort of "starting point" for digging into it that > > they recommend, etc. > > $ less Modules/gcmodule.c > > I think. Investigating the objects that are incorrectly returned as referrers are a good starting point, also. Set a breakpoint on the tp_traverse of these types, and watch it being called. Find out why it returns non-zero. Regards, Martin From wurmy at earthlink.net Fri Nov 9 18:44:58 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Fri, 09 Nov 2001 23:44:58 GMT Subject: String Search. References: Message-ID: <3BEC6A7F.9343AEDE@earthlink.net> Adonis Vargas wrote: > i posted a thread before asking help on how to find a specific string within > a line of string, i unfortunately did not get too specific on what i was > asking for. how can i do a search within a string using wildcards? > i.e.: > (pseudocode) > if "*something*is*" in "something is written here": return true > > ive looked into the re module and have been to the how-to pages, but i cant > seem to understand it. I suppose that, for a simple case like this, you can (ab)use the fnmatch module: >>> import fnmatch >>> fnmatch.fnmatch('something is written here', '*something*is*') 1 >>> fnmatch.fnmatch('something was written here', '*something*is*') 0 >>> For more sophisticated stuff, you'll really need the re module, though (or something with similar power). HTH, --Hans Nowak From mwh at python.net Thu Nov 29 06:08:12 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 29 Nov 2001 11:08:12 GMT Subject: Installing Python > 2.1: make fails in posixmodule.c References: <9u2g7u$5i5al$1@ID-113469.news.dfncis.de> <9u31it$60iuf$1@ID-113469.news.dfncis.de> <9u547c$6bbof$1@ID-113469.news.dfncis.de> Message-ID: I hate unix sometimes. Elmar H?fner writes: > > Do you mean to say the patch in the bug summary fixed the problem? > > That's very strange, seeing as that patch was applied before 2.1.1 was > > released. > > Well, looking at the sources of 2.2a2 and 2.2b4, it doesn't seem so for me. Do you mean 2.2a4 and 2.2b2? Not that it makes much difference. > After I added the following lines mentioned in file > > http://sourceforge.net/tracker/download.php?group_id=5470&atid=105470&file_id=8323&aid=440522 > > [which I found on the page above] in Modules/posixmodule.c, it compiles > fine: > > [line 34 in 2.2a4] > #ifdef HAVE_GETPRIORITY > #ifndef PRIO_PROCESS > #include > #endif /* !PRIO_PROCESS */ > #endif /* HAVE_GETPRIORITY */ > [line 40 in 2.2a4] There are lines *very similar* to these at ~1200: #if defined(HAVE_BROKEN_NICE) && defined(HAVE_SYS_RESOURCE_H) #if defined(HAVE_GETPRIORITY) && !defined(PRIO_PROCESS) #include #endif #endif > Well, yes and no. I can't submit this patch to sf, because I got it from > there. :) It seems the fix that got checked in wasn't the fix that got submitted to sf, and didn't work for you. Can you *email* me (i.e. don't post them to the ng) your pyconfig.h and config.log files so I can have a poke? I suspect HAVE_SYS_RESOURCE_H isn't getting defined for some reason. Cheers, M. -- > I'm a little confused. That's because you're Australian! So all the blood flows to your head, away from the organ most normal guys think with. -- Mark Hammond & Tim Peters, comp.lang.python From jdadson at ix.netcom.com Sun Nov 4 21:07:15 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 02:07:15 GMT Subject: COM objects and Python References: <3BE3F6F5.1020605@libero.it> Message-ID: <3BE5F42D.39E78E2D@ix.netcom.com> Riccardo Trocca wrote: > > Hello, just a simple question. I've just started learning some COM and > Com under Python concepts. Why?????? From peterb at cortland.com Thu Nov 29 11:03:00 2001 From: peterb at cortland.com (Peter Bismuti) Date: Thu, 29 Nov 2001 08:03:00 -0800 Subject: which is best for a singleton, module or class? References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C045C07.BA7B3FE6@engcorp.com> <3C05AE56.E2261313@engcorp.com> Message-ID: <3c05b472$1@207.229.64.20> What is best for a singleton, making it a module or a class within a module? I guess the reason why having a class within a module undesirable is that it adds to the namespace of the object mymodule.mclass.property instead of mymodule.property, and so fourth. I know you can import it in a way to reduce the path length of the object, but still, it seems like a cleaner coding style to just use the module itself. Opinions? THanks. From morten at thingamy.net Tue Nov 20 13:06:50 2001 From: morten at thingamy.net (Morten W. Petersen) Date: Tue, 20 Nov 2001 19:06:50 +0100 Subject: Python execution speed In-Reply-To: <3BF9D791.BEA22D61@engcorp.com> References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> <3BF9D791.BEA22D61@engcorp.com> Message-ID: On Mon, 19 Nov 2001, Peter Hansen wrote: > Fernando P?rez wrote: > > > > > I'm curious, however, why you believe you need to optimize Python's > > > execution speed so much? Do you have some application which is not > > > performing adequately? The usual approach is simply to profile the > > > code and recode the "hot spot" in C. > > > > I can mention one: scientific computing. Python is becoming very popular in > > that field, and Numeric goes a long way. But sometimes it's not enough, and > > being saved from dropping down to C for anything but the truly ugliest would > > be a big blessing. And yes, in scientific computing, things are *never* fast > > enough. If you can improve the speed of a code even by a factor of 2 only, > > that can be big news. Waiting for 2 days is still better than waiting for 4 > > days for your simulation to finish. > > I understand these issues, but I really wanted to know why the *OP* > thought he needed more speed (which I inferred was the only serious > advantage he felt he'd found with LISP over Python). It's one of the advantages I see, if true. Another is macros (which I don't fully understand the scope of yet). There's an underlying question here though, and that is how fast is the Python community able to adapt and implement good ideas. One of Python's advantages is a consistent (simple) design, (not counting small quirks like 'def function(): return 1' and 'function = lambda: 1'. Consistent design says 'less complexity' in my ears, along the same lines of the simpleness (ease of maintenance, readability, portability) of a python application if it can always be coded in Python. Regards, Morten From michael at stroeder.com Fri Nov 16 13:47:53 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 16 Nov 2001 19:47:53 +0100 Subject: Does smtplib lookup MX records? References: Message-ID: <3BF55F59.F0713081@stroeder.com> Skip Montanaro wrote: > > Dale> If it is, what do I need to do to lookup the MX record myself? > > There are some DNS bits floating around. http://pydns.sf.net Check out from CVS. Ciao, Michael. From nikander at mindspring.com Wed Nov 14 12:45:59 2001 From: nikander at mindspring.com (Robert Nikander) Date: Wed, 14 Nov 2001 12:45:59 -0500 Subject: anonymous functions,classes? References: <3bf2a42f$1@207.229.64.20> Message-ID: <20011114.124558.1160541797.7548@localhost.localdomain> In article <3bf2a42f$1 at 207.229.64.20>, "Peter Bismuti" wrote: > Anonymous was the word I was looking for in my previous post. I want to > pass a function as an argument but don't want to have to define it > globally. The way I don't want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) > Someone already mentioned lambda expressions, which should work if your function is just a simple thing. If if you are creating alot of these little functions and they all follow a certain pattern, you might want to write a class and define it's __call__(self, ...) method. Then you could callFunction( CallableObject(args) ) Rob From peter at engcorp.com Thu Nov 15 00:32:22 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 15 Nov 2001 00:32:22 -0500 Subject: How program a particilar algorithm ? References: <9sua59$3lh$1@wanadoo.fr> <3BF2B900.862EC64F@earthlink.net> Message-ID: <3BF35366.DABDC0AA@engcorp.com> Hans Nowak wrote: > > Michel Bonnifait wrote: > > I want to generate all possible lists with elements from another one. [...] > This question has been asked on the ng before, so you might be able to > find other (better?) replies by doing a google search or so. And I think we can count on it being asked again. And again. In the future, students will receive marks based on how quickly they can extract answers to their homework from newsgroups or google. Extract points for pretending a colleague gave them code code to optimize, or for understanding the answers... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From max at alcyone.com Fri Nov 16 13:39:17 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 16 Nov 2001 10:39:17 -0800 Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> <3BF4288A.FC68121F@alcyone.com> Message-ID: <3BF55D55.FA240E62@alcyone.com> Duncan Booth wrote: > Your second point is correct, but the first one is wrong. You can have > a > lambda with no arguments if you wish. True. Following the original poster's code, I was thinking of a lambda function (with no arguments) and which evaluates to `pass', which is of course illegal. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From marcoxa at cs.nyu.edu Tue Nov 20 17:19:56 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 20 Nov 2001 17:19:56 -0500 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> <3BF9D791.BEA22D61@engcorp.com> Message-ID: "Morten W. Petersen" writes: > On Mon, 19 Nov 2001, Peter Hansen wrote: > ... > > I understand these issues, but I really wanted to know why the *OP* > > thought he needed more speed (which I inferred was the only serious=20 > > advantage he felt he'd found with LISP over Python). > > It's one of the advantages I see, if true. Another is macros (which I > don't fully understand the scope of yet). The power of macros in CL comes from what is known as "read/write" consistency. A paraphrase of this is "what you READ you can PRINT" and "what you PRINT you can READ" (with some precise exceptions). In some ways the 'pickle' modules do a similar thing, but not quite (the CL package SAVE-OBJECTS is the more or less equivalent of 'pickle'). So, in CL cl-prompt> (print 123) 123 <= what got printed 123 <= the value of the expression cl-prompt> (print (make-array '(2 2) :initial-contents '((#C(0 1) 0) (0 #C(0 1))))) #2A((#C(0 1) 0) (0 #C(0 1))) #2A((#C(0 1) 0) (0 #C(0 1))) cl-prompt> (read) #2A((#C(0 1) 0) (0 #C(0 1))) <= what I typed in #2A((#C(0 1) 0) (0 #C(0 1))) <= the value returned by 'read'. Of course this works for lists, which are also CL programs. cl-print> (print '(defun fact (n) (if (zerop n) 1 (* n (fact (1- n)))))) (defun fact (n) (if (zerop n) 1 (* n (fact (1- n))))) (defun fact (n) (if (zerop n) 1 (* n (fact (1- n))))) and `read' works in the same way (note the irrelevance of the formatting). cl-prompt> (read) (defun fact (n) (if (zerop n) 1 (* n (fact (1- n))))) (defun fact (n) (if (zerop n) 1 (* n (fact (1- n))))) This is a major CL point de resistance. Note that since programs are lists you can manipulate them in a very easy way. E.g. cl-prompt> (defvar vector-form (cons 'vector (list 1 2 3 4 5))) vector-form cl-prompt> vector-form (vector 1 2 3 4 5) Of course I can `eval' this. But that is beyond the point. I can sneak in this "list construction" operations ad read and at compile time by declaring a macro cl-prompt> (defmacro my-vector-constructor (&rest forms) (cons 'vector forms)) my-vector-constructor cl-prompt> (my-vector-constructor 1 2 3 4 (* 3 #C(2 4))) #(1 2 3 4 #C(6 12)) Voila`. 'my-vector-constructor' *looks* like regular code, but it is a macro. Of course the example is stupid. To appreciate a better example just look at CL `defclass' macro or (not for the faint of heart) CL `loop' macro (built on top of more basic - and uglier - loop constructs). Just for a taste... WARNING! UNREADABLE CODE AHEAD. cl-prompt> (macroexpand-1 '(loop for x across "zut" collect (char-code c))) (let ((c nil) (#:g3635 "zut") (#:g3636 0)) (declare (type fixnum #:g3636) (type (or (member nil) vector) #:g3635)) (ansi-loop::with-loop-list-collection-head (#:g3637 #:g3638) (block nil (ansi-loop::loop-body nil (nil (ansi-loop::loop-really-desetq c (aref #:g3635 #:g3636)) nil (ansi-loop::loop-really-desetq #:g3636 (1+ #:g3636))) ((ansi-loop::loop-collect-rplacd (#:g3637 #:g3638) (list (char-code c)))) ((when (>= #:g3636 3) (go ansi-loop::end-loop)) (ansi-loop::loop-really-desetq c (aref #:g3635 #:g3636)) nil (ansi-loop::loop-really-desetq #:g3636 (1+ #:g3636))) ((return-from nil (ansi-loop::loop-collect-answer #:g3637))))))) where things like `ansi-loop::with-loop-list-collection-head' and 'ansi-loop::loop-collect-rplacd' are yet other macros waiting to be expanded. Of course (admittedly with a small trick) I could take the result of the macro-expansion and execute it directly (which is what similar to what the compiler does). > There's an underlying question here though, and that is how fast is the > Python community able to adapt and implement good ideas. Like multiple dispatch on methods? To put it bluntly, CL is a much better suited language to "import" good ideas, since it is one of its main raisons d'etre. The joke "Lisp is like a ball of mud: it does not matter how much mud you throw at it, it still looks like a ball of mud" has a core of truth about the overall beauty of CL. The macro facility is at the core of such beauty: it attracts mud. > One of Python's advantages is a consistent (simple) design, (not counting > small quirks like 'def function(): return 1' and 'function =3D =20 > lambda: 1'. Consistent design says 'less complexity' in my ears, along > the same lines of the simpleness (ease of maintenance, readability, > portability) of a python application if it can always be coded in Python. Python has had the advantage of hindsight on many accounts. This is its main advantage. But the overall CL design and its ANSI standard (http://www.alu.org) are an amazing achievement of clarity, simplicity and depth. Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From loewis at informatik.hu-berlin.de Mon Nov 5 04:10:53 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Nov 2001 10:10:53 +0100 Subject: 2.1 nested scope SyntaxWarning References: Message-ID: "John J. Lee" writes: > However, the GracePlotter class works fine. Why? Could it be that grace_np is also imported globally (i.e. on the module level)? That would explain it. Regards, Martin From claird at neosoft.com Wed Nov 28 12:52:36 2001 From: claird at neosoft.com (Cameron Laird) Date: 28 Nov 2001 11:52:36 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 28) Message-ID: <4B532065AD3A12CE.AFAE47E7521FD011.F09D149D697D4629@lp.airnews.net> "Python tries to make difficult things easy while making easy things stay fairly easy." Paul Rubin "Basically, I just sit there and read e-mail." "... I think Python will be able to position itself as a sort of Visual Basic-like language in the embedded space ..." "... [W]hen I was dating my wife ... I had better things to do with my time [than figure out PalmOS development tools]." Guido van Rossum, Object persistence! Application service! Nanotechnology! Type information! Docstring tricks! Andrew Kuchling touches on all this, and more, in a too-little-known paper. http://www.amk.ca/python/writing/mx-architecture http://groups.google.com/groups?hl=en&frame=right&th=1417d223e1605c9c Ron Stephens and David Mertz publish reviews of over a dozen Python books. http://www-106.ibm.com/developerworks/linux/library/l-pbook2.html http://www.awaretek.com/book.html Martin Brown publishes a Python book for Perl users. http://cseng.aw.com/book/backcover/0,3828,0201734885,00.html Amos Latteier publishes an important tutorial on Zope Page Templates. http://webtechniques.com/archives/2001/12/latteier/ While the venerable embedding-and-extending www.python.org documentation remains venerable, Kragen Sitaker and David Brady work out their own simple model for invoking Python from C. http://groups.google.com/groups?hl=en&frame=right&th=2402ef885355cd18 Simon Cozens engagingly reports on a Python-pertinent conference. http://www.perl.com/pub/a/2001/11/21/lightweight.html Developers continue their search for the right handle(s) on XML, with recent emphasis on XSLT and parsing. http://www-105.ibm.com/developerworks/education.nsf/xml-onlinecourse-bytitle/BE1A7E60838F9F7686256AF400523C58?open&l=810,t=grx,p=pyx2 http://diveintopython.org/ Psyco progress fascinates the performance-obsessed. http://homepages.ulb.ac.be/~arigo/psyco/ Jext acquires Jython scriptability. http://www.jext.org/ ======================================================================== Everything you want is probably one or two clicks away in these pages: Python.org's Python Language Website is the traditional center of Pythonia http://www.python.org Notice especially the master FAQ http://www.python.org/doc/FAQ.html PythonWare complements the digest you're reading with the daily python url http://www.pythonware.com/daily comp.lang.python.announce announces new Python software. Be sure to scan this newly-revitalized newsgroup at least weekly. http://groups.google.com/groups?oi=djq&as_ugroup=comp.lang.python.announce Michael Hudson continued Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week, into July 2001. Any volunteers to re-start this valuable series? 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/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html 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 Tenth International Python Conference http://www.python10.org 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://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) 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 maxm at mxm.dk Mon Nov 19 16:05:17 2001 From: maxm at mxm.dk (maxm) Date: Mon, 19 Nov 2001 22:05:17 +0100 Subject: General infrastructure/design question - long References: Message-ID: "Bill Witherspoon" wrote in message news:mailman.1006199666.10412.python-list at python.org... > My fear is that everytime I change the db schema, I have to run around and update all of the classes to insure that the data maps correctly. Is there any way to easily have a class that 'knows' how to create its own __init__ so that the db fields always become appropriate properties? This is a typical object/relational impedance mismatch problem you are trying to solve. I guess that almost every programmer tries to solve this problem one way or another at some time. I have attached a file with a semiworking solution that I am working on. It currently works on mx.odbc on windows but is rather generic. The idea is that there is a top class called "Table" that you subclass for every table in your rdbms. And then you declare your column names and type, with a default value, and wether the row should be updated or not. class Receipees(Table): dsn = 'DSN=odense_marcipan' tableName = 'receipees' columns = {} # R/W TYPE DEFAULT columns['id'] = 'KEY', 'INT', None columns['title'] = 'WRITE', 'STR', '' columns['summary'] = 'WRITE', 'TXT', '' columns['tips'] = 'WRITE', 'TXT', '' columns['receipee'] = 'WRITE', 'TXT', '' columns['ingredients'] = 'WRITE', 'TXT', '' columns['category'] = 'WRITE', 'INT', 0 columns['image'] = 'WRITE', 'STR', '' columns['visible'] = 'WRITE', 'INT', 1 This way you can ignore most of the rdbms specific code, and just code as if your tables are Python objects. The above table is used like this: rcps = Receipees() print 'creating new' newRcp = rcps.getNew() newRcp.title = 'The new architecture' newRcp.summary = 'A bad summary' rcps.save(newRcp) print 'Getting some' rcps.getByIds([11,10,12,13]) for rcp in rcps: print rcp.title print 'Getting one' rcp = rcps.getOneById(10) print rcp.title print 'Getting all' rcps.getAll() for rcp in rcps: print rcp.title print 'The shortcut' rcps2 = Receipees([10,11]) for rcp in rcps2: print rcp.title To make it work with mySql or PostgresSQL only the two methods '_query()' and 'save()' would need to be altered slightly. It would even be rather trivial to subclass 'Table' like: class mysqlTable(Table): ... and then overwrite _query and save. The idea is also that you should NEVER use a sql query directly in the objects. If you need a special query, you write a method that does it. Ie. if you want to get all the receipes by category you would write a method called: def getByCategory(self, category): query = 'where category=%s' % category self.getWhere(query) If later you find out that you need to put the categories in a many to many table you would only have to rewrite the "getByCategory()" method. Hiding the data structure. Anyhoo I like this style, I hopes that it is of any help to you. The class i have attached is rather simple and certainly not complete. But it was enough for my recent project, and I will make it more feature-complete as I need to solve other problems. regards Max M From huaiyu at gauss.almadan.ibm.com Tue Nov 6 20:50:56 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 7 Nov 2001 01:50:56 +0000 (UTC) Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> <9s9949$hm5$1@news.service.uci.edu> <8ef9bea6.0111061428.28c46fc0@posting.google.com> Message-ID: On 6 Nov 2001 14:28:26 -0800, Hung Jung Lu wrote: >#--------------------- >def flipflop(x): > if x == []: > x.append(1) > else: > x = [] > >a = [] >flipflop(a) >print a >flipflop(a) >print a >#--------------------- >output: >[1] >[1] > >In the above example, the 'global' statement plays no role. Nested >scope is not the problem. Not understanding the namespace mechanism is >the problem. > >The root of the non-trivialness is the namespace structure, not any >particular Python statement or keyword. If you think you can explain >to beginners the above example, more than a few dozen times, without >getting exhausted, then I think you will be highly admired. :) You are confused about the cause of this problem. It is has nothing to do with namespace. It is no more complicated than the following >>> a = [] >>> x = a >>> x.append(1) >>> print a [1] >>> x = [] >>> print a [1] What is going on? Well, remember the following two points: 1. Python distinguishes between names and objects. So when you see names like a, x, ask yourself whether they refer to the same object. 2. Python distinguishes between mutation and name-binding. Mutating an object will show the result in all names that point to this object. Rebinding a name to another object will not affect other names, even if they refer to the same object before. These two points should be easily explainable to newbies using simple analogies, such as tags tied to objects with strings. feeling-exhausted-explaining-this-many-times-ly yr's Huaiyu From grenieda at hotmail.com Thu Nov 15 11:29:25 2001 From: grenieda at hotmail.com (David Grenier) Date: Thu, 15 Nov 2001 11:29:25 -0500 Subject: Newbie questions part 2, thanks References: <7xzo5ojdqd.fsf@ruckus.brouhaha.com> Message-ID: <32SI7.34143$wd1.2586689@news20.bellglobal.com> Thanks, it worked... Now here: def mappe(fonction, schemeliste): if type(schemelist.cdr) is InstanceType and schemelist.cdr.__class__==cons: return cons(fonction(schemelist.car), cons.mappe(fonction, schemelist.cdr)) else: return fonction(schemelist.car) (still this is in class cons) Whenever I call cons.mappe(lambda x:2*x, cons(1,[])) I get the folowing error. Traceback (most recent call last): File "", line 1, in ? cons.mappe(lambda x:2*x, cons(1,[])) TypeError: unbound method mappe() must be called with instance as first argument You see as I saw that error I become to believe that whenever a function from a class as more than 1 argument, it assumes that the first argument is of the type of the class, now it expects fonction to be of class cons but it's just a function and gives me that error, besides, I've written my class as some of the tutorials i've seen. Still I'm required to put the function as the first argument, it's a specification. "Paul Rubin" a ?crit dans le message de news: 7xzo5ojdqd.fsf at ruckus.brouhaha.com... > "David Grenier" writes: > Change this: > > while type(champ)=='instance': > > to: > while isinstance(champ, cons): > > The problem is that type(champ) doesn't return a string, so your test > always is false. From Kevin.Smith at sas.com Tue Nov 13 10:50:08 2001 From: Kevin.Smith at sas.com (Kevin Smith) Date: Tue, 13 Nov 2001 15:50:08 GMT Subject: [ANN] pyLaTeX - Minor Bug Fix Release Message-ID: <9srffg$ndh$1@license1.unx.sas.com> pyLaTeX 1.0 alpha 1.1.1 ----------------------------------- A small bit of code had snuck into the first release that prevented it from running in Python 2.0. This has been fixed. If you downloaded the first release and used Python 2.1 to run, you do not need this update. If you have any problems with this package in installation, execution, etc., please let me know by contacting at the email address on the pyLaTeX website. http://pylatex.sourceforge.net/ Kevin Smith From wtanksle at dolphin.openprojects.net Thu Nov 15 19:10:25 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 16 Nov 2001 00:10:25 GMT Subject: PEP 276 Simple Iterator for ints References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> <9t0jko$14b$1@thorium.cix.co.uk> <3BF43EA3.42A5A4B6@ccvcorp.com> Message-ID: On Thu, 15 Nov 2001 14:23:45 -0800, David Eppstein wrote: > Jeff Shannon wrote: >> > >>> for i in int[2:10:2]: print i, >> > 2 4 6 8 >> This doesn't look too bad to me. I'd go for it. >Why is int[2:10:2] an improvement over range(2,10,2)? Because it names the type over which ranges are selected, gives the remote possibility of being useful for other types, and because it allows the possibility of infinite ranges. >They have the same number of words and the same argument values with the >same amount of punctuation, the only difference to me is that int[2:10:2] >is in a much less familiar syntax. Of course, you're right here. I see this as a problem with all the suggestions being made here -- the "problem" being solved is so tiny that the improvements suggested just don't matter. >David Eppstein UC Irvine Dept. of Information & Computer Science -- -William "Billy" Tanksley From jeff at ccvcorp.com Wed Nov 28 20:50:56 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 28 Nov 2001 17:50:56 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> <3C05758F.DBD8833@engcorp.com> Message-ID: <3C05947F.84992341@ccvcorp.com> David Eppstein wrote: > I take it you are viewing the syntax of a for-loop as > "for" variable "in" expression: > where "for" and "in" are keywords and expression must be something that > returns a list or iterator. So the "in" of a for-loop has very little > other than spelling to do with "in" operator for list expressions. > > I would rather view a for-loop as > "for" expression: > where (currently) the expression must have as its top level operation the > "in" operation and the lhs must be a variable. The variable is set in all > possible ways that make the expression true. From this point of view, "for > x in 5" looks really ugly, and "for 0 <= x < 5" makes a lot more sense: we > now simply allow one more kind of expression in a for loop, one where the > top level is a three-way comparison and the middle side of the comparison > must be a variable. It seems to me that the first of these is by far the more intuitive way to view this. Of course, this may well be due to my relative lack of understanding of advanced mathematics and computer science. Conversely, one could argue that the whole point of making a language intuitive, is to appeal to people with a lack of understanding of advanced mathematics and computer science... Jeff Shannon Technician/Programmer Credit International From nhodgson at bigpond.net.au Thu Nov 8 17:26:55 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 08 Nov 2001 22:26:55 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> <9sebn1$28g$1@news.lth.se> Message-ID: David Andreas Alderud: > Where you tought Ada prior to this? No, although I had read articles and the book by I.C. Pyle while at uni. > Task are extremly simple and powerful, they work excelent in multitasking > envirionment; tasks are like threading and any user, including the > beginners, can use tasks if they can use packages, which they can if they > ever printed anything to the screen. The team were either used to OS mediated tasking (like me) or to bare machines writing their own interrupt based code. We were familiar with low level IPC based on semaphores and shared memory and higher level techniques like queuing. Most of the IPC in the systems could be sensibly designed using message queues. Ada's rendezvous is both higher level and more expensive then the lower level techiques and less expressive than higher level techniques. So you get to build a message queuing package on top of rendezvous which is extra work and runs into the need for strict typing which conflicts with most links between tasks needing to send many types of message. To contrast, part way through the project we moved to a newer platform for the UI subsystems (written in C) which provided threading as well as the heavy-weight processes previously used for the UI. Threads were quickly and easily assimilated, being used to improve responsiveness. > I've found this to be very flexible, maybe you're school with C and that > caused problems? I went to a fairly conventional university that used Pascal as the primary teaching language although C (and FORTRAN, COBOL, lisp and awk) were given some time. Strictly statically typed languages have their place but I see that being in libraries of low-level code managed by script code and not for initial learning which should be about achieving outcomes. > Strange since in every report I've seen on productivity Smalltalk wins and > Ada in general is on a strong second place, C++ productivity is generally > considered to be 1/6:th or lower of Smalltalk for example. Defence contractors are forced to use Ada, companies that have a choice generally don't. Ada is not a bad language but for any given project I would be able to choose a language that IMO is superior to Ada. For low-level projects, that would be C++. Neil From huaiyu at gauss.almadan.ibm.com Thu Nov 29 14:13:55 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Thu, 29 Nov 2001 19:13:55 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C053AA4.97246A72@ccvcorp.com> Message-ID: On Wed, 28 Nov 2001 11:27:32 -0800, Jeff Shannon wrote: > >So, then... how is someone to know whether there is a tab character in the file >they are editing, if there is no standard way to represent that character? It >seems to me that just about every *other* ascii character has *some* default action >or symbol associated with it... The idea is that for everyone there is a standard way to display tab, but it may be different for each person. Since code is exchanged via ascii encoding instead of screen shots, different display does not matter. > If you >use a method that is visually equivalent to spaces, but can be customized to >however many spaces the current user wishes... well, then you've got our current >mess, with people wanting to mix the two and getting unpredictable results. If you do not let Python interpret tab as equivalent to n spaces for indentation, it remains predictable, because they can't be mixed. >The only real solution to the problem, is to insist that using one or the other is >an error. Of course, many people will, without thinking, use spaces to indent even >when they "know" that they should use tabs. (As evidence, the Python docs specify >that a tab is equal to two standard indent levels, and yet people insist on >ignoring this specification...) Tab keys, on the other hand, are easy (and >relatively painless) to reinterpret to insert spaces. The tab=2*indent spec does not work because it mandates the mixing of tab and space if you want to use tab at all. >Therefore, the easiest, least painful solution, is to disallow tab characters for >indenting. I'd be happy to see *every* appearance of 0x09 for indenting become a >syntax error. This would require a fair amount of fixing old code, but not too >much--running TabNanny once over all old code. From that point on, there would be >*no* confusion, as any reasonable editor would auto-convert tabs to spaces, and tab >characters would disappear from code. So the ideal world is all spaces, no tabs. It is then not a big leap to allow tab as a shorthand to replace the number of spaces used as indent. Huaiyu From skip at pobox.com Fri Nov 9 07:31:45 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 9 Nov 2001 13:31:45 +0100 Subject: Special celebration event for Orlijn? In-Reply-To: <3BEBA01A.2C5B468D@student.gu.edu.au> References: <3BEBA01A.2C5B468D@student.gu.edu.au> Message-ID: <15339.52401.804587.544175@beluga.mojam.com> >> Maybe we should hold a special event in celebration of Guido's new >> baby boy, Orlijn Michiel - perhaps a New Orlijn's Jazz Festival? Joal> Perhaps we should vote to rename the language in honour? At the Joal> very least somebody should name a new module. Would have been a helluva lot easier if Guido had simply named his son after a language that already existed. With your suggestion we'll have to get a huge population of existing users to change all their installations. Hmmm... Perl van Rossum. Has a kind of nice ring to it, don't you think? ;-) ;-) ;-) Skip From parz at shaw.SpamBucket.ca Sat Nov 24 21:30:09 2001 From: parz at shaw.SpamBucket.ca (Parzival Herzog) Date: Sun, 25 Nov 2001 02:30:09 GMT Subject: How do I use and debug with locally built Python executables? Message-ID: An earlier posting identified a crash in Python21.dll while using an extension module. I was unable to debug into the Python21.dll, so I downloaded the ActiveState 2.1.1 build 212 source tree, and used MSVC 6.0 to build Python_d.exe and Python21_d.dll. I then copied these dlls to my installed python directory, and ran a command line program: -------------------------------- F:\EmsView\New>python_d sample.py Adding parser accelerators ... Done. Traceback (most recent call last): File "sample.py", line 1, in ? import MyWin ImportError: No module named MyWin [2346 refs] F:\EmsView\New>dir *.pyd Volume in drive F has no label. Volume Serial Number is 2C38-2765 Directory of F:\EmsView\New 2001-11-22 18:19 110,641 MyWin.pyd 1 File(s) 110,641 bytes 0 Dir(s) 6,400,483,328 bytes free F:\EmsView\New> --------------------------------- Can anyone explain why the MyWin.pyd extension dll is not found using Python21_d.exe? It continues to be found using the installed Python.exe. Is this the right way to go about debugging problems with extension modules? (Er, obviously not, but what IS the right way?) - Parzival From tim at vegeta.ath.cx Thu Nov 1 18:12:01 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 01 Nov 2001 23:12:01 GMT Subject: Monty Python (was: Freeware Python editor) References: <3BE18C8E.D9E75CD4@ix.netcom.com> Message-ID: Me parece que Grant Edwards dijo: > In article <3BE18C8E.D9E75CD4 at ix.netcom.com>, Antaeus Feldspar wrote: > > Even some of those [Monty Python sketches] were much funnier at the > > time because the audience understood the references being made. > > I think some of the humor is lost on us Americans due to to the > cultural references that go flying past without comprehension > (assuming we can actually catch all of the dialog to begin > with). I thought the one German episode was still fairly funny > when subtitled... You mean "the humour is lost on _some of_ us Americans," right? Of course, I had a non-standard American growth in which I was exposed to many things British, including but not limited to: Dr. Who (mainly Tom Baker) (recorded). Red Dward (1st season, carrier did not renew) (recorded). Monty Python's Flying Circus and any of the movies I could find. How to Irritate People (John Cleese et al.; not "officially" Monty Python). (purchased) ...et cetera. Peter Cushing horror movies. ;) Susan Cooper's The Dark Is Rising sequence including dialects from Cornwall and Wales. A great many movies and series taking place in Yorkshire, probably responsible for my ability to understand more dialects than usual. :) Neil Gaiman novels. :) Far too many others to count. In any case, the humour was not lost on this American. Nor did it appear to have been lost on our BDFL, Mr. van Rossum. Many foreigners call America's culture (or lack thereof) bland. Well, from this American's perspective, they tend to be correct. My $0.03, Tim Hammerquist -- Error: No keyboard detected. Press F1 to continue. -- actual MS Windows error message From fredrik at pythonware.com Wed Nov 7 02:30:17 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 07:30:17 GMT Subject: Yahoo Groups archive of python-list wiped - what happened? References: <3BE878FA.103DA334@letterror.com> <9sa4hk$11vhaf$1@ID-11957.news.dfncis.de> Message-ID: Emile van Sebille wrote: > > > > note that the first post in their new archive is timestamped > > "Nov 5, 2001 7:29 pm". > > > before and after Orlijn? > > OK... what's that? The closest hit I get is spoorlijn. Has somebody pulled > a fast one? that's why you should check the daily URL several times a day: http://www.pythonware.com/daily "Orlijn Michiel Knapp-van Rossum, was born at 7:20 pm on Monday, Nov 5" From loewis at informatik.hu-berlin.de Fri Nov 9 08:14:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Nov 2001 14:14:21 +0100 Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: "harry" writes: > if you put data into dictionary, how do we calculate the data size? This is very difficult, and I suggest you don't really want to know. > example: > > dict = {"key1":1,2,3,4; "key2": "hello", [1,2,3]} This is invalid syntax, I'll assume that you meant {"key1":[1,2,3,4], "key2": "hello", "key3": [1,2,3]} > > how much is the data structure will cost? how to calculate it? Notice that dict is now a collection of 11 objects: - four strings - four integers: 1,2,3,4 - two lists: [1,2,3,4] and [1,2,3] - one dictionary You may think that the integers should be counted twice, but you actually have the same integer objects in each list. Do you want the siye of just the dictionary, or of all the objects together? What Python version? What operating system/microprocessor? What C library (to account for the overhead of malloc/free). Regards, Martin From bbollenbach at home.com Sat Nov 17 10:25:27 2001 From: bbollenbach at home.com (Brad Bollenbach) Date: Sat, 17 Nov 2001 15:25:27 GMT Subject: CGI output References: <63343bfd.0111161819.14263d83@posting.google.com> Message-ID: "Sebastien Delafond" wrote in message news:63343bfd.0111161819.14263d83 at posting.google.com... > Hi, > > I'm using python to write a CGI interface providing my users with the > ability to run a specific command, a.k.a. "command". > > This command takes about 3 to minutes to complete under normal > conditions, and the current Python solution I'm using to run it > prevent users to see its output before it's fully completed. I've > tried calling this command with [snip] Before coming up with a solution for displaying a progress indicator in some fashion (which is a nasty idea, over the web), consider speeding up your algorithm, or moving the slow parts to C code. Maybe you're doing something wrong, and should never have to even think of doing a "wait screen" of some type (if the task can actually be completed in, say, 15 seconds). Perhaps if you mentioned what you were doing, and what the slow parts of your code are, we could help you with that. If you think theres /no way/ you could make it this much faster, ask Guido: http://python.org/doc/essays/list2str.html I'd be interested in hearing more... Hope that helps, Brad From Administrator Thu Nov 29 15:12:48 2001 From: Administrator (Administrator) Date: Thu, 29 Nov 2001 13:12:48 -0700 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <03ed01c17912$36f23620$0e0fbb82@corp.es.com> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = Andrea Ghedina & Luisa Tomasi Recipient(s) = python-list at python.org Subject = Re: Scanning Time = 11/29/2001 13:12:47 Engine/Pattern = 5.600-1011/173 Action on virus found: The attachment images.DOC.pif contains WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to administrator. ScanMail has detected a virus. 11/29/2001 01:12 PM TORINO images.DOC.pif/Deleted python-list at python.org Andrea Ghedina & Luisa Tomasi Re: From eppstein at ics.uci.edu Wed Nov 14 12:47:39 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 14 Nov 2001 09:47:39 -0800 Subject: PEP 276 Simple Iterator for ints References: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> <15346.13388.182098.148832@beluga.mojam.com> Message-ID: In article , "Rainer Deyke" wrote: > One thing bothers me about the Haskell syntax: using it to generate > sequences of less than three elements just looks wrong. > > [1, 2, ... 3] # This is obviously [1, 2, 3]. > [1, 2, ... 2] # What is this? [1, 2]? > [1, 2, ... 1] # [1]? > [1, 2, ... 0] # []? > > Another thing that bothers me is that I'm it's not obvious how the elements > are evaluated. This is not an issue in Haskell, but it is in Python: > > def f(n): > print n > return n > > for i in [f(0), f(1), ... f(5)]: pass > > I assume that this prints 0, 1, and 5. That makes sense from one > perspective, but doesn't make sense at all from another perspective. > Another example: > > for i in [g() + 0, g() + 1, ... g() + 13]: pass > > How often is 'g' called? Once? 3 times? 14 times? My assumption would be that the syntax [x, y, ... z] is equivalent to range(x,z+y-x,y-x). This answers all of your questions: [1,2,...2] = [1,2] [1,2,...1] = [1] [1,2,...0] = [] [f(0),f(1),...f(5)] prints 0, 1, 5 and returns [0,1,2,3,4,5] [g()+0,g()+1,...g()+13] evaluates g() 3 times and (if g is side-effect-free) returns a list of 14 values -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From adamspitz at bigfoot.com Tue Nov 13 13:22:02 2001 From: adamspitz at bigfoot.com (Adam Spitz) Date: 13 Nov 2001 10:22:02 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> Message-ID: <87f44f44.0111131022.5ab1b6f@posting.google.com> Tim Hammerquist wrote: > Adam Spitz graced us by uttering: > > > For what it's worth, I consider myself a Smalltalker, and I like > > Python very much. I don't give a hoot about OO purity - I like > > Smalltalk because I'm really productive in it, and I like Python for > > the same reason. (Ruby, too. ;) > > This is the exact reason I included that phrase. =) Also, it might have > been an unconscious attempt to bring some of the less argumentative > Smalltalkers out of hiding. OK, I'm out of hiding. :) Anything in particular you'd like to discuss? > Before your post, every Smalltalker I'd talked to said something very > similar to "That's alright, but if you want a _real_ OO language, > look at Smalltalk." I *do* think that Smalltalk's got some advantages over Python, but I don't think they're in the area of OOness. In terms of OO, Python has everything I want. Does anybody mind if I gripe a bit? (If you do, stop reading now. :) I don't mean to piss anybody off. I'd just like to offer an outsider's perspective. I promise to be as unbiased as I know how to be. I'd be interested to see the current state of Python development environments. That's where Smalltalk really shines, and I've never seen an environment for any other language even come close. That's understandable, because Smalltalk's whole, um, paradigm is optimized for that kind of thing. Holding everything inside a monolithic image makes it really easy to create spectacular tools (but, of course, also costs Smalltalk a lot, like the ability to use Smalltalk for small scripts). In particular, I'd like to see the Python Refactoring Browser efforts bear fruit. I'm kinda annoyed about Python's silly type/class distinction. But then, so are you, and I'm glad to see the efforts at unification progressing. I'm also kinda annoyed that Python introduced generators, list comprehensions, and crippled lambdas to deal with an issue that Smalltalk solves very neatly with its blocks. Still, most of my use of blocks in Smalltalk is for conditionals (done in Python with nice, plain "if" statements), and #do and #select and #collect (done in Python with "for" statements and list comprehensions, and I kinda like having the more convenient syntax). So in real life, most of the time I don't even notice the lack of blocks. (I was surprised to realize this. I'd like to know if other Smalltalk/Ruby programmers' experiences with Python have been the same.) I'd like to see Python stop hiding its dynamic side. I had a discussion with some Python folks over at Ward Cunningham's Wiki (http://c2.com/cgi/wiki) a while ago, and I left with the impression that Python was dynamic enough to do the things that I wanted, but forced me to jump through some hoops to do them. (And that really surprised me, because I *know* that the Python community takes pride in Python's dynamicness and intuitiveness.) First example that comes to mind: adding methods to an existing class. In Smalltalk, I'd just browse over to that class and add the method. In Ruby, I'd just write: class MyClass def newMethod() print "new method" end end ... and it'd add the new method to the class. In Python, I think I have to define the method as a function *outside* the class and then assign it as an attribute on the class: def MyClass_newMethod(self): print "new method" MyClass.newMethod = MyClass_newMethod I smiled just now when I realized that the Python version is actually fewer lines of code. :) But I still don't think it feels right. In Smalltalk and Ruby, I'm just using the standard mechanism for adding methods to a class. In Python, it feels like I'm sneakily hacking an extra method into a class against its will. (Does that make any sense? Maybe I'm being too touchy-feely. :) (Sorry for digressing into Ruby. I just wanted to point out there *is* an intuitive syntax - at least, a syntax that *I* find intuitive :) - for this sort of thing, even for conventional file-based languages.) Oh, and I've been meaning to ask - is there a way for me to add methods to Dict or List or String? I couldn't figure out how to do it, and that's where I *really* want it. Anyway, I'd better stop now. I don't want to piss too many people off too quickly. :) I really do like Python a lot, and I'd be delighted if I ever got the opportunity to use it in an actual work environment. (If I had any control over my life, I'd push for it. ;) But maybe it's useful to hear the perspective of an almost-reasonable person from outside the community. Adam Spitz From sholden at holdenweb.com Mon Nov 5 21:29:17 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Nov 2001 21:29:17 -0500 Subject: gzip and file size References: <84a8bdbe.0111051534.501ea62e@posting.google.com> Message-ID: "ToddW" wrote ... > It's simple to get the correct file size for a file. But if it is > gzipped, is there a simple way to snag the file size of the > uncompressed file? Use getinfo() or infolist() to get the description of an individual entry as a ZipInfo object, and the file's size is the ZipInfo's file_size attribute. regards Steve -- http://www.holdenweb.com/ From david at dataovation.com Mon Nov 5 11:03:44 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 5 Nov 2001 08:03:44 -0800 Subject: MySQLdb Question In-Reply-To: Message-ID: Can anyone tell me why I need to connect twice in order to set cursorclass=MySQLdb.cursors.DictCursor? If I try to include this argument the first time, I get an error. The only way I can get it to work without the error is to recreate the connection object a second time like this. db1 = MySQLdb.connect(user = config.user, passwd=config.passwd, host= config.host, db = "prweb") db1 = MySQLdb.connect(user = config.user, passwd=config.passwd, host= config.host, db = "prweb",cursorclass=MySQLdb.cursors.DictCursor) Thanks, David McInnis From paul at svensson.org Wed Nov 7 13:43:03 2001 From: paul at svensson.org (Paul Svensson) Date: Wed, 7 Nov 2001 18:43:03 +0000 (UTC) Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: <9sbvbm$9ef$1@news.island.liu.se> Michael Abbott writes: > > Is the idea of "Stackless Python" fundamentally sound? > Looking at it from the other direction, seeing an interpreter involving the host stack in target recursion gives me a severe case of itching-to-fix-it. /Paul From tfb at cley.com Sun Nov 18 07:42:22 2001 From: tfb at cley.com (Tim Bradshaw) Date: 18 Nov 2001 12:42:22 +0000 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> <9srbs8$pur$1@slb2.atl.mindspring.net> Message-ID: * Erno Kuusela wrote: > sounds a lot like java (except the dropping 2 years later part). Yes, with the significant difference that Sun are not a monopolist, and so don't have the option of behaving so abusively. Sun realise that their interests and `community interest' are fairly (obviously, not completely) well aligned for the time being. --tim From cgaston at moonqzie.com Tue Nov 6 13:17:09 2001 From: cgaston at moonqzie.com (Carlos Gaston Alvarez) Date: Tue, 6 Nov 2001 19:17:09 +0100 Subject: Teaching python (programming) to children References: Message-ID: <009901c166ef$4033fb90$a500a8c0@moonqzie> I started programming when I was a child and english is not my mother language, so I can speak throught experience. Childs dont need commands in thear own language. Most words are new, so they learn the new word as if it where of their own language. ex: imprimir "hello world" surely you should not learn spanish to know what it means, once you have read on the manual what it does ... or you have tryed it. So imprimir for you would mean "print it in the computer's screen" There is the key point, childs need good documentation in their own language. I started learning english for real when I realised that if I was going to learn more about computers, I should learn it in english. The second great point is that they need a goal, been having fun the best of all. My father bought a computer program, so I (the little computer genious) could learn it and help him on his work. Result, total failure. Later, when I was grown up, well, I knew what it was expected of me and I realized that I knew how to do it, it was just that with my child's point on view I found it useless. If i would have known the real goal may be I would have solved the 'problem' (there was not a problem at all) but I saw things as useless. On the other hand I knew (and was doing it ) how to program small computer games, which where much more complex. So keep in mind the childs point of view. So, it seems that the most important for them is that they get the language doing that they want to do. And HAVE FUN in the process. The lesser the learning curve, the more reward they have for learning and the more that they will want to learn. May be that the best way to teach them is to give them a computer game and teach them how to improve it. Ok, it should not be too complex. They will add complexity as they learn more. Chau, Gaston ----- Original Message ----- From: "Brian Elmegaard" Newsgroups: comp.lang.python To: Sent: Monday, November 05, 2001 10:55 AM Subject: Teaching python (programming) to children > Hi, > > in the special Python issue of Linux Journal last year Guido explained > one of the perspectives of the future was children sitting in class > writing python code for a lot of different applications. > > I think that Python may be very well suited for this because it is > easy to get going with the language compared to other languages > (AFAICS). > > However, in order to program you need to be able to write. And out of > the English-speaking world, learning English will be one obstacle > delaying the learning of programming. > > So, any comments are appreciated, especially on: Are there good reasons > for advocating python being a language one could teach children > programming with and are there perspectives in translating python to many > different languages in order to facilitate this, or will children not be > ready for learning programming before they have learnt English after all? > -- > Brian (remove the sport for mail) > http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug > \TeX, tak. > -- > http://mail.python.org/mailman/listinfo/python-list > From volucris at hotmail.com Tue Nov 20 00:37:32 2001 From: volucris at hotmail.com (Greg Krohn) Date: Mon, 19 Nov 2001 23:37:32 -0600 Subject: Try block problem References: <9tcnls$42k$1@news1.ucsd.edu> Message-ID: <3bf9eacb$0$79564$6e49188b@news.goldengate.net> "Jeff Davis" wrote in message news:9tcnls$42k$1 at news1.ucsd.edu... > It seems like the following makes sense to me: > > try: > ... > except: > ... > finally: > ... except and finally can't be used together. >>> def spam(x): ... try: ... print 10 / x ... finally: ... print 'Cleanup before exception is raised' ... >>> def eggs(x): ... try: ... print 10 / x ... except: ... print 'Bad x! Bad, bad x!' ... >>> spam(1) 10 Cleanup before exception is raised >>> spam(0) Cleanup before exception is raised Traceback (most recent call last): File "", line 1, in ? File "", line 3, in spam ZeroDivisionError: integer division or modulo by zero >>> eggs(1) 10 >>> eggs(0) Bad x! Bad, bad x! More info: http://www.python.org/doc/current/ref/try.html greg From woodm at equire.com Tue Nov 20 12:50:44 2001 From: woodm at equire.com (Matthew D. Wood) Date: 20 Nov 2001 09:50:44 -0800 Subject: urllib.urlencode has 2 parameters?? Message-ID: <32cedc66.0111200950.4f44d898@posting.google.com> I've been staring at the documentation page for urllib for about 15 minutes, and experimenting around on the python-command-line trying to figure out what the second parameter for urllib.urlencode does. Does anyone know? I'm very confused. From kragen at canonical.org Sun Nov 25 21:37:05 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 21:37:05 -0500 Subject: A permutation on permutations References: Message-ID: <83heritfzi.fsf@panacea.canonical.org> "Arthur Siegel" writes: > The following little func does not work as I > would expect!!! > > Something about the iteration of p in t > with the list.remove(). > > Is the func as written certifiably bad > Python , or a bug/trap I fell into? > > def removedups(t): > for p in t: > if p[-1]>p[0]: > t.remove(p) > print t It's certifiably bad Python, because modifying a list you're iterating over is a bug/trap you fell into. One general way of solving this is to say for p in t[:]: instead of for p in t[:], but I'd probably say print [p for p in t if p[-1] > p[0]] instead of the whole function. From emile at fenx.com Tue Nov 6 09:59:31 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Nov 2001 06:59:31 -0800 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> Message-ID: <9s8u5d$11feke$1@ID-11957.news.dfncis.de> "Oleg Broytmann" wrote in message news:mailman.1005056230.17003.python-list at python.org... > On Tue, Nov 06, 2001 at 07:48:16AM -0600, DeepBlue wrote: > > Let me add to this that in such a boring predictable world, I have always > > appreciated Oleg's Pushkin-Lermentov-like sensibility and idealism :) > > Always? Did I really show it *so* many times? :) > ;-)) About as predictable as waiting for Martijn to jump in about the PS From coventry at one.net Thu Nov 29 09:10:17 2001 From: coventry at one.net (- c o v e n t r y -) Date: 29 Nov 2001 06:10:17 -0800 Subject: Psyco 0.3.2 References: <9t0op3$ste$1@news.panix.com> Message-ID: Please do write such a review! Myself and several others who are parusing the source code use all the help we can to get upto speed so we can start contributing. Also, is there any chance of moving the project to sourceforge or an equivilent? Thanks, -C- > Armin Rigo wrote: > >Shall I write a technical in-depth overview ? > > While I'm primarily trying to understand the Self implementation right > now, I've been following the Psyco stuff with some interest. A > technical summary would be great, and I'm pretty sure others would be > interested too. > > Thanks, > -Randy From max at alcyone.com Fri Nov 23 20:00:46 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Nov 2001 17:00:46 -0800 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <3BFC0365.21FB6AA1@alcyone.com> <9tm7go$atu$1@newshost.accu.uu.nl> <3BFEA602.FEF2FC2C@alcyone.com> <9tmofi$9ke$1@newshost.accu.uu.nl> Message-ID: <3BFEF13E.63293188@alcyone.com> Martijn Faassen wrote: > You can probably do something about that making instructions cost > something. :) That would limit the lengths of the programs, but here the problem is one of diversity and not length. Without care eventually all the programs in the population become degenerate versions of each other. > Very interesting. Please do. Sent. > Hm, so what evolves? :) My system has the ability to fork as well (in > fact that is a necessity). Indeed. There's actually a mutation factor which I neglected to mention. > A replicator exists in space on a grid, > can move around and gather resources. Using the resources it can > scan itself, copy itself to another area of the instruction string and > finally create another processor for it and split off the offspring > into > another location. What evolves are generally systems to gather more > resources and survive crowding conditions. A new 'organ' which > consists > of a doubly nested loop evolves which does that. Jupiter on the other hand is very much like MARS or Tierra in terms of being on a circular memory space with processes having private registers and stacks, rather than taking place on a two-dimensional grid. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From warkid at storm.ru Thu Nov 8 13:24:26 2001 From: warkid at storm.ru (Kerim Borchaev) Date: Thu, 8 Nov 2001 21:24:26 +0300 Subject: GC question Message-ID: <8891.011108@storm.ru> Hello , While trying to use gc I've encountered a problem, demonstrated by this script: ###################################### from __future__ import nested_scopes import gc gc.enable() gc.set_debug(gc.DEBUG_LEAK) def fun(): class C: def m(self): g = C() fun() del fun gc.collect() assert not gc.garbage, str(gc.garbage) ###################################### It's output: ###################################### gc: collectable gc: collectable gc: collectable gc: collectable gc: collectable Traceback (most recent call last): File "t.py", line 16, in ? assert not gc.garbage, str(gc.garbage) AssertionError: [, {'__doc__': None, 'm': , '__module__': '__main__'}, , (,), ] ###################################### can someone, please, explain what does it mean and why it happens? My python is: ActivePython 2.1.1, build 212 (ActiveState) Python 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on win32 Best regards, Kerim mailto:warkid at storm.ru From ws at mystrobl.de Mon Nov 12 17:43:07 2001 From: ws at mystrobl.de (Wolfgang Strobl) Date: Mon, 12 Nov 2001 23:43:07 +0100 Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: On Mon, 12 Nov 2001 22:08:51 GMT, "Neil Hodgson" wrote : >Wolfgang Strobl: > >> >>> Traceback (most recent call last): >> File "H:\Python21\Pythonwin\pywin\framework\intpyapp.py", line 349, >> in OnFileRun >> dirOfScript, starter) >> TypeError: CreateProcess() takes exactly 9 arguments (7 given) > > But there are 9 arguments (as there are 8 commas): > > win32process.CreateProcess(sys.exec_prefix + "\\python.exe", > "python -i " + pathToRun, None, None, 0, > win32process.CREATE_NEW_CONSOLE, None, > dirOfScript, starter) Eeek. You are right, of course. > > Maybe there was some line-end failure in transit - try adding \ at the >end of the lines to force it all on one logical line. Indeed. I just manually recreated the leading white space for the the continuation lines, now it works without \'s at the end. I guess the failure was caused by uudecoding the snippet on a linux machine and moving it over to my win2k computer (Pegasus didn't understand an embedded file, and doing it on the other machine seemed to be the easiest way of decoding the file). Again, thanks for the nice patch, and sorry for the confusion. What about convincing Mark Hammond about adding it to the standard distribution? -- Thank you for observing all safety precautions From dutka at edf.fr Mon Nov 19 10:25:57 2001 From: dutka at edf.fr (Ivan DUTKA-MALEN) Date: Mon, 19 Nov 2001 16:25:57 +0100 Subject: [Q] Printing color strings on stdout without using escape sequences ? References: <3BF4F588.9010500@edf.fr> Message-ID: <3BF92485.70801@edf.fr> Walter D?rwald wrote: > > You might want to take a look at ANSIStyle: > http://www.livinglogic.de/Python/ansistyle/ > > HTH, > Walter D?rwald > > Yes this package does exactly what I want. Moreover, it is very simple to use. But it doesn't work on 'old' version of Python (I mean 1.5.2). I tried to make some change in the source code (not too dificult to understand) but I've stopped on some internal Python functions (PyObject_DEL or PyUnicode_check) I think they're only valid in recent release of Python. I must say that I've never made any C extension to Python Do you think it would be a challenge to make it work on version 1.5.2 ? Ivan -- Ivan DUTKA-MALEN EDF R&D mailto: dutka at cli76al.der.edf.fr mailto: ivan.dutka-malen at edf.fr From greg at cosc.canterbury.ac.nz Wed Nov 28 18:31:18 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 29 Nov 2001 12:31:18 +1300 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C046EB4.55B36D9D@cosc.canterbury.ac.nz> Message-ID: <3C0573C6.C0C1AA9A@cosc.canterbury.ac.nz> Gareth McCaughan wrote: > > -1. The values of i/3 over that sequence are 0,1,2,3. Ick. Sorry, stuffed it up. I meant for 0 <= i/3 < 2: to give 0, 3, 6, 9. Of course, with the new-style division it should be for 0 <= i//3 < 2: :-) -- 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 R.Brodie at rl.ac.uk Fri Nov 2 05:59:17 2001 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Fri, 2 Nov 2001 10:59:17 -0000 Subject: MemoryError under 2.2b1 References: <1004688073.78898@lix-049dz-008.inside.impress.com> Message-ID: <9rtua3$14t0@newton.cc.rl.ac.uk> "wtr" wrote in message news:1004688073.78898 at lix-049dz-008.inside.impress.com... > The following little script ends in a MemoryError > > for j in range(99999999,1000000001): > MemoryError >>> print len(xrange(99999999,1000000001)) 900000002 From djrassoc01 at mindspring.com Thu Nov 8 11:19:00 2001 From: djrassoc01 at mindspring.com (Dr. David J. Ritchie, Sr.) Date: Thu, 08 Nov 2001 10:19:00 -0600 Subject: Teaching python (programming) to children References: <3BE88DAD.D29B72DD@svs.com> Message-ID: <3BEAB073.3AE0EACC@mindspring.com> "Dr. David J. Ritchie, Sr." wrote: > With regard to your question and general topic... > Well, I don't want to take issue with anyone so I'll just reply to my own post. What I'd like to report based on my own experience of having done multi-week programming sessions for Middle School kids at three different Middle Schools for three years are the following items. I have learned that they are important factors for success in my teaching of computer programming to Middle School Students--particularly as a volunteer. * It's important to figure out how what you want to do with teaching programming connects to the >existing< curriculum. For example, I learned that the existing curriculum is the product of many years of development by collaborations of teachers in the school district. It is very hard to get any long term involvement if you can't give the teacher a line of reasoning that goes from the existing curriculum to "and so we are teaching x or y or z in computer club". * It's important to understand what the typical distribution of readiness is in the age group at the school where you propose to teach the subject. For example, I learned that the students I had would have quite a range of skills in keyboarding and accurate typing. I also learned that the students would have quite a range in their understanding of abstract concepts (like what is an algorithm). I learned that they would do better at internally developing that understanding if they were walked through a set of tasks which exemplified that than if they were talked to about the concept. *It's important to match the approach of your teaching the subject to those readiness factors. For example, I changed from having the students type the three line exercise into the computer to having it all there already for them to use and then asking them to make small changes in it. I also changed from a textbook approach where I talked to them about concepts to a do it approach where they were asked to do a recipe and then asked questions about it afterwards. In the doing of it almost even in rote drill, I found that they would internally come to some level of an understanding about what was behind what they were doing. In some cases, I would be rewarded by the "Aha, I see" from the student. In other cases, they would just have fun and I learned to take that as sufficient accomplishment of >their< goals (appropriate for a club of course--may be different if you have your course locked into a curriculum which downstream courses are expecting to have the students know.) *Finally, it's important to be humble when approaching a teacher, computer learning center staff person, or administrative person. For example, I learned I had to realize that though I might think of myself as quite an expert in X or Y or Z, there were a lot of other factors involved in getting something up in running like making sure it didn't get in the way of the existing teaching of the existing curriculum and the running of the school. I learned also that it is important to partner with a teacher who has a lot of class room experience and >>listen<< to that individual when they express their opinion about something and, at the outset start by assuming that they are probably right, and then figure out how to move towards whatever it is that they are suggesting. I found that the teachers were a lot more subtle in their suggestions than I was used to experiencing in my professional work (i.e., they didn't exactly strongly confront you like I was commonly used to) and that it required a lot of care on my part to tune in and react and adapt in order to make the partnership work. With those factors addressed in the described manner, I have been able to do a computer club program as detailed on my web site over several years time. (See http://home.mindspring.com/~djrassoc01/ ) --David P.S. This is Naperville School District 203 whose 8th graders were top-ranked in the world on the TIMMS test. -- Dr. David J. Ritchie, Sr. djrassoc01 at mindspring.com http://home.mindspring.com/~djrassoc01/ From joost_jacob at hotmail.com Wed Nov 21 10:54:40 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 21 Nov 2001 07:54:40 -0800 Subject: Who can do genetic programming with Python Message-ID: <13285ea2.0111210754.13974f4d@posting.google.com> Does anyone have code that produces correct but random Python code ? This would be useful for a genetic programming (GP) test we want to do. Suppose you need a function that accepts a list (of unknown length and containing values of unknown type) and outputs a list of integer values with length outputlength. The function you are looking for would look like: def myFunction( inputlist, outputlength ): # black box code here, building outputlist return outputlist But you have no idea how to code the function, you only know it accepts a list and outputs a list of integers. You also have a way to test if the function does what you want, in some environment script. For example if you call the function with myFunction([3, 4], 1) you want it to return [12], being a list containing the product of the variables in inputlist. Suppose you cannot code the black box part yourself, now you would like a system that does if for you. With GP you can do things like this, it has been done before in lisp and even in C and Python seems very suitable for it. Before we are going to try to implement something we would like to know if somebody else has been doing this already. We did search internet and there are tons of GP links but we did not find a GP example with Python. From db3l at fitlinxx.com Tue Nov 6 16:10:00 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Nov 2001 16:10:00 -0500 Subject: Teaching python (programming) to children References: Message-ID: writes: > > For teaching programming I strongly belive that Ada95 is by far the best > > Ugh. At least teach them something that they can use elsewhere. ;-) Of course, to be fair, their odds of using Ada95 again are probably higher than using Logo ( prominently selected language in this context), so I'm not sure re-use should be a prominent criterion. :-) -- -- 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 mertz at gnosis.cx Mon Nov 26 02:57:09 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Mon, 26 Nov 2001 02:57:09 -0500 Subject: Python, licenses and CVS (fwd) Message-ID: Hans Nowak wrote: |I'm currently developing a program (in Python, obviously) and plan to |publish it. Before I do so, though, I would like to have some opinions |on the following: |- should I use a license / copyright notice? |- if so, which one would you recommend? YES, you should have a notice. As other folks have written, the code automatically has a copyright. If you want anyone to be able to do something with your code, you need to indicate that. Personally, I prefer to release my code into the public domain. But in order to do so, I create (and must do so) a prominent notice SAYING that the code is released to the public domain. Of course, being public domain, I can't require that anyone preserve that notice (but that's what I want too). Some licenses say that derived works must keep the same license, while others let the modifier change the license, so public domain isn't so different from certain licenses. Which license YOU should use (or lack thereof for public domain) depends on what you want to happen. That's for you to decide. Several people have posted pointers to discussions of these issues. I agree that using a well-known license is the best idea. Here are some general options: GPL - Anyone can use at the code. Any derived works must be GPL. BSD - Anyone can use YOUR code. Derived works may have different license. Public Domain - Anyone can do whatever they want. No copyright claim is made to the code at all, and the default copyright is eschewed. Proprietary - Only the listed people can use your code, and only in the listed circumstances (such as "consideration", i.e. paying you money). Derived works may only have the licenses that you explicitly say they can have. There are other Free or Open licenses. But the first three things listed are very popular choices. From skip at pobox.com Thu Nov 1 10:17:07 2001 From: skip at pobox.com (Skip Montanaro) Date: 1 Nov 2001 09:17:07 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 1) Message-ID: QOTWs: "Maybe the next slogan for the 10th International Python Conference should be 'Python has nothing to hide.'" F Basegmez "... [F]or now at least the cost-effective way to deal with that (in any language) is good testing. Your code will be tested either way, it's just a question of whether it is done by you or your customers." Dave Brueck "With the launch of Windows XP, there's no better time to think about upgrading your system memory." ZiffDavis-transported advertisement "Python ... finds itself used as a work horse or even a race horse. Neither type of horse belongs in the glue factory." Paul Rubin Emile van Sebille unearths an interesting Python Eggs page at http://www.rimbault.net/python/ Emile also writes a workalike for the ReXX translate() function: http://groups.google.com/groups?th=a0ffa6d492327146 Dave Brueck presents useful software development guidelines in response to a question about using Python in a commercial, team environment. Paul Rubin gets a quote-of-the-week nod from the timbot as well. http://groups.google.com/groups?th=673bf7e4b4a0ec1d Python's introspective interactivity is waaaaaayyy cool. http://groups.google.com/groups?th=2e24faedfe88aa4c Drew Csillag announces the release of SkunkWeb 3.1.3. http://skunkweb.sourceforge.net/ OSE is a generic application framework suitable for constructing general purpose applications, distributed systems and web based services. http://ose.sourceforge.net Martin von Loewis shows how to use random.shuffle to select items at random from a list. http://groups.google.com/groups?th=37fda6c40067f7a Two threads run about escaping strings for use in SQL statements: http://groups.google.com/groups?th=859eb6fb477658ca http://groups.google.com/groups?th=a5c057fededcb6 ======================================================================== 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 continued Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week, into July 2001. Any volunteers to re-start this valuable series? 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/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html 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://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) 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 shriek at gmx.co.uk Mon Nov 12 07:30:11 2001 From: shriek at gmx.co.uk (Stephen) Date: 12 Nov 2001 04:30:11 -0800 Subject: Designing socket messaging format References: None <97ae44ee.0111111912.14006c7f@posting.google.com> <1005540314.835539@yabetcha.sttl.drizzle.com> Message-ID: <97ae44ee.0111120430.53436029@posting.google.com> Donn wrote: > | Y is the message type, which in turn affects the message length. > | T represents a text message. (eg. "Hello World"). Note that > | it could also contain newlines (eg. "Hello World\nGood bye") > ... > | Other than facilitating use of SocketServer.ThreadingTCPServer, > | it seems that asyncore also looks out for termination strings, > | and the "Python Sockets HowTo" infers that using fixed-length > | for message termination is a bad idea. So everything seems to > | be pointing this way. > > I just looked briefly through asyncore.py, and I don't see the > termination string support you mention. Sorry, my mistake. The set_terminator() method is actually in asynchat. I never managed to get asyncore to both send and receive in the same channel. > As I understood it, the > readline() in your SocketServer example was your own code, and > your decision to use a line format. You are right. The SocketServer.StreamRequestHandler interface a filedescripter for reading (rfile) and writing (wfile). So I tried using rfile.read() instead ~ import SocketServer class RequestServer(SocketServer.ThreadingTCPServer): allow_reuse_address = 1 class RequestHandler(SocketServer.StreamRequestHandler): def handle(self): request = self.rfile.read() print "Received message, %s" % request self.wfile.write("Received OK") print "Ending request" This time the request handler hung at the self.rfile.read() until the client socket disconnected with a s.close(). Until that moment, the client socket could send multiple data segments with s.send(). In such a scenario, it seems that a delimiter is not even needed, as long as the message is kept smaller than the buffer, so this might be an even simpler solution. > If you want to use a line separated format, that's OK with me, > and \r\n is definitely a classic line separator. But it isn't > by any means the only right way to do things, and particularly > if the data can conceivably under any circumstances contain the > separator, it's actually the wrong way. The right way would, > of course, be XML! (Just kidding.) A common alternative to > line separation and fixed length is counted length - send the > size of the text data, and then the text itself. OK, did this as per Chris' e-mail too. Chris wrote: > LLLLYYYYTTTTTTTTTTTTTTTT > > Where: LLLL = total length of this message in bytes Following works fine ~ import SocketServer class RequestServer(SocketServer.ThreadingTCPServer): allow_reuse_address = 1 class RequestHandler(SocketServer.StreamRequestHandler): def handle(self): # Read the length YYYY request = self.rfile.read(4) length = int(request) print "Total length = ", length # Read off that many more bytes message = self.rfile.read(length) print "Received message, %s" % message self.wfile.write("Received OK") print "Ending request" host = "127.0.0.1" port = 1111 server = RequestServer((host, port), RequestHandler) print "SERVER : listening to socket [%s:%s]" % (host, port) server.serve_forever() Thanks for the help guys. Stephen From jdhunter at nitace.bsd.uchicago.edu Tue Nov 6 11:01:28 2001 From: jdhunter at nitace.bsd.uchicago.edu (John Hunter) Date: Tue, 06 Nov 2001 10:01:28 -0600 Subject: Tkinter bind single key References: Message-ID: >>>>> "Prabhu" == Prabhu Ramachandran writes: Prabhu> self.__canvas.bind('', self.zoomin) or Prabhu> self.__canvas.bind('', self.zoomin) Thanks for the suggestions, and for the pointer to keysymdef.h. Unfortunately, I am having no luck. I am working with the key 'z' to simplify. All I want to do is bind an event to the 'z' keypress. I have tried (without success): frame.bind('', press_z) frame.bind('', press_z) frame.bind('', press_z) frame.bind('KeyPress-z', press_z) frame.bind('Key-z', press_z) frame.bind('z', press_z) Ditto for 'plus' My keysymdef entries are: #define XK_z 0x07a #define XK_plus 0x02b Here is the test script; the mouse binding works fine: #!/usr/local/bin/python from Tkinter import * def press_z(event): print 'You pressed z' def press_mouse(event): print 'You pressed mouse-1' root = Tk() frame = Frame(root, width=500,height=500) frame.bind('', press_z) frame.bind('', press_mouse) frame.pack() root.mainloop() From sholden at holdenweb.com Wed Nov 14 07:46:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 14 Nov 2001 07:46:19 -0500 Subject: Configure Python CGI failed References: <9st2pt$158u4s$1@ID-12869.news.dfncis.de> Message-ID: <8FtI7.17605$vQ1.704641@atlpnn01.usenetserver.com> You should look in your Apache error log to see what's been entered there - you usually find much more information than you get in the browser, and it's often obvious what the problem is. Before going further, try the following: 1. Write a Python script and put it in the standard Apache cgi-bin directory, which comes ready-configured to run programs. This will eliminate configuration as a source of the problem. 2. Put a "shebang" line at the start of the script to tell Apache where to find the Python interpreter and identify the script as a script. It will look something like #!C:/Python21/python.exe 3. See if you can run this script in a browser. If not, make sure you check the Apache error log, and include any entries in it, as well as copying the exact browser error message, in a further post. Good luck! regards Steve -- http://www.holdenweb.com/ "Kick" wrote in message news:9st2pt$158u4s$1 at ID-12869.news.dfncis.de... > I use the follwing envioment to run pythin CGI: > > Windows 98 > Apache 1.3.22 > Active Python 2.11 > > I change the document root setting to my own directory. And add ExecCGI > option to that directory description. finally I changed AddHandle statement > to .cgi .py. > > When I try to execute a program located in my document root, the IE said > "Internel Error" > > What's wrong with my setting? > > Thanks for any help!! > > From maxm at normik.dk Fri Nov 23 03:51:06 2001 From: maxm at normik.dk (Max M) Date: Fri, 23 Nov 2001 09:51:06 +0100 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: <3bfe0df6$0$74762$edfadb0f@dspool01.news.tele.dk> "jcrowe" wrote in message news:iXlL7.966$mF3.18471 at eagle.america.net... > As far as I know you are stuck with cgi pages. CGI isn't really bad. there > are lots of good web apps written using CGI & Perl. But in my opinion it's > like riding a bike when you have the keys to a car. This I don't really understand. You can use Python in ASP, no problem. Even though you have to code a little different than you do in VB/JScript. Also the cgi module makes it very easy to write webpages in Python. At least as easy as VBScript in asp I think. Usually more, as VB/Jscript has no libraries and you have to spend most of your time surfing the web for semi-functional ActiveX components. Even for something as simple as file upload and jpeg rescaling. Not being able to make an ugly mess of your code by mixing it with html is really not a problem. Furthermore if you use something like mod_python, speed is not the problem. As soon as you go a little bit deeper asp quickly looses it's glory and ease of use. With Python on the other hand there are severel different open frameworks you can use to develop your apps in. Zope being the most famous one. Regards Max M From dhaaron at hotpop.com Sat Nov 3 23:55:05 2001 From: dhaaron at hotpop.com (Aaron Sterling) Date: Sun, 04 Nov 2001 04:55:05 GMT Subject: newbie Tkinter Text widget question Message-ID: <1103_1004849705@t4q4p0> hello exhalted python hackers, I understand that the Text widget has a built in tag called 'sel' or SEL. The question is how do I find the start and end of this (or any other) tags range. The Text class does not seem to define a method to do this. humbly awaiting an answer, aaron From news at davidglasser.net Mon Nov 26 21:56:45 2001 From: news at davidglasser.net (David Glasser) Date: Mon, 26 Nov 2001 21:56:45 -0500 Subject: function operators References: <3C02F6A3.941CCB5E@earthlink.net> Message-ID: <1f3i29s.cvf9nmpytuvkN%news@davidglasser.net> Hans Nowak wrote: > def __add__(self, other): > assert isinstance(other, ComposableFunction) > def glue(*args): > return self.f(*args) + other.f(*args) > return glue To make it even cleaner, how about 'return ComposableFunction(glue)'? -- David Glasser news at davidglasser.net http://www.davidglasser.net/ From qrczak at knm.org.pl Fri Nov 9 12:09:54 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 9 Nov 2001 17:09:54 +0000 (UTC) Subject: iters on ints? (reducing the need for range/xrange) References: <52e5ab5f.0111090851.2d4e023d@posting.google.com> Message-ID: 9 Nov 2001 08:51:05 -0800, Michael Robin pisze: >>>> lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>>> # this works, or gives "list index out of range" >>>> for i in len(lst): print lst[i] > or >>>> # this works, or really calls the fn eleven times >>>> for i in 10: doSomethingTenTimes() > > Only one of these can work - the above are either equivalent to > the interval [0..9] or [0..10] No, they both work, because it would be equivalent to [0..9]. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From sholden at holdenweb.com Fri Nov 30 18:31:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 18:31:27 -0500 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: "Erann Gat" wrote in message news:gat-3011011406550001 at eglaptop.jpl.nasa.gov... > In article , > morpheus at here.not.there wrote: > > > It is not backwards compatible if it solves your problem and if it is it > > doesn't solve your problem. As you can see in the second test the first line > > does not denote the end of the block because of the semicolon at the end. > > This is legal now. Under your proposal it would become illegal breaking > > compatibility. > > No, it would not become "illegal" under my proposal. Please go back and > re-read what I wrote, and pay particular attention to the word "optional". > Perhaps it wouldn't be "illegal". I think the point was that there may well be existing Python programs which are currently syntactically correct whose meaning would be altered by the adoption of your rule. If under present syntax I write def a(x,y): stm1 stm2 stm3; this is currently legal Python in which stm3 is not a part of the function body. Would your rule treat this as a syntax error, or observe the indentation and accept it? Or something else? regards Steve -- http://www.holdenweb.com/ From tim.one at home.com Sun Nov 4 16:00:02 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 16:00:02 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: <7xy9lmmmx7.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > Knuth says to use floor_mod? Where? Knuth *defines* x mod y as being x - y * floor(x/y), way back in volume 1. It simply has the nicest properties when x and y are ints and y > 0. > Every CPU that I know of uses trunc_mod (your 1st variant). A great many CPUs have no "mod" instruction at all; most with an integer division instruction truncate, possibly due to an unfortunate feedback loop involving early Fortran <0.7 wink>. > Floor_mod makes more sense for a lot of things. I can't help > thinking there must be a reason for all the implementations > using trunc_mod, but I don't know what it might be. Why do almost all PC keyboards have a giant CAP LOCKS key where the CTRL key ought to be? It's not really because they wanted to trick Sun keyboard users (or, at least, I hope not ). traditionally y'rs - tim From rnd at onego.ru Mon Nov 19 13:39:48 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 19 Nov 2001 21:39:48 +0300 (MSK) Subject: No, not THAT Python, THIS Python! In-Reply-To: <15352.47914.377014.144821@monster.linux.in> Message-ID: On Mon, 19 Nov 2001, Prabhu Ramachandran wrote: >>>>>> "BO" == Ben Ocean writes: > > BO> Hi; My server has 2 installations of python: 1.5 and > BO> 2.1.1. Now that Zope uses 2+, I've switched everything > BO> over. I'd like to install Tkinter, but when I try to install > BO> the rpm for 2.1.1 I get an error instructing me that I need > BO> Python 2.1.1 in order to proceed. How do I inform Linux (RH > BO> 7.1) that I do indeed have python2-2.1.1? TIA, BenO > >I guess you installed Python-2.1.1 from a source tarball? If that is >the case, you could simply rebuild/re-install 2.1.1 along with Tkinter >support. Maybe just use --nodeps option will help? Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Monday, November 19, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "I wouldn't touch the Metric System with a 3.048m pole!" _/ From guuge at localhost.localhost Mon Nov 19 10:23:18 2001 From: guuge at localhost.localhost (guuge) Date: 19 Nov 2001 15:23:18 GMT Subject: something Evil happens when large hashes destroyed References: <9t8m1c019qd@enews1.newsguy.com> Message-ID: <9tb8561vqq@enews1.newsguy.com> On Sun, 18 Nov 2001 11:37:19 -0600, Skip Montanaro wrote: > > guuge> I was trying to sort about 100,000 items by splitting them into > guuge> groups (using a python dictionary type) and then successively > guuge> splitting these groups until they were small enough to use a > guuge> brute force method. > > guuge> My test program, which used only two or three keys to create the > guuge> first split, worked fine. When I tried the real thing, using 256 > guuge> keys, the program slowed to a crawl. The python interpreter took > guuge> forever to destroy the dictionaries. > > I believe this topic has been discussed recently. When a dictionary is > deleted, the keys are traversed in their "natural order", that is, as they > are laid out in the dict. However, the values stored in the dict are > scattered all over the place, so lots of small chunks of memory are freed. > Your underlying malloc library is probably spending lots of time trying to > coalesce small chunks of freed memory into bigger chunks. > > One workaround seems to be to compile Python with pymalloc enabled. Pymalloc did the trick :) All destroy times are now a few seconds. Thanks. > Another is to use sys._exit to exit your program (assuming the storage > for your big hashes are getting reclaimed at program exit). > > On the other hand, are you sure you're not just running out of memory? 140 megabytes The program never used more than about 20 or 30. > > -- > Skip Montanaro (skip at pobox.com - http://www.mojam.com/) > From fperez528 at yahoo.com Mon Nov 12 09:12:13 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 13 Nov 2001 13:40:13 +2328 Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> Message-ID: <9ss0h1$2so$1@peabody.colorado.edu> Huaiyu Zhu wrote: > On Tue, 13 Nov 2001 16:55:48 GMT, Terry Reedy wrote: >>A recursive implementation like [snip] > Since m and n are symmetrical, one could also compare them and choose > between space optimization vs recursion depth optimization. The problem with all these forms is that they grow in execution time with the parameters (though they are exact, if they use longs). Here's a constant-time version, which is however limited to the range where the answer fits in a float (I fixed some things from yesterday's version). For low values of m this is expensive, but once m gets big it's immensely faster. If one really needs speed, the ideal solution is probably a combination of a good recursive solution for low m with this version for high m, and caching of results for low (m,n) values if those are commonly needed. from Numeric import * #----------------------------------------------------------------------------- def gammln(x): """Return the natural log of gamma(x)""" cof = array([76.18009172947146,-86.50532032941677, 24.01409824083091,-1.231739572450155, 0.1208650973866179e-2,-0.5395239384953e-5],Float) y = arange(x+1,x+7,typecode = Float) tmp = x+5.5 tmp -= (x+0.5)*log(tmp) ser = 1.000000000190015 + sum(cof/y) return -tmp+log(2.5066282746310005*ser/x) #----------------------------------------------------------------------------- def bico(n,k): """Return binomial coefficient (n k)""" return floor(0.5+exp(gammln(n+1.0)-gammln(k+1.0)-gammln(n-k+1.0))) #----------------------------------------------------------------------------- def combi_dist(m,n): """Return the number of combinations of m mutually distinguishable elements in which each element may occur 0,1,2,...,n times in any combination. Constant time, uses floats.""" # this is just bico(m+n-1,n). Write it out explicitly for speed nn = m+n-1 kk = n return floor(0.5 + exp(gammln(nn+1.0)-gammln(kk+1.0)-gammln(nn-kk+1.0))) This bypasses the issue of explicitly building the factorials by computing them through a gamma function (the implementation is from Numerical Recipes, so not necessarily the best). Cheers, f From d_blade8 at hotmail.com Fri Nov 2 02:52:44 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 1 Nov 2001 23:52:44 -0800 Subject: .exe References: <9rkcbb$ucb5d$1@ID-69142.news.dfncis.de> Message-ID: <7396d2b2.0111012352.469697e5@posting.google.com> Actually, get both py2exe and the Installer. You never know what you are going to like. I like the installer because you can use Simple, Freeze, etc. for differing goals. I wrote a little script (convert.py, of course) that prompts the user to enter the name of the .py file to be converted. It imported everything it needed so then I ran the file on itself, and Voila!, I have an exe that will convert any .py file to an exe for me (it gives me GUI choices such as whether to use Simple, Freeze, etc.). For me, Installer worked better in this respect but that is just me. In other words, try them both, look at the code, figure out what you want, and then you can be picky. One quick side note, if you want/need to keep your code 'closed-source' read the FAQ about Installer (the generated exe will have the code in it, if you know what I mean). Later. Benjamin Schollnick wrote in message news:... > In article <9rkcbb$ucb5d$1 at ID-69142.news.dfncis.de>, > "Andreas Penzel" wrote: > > > Hello NG! > > > > Is it possible to make an .exe file from the .py soure running under > > DOS/Windows? > > > > Thanks! > > - Andreas > > Yes, use Gordon Mcmillian's "Installer".... > > (And it's easier than py2exe)... > > - Benjamin From mertz at gnosis.cx Thu Nov 15 03:47:30 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Thu, 15 Nov 2001 03:47:30 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: David Eppstein wrote: > You seem to be inconsistent here about whether you want these ranges to be > open or closed on the right. I think closed is the only reasonable > choice for this syntax. Jeff Shannon wrote: |Which is exactly why I think that the Haskell-ish syntax is a bad idea. This |syntax cries out to be a closed interval, and it would be very confusing if |used as a half-open interval. But that would make it the *only* case of |Python using a closed interval. Well, not the -only- case. '[1,2,3,4,5]' looks like a closed interval to me... one whose ends are 1 and 5. But I do think that the square brackets -have- to indicate a (mostly) closed interval. I mentioned elsewhere that it is not entirely closed, since the increment can overshoot the end bound (and then neither the end bound nor the overshooting element are included). But for the count-integers-by-ones common case, the Haskell style is closed. What I would really like for Python would be the option of -explicitly- creating half-closed/half-open intervals. I don't really think there is any chance it will happen, but the syntax '[0 .. 5)' seems very natural to me (and familiar from mathematics). The down side might be that it seems to imply that '(0 .. 5)' is double-open and '[0 .. 5]' is double-closed. Even though the ellipsis/iteractor dots maybe distinguish this form, it starts to look disturbingly overloaded with the tuple/list distinction. One might use some other symbol for the open interval. '[0 .. 5>' is also something one sees in math. But I am pretty sure the parser would necessarily choke on that. '[0 .. 5}' doesn't look too awful, and is probably parsable. Then you get into multi-character possibilities like '[- 0 .. 5 -)' or the like. But I think by that point we are skating *way* too close to the line-noise of P**l. Yours, Lulu... From mjackson at wrc.xerox.com Fri Nov 2 08:58:40 2001 From: mjackson at wrc.xerox.com (Mark Jackson) Date: 2 Nov 2001 13:58:40 GMT Subject: Monty Python (was: Freeware Python editor) References: Message-ID: <9ru8qg$j9i$1@news.wrc.xerox.com> quinn at retch.ugcs.caltech.edu (Quinn Dunkan) writes: > On 1 Nov 2001 15:27:34 GMT, Mark Jackson wrote: > >Evidently Monty Python is funny in French. We once went to see Holy > >Grail in Paris and it's a good thing we knew the dialog by heart; since > >the audience could read French subtitles faster than the actors spoke > >in English there wasn't a single punchline that wasn't drowned out by > >audience laughter. > > I'm just curious. How did the "you can tell I'm French because I have this > outrrrrrageous accent" part get translated? Honestly, we didn't notice. We were concentrating on listening, not reading. -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson After a recent trip to New York one French journalist remarked that leafing through a copy of /Forbes/ or /Fortune/ is like reading the operating manual of a strangely sanctimonious pirate ship. - Adam Gopnik From mwh at python.net Wed Nov 14 05:14:18 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 10:14:18 GMT Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: Roy Smith writes: > ianb at colorstudy.com (Ian Bicking) wrote: > > If you look under the hood, Python is much more like Smalltalk than > > Java. > > I'm having trouble parsing that. Which of the following did you mean? > > 1) Python is more like Smalltalk that Python is like Java > 2) Python is more like Smalltalk than Java is like Smalltalk I think 1). Cheers, M. -- 39. Re graphics: A picture is worth 10K words - but only those to describe the picture. Hardly any sets of 10K words can be adequately described with pictures. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From daves_spam_dodging_account at yahoo.com Wed Nov 21 14:52:53 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Wed, 21 Nov 2001 11:52:53 -0800 (PST) Subject: DDE Client? Message-ID: <20011121195254.51281.qmail@web21103.mail.yahoo.com> > -----Original Message----- > From: Patrick Vrijlandt [mailto:p.vrijlandt at aig.azn.nl] > > I'm afraid python dde leaks memory, but I haven't > checked the source and have no confirmation from > the author. If your application crashes after a > few thousand dde-calls, think of this. Eww. The spec I'm leaning towards is to be able to run long-term and stable, with several thousand DDE calls per day. I wonder if it's Python that loses it or DDE itself. I recall finding a bug WAYYYY back when in the early DDE implementation. StdDde.c used a linked list of topics, and IIRC deleting a topic had a bug in it that would delete the desired node WITHOUT reattaching the prev node to the next node. This has probably changed since then; this was in my early coding days working with MFC 2.x. Any thoughts? Who is the author, Mark Hammond? Thanks, -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From wzdd at lardcave.net Tue Nov 27 10:23:16 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Wed, 28 Nov 2001 02:23:16 +1100 (EST) Subject: Non-Indented python In-Reply-To: <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: On 27 Nov, Terry Reedy wrote: > "Marcin 'Qrczak' Kowalczyk" wrote in message > news:slrna071tg.isc.qrczak at qrnik.zagroda... >> What should a Python interpreter do with this? >> >> if 0: >> print "0" >> print "1" > > Raise SyntaxError. > > Seriously. > > This would be consistent with general philosophy of not guessing in > the face of ambiguity. Insofar as my opinion makes any difference, I'd like to second that suggestion. The huge tab/space war above notwithstanding, I think that regardless of your preference, any file with mixed space/tab indenting is inherently evil and will only cause pain. I was aimlessly toying with the idea of writing a little utility to detect mixed space/tab indents in files and setting it to run whenever I do a CVS checkout or update, but I always welcome the opportunity to banish devilry on a more far-reaching scale. :) -- - Nicholas FitzRoy-Dale http://www.lardcave.net Feel my three-toed wrath! - Catie From lfini at arcetri.astro.it Tue Nov 20 07:35:36 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Tue, 20 Nov 2001 13:35:36 +0100 Subject: Still on python GUI toolkit Message-ID: I'm trying to make a sound decision of which GUI toolkit to use for a new software project (it is the control and supervision system for a complex scientific instrument). My target system is Linux both for development and for the final system, although portability to Windows coud be a plus. After browsing through the various comparisons I could find around I stripped down the list to three of them: Tkinter, wxWindows, PyQt. After some pain in the neck (mostly due to my own fault) and the help of peoples fron this and the PyKDE newsgroups I've succeeded in running a very simple application in the three different GUI toolkits for comparison purposes and I'd like to share my results and maybe to get more comments/suggestions. The application I tested is a pixel-intensive type of application because it is the most challenging of the tools I will need: it displays continuously an 80x80 syntetic image randomly generated with 256 graytones, by using small filled squares for each pixel. I coded the three versions in python to my best knowledge (which is almost zero) of each toolkit. My results are as follows: 1. The Tkinter version runs very close to half the speed of either PyQt and wxWindows. The latter two are very close by. 2. The code structure in Tkinter application is pretty different from the other two toolkits which are, again, very close. I mean you get classes which very similar in syntax and semantics; I actually coded the PyQt version from the wxWindows one almost only by changing names to the classes. 3. wxWindows and PyQt are richer than Tkinter in that they both provide more complex widgets and more control on many aspects. I've also the feeling that PyQt/wxWindows applications are somewhat more complex to code, but this could depend on the fact that I know Tkinter sligthly better. 4. Tkinter is better integrated into python distributions. 5. I'm not used to integrated environments, so I've not tested this particular point. Having said that I believe that I'll drop Tkinter on a speed basis, and also because if I actually need more efficience on some specific tools I can code them in c++, and my feeling is that it's easier with either PyQt and wxWindows than with Tkinter. I'm still trying to make a choice between PyQt and wxWindows and I'd like comments and suggestions on this point. Many thanks, l.f. -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From tim at zope.com Thu Nov 29 14:10:48 2001 From: tim at zope.com (Tim Peters) Date: Thu, 29 Nov 2001 14:10:48 -0500 Subject: list.sort() fails under Solaris 5.8 for Python 2.1 In-Reply-To: Message-ID: [Andres Corrada-Emmanuel] > I'm having problems with list.sort() on a Solaris 5.8 machine. > > My program reads a file that consisting of three columns that it then > sorts using list.sort(). > > If the input file is small enough (~400 lines), the right output is > obtained. If the file is large (~40K lines), the sort silently fails and > the list is returned unsorted as originally found in the file. > > Has anyone else seen this? No bugs have been reported against list.sort() since Python stopped using the platform C's qsort. Make the input file and a small test program available, so others can try it? From bill-bell at bill-bell.hamilton.on.ca Sun Nov 11 15:05:00 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Sun, 11 Nov 2001 15:05:00 -0500 Subject: Using browser as interface to python app In-Reply-To: <1005502589.987.16793.m12@yahoogroups.com> Message-ID: <3BEE939C.32623.65EFE17@localhost> sandskyfly at hotmail.com (Sandy Norton) wrote, in part: > I'm simply trying to use the browser as an interface to a small python > program that retrieves and parses webpages and then publishes the > results in an html page. I would like for example for the user to be > able to configure the app via the browser (by selecting checkboxes and > whatnot) without having to use a command-line menu or a full blown GUI > such as wxPython or Tkinter. Not a problem for a Windows-only app: just convert what you have into an "HTA". Scott Roberts: "An HTML Application (HTA) is a full- fledged Windows application that you can create by using only DHTML and script ... it appears to your users to be a normal Windows application ... unlike a web page, an HTA is trusted." ("Programming Microsoft Internet Explorer 5", MS Press) Further, when you install the Activestate distribution of Python, as a bonus you receive the ability to use Python as a (Windows) scripting language. That is, you can include Python code in HTML 'script' elements. When you need to display your results just launch IE itself with the page you've created. What more could a person want? Well, in your case, cross-platform functionality. :o) This is where I draw a blank. Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From dgallion1 at yahoo.com Fri Nov 2 23:46:46 2001 From: dgallion1 at yahoo.com (Darrell) Date: 2 Nov 2001 20:46:46 -0800 Subject: [ #456742 ] Failing test case for .*? Message-ID: Forgot the link. http://sourceforge.net/tracker/?func=detail&aid=456742&group_id=5470&atid=105470 From sandskyfly at hotmail.com Sun Nov 11 10:28:23 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 11 Nov 2001 07:28:23 -0800 Subject: Using browser as interface to python app References: Message-ID: wrote in message news:... > Have you considered a GUI built with Flash 5.0? It's very nice for > straightforward business apps, and is pretty much agnostic on the browser > and screen-resolution front. As long as you're just using Windows-type > widgets, etc., there's really no loading time. You'll probably think it's > overkill, but it's really no harder than HTML (and a heck of a lot simpler > than Tkinter, etc.) You're likely to spend an awful lot of time futzing > with HTML and Javascript in order to serve up those web pages... Cool idea.... but I'm clueless as to how this would be done. How would you get the python interpreter to handle data inputed into the flash interface and then pipe the output back to the browser? Do you have examples for doing this? Sandy From johnroth at ameritech.net Fri Nov 16 00:49:33 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 15 Nov 2001 21:49:33 -0800 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> <9t1uce$5d8$1@nntp1-cm.news.eni.net> Message-ID: Didn't we discuss this a month or two ago? There was quite a bit of talk about speeding up access to module level names and so forth, even going into the changes needed in the bytecode set, and possibly even an implementation. John Roth "Stuart D. Gathman" wrote in message news:9t1uce$5d8$1 at nntp1-cm.news.eni.net... > In article <7xu1vvo432.fsf at ruckus.brouhaha.com>, "Paul Rubin" > wrote: > > > I think it's more important to optimize locals and class attribute > > references (local.x.y.z), than globals. > > The SymbolTable/array separation optimizes class attributes. You missed > that section in my first post, so I'll repeat it in different words here. > > The SymbolTable is stored with the class - initialized to all class > attributes mentioned in the code defined within the class. The attribute > array is stored with each instance. Dynamically adding attributes to a > class is handled by > > a) growing the class SYmbolTable and expanding instance attribute arrays > as needed. This could result in lots of unused instance slots when lots > of random identifiers are added dynamically. > > b) keeping an auxilliary dictionary for attributes not mentioned in the > initial class definition. > > I guess the big problem is accounting for a class possibly overriding > attribute fetching. However, if we simply *always* call __getattr__, and > the default definition simply follows the same strategy as the load global > and is coded inline, then a class attribute lookup is essentially > equivalent to two optimized globals. > > E.g. > > load class idxOf__getattr__ # cached like global access if not > defined: > load class idxOfName # cached like global access > else: > call __getattr__ > > -- > Stuart D. Gathman > Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 > "Confutatis maledictis, flamis acribus addictis" - background song for > a Microsoft sponsored "Where do you want to go from here?" commercial. From timr at probo.com Tue Nov 6 01:24:40 2001 From: timr at probo.com (Tim Roberts) Date: Mon, 05 Nov 2001 22:24:40 -0800 Subject: Python packages - problems, pitfalls. References: Message-ID: Prabhu Ramachandran wrote: > >Recently I discovered that there is some very unfortunate behaviour >with python packages. > >Lets say I have a directory 'pkg' that is the root of a package. >Inside this directory I have a sub-package, called sub. So its >something like: > >pkg/ > __init__.py > a.py > sub/ > __init__.py > b.py > >Now, from b I'd expect to be able to import 'a' straight away. > >Say in b.py I do > >import a > >This will not work! But this will: import os os.path.append('..') import a That's what I've used in a similar situation. Is that really so horrible? -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From wurmy at earthlink.net Sun Nov 18 21:54:49 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Mon, 19 Nov 2001 02:54:49 GMT Subject: List-of-lists (aka array) mystery References: <4f49f3e8.0111181832.7162be1b@posting.google.com> Message-ID: <3BF8746D.ABBBE1BB@earthlink.net> aardvark wrote: > > Hi everyone > > A friend of mine has discovered some interesting behavior with > lists-of-lists (I suppose some call them "arrays"). When you define > (or "initialize") a list-of-lists using the range() function, then set > a value within one of the inner lists, the value of each inner list > item in that same position becomes the new value. When you explicitly > define (or "initialize") the list-of-lists the behavior is as > expected, i.e. only the value in the list position you specified, > within the list you specified, is changed. > > A better way to show this is with an example: > > Definition using range: > > >>> x=[range(-1,0)*3]*3 > >>> x > [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]] > >>> x[1][1]=0 > >>> x > [[-1, 0, -1], [-1, 0, -1], [-1, 0, -1]] > > I did not expect x[0][1] and x[2][1] to become 0. I only expected > x[1][1] to become 0. This does not happen when you explicitly define > the list: > > >>> x=[[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]] > >>> x > [[-1, -1, -1], [-1, -1, -1], [-1, -1, -1]] > >>> x[1][1]=0 > >>> x > [[-1, -1, -1], [-1, 0, -1], [-1, -1, -1]] > > Why is this? It would seem that multiplying the result of the range() > function twice returns pointers to a single list rather than discrete > lists. Is there a better way to initialize lists-of-lists? Should I be > going about this differently? It's a FAQ: http://www.python.org/cgi-bin/faqw.py?req=all#4.50 Note that this behavior is unrelated to range. HTH, From shriek at gmx.co.uk Sat Nov 24 00:29:22 2001 From: shriek at gmx.co.uk (Stephen) Date: 23 Nov 2001 21:29:22 -0800 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> <3bfecd77@brateggebdc5.br-automation.co.at> Message-ID: <97ae44ee.0111232129.550244cd@posting.google.com> Thanks for the reply, Werner. Now that you told me I should be searching for rotormodule.c as opposed to rotor.py, it was much easier. EG. http://www.mit.edu/afs/sipb/project/python/src/Python-2.1/Modules/rotormodule.c Which also answers my other question about it being available in C (obviously, it is !). Rewriting this in Java should be straightforward. Lance Ellinghouse (who wrote rotormodule.c) also writes that the output "is considered BINARY data" so a CRLF, LF or CR are not possible output. Reading his comments, this does not seem to be a "standard" rotor. However, having the C and Java equivalents will suffice at the moment. Makes me wonder why more people don't use the rotor when they need "just enough" encryption without going the full hog with PKI. Just to clear up my own understanding, is it fair to say that a "built-in" module can be defined as one that is included in the core Python distributed, and is written in C as oppopsed to Python, but which still needs to be imported before use ? Stephen > "Stephen" wrote in message > news:97ae44ee.0111231225.22760e5c at posting.google.com... > > Does the Python 'rotor' module conform cross-language algorithm > > that is also used in the corresponding C & Java libraries ? > > If so, where could I find the algorithm ? > > Sorry, no idea. > > > Why isn't rotor.py > > in the Python lib directory ? > > > > The rotor modul is built into the python library (at least in my > ActivePython 2.1.1 distribution) > If it is not builtin, it is still a C extension module (rotor.pyd for > Windows, probably rotor.so or rotormodule.so on *nix) > > You find the C sourcecode in the file Modules/rotormodule.c (if you have > source code installed, of course). > > > Also, is it possible for the output of the rotor to ever > > include \r, \n or CRLF ? > > > > see 1st remark :-) > > > hth > Werner From mgerrans at ix.netcom.com Fri Nov 30 16:28:37 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Fri, 30 Nov 2001 13:28:37 -0800 Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> <3c021287@brateggebdc5.br-automation.co.at> Message-ID: <9u8tl3$v8d$1@nntp9.atl.mindspring.net> > > I've decided to do what I should have from the beginning: always use > > string.join. I didn't want to because it seemed silly to import a whole > > module for one function, and as long as I'm using Official String Methods > > for everything else I should use them for joins too. > > I think this is no big deal, since the string module maps most of its > actions including join to the string methods. > Of course, this will slightly reduce the performance, but the module itself > is pretty light-weight. > > Moreover, I think readable code is more important than performance. Additionally, if you really hate to import string, this is easy enough to add: def join( seq, sep=' ' ): return sep.join(seq) - mfg From vigtest at hotmail.com Thu Nov 8 14:57:40 2001 From: vigtest at hotmail.com (Tom Higgins) Date: Thu, 8 Nov 2001 14:57:40 -0500 Subject: HOWTO change user on UNIX for os.system Message-ID: <2rBG7.27968$LD.1025113@e3500-atl2.usenetserver.com> Is there any way to su or login as a different user within a python script? I mainly need to discover a method which accepts a password from with the script. Regards, Tom From jbell at iinet.net.au Mon Nov 12 20:04:15 2001 From: jbell at iinet.net.au (John Bell) Date: Tue, 13 Nov 2001 09:04:15 +0800 Subject: Indirect Class Instance Invocation References: <3BF067CF.520F8E5C@iinet.net.au> Message-ID: <3BF0718F.BA671782@iinet.net.au> John Bell wrote: > I feel that this should be do-able, but can't see how. If I have some > class foo and string s='foo', can I invoke bar as an instance of foo > given only the string s? (ie. bar=(something on s)() )A kind of setattr > for classes rather than attributes. > > John > Disregard that, I realised the error of my ways a couple of minutes after > posting. I need more sleep! From sdm7g at Virginia.EDU Tue Nov 13 18:23:44 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Tue, 13 Nov 2001 18:23:44 -0500 (EST) Subject: dynamically generating a module In-Reply-To: <8ef9bea6.0111131459.38f96699@posting.google.com> Message-ID: On 13 Nov 2001, Hung Jung Lu wrote: > Here is one more challenge: is it possible to create a module on the > fly? > > Suppose I have the ASCII Python source code of a module-to-be, or even > better, suppose that I have the compiled byte code of a module-to-be, > stored in a Python string. Is there a simple way (meaning not tweaking > at C++ level) of making the module-to-be into a real module, without > hitting the harddrive? Sure: all you have to do is create an empty module and exec the code in that modules namespace: import new codestr = open( source_file ).read() ## source code in codestr module1 = new.module( 'module1' ) ## create a new, empty module exec codestr in module1.__dict__ ## exec code in module namespace dir( module1 ) ## inspect contents ## or, with a compiled module module2 = new.module( 'module2' ) code = compile( codestr, 'none', 'exec' ) ## 'none' can be anyname exec code in module2.__dict__ -- Steve From shriek at gmx.co.uk Fri Nov 23 15:25:56 2001 From: shriek at gmx.co.uk (Stephen) Date: 23 Nov 2001 12:25:56 -0800 Subject: Does rotor follow a cross-language encryption algorithm ? Message-ID: <97ae44ee.0111231225.22760e5c@posting.google.com> Does the Python 'rotor' module conform cross-language algorithm that is also used in the corresponding C & Java libraries ? If so, where could I find the algorithm ? Why isn't rotor.py in the Python lib directory ? Also, is it possible for the output of the rotor to ever include \r, \n or CRLF ? Stephen. From bemwom at salon.com Wed Nov 14 19:08:44 2001 From: bemwom at salon.com (Cristof Bryant) Date: Thu, 15 Nov 2001 00:08:44 GMT Subject: access greed? Message-ID: <20db6273.38778ed9@nntp.salon.com> Above all, think this through: Why is spam so annoying? Because you like the ease and convenience of e-mail, that's why. So your in box matters to you. Over the last decade it has become hugely easier and quicker for you to contact others on a much bigger scale than photocopied letters or even fax machines ever let us dream of. And you resent the fact that hundreds of thousands of nobodies now find it correspondingly easier to contact you? This is worse than snobbery; this is "access greed": wanting to have access to others for yourself but for them not to have access to you. This is the dirty secret of the anti-spammers. You want free speech for yourselves, and perhaps for others sometimes -- as long as you don't have to listen too often. Even listening for the 30 seconds it takes to delete a bunch of uninvited petitions is apparently too much for these people. Free speech -- as long as it has a nice, secure one-way valve attached? http://www.salon.com/tech/feature/2001/11/14/spam_love/index.html -- Tell Donald it's light smelling over a twig. From loewis at informatik.hu-berlin.de Fri Nov 9 07:05:32 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Nov 2001 13:05:32 +0100 Subject: NetBSD and threading errors References: Message-ID: Felicia Neff writes: > It does not fail with the same version of python compiled without threads. > Any help would be greatly appreciated. I think the common understanding is that threads on NetBSD simply don't work, because the system thread library has too many bugs. So I suggest to disable threads on that system. Regards, Martin From slinkp23 at yahoo.com Thu Nov 8 14:01:10 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 08 Nov 2001 19:01:10 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> <9sebn1$28g$1@news.lth.se> Message-ID: On Thu, 8 Nov 2001 17:24:55 +0100, David Andreas Alderud wrote: >Strange since in every report I've seen on productivity Smalltalk wins and >Ada in general is on a strong second place, C++ productivity is generally >considered to be 1/6:th or lower of Smalltalk for example. Anybody done such studies with python in the list? I'm curious how it would fare. (Of course I want to think it would rate very highly...) --PW From mwh at python.net Thu Nov 15 05:55:42 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 15 Nov 2001 10:55:42 GMT Subject: How to marshal a function? References: Message-ID: pinard at iro.umontreal.ca (Fran?ois Pinard) writes: > Earlier today, I wondered how to marshal a function, in view of > transmitting it to a remote machine and executing it there. The > idea was to not transmit Python source, when the byte-compilation > has already been done on this side. > > I quickly found out that, for a given `function f(...) ...' I should > transmit marshal-ed `f.func_code' instead of `f'. The resulting > code could even be eval'ed or exec'ed on the remote side, if the > function does not require arguments. I did not saw that I could > usefully return something from the function, and surely many other > properties are missing. Moreover, the manual suggests that this is > all internal things, subject to change at any time. The result of > marshal-ing is not guaranteed to work between Python versions, > either. Well, the bytecode has changed between every released version of Python, AFAIK. Certainly 1.5.2->2.0, 2.0->2.1 and 2.1->2.2, and not usually backward compatibly. So you can forget that idea. Cheers, M. -- You owe The Oracle a TV with an 'intelligence' control - I've tried 'brightness' but that didn't work. -- Internet Oracularity #1192-01 From grante at visi.com Thu Nov 1 14:54:09 2001 From: grante at visi.com (Grant Edwards) Date: Thu, 01 Nov 2001 19:54:09 GMT Subject: Monty Python (was: Freeware Python editor) References: <3BE18C8E.D9E75CD4@ix.netcom.com> Message-ID: In article <3BE18C8E.D9E75CD4 at ix.netcom.com>, Antaeus Feldspar wrote: >> On 01-Nov-2001 Oleg Broytmann wrote: >> > On Thu, Nov 01, 2001 at 07:39:31AM -0500, Steve Holden wrote: >> > > [Makes note to remember that Oleg isn't a Monty Python viewer.] >> > >> > Few years ago I tried to view the scetches - there was Russian >> > translation of them on TV - but found them stupid and boring. Well, I was >> > in bad mood those days, may be now I'd find it more interesting :) >> >> You should really watch them in their original language. And I admit, >> some of them are not that great (those where legs and arms are cut off >> and blod everywhere). But then there are the others (for instance the >> dead parrot sketch), where the humour is in the language. And they are >> fantastic. > > Even some of those were much funnier at the time because the audience > understood the references being made. I think some of the humor is lost on us Americans due to to the cultural references that go flying past without comprehension (assuming we can actually catch all of the dialog to begin with). I thought the one German episode was still fairly funny when subtitled... -- Grant Edwards grante Yow! I'm having fun at HITCHHIKING to CINCINNATI visi.com or FAR ROCKAWAY!! From peter at engcorp.com Thu Nov 22 21:33:55 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 22 Nov 2001 21:33:55 -0500 Subject: File Data Extraction Approach References: Message-ID: <3BFDB593.FB377DC5@engcorp.com> "Jim St.Cyr" wrote: > > I have a multiline file of the format: > > : Some Name = data : Another Name = data : etc = data: > > Each line consists of 20 tagnames and associated data. Some of the tagnames > have spaces in them though most don't. There is a space on each side of the > equal sign and on each side of the colon which acts as a field seperator. I > only need the data associated with 7 out of the 20 tagnames. > > I was thinking about removing the whitespace from the line and then seeking > the tagnames that I am interested in. This strikes me as sort of brute > force and I would like some help in formulating an approach that is a bit > more elegant. Just write code that reads *all* the tags and data from a line, then ignore the ones you don't want. Do the work once the data is in a more tractable form (i.e. in memory) rather than trying to dissect the file while it's still a file. Slightly ugly code which makes a dictionary from each line and prints it to stdout: >>> f = open('file') >>> import string >>> while line in f.readlines(): ... d = {} ... for field in line.split(':'): ... if field.strip(): ... tag, data = map(string.strip, field.split('=')) ... d[tag] = data ... print 'Result %s' % d -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From mwh at python.net Tue Nov 6 10:09:23 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 6 Nov 2001 15:09:23 GMT Subject: _nr and callbacks Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <5USF7.3918$Sx.1552470@news1.elcjn1.sdca.home.com> Message-ID: "Frederic Giacometti" writes: > "Michael Hudson" wrote in message > news:uady09pkm.fsf at python.net... > > Martin von Loewis writes: > > > > [schnipp] > > > * Are the _nr versions functionally completely backwards-compatible? > > > If not, why? If yes, why is the original version preserved? > > > > I think the originals are just around because the implementation of > > the _nr variants was tricky and Chris needed something to test > > against. Not sure, though. > > From what I understand in the stackless mechanism, the _nr functions are > used in the Python VM, but cannot be used in C extension callbacks. > In effect, in C extensions (or when embeding Python), Python must return to > the C code after executing the callback. So, distinct hybrid functions, > different from those used by the VM, are still needed. Huh? The builtin_foo functions in Python/bltinmodule.c are all declared static, so you can't call them from C extensions anyway. You could grub around in __builtins__ and call them using PyEval_CallObject or whatever, but do people actually do this? You could still "call" the _nr variants, but any "call" of a C function that might end up calling Python code (i.e. almost anything in the Python C API!) must[1] actually be structured as a stack-push-then-return wotsit like I tried (and probably failed) to explain in the quoted post. > It's true that stackless introduces an additional level of complexity, and > that its implementation could be lifted up. These can be the actual reasons > why this has not been merged... I think Gordon's post got the nail on the head here. Cheers, M. [1] If continuations are to be allowed to escape from the called Python code, anyway. -- Any form of evilness that can be detected without *too* much effort is worth it... I have no idea what kind of evil we're looking for here or how to detect is, so I can't answer yes or no. -- Guido Van Rossum, python-dev From phd at phd.pp.ru Thu Nov 29 06:42:27 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 14:42:27 +0300 Subject: mimedecode.py version 1.1.1 Message-ID: <20011129144227.L16265@phd.pp.ru> Hello! mimedecode.py WHAT IS IT Mail users, especially in non-English countries, often find that mail messages arrived in different formats, with different content types, in different encodings and charsets. Usually this is very good because it allows us to use apropriate formats/encodings/whatever. Sometimes, though, some unification is desireable. For example, one may want to put mail messages into an archive, make HTML indicies, run search indexer, etc. In such situations converting messages to text in one character set and skipping some binary atachmetnts will be much desireable. Here is the solution - mimedecode.py. This is a program to decode MIME messages. The program expects one input file (either on command line or on stdin) which treated as an RFC822 mesage, and decoded to stdout. If the file is not an RFC822 message the file just piped to stdout one-to-one. If it is a simple RFC822 message it is just decoded as one part. If it is a MIME message with multiple parts ("attachments") all parts decoded. Decoding can be controlled by command-line options. WHAT'S NEW in version 1.1.1 Documentation in DocBook v4.1 format. HTML, plain text and manual page. WHERE TO GET Master site: http://phd.pp.ru/Software/Python/#mimedecode Faster mirrors: http://phd.by.ru/Software/Python/#mimedecode http://phd2.chat.ru/Software/Python/#mimedecode Requires: Python 2.0+ (actually tested with 2.1.1), configured mailcap database. Documentation (also included in the package): http://phd.pp.ru/Software/Python/mimedecode.txt http://phd.by.ru/Software/Python/mimedecode.txt http://phd2.chat.ru/Software/Python/mimedecode.txt AUTHOR Oleg Broytmann COPYRIGHT Copyright (C) 2001 PhiloSoft Design LICENSE GPL Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tavis at calrudd.com Fri Nov 23 19:32:36 2001 From: tavis at calrudd.com (Tavis Rudd) Date: 23 Nov 2001 16:32:36 -0800 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: "the Spinning Spider" wrote in message news:<9tia10$43o$1 at dahlia.singnet.com.sg>... > I notice there doesn't seem to be much mention about PHP by Python people > whenever they mention other languages, > e.g.,see http://www.python.org/doc/Comparisons.html. Seeing as there's no mention of PHP on Python's Comparison's page, and this question comes up monthly, I've started a page on the Webware project's Wiki to provide a comparison: http://webware.colorstudy.net/twiki/bin/view/Webware/PythonVsPHP It's a work-in-progress and any can contribute (just register using the link at the top). Once there's some flesh on the skeleton I've laid out, I'll tidy it up and submit it for inclusion on Python's Comparisons page. Cheers, Tavis From max at alcyone.com Wed Nov 14 14:43:04 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 14 Nov 2001 11:43:04 -0800 Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: <3BF2C948.87C9B103@alcyone.com> Michael Hudson wrote: ... > > > Roy Smith writes: > > > > > > > 1) Python is more like Smalltalk that Python is like Java > > > > 2) Python is more like Smalltalk than Java is like Smalltalk ... > No they don't. > > 1) means > > Smalltalk Python Java > ^ ^ > little gap big gap > > 2) means > > Python Smalltalk Java > ^ ^ > little gap big gap > > both are true, but they're not the same. I'm not sure what you intend to signify by the placement of the names on the line. Surely "X is like Y to degree Z" is symmetric with respect to X and Y. If X is very much like Y, then Y is very much like X; if X is very different from Y, then Y is very different from X too. In which case the swapping of Smalltalk and Python on the above diagrams doesn't mean anything and the two statements are in fact equivalent. Unless you want to suggest that X can be very much like Y, but Y can be very different from X, which doesn't make much sense. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From glingl at aon.at Thu Nov 8 01:23:05 2001 From: glingl at aon.at (Gregor Lingl) Date: Thu, 8 Nov 2001 07:23:05 +0100 Subject: How to install blt-extension for Tkinter Message-ID: <3bea2492$0$26760$5039e797@newsreader01.highway.telekom.at> Dear Pythonistas! After having installed successfully Python - MageWidgets and after having run partially successfully the All.py - demo I ran into a problem when trying to install blt - which is necessary to execute some of the options in All.py ( and which I'm rather interested to use): I'm running Python 2.1 in the ActiveState-flavour (including Tcl/Tkinter) under WindowsNT 4.0 I downloaded blt2_4u-for-8_3.exe and then tinkered around a lot of time without success, The installer ran "successfully", but I seem not to know where to install the things correctly (Perhaps the installer doesn't know that I want to know them with Python?). It installs 3 subdirectories: bin include lib but not in the correct place. It doesn't seem to modify then registry (hopefully). So All.py complains still with: "I'm sorry, but btl has not been installed" ... or similar My dir-structure is: C:\Python21\ DLLs Doc Lib libs Pmw pygame tcl\ tcl8.3 tk8.3 ( and more ...) Could anybody help with hints - if I downloaded the correct file - what to enter when asked for the install-dir - how to get it to run (Dirty question, I assume) Thanks in advance Gregor Lingl From tub4jxr at hotmail.com Mon Nov 26 21:04:23 2001 From: tub4jxr at hotmail.com (Jose Rodriguez) Date: 26 Nov 2001 18:04:23 -0800 Subject: IIS with Python Message-ID: <89302408.0111261804.62ec6f@posting.google.com> I have looked at the Python.org site but I must admit that I am a little unsure of whether a separate python interpreter is started on each call from a different IIS session that needs to run some Python code. What I understand, I believe, is that you can script web pages with Python just as you would with ECMAscript but that the Python interpreter starts a separate session for each web call as opposed to using one instance that remains loaded in memory. In addition, the pages aren't then cached so as to prevent an additional hit for future loads of the same pages. I know that I can use ZOPE or Skunkweb but my company is requiring that we use IIS (and all of its native problems). Regards From kragen at canonical.org Sun Nov 25 20:39:10 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 20:39:10 -0500 Subject: Keeping Python loaded References: <9tndpi$qbe$1@slb0.atl.mindspring.net> Message-ID: <83zo5atio1.fsf@panacea.canonical.org> pinard at iro.umontreal.ca (Fran?ois Pinard) writes: > If you merely want to spare disk acceses under Unix, a possible approach > might be to set the sticky bit on the Python executable. You might need > to be super-user to do that: > > chmod 1755 /usr/bin/python > > On the other hand, on Linux at least, the disk cache maintained by > the system might be helpful to the point of not even having to > resort to the above trick. If you're using a version of Unix that runs on hardware that doesn't support paging, such as a PDP-11, then this might help. But I don't think Python runs on any such versions of Unix, so the sticky bit on ordinary files is purely an anachronism. From skip at pobox.com Tue Nov 27 13:53:38 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 27 Nov 2001 12:53:38 -0600 Subject: python vs ecmascript In-Reply-To: References: <01111609593502.02629@logiplex1.logiplex.net> <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> <2NPM7.568$_06.167730@newsb.telia.net> Message-ID: <15363.57650.150923.482890@beluga.mojam.com> Yong> I simply looked up "%" itself. I thought this would be listed as Yong> a special operator. I sent a note to Fred Drake asking if an index entry containing "%" could be added. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From fperez528 at yahoo.com Sat Nov 24 09:38:31 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 25 Nov 2001 14:06:31 +2328 Subject: Scientific Libraries in Python References: Message-ID: <9trmi2$363$1@peabody.colorado.edu> Horatio Davis wrote: > Having read this excellent mud map of the problem space, and the > followups, I'd like to add my my $0.01 (would be $0.02 but the exchange > rate on the Aussie dollar is fairly embarrassing right now). [snip] Thanks for the compliment. In return, you did what I didn't finish: a good update of the graphical tools (I forgot scigraphica in my first draft) and a decent summary. I fully agree with you at this point. In the graphing dept, I don't mind having separate 2d/3d tools (scigraphica and mayavi), that may even be an asset. But it would be great if the two projects could keep an eye on each other so that they expose a similar scripting interface. It would be pain in the ass to have to remember completely different syntaxes for trivial things like setting a plot title depending on whether one is doing 2d or 3d. > > Numeric Python, of course, makes whichever list it feels like. (: > > I've left it out of both lists because there's an announcement on the > NumPy home page that it is being reimplemented from scratch by Perry > Greenfield and company. This looks (to my untrained eye) like they're > going ahead with the Numeric 2 proposed in PEP 209, and are going for > inclusion in the Python standard library. Implications for the unified > scientific library are left as an exercise for the reader. Could we have > comments from anybody on that project team? Very interesting... I hadn't seen this. I hope they can come through without too high costs in speed for smaller arrays (currently they only reach 1/2 asymptotic throughput at >20k elements, which may be too slow for many applications). > Now... licensing. While the top two projects are both less...restrictive, > I reluctantly have to concede that these lists have an awful lot of GPL > code that would be difficult or impossible to do without. The eventual > license, therefore, looks like GPL or (if we're lucky) LGPL. I can even > live with that if it'll get me a coherent scientific library, but others > might have a different viewpoint. What would those viewpoints be? At this point we need to hear from the code owners, who are ultimately the ones who will have to make those decisions. There does seem to be a lot of interest from many into a saner organization of python's scientific abilities. I hope the scipy folks are reading this and can incorporate some of these comments/suggestions into their project. And again, I think your summary has a very good layout of what's needed to minimize duplication of effort and having something fully useful *soon*. Cheers, f. From info.jyv at videotron.ca Fri Nov 30 02:49:32 2001 From: info.jyv at videotron.ca (Jean-Yves Vinet) Date: Thu, 29 Nov 2001 23:49:32 -0800 Subject: A modest indentation proposal References: Message-ID: <%7EN7.1769$n03.277119@weber.videotron.net> I don't think it's a good idea to add a way to write not well indentate codes. The best way to recover from a screwed up indentation it's to use remark like #end at the end of each block. if a == 2 : print "ok' #end JYV "Erann Gat" wrote in message news:gat-2911011409280001 at jansma-mac.jpl.nasa.gov... > > The subject of syntactically-significant indentation seems to dominate a > lot of discussions on Python. Personally I've found it to be less of a > problem than I thought it would be, but annoying nonetheless. It also IMO > makes the language unsuitable for mission-critical applications. It's > just too easy to screw up indentation (particularly when cutting and > pasting large blocks of code) without realizing it. > > I have a suggestion for how to make people like me who are uneasy with > syntactically significant indentation feel more comfortable while at the > same time not alienating those who thing that it's a really cool feature. > The proposal is based on the observation that Python already has the > equivalent of an open-brace for code blocks. It's the colon. To see that > this is so you have only to observe that a good editor can automatically > indent code properly at the beginnings of blocks, but not at the end. The > solution to the problem is to add an optional end-of-block identifier. > > I propose to use a semicolon at the end of a line to denote the end of a > block, e.g.: > > for i in l: # Colon signals beginning of block > foo() > baz(); boff() # Semicolon separating statements works as usual > bar(); # Semicolon at end of line signals end of block > biff() > > > This convention is 100% backwards-compatible with current practice, that > is, code written using this convention runs with no problems in Python as > it currently stands. > > What I would like to see in terms of support for this convention from the > Python community is two things: > > 1) Editor support for this convention so that a semicolon at the end of a > line causes the editor to unindent, and > > 2) Parser support. It would be enough to simply give a warning if there > is a discrepancy between the block structure defined by indentation and > that defined by the semicolon-at-end-of-line convention (i.e. "Warning: > end of block detected without trailing semicolon"). Making this optional > so that die-hard indentation fans could turn it off would also be fine. > > Comments? > > Erann Gat > gat at jpl.nasa.gov From rand0m at nelvento.it Sat Nov 3 08:23:49 2001 From: rand0m at nelvento.it (rand0m) Date: Sat, 03 Nov 2001 13:23:49 GMT Subject: Python/QT Book no in final edit References: <7xady4cxng.fsf@ruckus.brouhaha.com> Message-ID: >Looks nice. It would be nice to have a link to render it all on one web page. why not just wgetting it! (wget exists also for ms-dos and it's a really cute software) wget -m -c -np http://stage.linuxports.com/projects/pyqt Lo From root at rainerdeyke.com Tue Nov 27 22:16:26 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 28 Nov 2001 03:16:26 GMT Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> Message-ID: "David Eppstein" wrote in message news:eppstein-AEB95C.16365127112001 at news.service.uci.edu... > In article , > Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote: > > > Greg Ewing wrote: > > > > > While trying to think of a range syntax that looks > > > unambiguously half-open without clashing with list > > > or tuple constructors, the following blindingly > > > obvious solution occurred to me: > > > > > > for 0 <= i < 5: > > > ... > > > > +1 if it also groks "for 0 < i <= 5" and so on. > > Also +1 if it gives the reversed sequence for "for 5 > i >= 0". +666 if it understands arbitrary expressions: for 0 <= i < 5 and i % 0 == 0: # possible pass for 0 < i + 2 <= 5: # unlikely pass for i.__class__ == str: # impossible pass for a * x ** 2 + b * x + c == 0: # what's this even supposed to do? pass On second thought, let's not go there. It's a silly place. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From patricg at fys.uio.no Thu Nov 8 07:08:34 2001 From: patricg at fys.uio.no (Patrick Guio) Date: Thu, 8 Nov 2001 13:08:34 +0100 Subject: HOWTO execute an external program? In-Reply-To: <9sdqtk$127dt6$1@ID-11957.news.dfncis.de> References: <9sdqtk$127dt6$1@ID-11957.news.dfncis.de> Message-ID: On Thu, 8 Nov 2001, Emile van Sebille wrote: > > I would like to use python as a scripting language to run my simulation > > code. I would like to know how do I do that ? > > There are lots of ways. If you provide more details of where you're > starting from and what you want to get done I'm sure you'll get responses to > help you get there. I want to run my simulation code in a loop with different argument values, I now use a bourne shell script like timelogger="/usr/bin/time -p execname="picsim" for B in 0.1 0.2 0.3 0.4 0.5 0.6 ; do if [ ! -f $dir/${filename}B$B.hdf ] ; then command="$execname bvector=0,$B -o $filename.hdf -i $conffile" ($timelogger $command > run.log) > run.cmd 2>&1 .... fi done Now I need to calculate, at each iteration, new values of several other arguments and it looks like python is nice to do maths operations. So what I need is iteration loop calculate argument values val1,val2,...valn command="myprog -arg1="+val1+ " -arg2="+val2.... execute the command AND time it AND log the stdout and stderr of running it end I hope it helps you understanding the problem. Sincerely Patrick From johnroth at ameritech.net Wed Nov 14 20:49:57 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 14 Nov 2001 17:49:57 -0800 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> Message-ID: "Gernot" wrote in message news:9sv2c7$6qa$06$1 at news.t-online.com... > Hi, > > I want to implement the functions myand, myor and mynot. They should have > the same effect as the known boolean operators and, or and not. > > The trick is that I am not allowed to use the boolean operators and, or and > not. > AFIK, it can't be done because the 'and' and 'or' operators have short circuit evaluation. There is no way to build a function that does not evaluate each of its arguments before invoking the function. John Roth From emile at fenx.com Mon Nov 5 13:57:34 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 5 Nov 2001 10:57:34 -0800 Subject: find network drives, win References: <3be6c267.21367859@news.easynews.net> Message-ID: <9s6na8$11dkuv$1@ID-11957.news.dfncis.de> "Gerhard H?ring" wrote in message news:mailman.1004981779.14538.python-list at python.org... > On Mon, Nov 05, 2001 at 04:51:10PM +0000, Marcus Stojek wrote: > > Hi, > > > > under windows I have to find out for a given path whether the drive is local > > or a network drive (is "mounted" the right word for this?) > > I tried: > > ----------------------------------------------- > > import string > > import os.path > > [...] > > I think you cannot find that out with the standard Python libraries. I propose > you get the ActivePython distribution from ActiveState or install their > Windows-Extensions, named win32all on top of your existing Python installation. > > Then, check out the win32file module, and especially the GetDriveType() > function there. > > Btw. the Windows extensions are *very* useful on Windows. They give you access > to a large part of the Windows API and you can use them to access most ActiveX > controls and do COM-automation of applications, such as MS Excel. > Seconded. In a pinch, you can parse the results of: info = os.popen('net use').readlines() Emile van Sebille emile at fenx.com From iwk_nospam at xs4all_nospam.nl Wed Nov 28 18:05:12 2001 From: iwk_nospam at xs4all_nospam.nl (iwk) Date: Thu, 29 Nov 2001 00:05:12 +0100 Subject: Problem with inetd & Python Message-ID: <3C056DA8.4020001@xs4all_nospam.nl> Hi there, I've written an M$ Office monitoring add-in which communicates with a Python script, a SocketServer, running on Linux. Works flawlessly, but I was wondering whether it would be possible to get it to run under xinetd or indetd. For no paticular reason, except curiosity and the possibility of simplified code (it is with C). I went to work and ran into a problem: According to the little information I found, a process being started by (x)inetd could use stin & stout to transfer data from and to the client. And when I telnet to a script which justs writes data to sys.stdout it works: al data is being displayed on the screen of the telnet client However, when I try to *read* data from sys.stdin, nothing works anymore, not even the writing to sys.stdout So code like: x = sys.stdin.readline() while x != '': sys.stdout.write(x) x = sys.stdin.readline() doensn't do a thing. What am I doing wrong here? Regards, Iwan From James_Althoff at i2.com Fri Nov 16 14:55:12 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 16 Nov 2001 11:55:12 -0800 Subject: Recap: PEP 276 Simple Iterator for ints Message-ID: William Tanksley wrote: >I've lost track of why we're arguing about this. Why should we >make any change here? What are we fixing? The discussion surrounding PEP 276, "Simple Iterator for ints", has wandered off into several interesting areas. As PEP 276 notes, there appears to be interest in the Python community for inventing new syntax or other mechanisms that makes it easier and more natural to specify a list of numbers (for clarity of indexed-for-loop-based algorithms and other scenarios). The recent discussions around PEP 276 suggests that some people like the idea of a Haskell-esque syntax whereby one specifies a list of numbers using a closed-interval notation that includes a starting number, a secondary number that helps to establish the step size, an ellipsis-style notation, and an ending number (or variants on the above). For example. for i in [1, 2 .. 10]: Another camp feels that the closed-interval notion is inconsistent with other interval-oriented notations in Python and is inconvenient for the common case of indexing sequences whereby the established convention is to use a half-open interval that starts at 0 and ends (inclusively) at len(sequence)-1. Some in this camp favor the use of Python's slicing syntax in conjunction with some existing object (the types.IntType class object, or some specially created object, etc.) so that a list of integers could be creating using, for example, for i in int[0:10:2]: Others suggest using a generalization of the first mechanism (new Haskell-esque syntax) that allows one to specify open versus closed intervals using some syntactic means such as "]" for a closed (on one side) interval and ")" for open, as in for example: for i in [1, 2 .. 10): Mixed in with this are differing viewpoints on whether the syntax should use double dots, triple dots, no dots, fewer commas, more commas, colons, square brackets, paren.s, etc. Mixed in to some extent also are ambiguities about whether such constructs return lists -- some of the proposed examples lend themselves to the expectation that a list is constructed -- or iterators, which are better when such lists are used in the context of a for-loop -- which is much of the time. The are enough variations and issues that most seem to agree that one or more PEPs are needed to more fully specify one or more of the given proposals. Getting back, then, to PEP 276 ... PEP 276 does not attempt to solve the above problem of creating a new, general-purpose mechanism for writing out a list of numbers using some literal syntax. PEP 276, instead, suggests a way of using iterators to simplify the common case of using a for-loop to access items in a structure when it is the case that those items need to be accessed by an index or (multiple indices as in the example below). The real-life example (modified slightly here) from PEP 276 is a two dimensional table structure whereby cells can be accessed via a combination of a row index and a column index and by *no* other mechanism (this is an important point). In current Python one might write: for i in xrange(table.getRowCount()): for j in xrange(table.getColumnCount()): print table.getValueAt(i,j) Some posters seem to agree that the need to use xrange (or range) in this (and other similar situations) is less than ideal, at best. The mechanism of PEP 276 -- which requires no new syntax, is straightforward to implement, and (the author alleges) is consistent with recent iterator-oriented changes to dictionaries, strings, lists, and tuples, -- would allow the example above to be written simply as: for i in table.getRowCount(): for j in table.getColumnCount(): print table.getValueAt(i,j) While there is certainly merit and potential benefit in trying to invent a new, general purpose mechanism for specifying lists of numbers, it should be noted that for the problem that PEP 276 addresses, the various proposals above yield things like: for i in [0, 1 .. table.getRowCount()-1]: for j in [0, 1 .. table.getColumnCount()-1]: print table.getValueAt(i,j) for i in int[0:table.getRowCount()]: for j in int[0:table.getColumnCount()]: print table.getValueAt(i,j) for i in integers[0:table.getRowCount()]: for j in integers[0:table.getRowCount()]: print table.getValueAt(i,j) (Acknowledging that not every proposed variation is shown here nor various proposed shortcuts for various proposals). While acknowledging that several of these might read somewhat better than xrange/range in the scenario above, it is not universally apparent that they are a vast improvement (in this context). And for each such proposal, there is the issue as to whether the proposed new form returns an actualized list or an iterator and how well suited the given choice might be in various usage scenarios (given that you have to pick one or the other: actualized list or iterator). Nonetheless, as stated several times before, PEP 276 does not preclude the adoption of a new mechanism for specifying lists of numbers similar to any of the above proposals -- it doesn't have to be an "either or" choice. It simply provides a convenient way to access indexed structures in a for-loop. Jim From sabren at manifestation.com Wed Nov 21 19:05:29 2001 From: sabren at manifestation.com (Michal Wallace) Date: Wed, 21 Nov 2001 19:05:29 -0500 (EST) Subject: Who can do genetic programming with Python In-Reply-To: <13285ea2.0111210754.13974f4d@posting.google.com> Message-ID: On 21 Nov 2001, J.Jacob wrote: > Does anyone have code that produces correct but random > Python code ? This would be useful for a genetic > programming (GP) test we want to do. I agree with the other responses about syntax... BUT... Here's two things you might consider: - Neil Schemenauer has an S-expression parser for python http://www.enme.ucalgary.ca/~nascheme/ - You might have some success generating python bytecode. I'm not sure, but the bytecodehacks might help here: http://sourceforge.net/projects/bytecodehacks/ Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From fungho at sinaman.com Fri Nov 16 05:10:14 2001 From: fungho at sinaman.com (Stephen) Date: 16 Nov 2001 02:10:14 -0800 Subject: question of regular expression Message-ID: Actually, I don't know which newsgroup should I ask for this question? I am now using org.apache.regexp for regular expression in Java. I want to search the unicode characters (i am afraid the others can't understand the language of the unicode, so I still try to use English for my example, assume all the following words are unicode) e.g. I want to search the words with the following possibilities: AB or C or E or ST how to I write the expression? I have tried this: (AB|C|E|ST), however, it also matches when there is B and T only.... (while only AB or ST allows to be matched)...... thx! From altis at semi-retired.com Wed Nov 21 17:30:41 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 21 Nov 2001 14:30:41 -0800 Subject: Still on python GUI toolkit References: Message-ID: "Fredrik Lundh" wrote in message news:GDSK7.7557$Z_1.1235809 at newsc.telia.net... > Tyler Eaves wrote: > > > > > The application I tested is a pixel-intensive type of application because > > > it is the most challenging of the tools I will need: it displays > > > continuously an 80x80 syntetic image randomly generated with 256 > > > graytones, by using small filled squares for each pixel > > > > Unless you used Tkinter's canvas widget, this wasn't a fair test. > > if he *did* use the canvas widget, it wasn't a fair test. > > the Tkinter canvas is optimized for applications that create > a model once, and then make relatively minor modifications > to it (e.g. graphics editors). > > if you have data that changes rapidly, you'll likely to spend > more time tranferring data between Python and the canvas > model than you spend on updating the screen. > > better use a data display widget (try searching google for > "custom Tk widgets"), or use something like Tkinter 3000's > WCK: > > http://www.pythonware.com/products/tkinter/tkinter3000.htm > > as an example, here are timings for Gordon Williams' oscillo- > scope benchmark (search the archives for source code; the > Tkinter 3000 version is available in the WCK source kit): The other thing I noticed last time I did some plotting and drawing with the canvas widget was the huge amount of memory consumed and long redraw times when you had lots of points or lines. It appears it is maintaining lists of all the drawing operations and then playing those back for a window redraw rather than using an offscreen buffer. My mistake was using it to draw millions of points :) Around that time I also decided I wanted native widgets so I switched to wxPython for apps, but it is nice to know there is a tkinter canvas widget that is more appropriate for plotting for those that want to use tkinter. ka From niemeyer at conectiva.com Mon Nov 5 09:48:20 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Mon, 5 Nov 2001 12:48:20 -0200 Subject: How can i retrieve a key from a dictionary? In-Reply-To: <3BE52DBC.724B1C6F@student.kun.nl>; from h.jehadalwan@student.kun.nl on Sun, Nov 04, 2001 at 12:59:56PM +0100 References: <3BE519E0.34312B48@student.kun.nl> <3BE52DBC.724B1C6F@student.kun.nl> Message-ID: <20011105124820.A2584@ibook.distro.conectiva> Hi Husam! > > Try this: > > > > dict.keys()[dict.values().index('one')] > > > > prabhu > > it works, but wat does the -index- means? I'd advice you to work with two dictionaries, one of them being reverse. Otherwise, there's no benefit in using dictionaries instead of a plain lists. Best regards!! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From barry at zope.com Thu Nov 1 02:30:43 2001 From: barry at zope.com (Barry A. Warsaw) Date: 01 Nov 2001 02:30:43 -0500 Subject: A better way to send mail? References: Message-ID: >>>>> "DB" == David Brady writes: DB> Python promotes marital harmony. My wife will be very happy to hear this! :) DB> My question is this: someone on this list just DB> mentioned MimeWriter as the better package to use for DB> authoring e-mail and attachments. I could not figure DB> MimeWriter out in the hour or so I spent trying to get DB> this script working, and I finally got the uu module DB> to do what I needed so I used that instead. But I DB> wonder if mime wouldn't be the better way. Probably so. I'm hoping the email package[1] will promote MIME and email handling harmony in the Python standard library. :) I developed it for Mailman 2.1, which uses it exclusive now, and others have started using it too. Here's an example of some (untested) code that should be largely equivalent to your own. One difference: it base64 encodes the image data rather than uuencoding it. The email package doesn't have a built-in uuencoder, although one could be easily added if there's enough of a demand. -------------------- snip snip -------------------- from email.MIMEText import MIMEText from email.MIMEImage import MIMEImage from email.MIMEBase import MIMEBase text_attachment = MIMEText(boilerplate) image_attachment = MIMEImage(img) outer = MIMEBase('multipart', 'mixed') outer.attach(text_attachment) outer.attach(image_attachment) outer['From'] = SMTPSender outer['To'] = SMTPRecipient outer['Subject'] = 'Here ya go, honey!' # SMTPSender, SMTPRecipient are set to my and her # e-mail addresses, respectively s = smtplib.SMTP(SMTPServer) ErrorAddresses = s.sendmail( SMTPSender, SMTPRecipient, str(msg) ) s.close() -------------------- snip snip -------------------- I hope this makes sense! -Barry [1] The email package comes with Python 2.2, but there is a distutils-based compatibility package for earlier versions. It requires at least Python 2.0. See http://sourceforge.net/projects/mimelib/ for more details. Documentation is at: http://python.sourceforge.net/devel-docs/lib/module-email.html From shalehperry at home.com Fri Nov 16 14:19:01 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 16 Nov 2001 11:19:01 -0800 (PST) Subject: Xlib bindings for Python? In-Reply-To: <20011116213729.Q22329@phd.pp.ru> Message-ID: On 16-Nov-2001 Oleg Broytmann wrote: > On Fri, Nov 16, 2001 at 12:31:58PM -0600, Mike Meyer wrote: >> Yes, I'm really looking for a set of bindings for Xlib, not a Xt or Xm > > http://sourceforge.net/projects/python-xlib > This is *NOT* a binding, it is a new implementation in 100% python. From alain.desilets at nrc.ca Thu Nov 22 15:29:28 2001 From: alain.desilets at nrc.ca (Alain =?iso-8859-1?Q?D=E9silets?=) Date: Thu, 22 Nov 2001 15:29:28 -0500 Subject: PLEASE OH PLEASE UNSUBSCRIBE ME! References: <3BF95C82.A5688F06@nrc.ca> <3BFA9EEF.61CFBC43@nrc.ca> Message-ID: <3BFD6028.E43777E5@nrc.ca> Can an administrator of the list please address this! I have sent 3 messages to both python-list-admin at python.org and python-list at python.org and I am still drowning in messages. NO, I can't unsubsrcribe through the web or mail interface because I don't know my stupid password. It doesn't seem to be any of the ones I typically use. YES, I know that the passwords is mentioned in the monthly reminder and in the original confirmation message. But I haven't been on the list long enough to receive a monthly reminder, and I don't have the original confirmation. YES, I agree that one should always keep the original confirmation message and I usually do. This time though, I can't find it. I deleted so many messages from this list that I probably deleted that one by accident too. Thanks Alain D?silets python-list-admin at python.org Alain D?silets wrote: > Apologies everyone. I know I'm not supposed to send this on the list, > but I sent it to the mail admin yesterday and am still drowning in the > volume. And I'm going away for 3 days ;-)! > > Any admins listening on the list? > > Thx > > Alain D?silets wrote: > > > I tried to unsubscribe, but I can't remember the password I gave. I > > tried all my known passwords and none of them worked. Can you > > unsubscribe me manually? > > > > Thanks > > > > Alain D?silets From aquarius at kryogenix.org Sun Nov 4 19:10:40 2001 From: aquarius at kryogenix.org (Aquarius) Date: 4 Nov 2001 16:10:40 -0800 Subject: Dockapp in Tkinter References: Message-ID: <600190a9.0111041610.53a75a6b@posting.google.com> Bj?rn Lindstr?m wrote in message news:... > Has anyone here tried to write a Window Maker dockapp in Tkinter. > In that case, I would be very interested in an example. I wrote one: see http://www.kryogenix.org/code/wm8ball.py.html. It was based on some code I dug up from a guy called Robert Vollmert; however, I dug that code out of the Google cache because the actual site appeared to have died. Hopefully you might find it useful. Aq. From sandskyfly at hotmail.com Sun Nov 11 10:22:10 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 11 Nov 2001 07:22:10 -0800 Subject: Using browser as interface to python app References: Message-ID: "Bill Bell" wrote: > I can't claim to understand what you're doing ... I'm simply trying to use the browser as an interface to a small python program that retrieves and parses webpages and then publishes the results in an html page. I would like for example for the user to be able to configure the app via the browser (by selecting checkboxes and whatnot) without having to use a command-line menu or a full blown GUI such as wxPython or Tkinter. "Sandy Norton" wrote: > > I thought about using CGIHTTPServer in the Standard Lib but its use of > > forking doesn't make sense for Windows. OTOH, I'm also sure that > > there's a COM way to do this somehow, but I'd really like to try to > > make the end app as portable as possible. Another consideration is > > distribution footprint...(we wouldn't want the user to have to > > download and set up apache :-) "Bill Bell" wrote: > How about Zope? Download is 5 Mbytes, extremely easy to install, > includes web server. > > I've installed it for use by one of my smallest clients in maintaining > their documentation. For what they need, it's very easy to maintain. Thanks for the suggestion. I'm afraid Zope is also perceived to be a bit of an overkill solution as the py2exe distribution of the GUI-less (w/ command-line driven) app is 1 meg: adding Zope and 5 more megs to the distro doesn't seem right. Sandy From gh_pythonlist at gmx.de Tue Nov 20 19:43:16 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 21 Nov 2001 01:43:16 +0100 Subject: distutils for old pythons? In-Reply-To: References: Message-ID: <20011121004315.GA4669@lilith.hqd-internal> On Tue, Nov 20, 2001 at 11:17:09PM +0000, Andrei Kulakov wrote: > Hello, > > I just found out that distutils were not included in python1.5 and 2.0. > [...] They are included since 2.0. For 1.5.x, use the downloads from: http://www.python.org/sigs/distutils-sig/download.html State distutils as a requirement for your Python installers (even 1.5.x) and you're set. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From boramae at banktown.com Fri Nov 23 21:55:22 2001 From: boramae at banktown.com (¿ÀÁ¤¿î) Date: Sat, 24 Nov 2001 11:55:22 +0900 Subject: Error on Disconnection from odbc (SQL Server) ?? Message-ID: <9tn1o9$i52$1@news1.kornet.net> Hello... I succeeded to connect to SQL Server via odbc but.. i had trouble to disconnect .. con = odbc.odbc("DSN...") -> success Cursor1 = con.cursor() ... Cursor1.close() con.close() but 'netstat -n' at SQL Server ... connection still established... From dale at riverhall.NOTHANKS.co.uk Thu Nov 15 11:55:17 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Thu, 15 Nov 2001 16:55:17 +0000 Subject: PEP proposal: enhanced string functions References: Message-ID: I don't think you can have too much string processing help. Without it you are frequently left with character-level manipulation and code that starts to resemble assembler in detail. That said, you can achieve an awful lot with cunning use of re and %. -- Dale Strickland-Clark Riverhall Systems Ltd From ejohnso9 at earthlink.net Sun Nov 11 17:16:38 2001 From: ejohnso9 at earthlink.net (Erik Johnson) Date: Sun, 11 Nov 2001 22:16:38 GMT Subject: Easy(?) newbie question Message-ID: <3BEEF8A9.DBF96E74@earthlink.net> Hi, I am just getting savvy to Python - rather excited about the possibilities, but I have come across something that seems rather simple but I'm stumped... The following loop does what I would expect: >>> for x in range(10): print x, ... 0 1 2 3 4 5 6 7 8 9 but when I try to put this code into a string and evaluate it, I get a syntax error: >>> s = "for x in range(10): print x," >>> s 'for x in range(10): print x,' >>> eval(s) Traceback (most recent call last): File "", line 1, in ? File "", line 1 for x in range(10): print x, ^ SyntaxError: invalid syntax >>> None of these forms are any better... s = """for x in range(10): print x,""" s = """ for x in range(10): print x,""" s = """ for x in range(10): print x, """ s = """ for x in range(10): print x, """ I don't get it - this syntax seems to be fine when executed directly as statements, but if I put the same statements in a string and eval()'uate them, it's no longer valid syntax? What am I missing here? Thanks in advance, -ej -------------- next part -------------- An HTML attachment was scrubbed... URL: From nospam at bigfoot.com Mon Nov 26 15:22:51 2001 From: nospam at bigfoot.com (Gillou) Date: Mon, 26 Nov 2001 21:22:51 +0100 Subject: vCard parser anywhere ? References: <9trh93$o1e$1@norfair.nerim.net> Message-ID: <9tu7ue$75m$1@norfair.nerim.net> Merci Fran?ois... I'm gonna take some aspirin, learn some lisp and make it pythonic. --Gillou "Fran?ois Pinard" a ?crit dans le message news: mailman.1006719820.12406.python-list at python.org... > [Gillou] > > > I'm looking for a vCard parser that changes a vCard stream into a > > Python object. Did not find this treasure in Vault of Parnassus ! > From mal at lemburg.com Fri Nov 30 18:09:29 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Sat, 01 Dec 2001 00:09:29 +0100 Subject: ANNOUNCE: WeakList References: <005201c179c5$3465ce90$f575393e@integralabzenon> Message-ID: <3C0811A9.645BC1DC@lemburg.com> > Andres Tuells wrote: > > What is: > Python implementation of weaklist: list whose entries are > weak references, and are removed when the original object is > garbage collected. They are useful for example when you want a > publisher/subscriber list. Subscriber are authomatically removed > from the publisher list when they are gc (and can be gc). > > You can do: > for subscriber in weaklist_subscribers: > self.notify(subscriber, message) > > If a subscriber is gc while the for is running, then it will be > removed also be removed from the weak_list. WeakList has > an iterator that constains a weaklist. > > I think that WeakList place is inside weakref.py, but I don't now how > to contribute to python code. Try by uploading your patch to SourceForge as first step :-) -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From ajs at ix.netcom.com Sat Nov 10 12:54:09 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 10 Nov 2001 12:54:09 -0500 Subject: Teaching python (programming) to children Message-ID: <000f01c16a10$b37e3ba0$a9e1fea9@carol> Sheila writes - >If you were in the classroom working with >students, this wouldn't be important at all. Not sure what you are saying. According to Paul, Piaget (and anything that invokes the name) is a done deal. But, perhaps its more that the folks who see it otherwise just got exhausted counter-arguing. Maybe teachers need to be exposed to some counter din. I volunteer. Art From sholden at holdenweb.com Thu Nov 8 18:49:35 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Nov 2001 18:49:35 -0500 Subject: Gratuitous post Message-ID: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> Free software. missing-oleg-ly y'rs - steve -- http://www.holdenweb.com/ From michael at rcp.co.uk Fri Nov 30 07:13:20 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 30 Nov 2001 12:13:20 +0000 (UTC) Subject: Non-Indented python References: <3C0678DF.2DFE924A@home.net> Message-ID: Marcin 'Qrczak' Kowalczyk wrote in news:slrna0d40v.ugq.qrczak at qrnik.zagroda: > Thu, 29 Nov 2001 10:05:19 -0800, Chris Barker > pisze: > >> I often start working on a file I got from elsewhere with tabs in >> it, get some wierd error, eventually think to check for tabs. Then >> I run a script on it, clean it up, and all is well. > > This problem doesn't exist if you use 8 as the tab width because then > the apperance is consistent with semantics. Until you (or, more likely, someone else) run the source through an editor which happens to be configured for a different tab size and which happens to also be configured to convert tabs back to spaces (this is how MSVC interprets "expand tabs as spaces"). This has happened to me (with C), and the result is completely unreadable. I ban tab characters whenever I have the opportunity. From tdelaney at avaya.com Sun Nov 4 18:30:30 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 5 Nov 2001 10:30:30 +1100 Subject: Python 2.1 syntax to Python 1.5.2 Message-ID: > From: Sean 'Shaleh' Perry [mailto:shalehperry at home.com] > On 02-Nov-2001 Stuart Bishop wrote: > > Before I rewrite all my lovely list comprehensions and > > 'print >>' statements into python 1.5 syntax, I don't suppose > > anyone has code that automagically does the translation? > > > > the list comprehension could be tricky, the print is fairly easy. All list comprehensions should translate directly to a combination of map() and filter() calls, unless you're doing something nasty like rebinding names during the course of the comprehension. def process (x): """""" return x**2 r = xrange(1000) lc = [process(x) for x in r if not (x % 3)] mf = map(process, filter(lambda x: not (x % 3), r)) print len(lc) print len(mf) print lc == mf # timings import time print startTime = time.clock() lc = [process(x) for x in r if (x % 3)] lcTime = time.clock() - startTime print lcTime startTime = time.clock() mf = map(process, filter(lambda x: (x % 3), r)) mfTime = time.clock() - startTime print mfTime However, it would be tricky to write an automated tool which could deal with more than just the above. Tim Delaney From nas at python.ca Fri Nov 30 13:05:58 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 30 Nov 2001 10:05:58 -0800 Subject: A modest indentation proposal In-Reply-To: <20011130094100.B4450@glacier.arctrix.com>; from nas@python.ca on Fri, Nov 30, 2001 at 09:41:00AM -0800 References: <3C0773C2.A12D0BAC@pacific.net.hk> <20011130094100.B4450@glacier.arctrix.com> Message-ID: <20011130100558.A4720@glacier.arctrix.com> Neil Schemenauer wrote: > I believe effbot and the other people at Python Labs are working on a ^^^^^^^^^^^ > "refactoring browser" for Python. Argh, that should be PythonWare. Neil From hungjunglu at yahoo.com Wed Nov 14 10:48:35 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 14 Nov 2001 07:48:35 -0800 Subject: dynamically generating a module References: <8ef9bea6.0111131459.38f96699@posting.google.com> <3BF1CD9E.A9C9712B@engcorp.com> Message-ID: <8ef9bea6.0111140748.5956355f@posting.google.com> Thanks everyone! Hung Jung From johnroth at ameritech.net Sat Nov 3 22:21:04 2001 From: johnroth at ameritech.net (John Roth) Date: Sat, 3 Nov 2001 19:21:04 -0800 Subject: [Q] Python and expert system shell References: <3BE46FA9.72DFFDB0@olen.to> Message-ID: "Joonas Paalasmaa" wrote in message news:3BE46FA9.72DFFDB0 at olen.to... > Young-Jin Lee wrote: > [...] > > I found one URL for an expert system shell in Python, > > http://www.python.org/ftp/python/contrib/All/holmes.tar.gz ,but it seemed > > be not available any more. > > I can e-mail it to you if you want. It's on the CD that comes with Programming Python, 2nd Edition, by Mark Lutz. O'Reilly & Assoc. John Roth From kragen at pobox.com Wed Nov 28 17:15:04 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 28 Nov 2001 17:15:04 -0500 Subject: Should I use threads here? References: Message-ID: <83bshmv8yf.fsf@panacea.canonical.org> "Steve Holden" writes: > readlines() doesn't terminate until it knows (by seeing and end of file on > its input stream) that it has read all the input. If you built a loop using > readline() you might find you got better results. This is assuming that the program actually outputs stuff as it goes; many programs buffer output in big blocks when they're talking down a pipe instead of outputting line by line. From logiplexsoftware at earthlink.net Wed Nov 14 18:38:42 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 14 Nov 2001 15:38:42 -0800 Subject: How to marshal a function? In-Reply-To: References: <01111412544105.04702@logiplex1.logiplex.net> Message-ID: <0111141538420B.04702@logiplex1.logiplex.net> On Wednesday 14 November 2001 14:53, Fran?ois Pinard wrote: > I did not even try `pickle' for that, after the documentation (printed at > 1.5.2 time) insists that `pickle' has no representation for code objects. > If you examine `pc', you will have some difficulty to believe that it > actually conveys the function definition. It probably only holds a > reference to the name. Oh, it does works if I do everything in a single > Python session, because `f' is already defined. But if I save `pc' to > disk and reload it in a fresh Python session, the `pickle.loads(pc)' > yields: > > SystemError: Failed to import class f from module __main__ > > So, I would not think that `pickle' is a solution. How embarrassing. I dug around and found the code I had used, and sure enough, I was using marshal. Further, due to the way I was using the code (the compiled bytecode was fairly self-contained) I never encountered the limitations you mention. Still, I think there must be a way around this... I will look further. BTW, are you aware that you are double-posting? -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From glauco.silva at iti.gov.br Tue Nov 6 12:14:50 2001 From: glauco.silva at iti.gov.br (Glauco Silva) Date: Tue, 6 Nov 2001 15:14:50 -0200 Subject: Help - Create dll Message-ID: <006001c166e6$8d3ed120$107290c8@iti.gov.br> Hi , How can i create a dll file ( C dynamic library) from windows to be imported by python . Thank you Glauco -------------- next part -------------- An HTML attachment was scrubbed... URL: From eyal at hyperroll.com Fri Nov 2 10:08:02 2001 From: eyal at hyperroll.com (Eyal Lotem) Date: Fri, 02 Nov 2001 17:08:02 +0200 Subject: extending yield's functionality Message-ID: <3be2b616@news.bezeqint.net> I was excited to find out about the new yield functionality, of generator functions, that will be formally in 2.3 I wanted to ask if its possible to have yield receive some more information from the caller, between the yield stages. An example syntax to implement this could look like: >>> def a(): ... print "Hello" ... b=yield 1 ... yield b*2 ... yield 3 >>> gen = a() >>> gen.next() 1 >>> gen.next(3) 6 >>> gen.next() 3 This could make yield far more useful, and allow its use for more than just simple generator functions. It could then be used to implement functions that maintain a current-state through their internal flow, while using event-driven programming. Example: A negotiation protocol can be implemented using a loop of recv/send operations, and yield the next stage's data each time, and accept new external information from the event handler (perhaps the received data). Is this worth a PEP? From deoradh at yahoo.com Thu Nov 8 22:03:30 2001 From: deoradh at yahoo.com (Keith Farmer) Date: 8 Nov 2001 19:03:30 -0800 Subject: C-extension in Python -- returning results References: Message-ID: deoradh at yahoo.com (Keith Farmer) wrote in message news:... > for (j = 1; j < 11; j++) > tpow[j] = tpow[j-1] * t0; /* tpow[j] = t0^j = tpow[j-1] * t0 */ > sumsX[j] += tpow[j]; /* sumsX[j] = Sum(t0^j) */ I misdiagnosed where the error was. Rule Zero of C-Programming: It's Not Python -- Remember Braces. From mertz at gnosis.cx Wed Nov 14 05:26:54 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Wed, 14 Nov 2001 05:26:54 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: >Well... here's how Haskell does it: > > [1 .. 4] --> [1,2,3,4] > [4,3 .. 0] --> [4,3,2,1,0] > [2,4 .. 10] --> [2,4,6,8,10] > [0.0,0.3 .. 1.0] --> [0.0,0.3,0.6,0.9] James_Althoff at i2.com wrote: |A couple of points: it appears that the Haskell syntax mentioned above |assumes a closed interval. This means that in the common case of indexing |a sequence, one must remember to subtract 1 from the ending value. Basically true. If the step "overshoots" the sequence end, the final element is excluded. So 1.2 is not included in the last example (nor is 1.0). But in the very frequent "count integers by ones" case, the interval is closed. |it appears that this syntax creates an actual list, not an iterator. This is not quite true *in* Haskell. Since Haskell is lazy, lists are themselves much more like iterators. They only get filled in as needed. But it is not obvious how that might translate to Python. One possibility is to build a complete list (like 'range()' does). But one could also let the dots signal that an iterator is being built. Well, there could be problems. I'm not sure if that works with the parser, and this would also seem to require that iterators become indexable (and sliceable?!). FWIW, my own feeling is that PEP 276 is not a good idea. The fact that integers start acting different in scalar and iterator contexts is troublesome. And even though 'xrange()' is easy to forget, it is at least explicit about the fact that integers are being listed. The construct like: for i in table.rowCount(): is overly subtle, IMO. One might intuitively expect it to return actual "row" objects or something like that. Using one of the syntaxes that explicitly list numbers is less likely to cause confusion. Yours, Lulu... From jeff at ccvcorp.com Wed Nov 7 19:28:09 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 07 Nov 2001 16:28:09 -0800 Subject: wxWindows link error References: <3BE8AA75.1090101@yahoo.com> <3BE8BFC8.3000803@yahoo.com> Message-ID: <3BE9D199.592FC63F@ccvcorp.com> Jp Calderone wrote: > Well after a few hours of looking around and rebuilding a few > times, this bug appears to have been due to wxPython's setup.py > script (directly? indirectly? I have *no* clue how python's > distutil system works) using gcc instead of g++. I fixed by > symlinking /usr/bin/g++ to ./gcc in the base directory and including > . in my path before anything else. Clearly this is not the right > way to fix this. Can anyone tell me what is (or point me to some > docs on distutils)? Have you tried checking the wxPython site itself (www.wxpython.org)? There are detailed build instructions for win32 and unix (the unix version is at http://wxpython.org/BUILD.unix.txt), and if you can't find the answer to your problems there (or already looked with no success), then ask this question on the wxpython-users mailing list. Robin Dunn, the author of wxPython, is *very* good about answering questions there. Jeff Shannon Technician/Programmer Credit International From com-nospam at ccraig.org Thu Nov 15 11:44:55 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 15 Nov 2001 11:44:55 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) In-Reply-To: References: Message-ID: James_Althoff at i2.com writes: > Magnus Lie Hetland wrote: > > for i in 1 .. 10: print i > > > >or > > > > for i in 0, 2 .. 20: print i > > > >But I guess getting this in as part of the language isn't very realistic. > > Which of the below would "0 .. 5" specify? > 1) 0,1,2,3,4,5 > 2) 1,2,3,4 > 3) 0,1,2,3,4 > 4) 1,2,3,4,5 You think that is bad. What do you think "1, 2 .. 5" specifies? 1) 1, 2, 3, 4, 5 2) 1, 3, 5 3) 1, 3 If I saw it on a math paper, I would immediately presume (1). After all, (2) and (3) don't even include "2" which, it would seem should be the second element of the sequence. If it is (1), then what do we do about "0, 2 .. 6"? Is this "[0, 2, 5]"? -- Christopher A. Craig From spike at rollerfeet.com Mon Nov 5 16:06:44 2001 From: spike at rollerfeet.com (Tim Keating) Date: 5 Nov 2001 13:06:44 -0800 Subject: find network drives, win References: <3be6c267.21367859@news.easynews.net> Message-ID: <404e54a5.0111051306.29c2b2ab@posting.google.com> stojek at part-gmbh.de (Marcus Stojek) wrote in message news:<3be6c267.21367859 at news.easynews.net>... > under windows I have to find out for a given path whether > the drive is local or a network drive (is "mounted" the right word for > this?) > I tried: > for l in string.uppercase: > d=l+":/" Try: for l in string.uppercase: d=l+":\\" That may not get you all of what you want, but it will get you closer. TK From sill at optonline.net Sun Nov 4 17:21:44 2001 From: sill at optonline.net (Andrei Kulakov) Date: Sun, 04 Nov 2001 22:21:44 GMT Subject: Raw input buffer References: <3be54141$0$15992$afc38c87@news.optusnet.com.au> Message-ID: On Sun, 4 Nov 2001 23:23:13 +1000, nobody wrote: > How would 'peek' to see if there's data waiting to be read in the input > (stdin, or I suppose any such stream like a tty) buffer, and optionally read > it raw (ie. just what is currently in the buffer, without waiting for a > )? > > thanks. Get one key at a time (and manually buffer it): http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.074.htp > > > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From stuart at bmsi.com Thu Nov 15 20:39:36 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Thu, 15 Nov 2001 20:39:36 -0500 Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <7xg07fwn6l.fsf@ruckus.brouhaha.com> Message-ID: <9t1qon$8tq$1@nntp2-cm.news.eni.net> In article <7xg07fwn6l.fsf at ruckus.brouhaha.com>, "Paul Rubin" wrote: > "Stuart D. Gathman" writes: >> I have been putting my thoughts toward the elusive goal of making >> python as fast as some LISP dialects. > > The way to do that is with a compiler. Speeding up access to globals > may help a little, but probably not nearly as much. Yes, but the globals need a data structure that is compiler friendly, but keeps the dynamic semantics. If the interpreter uses a similar model, the compiler is a much more straightforward drop-in. -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From just at letterror.com Mon Nov 19 02:34:10 2001 From: just at letterror.com (Just van Rossum) Date: Mon, 19 Nov 2001 08:34:10 +0100 Subject: Looking for 1.5.2 for an ancient Macintosh - Anyone have it? References: <9ta6g5$mpp$2@slb7.atl.mindspring.net> Message-ID: <3BF8C40A.EB698FA4@letterror.com> Derrick wrote: > I'm trying to find 1.5.2 for a very nice old PowerBook 165 that someone is > giving me. Its using MacOS 7.1 to 7.6 - I don't know which one just yet. > > The Mac's good for word processing because of its portability and great > keyboard, but I'm looking for Python (I use 2.1.1 on my PC) in order to have > something useful to do on the machine when I'm not writing stories. http://www.cwi.nl/ftp/jack/python/mac/old/ Just From john at yates-sheets.org Mon Nov 5 11:01:08 2001 From: john at yates-sheets.org (John S. Yates, Jr.) Date: Mon, 05 Nov 2001 16:01:08 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> Message-ID: <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> On 5 Nov 2001 13:53:28 GMT, amk at localhost.debian.org (A.M. Kuchling) wrote: >Not at all. Stackless would have ramifications not just for a few >files in the core, but also for all the extension modules that come >with Python and for all the authors of third-party extension modules. Is this because those extension modules would break? Or because they would be sub-optimal until they took advantage of continuations? /john -- John Yates 40 Pine Street Needham, MA 02492 781 444-2899 From rdsteph at earthlink.net Mon Nov 26 21:21:28 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Tue, 27 Nov 2001 02:21:28 GMT Subject: 11-15 new Python Books on the way! (fwd) References: Message-ID: <3C02F9FB.DF1AD24@earthlink.net> Got and added it to the list thx Laura Lewin wrote: > This is a great list! You can also add Jython Essentials, O'Reilly, > Samuele Pedroni and Noel Rappin. The book is due out in March. > Laura > LLewin at oreilly.com > > > Ron Stephens wrote: > > |Truly a surfeit of books. But, for what it is worth, I have listed all I > > |could find out about them all at http://www.awaretek.com/plf.html > > From ejohnso9 at earthlink.net Mon Nov 19 19:55:38 2001 From: ejohnso9 at earthlink.net (Erik Johnson) Date: Tue, 20 Nov 2001 00:55:38 GMT Subject: Newbie Q: efficiency of list -> string conversion Message-ID: <3BF9A7C9.6D425D0B@earthlink.net> s = "string" l = list(s) l.reverse() rv = "" for i in xrange(len(s)): rv += l[i] print rv From phd at phd.pp.ru Thu Nov 1 16:48:25 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 2 Nov 2001 00:48:25 +0300 Subject: Freeware Python editor In-Reply-To: <3BE18A02.76FE1AB@alcyone.com>; from max@alcyone.com on Thu, Nov 01, 2001 at 09:44:34AM -0800 References: <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> <3BE11391.BF044772@alcyone.com> <3BE18A02.76FE1AB@alcyone.com> Message-ID: <20011102004825.A9655@phd.pp.ru> On Thu, Nov 01, 2001 at 09:44:34AM -0800, Erik Max Francis wrote: > > > Oh, please. You don't have the "freedom" to dictate to other people > > > what license to put on software that _they_ write. > > > > When and where was I dictating this? > > You're talking about people "restricting your freedoms," presumably by > providing closed source licenses. What else did you mean? I m saying this third or fourth time - it was not a complain, just a clarification: the editor is "freeware", but not "free". I do not force anyone to change license, or do something. I just want to warn people, not force them. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From gh_pythonlist at gmx.de Sun Nov 11 17:44:44 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 11 Nov 2001 23:44:44 +0100 Subject: Easy(?) newbie question In-Reply-To: <3BEEF8A9.DBF96E74@earthlink.net> References: <3BEEF8A9.DBF96E74@earthlink.net> Message-ID: <20011111234442.A1383@lilith.hqd-internal> On Sun, Nov 11, 2001 at 10:16:38PM +0000, Erik Johnson wrote: > > Hi, > > I am just getting savvy to Python - rather excited about the > possibilities, but I have come across something that seems rather simple > but I'm stumped... > > The following loop does what I would expect: > > >>> for x in range(10): print x, > ... > 0 1 2 3 4 5 6 7 8 9 > > but when I try to put this code into a string and evaluate it, I get a > syntax error: > > >>> s = "for x in range(10): print x," > >>> s > 'for x in range(10): print x,' > >>> eval(s) eval() evaluates expressions, exec() executes statements. More about what is an expression/a statement can be found in the Python documentation. Also, the Python interactive prompt does both execute and evaluate, depending on what you feed it. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From andreas at mtg.co.at Thu Nov 29 17:43:15 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Thu, 29 Nov 2001 23:43:15 +0100 Subject: U=TP Message-ID: <200111292243.fATMhGY25047@lap1.mtg.at> -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 From tim at zope.com Tue Nov 13 11:54:47 2001 From: tim at zope.com (Tim Peters) Date: Tue, 13 Nov 2001 11:54:47 -0500 Subject: Are there any list comparison optimizations in Python? In-Reply-To: Message-ID: [Michael Hudson] > I'm pretty sure that in Python <2.1 this "optimization" was enabled > for all comparisons (i.e. if "x is y", then "x == y" returns 1 without > calling any comparison methods). Yes. > It disappeared when rich comparisons turned up; for one thing NaNs > sohuld not compare equal to themselves according to ieee754 (tho' they > still seem to in 2.2). This is a platform-dependent crapshoot: it depends on what the platform C does. For paradoxical(*) reasons, it gives the illusion of working on Windows (under MSVC) today: >>> x = 1e300 >>> x *= x # build an infinity >>> x 1.#INF >>> n = x - x # build a NaN >>> n -1.#IND >>> n == n 0 >>> OTOH, 754 doesn't specify language bindings, and Python doesn't say anything about 754, so the notion that Python "==" maps to 754's equality operator is presumption on both ends . (*) It's "paradoxical" because MSVC doesn't generate correct fp comparison from 754's viewpoint. But toss in a few other accidents, and by the time Python reports a result, an even number of mistakes cancel out. From phr-n2001d at nightsong.com Fri Nov 16 17:38:38 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 16 Nov 2001 14:38:38 -0800 Subject: python vs ecmascript References: Message-ID: <7xwv0qnxxt.fsf@ruckus.brouhaha.com> I've done a fair amount of Javascript programming in browser scripts and also in a fairly big web application in server side Javascript under Netscape Enterprise Server. I think Javascript (ECMAscript) is a nice language in somewhat the same spirit as Python. It has a few minor features Python lacks. However, it's nowhere near as well developed as Python, it doesn't support the basic facilities needed for organizing big programs, and the implementations I've used (Netscape and Microsoft) are an order of magnitude slower than Python (basically, the interpreters work by constantly evaling the source code strings--there's no byte compiler and I think no parse trees kept around). ECMAscript has the potential for becoming a more capable language than it currently is. Before discovering Python, I gave some thought to what it would take to make a good ECMAscript implementation. The imagined end result turned out to be pretty close to what Python is now. Basically if you're trying to choose between ECMAscript and Python to implement something nontrivial, you should choose Python every time. However, the underlying ideas in the languages aren't as far apart as some people seem to think. Python has just done a better job carrying out the ideas. From jdadson at ix.netcom.com Sun Nov 4 20:18:22 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 01:18:22 GMT Subject: Solving Partial Differential equation in Python References: <3BE51085.90702@stu.ust.hk> Message-ID: <3BE5E8B9.ED51D0D7@ix.netcom.com> Calvin wrote: > > Greetings, > Did anyone have the experience in solving a PDE numerically in Python. > The PDE is a Euler-Lagrange equation. In fact it is a simulation of LCD > modeling. I search the web and find many libraries like Numeric Python. > But I cannot find any library aim at solving PDE. So I think I have to > design my own Algorithm. Could anyone help me. > > -Calvin I think MATLAB probably has the feature you're looking for. Not Python, but... From emile at fenx.com Thu Nov 8 11:48:54 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 08:48:54 -0800 Subject: HOWTO execute an external program? References: <9sdqtk$127dt6$1@ID-11957.news.dfncis.de> Message-ID: <9sedap$12ejvr$1@ID-11957.news.dfncis.de> "Patrick Guio" wrote in message news:Pine.LNX.4.30.0111081248470.5502-100000 at fyspc-rp18.uio.no... > I want to run my simulation code in a loop with different argument values, > I now use a bourne shell script like > > timelogger="/usr/bin/time -p > execname="picsim" > for B in 0.1 0.2 0.3 0.4 0.5 0.6 ; do > if [ ! -f $dir/${filename}B$B.hdf ] ; then > command="$execname bvector=0,$B -o $filename.hdf -i $conffile" > ($timelogger $command > run.log) > run.cmd 2>&1 > .... > fi > done > > Now I need to calculate, at each iteration, new values of several other > arguments and it looks like python is nice to do maths operations. > So what I need is > > iteration loop > calculate argument values val1,val2,...valn > command="myprog -arg1="+val1+ " -arg2="+val2.... > execute the command AND time it AND log the stdout and stderr of running > it > end > Something building on this could do it: import os for command, filetype in [('locate','.py'), ('locate','.pl'), ('locatex','.html')]: cmd = "(time %s %s >>test.log) " i, o, e = os.popen3(cmd % (command, filetype)) timings = e.readlines() print '%s : %s' % (filetype, timings) which yields: .py : ['\n', 'real\t0m6.589s\n', 'user\t0m1.900s\n', 'sys\t0m3.810s\n'] .pl : ['\n', 'real\t0m1.932s\n', 'user\t0m1.390s\n', 'sys\t0m0.070s\n'] .html : ['/bin/sh: locatex: command not found\n', '\n', 'real\t0m0.003s\n', 'user\t0m0.000s\n', 'sys\t0m0.000s\n'] HTH, -- Emile van Sebille emile at fenx.com --------- From barabba72 at hotmail.com Thu Nov 8 05:07:46 2001 From: barabba72 at hotmail.com (barabba) Date: 8 Nov 2001 02:07:46 -0800 Subject: problems when starting python References: <8ec33ba5.0111062326.1035edf2@posting.google.com> Message-ID: <8ec33ba5.0111080207.2e3c4b0@posting.google.com> Hi, this is driving me crazy !!! if I create file containing print "hi" and name it test.pyw and then click on it with the right button it says edit with IDLE but then nothing happen when i click on this item. If I double click on the file to run it...same...nothing happens !!! why ???? I have python at home and it works fine but I have noticed that even there IDLE starts fine if I run it from start | programs | IDLE but if I start it from the program icon (c:\winnt\etc etc) it doesn't start...why ???? Thank you Barabba "Fredrik Lundh" wrote in message news:... > "barabba" wrote: > > I just started using python and have the following problem. > > when i double-click the pythonw.exe the application does not start !! > > Anybody knows why ? > > pythonw.exe is designed to let you run a python script without > an associated console window. > > to make something appear on the screen, you must 1) pass > a script name to pythonw.exe, and 2) make sure that script > creates a window (usually by using Tkinter or any other UI > toolkit). > > (you can get around (1) by using the extension ".pyw" instead > of ".py", and clicking on the pyw file. the following excerpt from > o'reillys "python programming on win32" contains a little more info: > > http://www.onlamp.com/pub/a/python/excerpts/chpt20/?page=2 > > ::: > > if you're just tinkering, use IDLE or fire up a command (MS-DOS) > window, and run the interpreter from there: > > c:\mydir> python myscript.py > > or > > c:\mydir> python > PythonWare 2.2b1 on win32 > Type "help", "copyright", "credits" or "license" for more information. > >>> import mymodule > > From root at rainerdeyke.com Tue Nov 27 23:23:17 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 28 Nov 2001 04:23:17 GMT Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> Message-ID: "Peter Hansen" wrote in message news:3C045F92.AD720B at engcorp.com... > Greg Ewing wrote: > > > > While trying to think of a range syntax that looks > > unambiguously half-open without clashing with list > > or tuple constructors, the following blindingly > > obvious solution occurred to me: > > > > for 0 <= i < 5: > > ... > > -1 for being ambiguous to newbies. What would > that mean, start and zero and go until four? > Probably, but *I* read the previous thread on this. > If a newbie had just learned about Python's ability > to evaluate 0 <= i < 5 and return 1 or 0 for true/false > the above might be a little perplexing. Is it like > for 1: if i is in that range, and for 0: if not? The same could be said for 'for i in range(5)', since 'i in range(5)' is an expression that is roughly equivalent to '0 <= i < 5'. > Just in typing the above I had to hit backspace > three times to type it right. May "look" nice > to some, but too obscure to others I think. > Why fix what doesn't need fixing? Having written several programs where the vast majority of 'for' loops were in the form 'for something in range(something_else)', I would appreciate the syntax sugar of 'for i in 5'. All the other suggestions strike me as worse than 'range'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From deoradh at yahoo.com Sat Nov 10 20:00:31 2001 From: deoradh at yahoo.com (Keith Farmer) Date: 10 Nov 2001 17:00:31 -0800 Subject: C-extension in Python -- returning results References: Message-ID: "Delaney, Timothy" wrote in message news:... > Don't even think about it ... the braces are *always* there by the time I > start writing the enclosed code, properly indented. I used to be that way, too. Hell, I just finished (not long ago) converting an atrocious amount of Tcl to J2EE. You'd think I'd have noticed it. ... Bless Python ... Now to test that the numbers actually match what they should be. From matt at mondoinfo.com Tue Nov 13 23:15:29 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 14 Nov 2001 04:15:29 GMT Subject: PEP proposal: enhanced string functions References: Message-ID: On 13 Nov 2001 12:54:47 -0800, Stephen Ferg wrote: Steve, >Title: Optional pad character for string justification functions I like this. >Title: Optional argument for string strip functions > The proposal is to allow these functions and methods to take one > optional argument in addition to the arguments that they now > accept. The argument is called "stripchar". If the stripchar > argument is unspecified or is specified as None, then these > functions and methods will do exactly what they now do, and strip > whitespace. If the stripchar argument is specified, and not > specified as None, it must contain a single character. If the > stripchar argument is specified, then rather than stripping out > whitespace, the functions and methods will strip out the > specified stripchar character. This bothers me a bit for the same reason that the split() method does. It strikes me as weird that without arguments, split() splits on all whitespace but that it will only take one character as an argument. I'd prefer to be able to pass a sequence to strip() and have any of those characters stripped. Regards, Matt From gh_pythonlist at gmx.de Thu Nov 1 16:41:04 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 1 Nov 2001 22:41:04 +0100 Subject: List transpose method In-Reply-To: <20011101221213.A7406@lilith.hqd-internal>; from gh_pythonlist@gmx.de on Thu, Nov 01, 2001 at 10:12:16PM +0100 References: <20011101221213.A7406@lilith.hqd-internal> Message-ID: <20011101224104.B7406@lilith.hqd-internal> On Thu, Nov 01, 2001 at 10:12:16PM +0100, Gerhard H?ring wrote: > On Fri, Nov 02, 2001 at 08:42:23AM +1100, Tom Harris wrote: > > Hi, > > > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > > only come up with an ugly multiliner. > > I guess any single-liner will be obfuscated Python and not necessarily > any more efficient. > > If you need such things often, I'd suggest you take a look at Numeric > Python. It contains many functions for matrices. > > Interesting problem nevertheless ... This is my ugly version with list comprehensions. I'm looking forward to seeing better ones :-) # Fun with list comprehensions def transpose(m): n = len(m) return [[m[j][i] for i in range(len(m[0])) for j in range(n)][k*n:k*n+n] for k in range(len(m[0]))] l = ((1,2), (3,4), (5,6)) print l print transpose(l) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From skip at pobox.com Tue Nov 6 08:49:14 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 6 Nov 2001 14:49:14 +0100 Subject: Finding name for a signal number In-Reply-To: <9s8oqk$a38$1@isp-m-srv06.izb.net> References: <9s8oqk$a38$1@isp-m-srv06.izb.net> Message-ID: <15335.59994.988910.81591@beluga.mojam.com> Oliver> In a small script I'd like to print the name of a signal number: Oliver> In the event that an os.system() call is aborted by a signal, Oliver> the signal number is returned in the lower 7 bits of the return Oliver> value. I'd like to print a meaningful message which includes Oliver> the signal name (like "SIGQUIT"), not just the number. ... Oliver> The next thing I came up with is extracting the signal Oliver> names from the namespace dictionary of the signal module Oliver> itself, like this: You are very close, but if you have to do this repeated, you probably don't want to do it on-the-fly, just once ahead of tim. As you noticed, the names are there in the signal module, just not in quite the format you'd like. Try something like the following to generate a dictionary that will map a signal number back to its name: >>> import signal >>> for nm in dir(signal): ... if nm.startswith("SIG"): ... v = getattr(signal, nm) ... if type(v) == type(1): ... d[v] = nm ... >>> d {0: 'SIG_DFL', 1: 'SIG_IGN', 2: 'SIGINT', 3: 'SIGQUIT', 4: 'SIGILL', 5: 'SIGTRAP', 6: 'SIGIOT', 7: 'SIGBUS', 8: 'SIGFPE', 9: 'SIGKILL', 10: 'SIGUSR1', 11: 'SIGSEGV', 12: 'SIGUSR2', 13: 'SIGPIPE', 14: 'SIGALRM', 15: 'SIGTERM', 17: 'SIGCLD', 18: 'SIGCONT', 19: 'SIGSTOP', 20: 'SIGTSTP', 21: 'SIGTTIN', 22: 'SIGTTOU', 23: 'SIGURG', 24: 'SIGXCPU', 25: 'SIGXFSZ', 26: 'SIGVTALRM', 27: 'SIGPROF', 28: 'SIGWINCH', 29: 'SIGPOLL', 30: 'SIGPWR', 31: 'SIGSYS'} You can then use the dictionary in your get_signame function to map signals to their names quickly. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From logiplexsoftware at earthlink.net Thu Nov 15 15:55:21 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 15 Nov 2001 12:55:21 -0800 Subject: What is "marshal data"? In-Reply-To: References: <859c71be.0111151028.63227109@posting.google.com> Message-ID: <01111512552100.23196@logiplex1.logiplex.net> On Thursday 15 November 2001 11:24, Michael Hudson wrote: > Cliff Wells writes: > > On Thursday 15 November 2001 10:28, Soren Ragsdale wrote: > > > Possible sources of the problem: "uh.py" is imported from MANY > > > programs on our network. It's being imported by Linux and Irix > > > machines running 1.5.2 and 2.1.1 versions of Python. Could this be > > > > As mentioned in another thread, the bytecode between python versions is > > not backward compatible, so you may be trying to execute 2.1.1 bytecode > > on a 1.5.2 interpreter and that may be causing the problem. > > Shouldn't be. The first four bytes of a .pyc file are a > version-specific magic number, meant to stop this happening. > > Executing the wrong bytecode would cause SystemErrors or core dumps, > not ValueErrors complaining about marshal data -- the marshal module > does little checking of its input, as it's only there to speed things > up... So what is probably happening then is similar to what Soren originally suggested: the different python versions read the .pyc, occasionally seeing that it isn't the correct bytecode version and so rewrite it, and it basically comes down to concurrency issues (one process rewriting the file while another is reading from it). If this is the issue, then my suggestion for maintaining separate directories for each version should still resolve the problem. Something else that may help would be to also pre-compile the .pyc files rather than doing it at runtime (he would still need to maintain separate directories for the different versions). Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From phd at phd.pp.ru Tue Nov 6 10:18:12 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 6 Nov 2001 18:18:12 +0300 Subject: Freeware Python editor In-Reply-To: <9s8u5d$11feke$1@ID-11957.news.dfncis.de>; from emile@fenx.com on Tue, Nov 06, 2001 at 06:59:31AM -0800 References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> <9s8u5d$11feke$1@ID-11957.news.dfncis.de> Message-ID: <20011106181812.F20452@phd.pp.ru> On Tue, Nov 06, 2001 at 06:59:31AM -0800, Emile van Sebille wrote: > > > Let me add to this that in such a boring predictable world, I have > always > > > appreciated Oleg's Pushkin-Lermentov-like sensibility and idealism :) > > > > Always? Did I really show it *so* many times? :) > > ;-)) > About as predictable as waiting for Martijn to jump in about the PS Hmm. Something funny is in the Russian air if even me (neither Russian, nor even born in Russia, though I live in Moscow now) behave like that :))) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From slinkp23 at yahoo.com Thu Nov 22 17:22:13 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 22 Nov 2001 22:22:13 GMT Subject: Web hosts and Python 2.1 References: <20011122.082840.1253263156.7318@localhost.localdomain> Message-ID: On Thu, 22 Nov 2001 16:31:06 GMT, Harold Shore wrote: >So my question is: does anyone on this group know of a North American web >host who offers an up-to-date python package? www.hurrah.com has both 1.5.2 and 2.1.0. They'd probably upgrade the 2.1 if asked - they've been very accommodating to my requests so far. --PW From gh_pythonlist at gmx.de Sat Nov 17 02:32:22 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sat, 17 Nov 2001 08:32:22 +0100 Subject: CGI output In-Reply-To: References: <63343bfd.0111161819.14263d83@posting.google.com> Message-ID: <20011117083220.A940@lilith.hqd-internal> On Fri, Nov 16, 2001 at 06:41:31PM -0800, Sean 'Shaleh' Perry wrote: > > > > but I still can't manage to do it... How would I call my command so > > that the output is displayed "continuously" to my user on the web page > > ? > > > > you can't, web pages don't work that way. It *is* possible, using HTTP/1.1. I'd have to dig out the RFC for details, though. Gerhard -- The information transmitted in this message (if any) is intended only for the person or entity to which it is addressed. The message may contain confidential and/or privileged material. It doesn't really matter, we will append this lengthy legalese mumbo-jumbo anyway. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited. The same goes for the intended recipient herself. If you have received this in error, please contact your lawyer and delete this e-mail and everything else from any computer in your vicinity. The intended recipient of this e-mail may only use, reproduce, disclose or distribute the information contained in this e-mail and any attached files, with the permission of BigBrother Inc. This message has been scanned for anti-Microsoft propaganda and cleared by MailMarshal. From jgardn at alumni.washington.edu Wed Nov 28 09:38:28 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Wed, 28 Nov 2001 23:38:28 +0900 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) In-Reply-To: <000201c17796$08a02fc0$1d4bb43f@kens> References: <9tia10$43o$1@dahlia.singnet.com.sg> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: <01112823382803.13207@linux> Ken Seehof wrote: > > > > more. True, I think .NET is cool - but I'll only use it if MS keeps it > > promise and ports it too Linux and such. > > Odds of MS keeping any promises of this kind: 0.027% > > It has never been in MS's best interest to be compatible with the rest of > the > computing world. > Look at Visual C++. Portability? Compatability? Ha. Look what they did to Java, HTTP, HTML, and JavaScript. Microsoft is in the business of making money, not software. Jonathan From xx758 at cam.ac.uk Thu Nov 22 10:11:57 2001 From: xx758 at cam.ac.uk (Xiao-Qin Xia) Date: Thu, 22 Nov 2001 15:11:57 -0000 Subject: Bug in Python 2.1.1? Message-ID: <9tj4fm$5oq$1@pegasus.csx.cam.ac.uk> Hi, I write a program for simulation in pure python with Tkinter. In order to be able to interrupt at any time, the simulation module runs as a thread. It can run days in python 2.0, but if running python 2.1.1 it will be closed by windows 2000 in about half a hour. If running not as a thread, no problem. Does that mean Python 2.1.1 has a bug in thread management? Cheers, Xiao-Qin From peterb at cortland.com Thu Nov 15 14:56:26 2001 From: peterb at cortland.com (Peter Bismuti) Date: Thu, 15 Nov 2001 11:56:26 -0800 Subject: anonymous functions? class? Message-ID: <3bf4240d$1@207.229.64.20> I want to pass a function as an argument but don't want to have to define it globally. I think the proper terminology for this is "anonymous". The way I *don't* want to do it: def foo(): pass callFunction(foo) The way I want to do it: callFunction(def foo(): pass) I'm guessing this can't be done because of Python's indenting syntax. In ECMAscript you can send a function as an argument that is defined on the fly such as: callMyFunction( new Function(){ blah blah }) Something like that. Here the function has not been named and was not defined outside of the call. Can this be done in Python? Thanks From barry at zope.com Tue Nov 27 23:38:27 2001 From: barry at zope.com (Barry A. Warsaw) Date: Tue, 27 Nov 2001 23:38:27 -0500 Subject: RELEASE Mailman 2.0.8 Message-ID: <15364.27203.371506.802338@anthem.wooz.org> I've just released version 2.0.8 of Mailman, the GNU Mailing List Manager. Mailman is released under the GNU General Public License (GPL). Version 2.0.8 closes several cross-site scripting vulnerabilities and includes a few other minor bug fixes. More information on cross-site scripting exploits in general can be found at http://www.cert.org/advisories/CA-2000-02.html I recommend anybody running a version of Mailman up to, and including 2.0.7 to upgrade to version 2.0.8. GNU Mailman is software to help manage electronic mail discussion lists. Mailman gives each mailing list a unique web page and allows users to subscribe, unsubscribe, and change their account options over the web. Even the list manager can administer his or her list entirely via the web. Mailman has most of the features that people want in a mailing list management system, including built-in archiving, mail-to-news gateways, spam filters, bounce detection, digest delivery, and so on. Mailman is compatible with most web servers, web browsers, and mail servers. It runs on GNU/Linux and should run on any other Unix-like operating system. Mailman 2.0.8 requires Python 1.5.2 or newer. To install Mailman from source, you will need a C compiler. For more information on Mailman, including links to file downloads, please see the Mailman web page: http://www.gnu.org/software/mailman And its mirrors at: http://mailman.sourceforge.net http://www.list.org (Note: the gnu.org mirror is not yet updated.) Patches and tarbals are available at http://sourceforge.net/project/showfiles.php?group_id=103 There are email lists (managed by Mailman, of course!) for both Mailman users and developers. See the web sites above for details. Cheers, -Barry -------------------- snip snip -------------------- 2.0.8 (27-Nov-2001) Security fix release to prevent cross-site scripting exploits. See http://www.cert.org/advisories/CA-2000-02.html for a description of the general problem (not Mailman specific). From donn at drizzle.com Sat Nov 10 12:23:55 2001 From: donn at drizzle.com (Donn Cave) Date: Sat, 10 Nov 2001 17:23:55 -0000 Subject: string manipulation question References: None Message-ID: <1005413035.12088@yabetcha.sttl.drizzle.com> Quoth "AT&T News" : | I am looking for a more resaonable way to do the following, instead of ugly | "if", "elif" constructs. Here goes: | | I have a string (line) that might contain, for example *any* *one* of the | patterns or words "whale" , "cat". | How do I elegantly set a variable say "animal" depending upon what word is | there. I.e I want | animal = "MAMMAL" if line contains the word "whale" | or | animal = "FELINE" if line contains the word "cat". | | is there a elegant way to code the above construct, I have 10 of these | patterns/keywords that can be found in a line. I thought of using a | dictionary for the keyword patterns, but the pattern/keyword does not have | any known context in the line. I guess the assignment is clear enough here, but your goal has an esthetic dimension that isn't so clear. Can you be more specific about ugliness and elegance? Do it the obvious way, why not? Donn Cave, donn at drizzle.com From dalke at dalkescientific.com Sun Nov 18 15:00:15 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sun, 18 Nov 2001 13:00:15 -0700 Subject: identity = lambda x: x -- a Pythonic idiom? References: Message-ID: <9t93vi$6gi$1@slb7.atl.mindspring.net> Marco Antoniotti: >Within CL, it turns out that `identity' is useful in a number of >cases, especially when dealing with sequence operators. E.g. the >`sort' function is really defined as > > sort &key (key #'identity) > >So that you can write things like > > * (sort '(2 3 4 1) #'<) > '(1 2 3 4) > * (sort '((1 3) (3 0) (33 9) (19 5)) #'< :key #'second) > ((3 0) (1 3) (19 5) (33 9)) > >All in all a good thing. I've been staring at this trying to figure out what it does, and I think I got it. What threw me off, I think, was the '*'. It's a prompt, and the indented one on the 3rd line is a misindent -- it should be 7 characters to the left, and there are actually two different one-line expressions evaluated here. Then in the "sort &key (key #'identity)" line the '&key' says that field is 1) optional and 2) a keyword argument, and that if not given the identity function is used. Finally, the "#'" syntax is used to get a reference to a special symbol, and ':key' is how to specify a keyword argument. Am I right so far? Python only uses one function for this, which means the field extraction and data comparison must be composed into one function, >>> a = [(1, 3), (3, 0), (33, 9), (19, 5)] >>> a.sort(lambda x, y: cmp(x[1], y[1])) >>> a [(3, 0), (1, 3), (19, 5), (33, 9)] >>> The sort function is (was) also defined in terms of C-style three-way sorting. It's been changed so that only '<' comparison is needed, but I don't know how that change affects the comparison function used. In CL it looks like you'll have to do the same sort of thing for data values which don't have a 1D sorting, like >>> a = [(1, 3), (100, 5), (33, 9), (19, 5)] >>> a.sort(lambda x, y: cmp(x[1], y[1]) or cmp(x[0], y[0])) >>> a [(1, 3), (19, 5), (100, 5), (33, 9)] >>> Andrew dalke at dalkescientific.com From just at letterror.com Sat Nov 17 05:27:21 2001 From: just at letterror.com (Just van Rossum) Date: Sat, 17 Nov 2001 11:27:21 +0100 Subject: Does smtplib lookup MX records? References: <3BF56916.8834B8D7@letterror.com> <52ac9479.0111170050.f56492a@posting.google.com> Message-ID: <3BF63C49.E0B87A0E@letterror.com> Lad wrote: > > Just van Rossum wrote in message news:<3BF56916.8834B8D7 at letterror.com>... > > Dale Strickland-Clark wrote: > > > > > I've been trying to send emails with smtplib and had a large number of > > > failures. Investigation seems to reveal the the smtplib module does a > > > simple connect passing the hostname to socket.connect without trying > > > to resolve the MX record. > > > > > > In some cases this works where the mail server happens to have an > > > A-type DNS record anyway but otherwise it fails with a connection > > > error. > > > > > > Is this really the case? > > > > > > If it is, what do I need to do to lookup the MX record myself? > > > > > > (This is rather urgent now as this program was hastily written to help > > > a client out who's mail server has died.) > > > > Are you sure you're using smtplib correctly? I *think* it's mostly meant > > to talk to a local relay host (eg. smtp.my-isp.com). The smtp server > > will take care of the rest. If you insist on delivering yourself, then > > yeah, you'd have to look up the mx record for each recipient, but I > > wouldn't consider that typical usage of smtplib. Am I missing something? > > > > Just > > If you use windows you can use , for MX records lookup, > http://www.internext.co.za/stefan/aspmx/aspmx.zip > It works well. > Ladislav But isn't the point that you shouldn't *have to* look up mx records? Just use your local smtp server and you're set. Just From thomas at gatsoft.no Mon Nov 19 07:00:10 2001 From: thomas at gatsoft.no (Thomas Weholt) Date: Mon, 19 Nov 2001 12:00:10 GMT Subject: ANN : DivXInfo v0.1.0 Message-ID: DivXInfo extracts information from AVI- and DivX-files. Get it from : http://projects.weholt.org/ Enhancements, improvements etc. are very welcome. PS ! If anybody know of ways to extract similar information from MPEGs, RealPlayer files or QuickTime movies using pure Python, I'd be glad to know. Best regards, Thomas Weholt From justin at iago.org Thu Nov 29 16:59:53 2001 From: justin at iago.org (Justin Sheehy) Date: Thu, 29 Nov 2001 16:59:53 -0500 Subject: Python, licenses and CVS In-Reply-To: <9u5d00$6aald$1@ID-59885.news.dfncis.de> ("Thomas Heller"'s message of "Thu, 29 Nov 2001 14:10:49 +0100") References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <9u5d00$6aald$1@ID-59885.news.dfncis.de> Message-ID: "Thomas Heller" writes: > Sometimes I hear some rumour about Perforce, but I never tried it. Perforce is very nice, but not free if you want more than two users. -Justin From dag4004 at caramail.com Tue Nov 13 17:21:02 2001 From: dag4004 at caramail.com (dag4004) Date: Tue, 13 Nov 2001 23:21:02 +0100 Subject: PyRun_SimpleFile Error on Windows ??? Message-ID: <3bf19d44$0$32060$626a54ce@news.free.fr> Hello, I embedded Python in Win32 C application and I have an error with PyRun_SimpleFile. I compile with MVSC 6.0 on Win2000. I have seen on an FAQ that it could be due to /MD flag for Multi-threading DLL but it hasn't any effect. Does some one know how to solve it. Thanks From skip at pobox.com Fri Nov 16 09:28:44 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 15:28:44 +0100 Subject: OT:This group archived? In-Reply-To: <9t367u$kg6$1@neptunium.btinternet.com> References: <9t367u$kg6$1@neptunium.btinternet.com> Message-ID: <15349.8860.18667.374422@beluga.mojam.com> Derek> Is this group archived anywhere ... Yeah, there are a couple archives. I believe Google, Yahoo! Groups and mail.python.org have fairly complete archives. I think the Yahoo! Groups archive may be the only one that actually goes back to message #1 of python-list at cwi.nl: http://groups.google.com/groups?hl=en&group=comp.lang.python (can't find the page for the Yahoo! Groups version just now) http://mail.python.org/mailman/listinfo/python-list Other places to look for information before posting questions to the list include (but are not limited to): The Python FAQ: http://www.python.org/doc/FAQ.html The Python Tutorial: http://www.python.org/doc/tut/tut.html The Python Cookbook: http://aspn.activestate.com/ASPN/Python/Cookbook/ Useless Python: http://www.lowerstandard.com/python/ The Vaults of Parnassus: http://www.vex.net/parnassus/ -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From jeff at ccvcorp.com Mon Nov 19 20:42:42 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 19 Nov 2001 17:42:42 -0800 Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> Message-ID: <3BF9B512.A784475C@ccvcorp.com> Don Arnold wrote: > I'm new to python and am interested in developing apps with Tkinter. > However, every IDE I've come across for the Win32 platform experiences > lockups/aborts when running Tkinter code. So far I've tried IDLE, PythonWin, > and WING with little luck. Does anyone know of an IDE that successfully > executes Tkinter code? There are two problems with running Tkinter in most IDE's. One is that Tk-based apps share the same event queue, so that running a Tk app inside of another Tk app will confuse things. The other is that different GUI toolkits almost never play well together, so running a Tk app inside of a different GUI kit's apps will confuse things. The full solution is to find an IDE that executes programs in a separate process. I couldn't tell you offhand which IDEs do this, but neither IDLE nor PythonWin do, and it's fairly likely that you would need to use a commercial IDE for this (though you may find one that's free for open-source development). The workaround, is to have both an IDE *and* a shell window (dos prompt) open at the same time. Make changes to your app, save them, switch to the dos prompt, and "python myscript.py", which you can do repeatedly by using up-arrow (you will need to run doskey first on win95/98, but not on NT/2k). This doesn't allow much interactive debugging, but overall seems to work fairly well (you can use print statements to send comments to the dos window). Jeff Shannon Technician/Programmer Credit International From neilb at nbt.co.za Sat Nov 17 01:02:01 2001 From: neilb at nbt.co.za (Neil Beattie) Date: Sat, 17 Nov 2001 08:02:01 +0200 Subject: MultiThread Socket on NT In-Reply-To: <01111616083701.03405@logiplex1.logiplex.net> Message-ID: The ms documentation says this about sockets "Windows NT Server version 4.0 allows a backlog maximum of 200. Windows NT Workstation version 4.0 supports only a maximum allowable value of 5." Does this not affect the situation? Neil. > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Cliff Wells > Sent: Saturday, November 17, 2001 2:09 AM > To: python-list at python.org > Subject: Re: MultiThread Socket on NT > > > On Friday 16 November 2001 14:26, David Bolen wrote: > > Cliff Wells writes: > > > Be sure you are using at least SP5. NT 4 had serious threading issues > > > prior to that. > > > > Do you have any pointers or references to what the problem was? I've > > been using multi-threaded applications (although not a high density > > connection server) under NT4 SP4 without any observable problems. > > It's been around three or four years since I encountered that, so the > details are pretty vague now.... I was writing an instant > messaging server > that spawned a thread for every incoming connection (not the best > way, but > it was my first attempt at network programming, multithreading and my > first Python program to boot =). I was stress-testing my server > and I had > an adjustable parameter limiting the number of threads allowed at any one > time. If I set this higher than, say 20 (highly questionable if that's > the number), NT would flake out (I think to the point of BSOD, > but I can't > recall). Anyway, without changing any code, applying SP5 fixed it, and I > seem to recall that threading was one of the issues addressed in SP5. > > -- > Cliff Wells > Software Engineer > Logiplex Corporation (www.logiplex.net) > (503) 978-6726 x308 > (800) 735-0555 x308 > > -- > http://mail.python.org/mailman/listinfo/python-list > From sholden at holdenweb.com Mon Nov 26 07:37:23 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Nov 2001 07:37:23 -0500 Subject: (newbie) A very weird Python CGI problem, possibly related to os.system References: Message-ID: "Simon Willison" wrote ... > I have a very odd Python CGI problem. I'm writing a simple web script > which queries Quake III game servers and displays the server name / > map / number of players on a web page. The script works by executing a > command line program called qstat (www.qstat.org). I'm very new to > python, and I'm using this project as a learning excercise. > > Anyway, here's the problem: When I run the script I have written from > the command line it works fine: > > bwaf $ qstat.py > > > OMG!! > > > > ResNet Game Server Listing System

> [{'maxplayers': '12', 'name': 'blueyonder Quake 3 Free For All #2', > 'players': ' > 0', 'ip': '62.30.30.160:27961', 'map': 'q3dm8'}, {'maxplayers': '12', > 'name': 'b > lueyonder Quake 3 Free For All #1', 'players': '0', 'ip': > '62.30.30.160:27960', > 'map': 'q3dm13'}] > > > > > However, when I visit the script on the web the page displayed shows > an empty list: > > ResNet Game Server Listing System > > [] > > The script is here: http://www.bath.ac.uk/~cs1spw/cgi/servers/qstat.py > > I'm completely baffled as to why the list is populated when I run the > script myself, but appears empty when the script is executed via the > web. Could this be a unix permissions problem? I doubt it, as a > smaller test script which I wrote to display results from qstat shows > information in the browser fine. Unfortunately the script is quite > long so I'll only post a snippet here, I'm happy to post the rest (or > place it on the web) if it will help solve the problem. > > Cheers, > > Simon > > import os, sys, string, tempfile, common > from common import custom_die, servertypes > > qstat = '/u/cs/1/cs1spw/qstat24e/qstat' # Path to qstat > tempdir = '/u/cs/1/cs1spw/public_html/cgi/servers' # Used by mktemp() > badstatus = ['DOWN', 'TIMEOUT'] > > def gameservers(game): > """ returns array of dictionaries of server details for game """ > array = [] > # Run qstat on the game file > if (not servertypes.has_key(game)): > custom_die('Invalid game specified!') > tmp = tempfile.mktemp() > run = qstat + " -raw ~@~@~ -f " + game + " > " + tmp > os.system(run) > file = open(tmp, 'r') > lines = file.readlines() > file.close() > os.remove(tmp) > for line in lines: > if (string.strip(line)): > try: > bits = string.split(line, '~@~@~') > except ValueError: > continue > if (string.strip(bits[2]) in badstatus): > continue > else: > # Create a dictionary of details about the server > dict = {} > dict = { > 'ip': bits[1], > 'name': bits[2], > 'map': bits[3], > 'maxplayers': bits[4], > 'players': bits[5] > } > # put the dictionary in the array > array.append(dict) > return array > > # test code > common.output('OMG!!', gameservers('q3s')) > > And from common.py... > > servertypes = { > 'q3s': 'Quake III', > 'hls': 'Half-Life' > } > > def output(title, html): > """ outputs a page using header.txt with %title% replaced and > footer.txt """ > file = open('header.txt', 'r') > lines = file.readlines() > file.close() > for line in lines: > line = string.replace(line, '%title%', title) > print line > print html > file = open('footer.txt', 'r') > lines = file.readlines() > file.close() > for line in lines: > print line > sys.exit(0) > > def custom_die(message): > """ Die with an error message """ > output('Error!', message) What server are you running with? If it's Apache, you should look in the error log to see whether messages are being logged. Perhaps environment differences are causing errors you aren't seeing? regards Steve -- http://www.holdenweb.com/ From glchapman at earthlink.net Mon Nov 5 08:32:29 2001 From: glchapman at earthlink.net (Greg Chapman) Date: Mon, 05 Nov 2001 13:32:29 GMT Subject: [ #456742 ] Failing test case for .*? References: <9s0rqo$rrg$1@bob.news.rcn.net> Message-ID: On Sat, 3 Nov 2001 13:06:03 -0500, "Tim Peters" wrote: >The bug is that the pattern should have found just the 'a1' tail, not all of >s; it's the same bug in both cases: > >import re >s = "a\nb\na1" > >m = re.search(r'[^\n]+?\d', s) >print m and `m.group(0)` # prints 'a\nb\na1'; should have been 'a1' > >m = re.search(r'([^\n]+?)\d', s) >print m and `m.group(0)` # also prints 'a\nb\na1' I think this is the same bug I ran into in August (see report 456612). Note that newlines are not special for this: >>> s = "acbca1" >>> m = re.search(r"[^c]+?\d", s) >>> m.group(0) 'acbca1' >>> m = re.search(r"([^c]+?)\d", s) >>> m.group(0) 'acbca1' I did a little tracing through the SRE code, and it looked to me that the change labled 133283 caused this. I believe the change was made so that minimizing repeats minimized the number of characters they match (rather than minimizing the number of times the repeated pattern matches); see the test case (also labeled 133283) added to re_tests.py. This is done by finding the nearest occurance of the pattern following the minimizing repeat (the "\d" in this example), and then (in theory) checking to see if the intervening characters match the minimally repeated pattern. Unfortunately, it appears that in some cases SRE skips the check of the intervening characters, so minimally repeated groups end up matching anything. I think this may also explain the matching of newlines in the absence of re.DOTALL as reported in bug 477728. --- Greg Chapman From matt at mondoinfo.com Wed Nov 28 15:53:21 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Wed, 28 Nov 2001 20:53:21 GMT Subject: Determining word wraps in Tkinter text widget References: <371b5d38.0111270218.4b92b810@posting.google.com> <9u037i$u76$1@mail1.wg.waii.com> <371b5d38.0111281224.2eb362d@posting.google.com> Message-ID: <59cN7.32194$H7.4110530@ruti.visi.com> On 28 Nov 2001 12:24:46 -0800, David Wangerin wrote: >By floating, I mean that I have a frame on the side of the textbox >(it's filled so it is the same size as the textbox) that will contain >the widgets. There will be a set of widgets corresponding to each >line in the textbox. To keep the appearance of the text consistent, I >would like to keep the controls outside of the textbox. As the text >is scrolled up or down, the frame with the widgets gets redrawn to >reflect the new viewable text. If I lock the size of the textbox, I >can always know how many lines are being displayed, but whenever a >line wraps, I need to lower that number by one (I can't have two sets >of controls, one for the start of the line and another for the end of >the line). Horizontal scrollbars would solve this problem, but I will >only use them as a last resort. Dear David, You can do that but the only technique I can think of is something of a nuisance. You'll need to figure out how many dots tall a line is (the tkFont module may help here) and then step down the widget one line-height at a time and use the widget's index() method with argument of the form @x,y to see if you've gone on to the next line of text when you've gone down one line-height. Here's a small example: >>> from Tkinter import * >>> r=Tk() >>> t=Text(r,width=10) >>> t.pack() >>> t.insert(END,"one\ntwo\n") >>> t.index("@0,5") '1.0' >>> t.index("@0,25") '2.0' >>> t.delete("1.0",END) >>> t.insert("1.0","one two three four five six") >>> t.index("@0,5") '1.0' >>> t.index("@0,25") '1.10' In the first case, going down 25 dots puts us at the beginning of line two but in the second case, we're at the tenth character of line one. Regards, Matt From logiplexsoftware at earthlink.net Fri Nov 2 18:07:05 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 15:07:05 -0800 Subject: Freeware Python editor In-Reply-To: <9rv6ga0108t@drn.newsguy.com> References: <9rv6ga0108t@drn.newsguy.com> Message-ID: <01110215070508.09296@logiplex1.logiplex.net> On Friday 02 November 2001 14:25, Grant Griffin wrote: > About which part? (And no fair saying "all" .) Due to PSA restrictions, I'm not "free" to divul -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From mertz at gnosis.cx Tue Nov 13 10:20:25 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Tue, 13 Nov 2001 10:20:25 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: <5oT87kKkX0VS092yn@bellatlantic.net> David Eppstein wrote: > for i in [n-1, n-2, ... 0]: > for j in [i+1, i+2, ... n]: > ...do something... James_Althoff at i2.com wrote: |Thanks for your interesting example. I agree that your notation "[n-1, |n-2, ... 0]" is a very nice way of showing a sequence of integers. I'm not |sure how one would turn this into programming language syntax that would be |as clear. Well... here's how Haskell does it: [1 .. 4] --> [1,2,3,4] [4,3 .. 0] --> [4,3,2,1,0] [2,4 .. 10] --> [2,4,6,8,10] [0.0,0.3 .. 1.0] --> [0.0,0.3,0.6,0.9] It's hard to think of a better syntax for Python to use. From dalke at dalkescientific.com Tue Nov 6 13:34:18 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 6 Nov 2001 11:34:18 -0700 Subject: Having a builtin exit function in python interpreter References: <3BE7B2D7.3080605@sferacarta.com> Message-ID: <9s9ajr$qmg$1@slb4.atl.mindspring.net> zammon at libero.it (forwarding from Jose Soares): >> I think this interest every else programming with curses or slang. But not those not programming terminal applications. >> >>> import sys >> >>> sys.exit(0) >> ----------------------------------------------------------------------- >> >> How to solve this problem: >> __builtin__.exit = __builtin__.quit = sys.exit The 'exit' and 'quit' builtins are strings that hint to the programmer that those commands don't work as expected. The key part is 'expected.' Beginning Python developers don't expect that 'exit()' is require to exit and would be confused if typing 'exit' by itself returns "". I suspect they wouldn't think to try 'exit()'. Those programming terminal apps are rare, and usually able to figure out how to tweak site.py to make the way they want it to be. >> I think it whould be very useful to have a builtin function quit() or >> exit() to avoid to import the sys module to exit from python. Another way to exit, without importing sys, is raise SystemExit >> I modified site.py in my system. What about to have this modify in the >> official release? You could also have a 'sitecustomize.py' in your working directory which would do this for you, instead of modifying site.py. So -1 for me on your proposal. Makes things more complicated for the people for which it is designed. Andrew dalke at dalkescientific.com From sholden at holdenweb.com Mon Nov 19 12:34:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Nov 2001 12:34:24 -0500 Subject: context-sensitive help from editor References: <9tbetv$e92$1@netnews.upenn.edu> Message-ID: The ActiveState distributions usually come with a .CHM file, and Robin Dunn has made such files available through his web site (you can track these down via www.activestate.com and www.alldunn.com respectively). I have noticed that some of the inter-section links seem to be missing in the .CHM versins, but they are nevertheless extremely useful. regards Steve -- http://www.holdenweb.com/ "Mike Maxwell" wrote in message news:9tbetv$e92$1 at netnews.upenn.edu... > Excuse me if this has been asked, but I didn't see anything in the FAQ, the > archive of this newsgroup (except for a 1995 msg), etc. > > My editor (Visual SlickEdit, on Win2k) has context-sensitive help for a > number of programming languages. Normally, this calls a Windows Help (.HLP, > or nowadays .CHM) file with a keyword. I would like to be able to do this > with Python, but all I can find are .html, .PDF, and .PS files, and I don't > know how to open one of these at a given keyword (or make it jump to a new > keyword if it's already open). I can of course drill down through the > links, but that misses the point of having context-sensitive help. > > Is there a .HLP or .CHM file out there somewhere? Or is there an easy way > to turn a .HTML file into a .CHM file? (Or a way of passing a keyword to > Adobe Reader or GhostView, so it goes directly to the relevant place in the > doc.) > > -- > Mike Maxwell > Linguistic Data Consortium > maxwell at ldc.upenn.edu > > From phr-n2001d at nightsong.com Thu Nov 15 19:15:23 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 16:15:23 -0800 Subject: Inter-Thread Communication References: <4go7vtc8dqm8qsfq8ttv95bopidscj56l2@4ax.com> <3bf3fcfa$1@brateggebdc5.br-automation.co.at> <4018vt4s27jv3ranig9apbeonfjsgp5ke1@4ax.com> Message-ID: <7x8zd7y3j8.fsf@ruckus.brouhaha.com> Dale Strickland-Clark writes: > I wonder how many more standard modules I have no clue about. You could read the manual and find out about most of them . From syver-en at online.no Thu Nov 29 13:34:25 2001 From: syver-en at online.no (Syver Enstad) Date: 29 Nov 2001 19:34:25 +0100 Subject: If UR brand spanking new to programming (like me)... References: <3c064aa3.8700849@news> Message-ID: ophiel_magick at yahoo.com (Ophiel Magic) writes: > I just started working with Python last week. I have had NO > programming experience, other than writing macros for Access. >I was > fortunate to find this group and found, through the group, MANY online > resources. I think very fortunate, this is the best newsgroup I've been to. Very knowledgeable AND nice people, and no trolls. -- Vennlig hilsen Syver Enstad From lac at strakt.com Tue Nov 6 07:16:01 2001 From: lac at strakt.com (Laura Creighton) Date: Tue, 06 Nov 2001 13:16:01 +0100 Subject: Tkinter bind single key In-Reply-To: Your message of "Tue, 06 Nov 2001 10:44:48 +0530." <15335.29128.684790.926174@monster.linux.in> References: <15335.29128.684790.926174@monster.linux.in> Message-ID: <200111061216.fA6CG1ua004275@ratthing-b246.strakt.com> Your problem is the the key with the + on it isn't called +. If you have a linux system, you can look in /usr/X11R6/include/X11/keysymdef.h to find out what something is called. What you want is called plus, unless it is on the keypad in which case it is called KP_Add. You probably want to bind both of them. So bind it to and . By the way, this business of the key-on-the-keypad is not the same as the key-not-on-the-keypad is a general problem. If you are binding to 1 2 3 then you will need to bind to KP_1 KP_2 KP_3 or else keypad users will not be able to use the keypad, which will annoy them to no end. Laura Creighton From vecernik at aon.at Fri Nov 16 13:59:16 2001 From: vecernik at aon.at (Oliver Vecernik) Date: Fri, 16 Nov 2001 19:59:16 +0100 Subject: publishing homepage Message-ID: <3BF56204.8090603@aon.at> Hi, can anyone point me to an already written python script to publish a homepage via ftp to the ISP? The problem is that I don't want to publish the whole tree, only html files and images recursing through the tree. Any glues? Best Regards, Oliver From opengeometry at yahoo.ca Fri Nov 30 15:37:29 2001 From: opengeometry at yahoo.ca (William Park) Date: Fri, 30 Nov 2001 15:37:29 -0500 Subject: Converting an integer to base 2 In-Reply-To: ; from erno-news@erno.iki.fi on Fri, Nov 30, 2001 at 10:16:16PM +0200 References: <3C07CFED.C7F7CA38@motorola.com> Message-ID: <20011130153729.A1362@node0.opengeometry.ca> On Fri, Nov 30, 2001 at 10:16:16PM +0200, Erno Kuusela wrote: > def itoa2(n): > if n < 1: > return '' > else: > return itoa2(n / 2) + str(n & 1) Brillant! -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From fredrik at pythonware.com Wed Nov 7 12:14:47 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 17:14:47 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> Message-ID: Brian Elmegaard wrote: > Exactly, you don't have to do it perfectly, when you start learning > how to do it. In schools nowadays you are awarded for a cribbled, > backwards, upside-down G, the first day and is punished for it two > years after. what many people are missing is that in real life, the software equivalents to backwards upside-down G's are often good enough. even two years later. From headroom02 at gmx.de Sun Nov 18 17:07:44 2001 From: headroom02 at gmx.de (Gernot) Date: Sun, 18 Nov 2001 23:07:44 +0100 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> <3BF429F1.146759EA@ccvcorp.com> Message-ID: <9t9bk1$np2$07$1@news.t-online.com> "Jeff Shannon" schrieb im Newsbeitrag news:3BF429F1.146759EA at ccvcorp.com... > > Gernot wrote: [deleted] > > module which i have to "activate" first?? > > There is no bool() in Python. You'll have to build your own. But at least > you've got a decent start on your homework. You are right, i mixed it up with something different. Thanks for your comment. Gernot > > Jeff Shannon > Technician/Programmer > Credit International > > From kseehof at neuralintegrator.com Wed Nov 14 20:46:05 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Wed, 14 Nov 2001 17:46:05 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> <9nj5vto66nk83romuu3f40qrd72lmrjpui@4ax.com> <9sut89$b7v$1@slb7.atl.mindspring.net> Message-ID: <014701c16d77$b4d861a0$7a93b23f@kens> > "Andrew Dalke" wrote . > > Me: > > >>I wanted to add a new method, so I did > > >> > > >>class Spam: > > >> def double(self): > > >> self.x = self.x * 2 > > > > Daniel Klein: > > >Just curious to know how it is that you expected this to work > > > > Because I didn't think that 'class Spam' always created a new > > class. I thought it would reuse a definition of one already exists. > > I believe this is similar to what Smalltalk does. > > > > > why you were 'annoyed'? > > > > Because it didn't fit my model of how the language worked, so > > was more effort to learn. > > > > >I can't > > >see what the problem is with the double() method. > > > > The problem was I wanted to add a method to an existing class. > > The method definition was fine. > > > ISTR someone suggested some time ago that we might use > > def Spam.double(self): > self.x *= 2 > > to add or redefine methods, but I don't remember why this was thought to be > a bad idea. I suppose in all such cases it's bad that there's no way to > reach out to existing instances and modify them. SmallTalk's introspection > system has it over Python in that respect, but then (like me :) it's more > mature. > > memory's-not-what-it-was-ly y'rs - steve > -- > http://www.holdenweb.com/ If the syntax you describe were implemented, it would presumable modify the class directly, and therefore would affect all existing instances (the instances all refer to the same class object, so there is no reason to need to reach out to the existing instances). There isn't any semantic reason against it, in fact here's a recipe describing how to add or replace a method in an existing class using the 'new' module: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81982 So python seems to be just as flexible as smalltalk is this respect, but you have to get under the hood a bit more. I've used this trick on a few occaisions; usually for debugging, but also to work around design problems in existing python packages. - Ken From fperez528 at yahoo.com Mon Nov 26 12:02:47 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 16:30:47 +2328 Subject: Regular expression References: <6039af6a.0111262123.54806bb7@posting.google.com> <3C032B29.A77DE30@earthlink.net> <9tvbv4$2uo$1@peabody.colorado.edu> <6039af6a.0111271523.38a21fa2@posting.google.com> Message-ID: <9u17oi$hh6$1@peabody.colorado.edu> Sang DeSibtis wrote: > Thanks! It solves my problem and also leads to another one. Isn't the > 'line' on both side of the assingment are using the same memory > address? I am really confused by this; isn't the 'line' the name of > the list object holding the contents of the file 'junk' I opened and > my understanding is, list contents are mutable. > > line = re.sub('AAAA', 'aaaa', line) > No. First, line has to be a string for the above to work. If it's a list, you get: TypeError: expected string or buffer Now, if line is a 'line' of your open file (meaning it's one string), the above re.sub() will make a temporary new string in memory with the new value ('aaaa'), assign this to line, and the old value of line will now be junk in memory. That junk will get discarded when the garbage collector gets around to it. Cheers, f. From jtdubs at eos.ncsu.edu Wed Nov 14 10:43:38 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Wed, 14 Nov 2001 10:43:38 -0500 Subject: How to know when a variable is set References: Message-ID: <9su3c1$p84$1@uni00nw.unity.ncsu.edu> "-" wrote in message news:fef0a228.0111140715.24b5cfc7 at posting.google.com... > How can I test if a variable has been given a value, or if it's undefined? I'm still playing with it. Here's another way: >>> foo = 5 >>> try: foo ... except NameError, detail: print detail 5 >>> try: bar ... except NameError, detail: print detail name 'bar' is not defined >>> Have fun, Justin Dubs From qrczak at knm.org.pl Wed Nov 28 04:28:50 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Wed, 28 Nov 2001 09:28:50 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: Wed, 28 Nov 2001 00:13:11 +0000 (UTC), Huaiyu Zhu pisze: > An easy and brutal solution is to mandate that tab is the only indent > charactor. I refuse to use tabs in size != 8 and want 4-character indents. And some people don't use tabs at all. Your proposal is incompatible with those (reasonable IMHO) positions. > A better long term solution is to write a smarter python-mode for > your editor. It's not only an editor but all tools which display or print the file, terminals, mailers and newsreaders. It makes no sense to require special tools just for working with Python source. > The fault is at the utilities that on the one hand think tab could > be equivalent to some spaces but on the other hand cannot guess > exactly how many. They can. It's always 8 precisely to avoid guessing. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From fperez528 at yahoo.com Fri Nov 9 21:46:22 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 11 Nov 2001 02:14:22 +2328 Subject: mapping a statement over all list items References: <3BEE4077.8070407@hotmail.com> Message-ID: <9slfje$p9c$2@peabody.colorado.edu> > Thus if Foo was ['abc-xyz', 'black-blue', '123-987'], the result after > mapping to Foo would be: > > Foo = [ ['abc', 'xyz'], ['black','blue'], ['123','987'] ] > Is this good enough for you (never mind the bizarre prompts, I have my own interpreter)? In[1]:= foo=['abc-xyz', 'black-blue', '123-987'] In[1]:= [x.split('-') for x in foo] Out[1]= [['abc', 'xyz'], ['black', 'blue'], ['123', '987']] Cheers, f From gh_pythonlist at gmx.de Sat Nov 3 15:03:17 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sat, 3 Nov 2001 21:03:17 +0100 Subject: dictionaries and 'in' in 2.1 In-Reply-To: References: Message-ID: <20011103210316.A390@lilith.hqd-internal> On Sat, Nov 03, 2001 at 08:46:08PM +0000, John J. Lee wrote: > > The Python 2.1.1 manual, section 2.1.6, says: > > k in a 1 if a has a key k, else 0 > k not in a 0 if a has a key k, else 1 > > > But when I attempt to use this feature, I get: > > Python 2.1.1 (#1, Oct 23 2001, 15:59:13) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> d = {1:2} > >>> 1 in d > Traceback (most recent call last): > File "", line 1, in ? > TypeError: 'in' or 'not in' needs sequence right argument > >>> > > > I must be doing something stupid, but I don't see what. Are you sure you have been reading the 2.1.1 manual and not the development version of the docs? AFAIK the x in dict form is only available in Python 2.2. What you want in earlier versions is probably: 1 in d.keys() Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From tanzer at swing.co.at Fri Nov 30 02:03:43 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 30 Nov 2001 08:03:43 +0100 Subject: Python evangelists unite! In-Reply-To: Your message of "Fri, 30 Nov 2001 10:18:00 +1100." <9u6fnl$b343@news1.gtech.com> Message-ID: "Peter Milliken" wrote: > I use Python as a good, quick and dirty hacking language. For real (read > production) stuff that I expect a customer to run or will require more than > a single person working for a couple of hours, I look elsewhere :-). Like what? > They could have been more productive with other languages that provide > better support for generic software engineering principles/standards. What other languages? What principles/standards? -- 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 jdadson at ix.netcom.com Sun Nov 4 22:45:57 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 03:45:57 GMT Subject: how to start Idle under Windows Message-ID: <3BE60B50.88B1E792@ix.netcom.com> How do you start Idle when running Windows? I can get it to come up, but I get two extraneous windows on the screen -- a console window and a Python interactive window. Jive From root at [127.0.0.1] Wed Nov 7 12:44:53 2001 From: root at [127.0.0.1] (nobody) Date: Thu, 8 Nov 2001 03:44:53 +1000 Subject: Returning a python value to the calling bat file References: Message-ID: <3be97315$0$1773$afc38c87@news.optusnet.com.au> > I have a NT Shell bat file that calls a python script to do some processing, > then want that python to return the value to the calling bat file. How do I > do that? import sys sys.exit(errorlevel) where "errorlevel" is an integer From john at ecsc.co.uk Sat Nov 10 20:15:18 2001 From: john at ecsc.co.uk (John Leach) Date: 11 Nov 2001 01:15:18 +0000 Subject: Newbie: Using MySQL In-Reply-To: <200111110056.fAB0u0V02578@localhost.localdomain> References: <200111110056.fAB0u0V02578@localhost.localdomain> Message-ID: <1005441318.2708.5.camel@murdock> On Sun, 2001-11-11 at 00:55, Jordan Elver wrote: > Could someone point me in the right direction for MySQL using Python > tutorials etc. I've tried using the MySQLdb module (I think) and I cannot > connect. I know that the server is running and that the passwords are correct? > > db = MySQLdb.Connect(host=db_host, user=db_user, passwd=db_passwd, db=db_db) looks fine to me, I've used it with no problems in a similar fashion. What is the error message you get? John Leach. ECSC Ltd. -- ======================================================================== This email is intended solely for the addressee. When addressed to our clients any opinions or advice contained are subject to the terms and conditions expressed in the governing ECSC Conditions of Service. From Administrator Mon Nov 26 03:58:40 2001 From: Administrator (Administrator) Date: Mon, 26 Nov 2001 01:58:40 -0700 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <028b01c17658$8b1a97e0$0e0fbb82@corp.es.com> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = Joanna Recipient(s) = python-list at python.org Subject = Re: Scanning Time = 11/26/2001 01:58:40 Engine/Pattern = 5.600-1011/171 Action on virus found: The attachment stuff.MP3.pif contains WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to administrator. ScanMail has detected a virus. 11/26/2001 01:58 AM TORINO stuff.MP3.pif/Deleted python-list at python.org Joanna Re: From peter at engcorp.com Tue Nov 27 22:52:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 27 Nov 2001 22:52:50 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> Message-ID: <3C045F92.AD720B@engcorp.com> Greg Ewing wrote: > > While trying to think of a range syntax that looks > unambiguously half-open without clashing with list > or tuple constructors, the following blindingly > obvious solution occurred to me: > > for 0 <= i < 5: > ... -1 for being ambiguous to newbies. What would that mean, start and zero and go until four? Probably, but *I* read the previous thread on this. If a newbie had just learned about Python's ability to evaluate 0 <= i < 5 and return 1 or 0 for true/false the above might be a little perplexing. Is it like for 1: if i is in that range, and for 0: if not? Just in typing the above I had to hit backspace three times to type it right. May "look" nice to some, but too obscure to others I think. Why fix what doesn't need fixing? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From bill-bell at bill-bell.hamilton.on.ca Wed Nov 7 09:04:32 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 7 Nov 2001 09:04:32 -0500 Subject: Focus problem In-Reply-To: <1005141342.812.66177.m5@yahoogroups.com> Message-ID: <3BE8F920.6447.7D62E01@localhost> "Danijel" > I need that for validation check, when user enter some value into > TextControl, and go FROM THAT FIELD. Danijel, we'd need more information in order to answer your question: what OS? what software is involved? - Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From duncan at NOSPAMrcp.co.uk Fri Nov 30 06:12:44 2001 From: duncan at NOSPAMrcp.co.uk (Duncan Booth) Date: Fri, 30 Nov 2001 11:12:44 +0000 (UTC) Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> <3C06AF9D.E6DEB295@home.net> Message-ID: Chris Barker wrote in news:3C06AF9D.E6DEB295 at home.net: > Actually, no. It is a "list". It would be a tuple if you had built it > like this: > > mylist = ('one','two','three') > > Parentheses rather than square brackets. The difference is that lists > are mutable (can be changed in place) and tuples care not. Or even if you had built it thus: mylist = 'one', 'two', 'three' The parentheses are not part of the tuple syntax (except for empty tuples): they are only required when the expression would otherwise be ambiguous. -- Duncan Booth duncan at rcp.co.uk int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3" "\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure? From cliechti at gmx.net Thu Nov 15 15:18:25 2001 From: cliechti at gmx.net (Chris Liechti) Date: 15 Nov 2001 22:18:25 +0200 Subject: PEP 276 Simple Iterator for ints References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> <9t0jko$14b$1@thorium.cix.co.uk> Message-ID: "Ken Seehof" wrote in news:mailman.1005848962.18049.python-list at python.org: > Hey, what ever happened to the int[:10] iterator idea? > >>>> for i in int[2:10:2]: print i, 2 4 6 8 I've played around with an implementation for that and I like it. > > Like PEP 276, it doesn't require new syntax (just implement a slice > operator for int). > > int[3:8] should return an iterator equivalent to [3,4,5,6,7] > > int[-4::2] should return an infinite sequence iterator [-4, -2, 0, 2, > ...] > > I think that this solves all of the problems that PEP 276 solves, > without any inconsistent idioms or warts. i think the advantage of pep 276 would be that you don't need to write an extra word "for i in 10:" as oposed to "for i in int[:10]:". but i don't like the pep 276 syntax much. i think its better when you see that its a sequence and just a number realy isn't a sequence. (yes i know it would return an iterator but an iterator just returns the elements of a sequence, even if the values are calculated) > > Here's what http://python.sourceforge.net/peps/pep-0276.html has to > say about it: > > - It would be better to reuse the slicing literal syntax attached > to the int class, e.g., int[0:10] > > Response: Same as previous response. > > """ Response: Shares disadvantages of other proposals that > require > changes to the syntax. Needs more design to determine how it > would handle the general case of start,stop,step, > open/closed/half-closed intervals, etc. Needs a PEP.""" > > In addition, design > consideration needs to be given to what it would mean if one > uses slicing syntax after some arbitrary class other than class > int. Needs a PEP. > > What syntax change? There is no syntax change. A slice operator would > simply be added to the int class. Slicing syntax applied to some > arbitrary class would naturally depend on the slice implementation for > that class :-) I agree that it needs a PEP. > > Hey, you could also do floats! > >>>> for x in float[ :1.0 : 0.2]: print x, 0.0 0.2 0.4 0.6 0.8 >>>> list(float[3.0:1.0:-0.5]) > [3.0, 2.5, 2.0, 1.5] and that would be an advantage over [x]range()! > Hmm. Complex numbers? Of course the step would be in radians :-) heh > heh. what do you want? drawing circles? ;-) > > - Ken > > > -- Chris From Gareth.McCaughan at pobox.com Sun Nov 4 15:45:38 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Sun, 4 Nov 2001 20:45:38 +0000 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <570711d44a.simon@satin.callan.demon.co.uk> Message-ID: Simon Callan wrote: [someone else:] > > "There was a young man from Wooloomooloo (*) > > Whose limericks always finished on line two." > > > > (* - or somewhere ending in "oo" - can't remember now) [Simon:] > Which inevitably has the followup rhyme > "There was a young man from Verdun". But somehow no one ever seems to be able to remember what it was about the man from Abdero. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From mwm at mired.org Fri Nov 16 13:31:58 2001 From: mwm at mired.org (Mike Meyer) Date: Fri, 16 Nov 2001 12:31:58 -0600 Subject: Xlib bindings for Python? Message-ID: <15349.23454.825969.994918@guru.mired.org> Yes, I'm really looking for a set of bindings for Xlib, not a Xt or Xm or some other GUI toolkit. It's probably best not to ask why. I found the X-extensions package, but that apparently stopped being updated about python 1.4. Anyone got pointers to something more recent than that? Thanx, http://www.mired.org/home/mwm/ Q: How do you make the gods laugh? A: Tell them your plans. From clpy at snakefarm.org Fri Nov 9 04:50:45 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Fri, 09 Nov 2001 10:50:45 +0100 Subject: iters on ints? (reducing the need for range/xrange) References: <3BEB4F6E.A173C05D@cosc.canterbury.ac.nz> Message-ID: <3BEBA6F5.BC7AB9D5@snakefarm.org> Greg Ewing wrote: > It makes sense to think of files as containing lines, > but it's stretching things to think of the integer 10 > somehow "containing" the integers 0 to 9. Well, actually the integer 10 *does* contain the integers 0 to 9. This is one way of defining integers mathematically. Let 0 := {} (the empty set), then 1 := {0} 2 := {0, 1} 3 := {0, 1, 2} 'and so on ...' (which is deliberately un-mathematic :-) So 'for i in 10:' would be okay because 10 is actually some sort of sequence. cg. --- 'In iteger arithetric divsion is no the oposite of multiplication.' From tim at zope.com Tue Nov 27 14:59:31 2001 From: tim at zope.com (Tim Peters) Date: Tue, 27 Nov 2001 14:59:31 -0500 Subject: Integer Overflow In-Reply-To: <9u0oih$64q$2@peabody.colorado.edu> Message-ID: [Skip Montanaro] > In the current 2.2 beta, int operations that would overflow > silently return longs: > > >>> 3**100 > 515377520732011331036461129765621272702107522001L [Fernando Perez] > Just curious: how bad is the performance impact from this (if any)? Python was always checking for overflow, so a non-overflowing case is as quick as before. The new expense when it does overflow is subtle: you can still get optional warnings about overflows in 2.2, so an overflow takes an expensive trip through the warning-suppression machinery to see whether or not you want a warning. I expect that option will go away in 2.3. From sholden at holdenweb.com Fri Nov 2 08:57:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 08:57:29 -0500 Subject: Non-parsed headers in Python References: <3BE299F8.41112AB7@nada.kth.se> Message-ID: "Laurent Dupont" wrote in message news:3BE299F8.41112AB7 at nada.kth.se... > Hello everybody, > > How do you specify in a Python CGI-script that you want non-parsed > headers, e.g. in order to do a server-push (Content-type: > multipart/x-mixed-replace) ? > This will depend which server you are using. There's quite a good explanation of the topic at http://www.oreilly.com/openbook/cgi/ch03_08.html but you'll need to look at your own server documentation to be sure. regards STeve -- http://www.holdenweb.com/ From jlh at home.com Sun Nov 25 22:33:48 2001 From: jlh at home.com (Jeff Hinrichs) Date: Sun, 25 Nov 2001 21:33:48 -0600 Subject: A permutation on permutations References: <83heritfzi.fsf@panacea.canonical.org> Message-ID: <005201c1762b$29277e90$6702a8c0@gato> Sorry for naivet? but wouldn't this be a candidate for a filter? I'm just learning python and diveintopython.org has a section on filters that looks as if this question was made for it. http://diveintopython.org/regression_filter.html -Jeff ----- Original Message ----- From: "Kragen Sitaker" Newsgroups: comp.lang.python To: Sent: Sunday, November 25, 2001 8:37 PM Subject: Re: A permutation on permutations > "Arthur Siegel" writes: > > The following little func does not work as I > > would expect!!! > > > > Something about the iteration of p in t > > with the list.remove(). > > > > Is the func as written certifiably bad > > Python , or a bug/trap I fell into? > > > > def removedups(t): > > for p in t: > > if p[-1]>p[0]: > > t.remove(p) > > print t > > It's certifiably bad Python, because modifying a list you're iterating > over is a bug/trap you fell into. One general way of solving this is > to say for p in t[:]: instead of for p in t[:], but I'd probably say > print [p for p in t if p[-1] > p[0]] instead of the whole function. > > -- > http://mail.python.org/mailman/listinfo/python-list From dale at riverhall.NOTHANKS.co.uk Mon Nov 5 08:34:27 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Mon, 05 Nov 2001 13:34:27 +0000 Subject: Exception holes, again. References: Message-ID: "Steve Holden" wrote: >Dale: > >If you can persuade the Python interpreter to raise this error, surely the >exception traceback tells you exactly what you need to check for in terms of >module.exceptionname? Or am I mistaken? The exception is probably defined in >an extension library. > >regards > Steve Well, I'd have thought so too. Here's a little program to provoke an error: import win32api import win32con key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, "Software", 0, win32con.KEY_READ) print win32api.RegQueryValueEx(key, 'Spam') ...and here's the traceback: Traceback (most recent call last): File "I:\BATCH\tests\testreg2.py", line 6, in ? print win32api.RegQueryValueEx(key, 'Spam') pywintypes.api_error: (2, 'RegQueryValueEx', 'The system cannot find the file specified.') Doesn't tell you much, does it! I've tried to find pywintypes but can't and I had a hunt through the Python directories to see if I could find the definition but came up with nothing. -- Dale Strickland-Clark Riverhall Systems Ltd From DeepBlue at DeepBlue.org Fri Nov 2 12:57:26 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Fri, 2 Nov 2001 11:57:26 -0600 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9rulu9$n2m$1@tyfon.itea.ntnu.no> Message-ID: "Magnus Lie Hetland" wrote in message news:9rulu9$n2m$1 at tyfon.itea.ntnu.no... > "Oleg Broytmann" wrote in message > news:mailman.1004711703.24605.python-list at python.org... > [snip] > > And after you've modified it - do you have > > rights to distribute it to your friends? > > I hope you are not claiming that what you said above is something peculiar > to Free (as in Gnu/FSF) Software? It would also apply to Open Source > software. (And, yes, people would be allowed to make non-open-source > software based on it, and _that_ software might not be free in any > sense.) > This is contested. check the issue with Virtual Dub. An open source project. Someone used the code to produce an **unopen application. Virtual Dub guy does not like and he is threatening to sue. What you describe is called theft. DeepBlue From phr-n2001d at nightsong.com Thu Nov 15 11:45:35 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 08:45:35 -0800 Subject: Newbie questions part 2, thanks References: <7xzo5ojdqd.fsf@ruckus.brouhaha.com> <32SI7.34143$wd1.2586689@news20.bellglobal.com> Message-ID: <7x4rnwyocw.fsf@ruckus.brouhaha.com> "David Grenier" writes: > Thanks, it worked... > > Now here: > > Whenever I call cons.mappe(lambda x:2*x, cons(1,[])) When you call cons.mappe(x,y), the method actually gets called with 3 args. The first is bound to cons itself. Normally you define a method like this: def methodname(self, arg1, arg2): ... Also you can rewrite > if type(schemelist.cdr) is InstanceType and schemelist.cdr.__class__==cons: as if isinstance(schemelist.cdr, cons): Please try reading through the Python language reference to understand this stuff. From thomasNO at SPAM.obscure.dk Thu Nov 1 13:02:33 2001 From: thomasNO at SPAM.obscure.dk (Thomas Jensen) Date: Thu, 01 Nov 2001 18:02:33 GMT Subject: verifying type of socket object? References: <+YrhO+rceV33qbXjWckIp8NUkWP4@4ax.com> Message-ID: Peter Wang wrote in news:+YrhO+rceV33qbXjWckIp8NUkWP4 at 4ax.com: > in my code, i'd like to verify that i get passed a socket object. > however, i'm having some trouble figuring out what exactly > represents the "socket type". the main problem is that > socket.socket() doesn't return instances of socket.SocketType: It does here, se below >>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>>> socket.SocketType isinstance(x, >>>> socket.SocketType) 0 x >>> 011232A4> isinstance(x, socket._socketobject) 1 Whats your system and Python version? (Mine is Python 2.1.1 on FreeBSD4.4-RELEASE) Here's what I got: >>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>> socket.SocketType >>> isinstance(x, socket.SocketType) 1 >>> x >>> isinstance(x, socket._socketobject) 0 And adding: >>> type(x) == socket.SocketType 1 -- Best Regards Thomas Jensen From bt98 at doc.ic.ac.uk Mon Nov 19 16:31:09 2001 From: bt98 at doc.ic.ac.uk (Benjamin Tai) Date: Mon, 19 Nov 2001 21:31:09 +0000 Subject: function return -> input parameter Message-ID: <3BF97A1D.C1A165A8@doc.ic.ac.uk> Hi, I am not certain if I cam extend recursive C function call using Python. Image I want to construct a link list of alphabet implemented in C: Alphabet A, B, C, D; setNext( A, B ); It would be the same as saying: setNext( A, getPrev(C) ); "getPrev(C)" returns B, the right type and answer for A. I could also say: setNext( A, getPrev(getPrev(D)) ); "getPrev(D)" retuns C, recursively returns B. I am getting confused when I am trying to extend the above: 1) Can I distinguish the calls and how? One should be using "PyArg_Parse()", and the other using "PyEval_CallObject()". 2) The 2nd argument of function "PyEval_CallObject()" is expecting a Python argument object. What if it is a recursive call? How can I construct this argument which is a function call itself? Thanks in advance. Ben From garys at ihug.com.au Tue Nov 6 23:33:14 2001 From: garys at ihug.com.au (Gary Stephenson) Date: Wed, 7 Nov 2001 15:33:14 +1100 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: Message-ID: <9sacsk$r82$1@bugstomper.ihug.com.au> "Delaney, Timothy" wrote in message news:mailman.1005090308.3549.python-list at python.org... > > From: Fredrik Lundh [mailto:fredrik at pythonware.com] > > Gary Stephenson wrote: > > > We here downunder have just always claimed him as one of our own > > > > like ABBA? > > We've never claimed ABBA. We merely claim to have made them popular and > famous ... > > Tim Delaney Umm, I'm not really sure this is a claim we should be making! Next thing you'll have us claiming responsibility for making disco popular - and then they'll just have to shoot us! ;-) - senseless waste of human endeavour and all that.. cheers, gary ... And now it's time for "Stake your claim". Our first guest is ...(???) [compere (JC) ] What is your claim? [claimant (TJ) ] That I can burrow through an elephant [compere] Ahhh, now you've changed your claim - haven't you! You distinctly claimed that you could be... (shot through the head? can't remember any more...) From emile at fenx.com Fri Nov 30 22:04:36 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 30 Nov 2001 19:04:36 -0800 Subject: load a class dynamically References: Message-ID: <9u9hn1$725uf$1@ID-11957.news.dfncis.de> "Jeremy Lowery" wrote in message news:OqXN7.31025$8n4.2064260 at e3500-atl1.usenetserver.com... > I know that implementing this may be a little bit of work, but could someone > point me in the right direction? > > Have a text file that only contains a class definition, or just a string for > the sake of simplicity. > > str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1" > > #the magical code goes here. > > obj = myClass() > # of course, it doesn't have to be called like that, but to > #get the ability to instantainate that class. > What's wrong with importing the file? -- Emile van Sebille emile at fenx.com --------- From robin at execulink.com Sat Nov 17 13:03:34 2001 From: robin at execulink.com (robin at execulink.com) Date: Sat, 17 Nov 2001 13:03:34 -0500 Subject: How do you get persistent database connections with Python? References: <9sshgb$eh4$1@laptop.local> Message-ID: Gerhard H?ring wrote: >There are three alternatives to PyGreSQL: pyPgSQL, psycopg and PoPy (I'm >a developer in the pyPgSQL project). I'd recommend you check out the >alternatives, too if you're interested in a good db module 4 PG. Iff you >want to continue using PyGreSQL, I recommend you check out the latest >version from *PostgreSQL* CVS - it contains several bugfixes when >compared to the latest "released" version of PyGreSQL (3.2). Gerhard is too nice to say it, but you should start with his interface and go from there. Our company has spent significant time trying out all available Postgres interfaces and pyPgSQL is the most robust and bug-free. I would like to see Python incorporate "best-of-breed" database interfaces in the standard libraries to save work for new users and consolidate development. ----- robin robin at brainexeculink.com (remove "brain" to reply) From tim at vegeta.ath.cx Wed Nov 28 07:28:57 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 28 Nov 2001 12:28:57 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> Message-ID: Michael Hudson graced us by uttering: [ snip ] > And the one I use *contains* the mail (and news) client that sucks > less than all the others... Besides, I tried GNUS and didn't like it. The mail client fell short, too. Yeah, I suppose in this way, Emacs breaks free from the all too confining Unix Philosophy... Do _one_ thing and do it well. (PS: I don't have to learn Lisp to script Vim...I can use Python... This was originally a python thread, wasn't it? =) Tim Hammerquist -- If you had two people with a motive, and one of them was alive, who would you arrest? -- Inspector Boot, "Theater of Blood" From gward at python.net Wed Nov 14 10:42:56 2001 From: gward at python.net (Greg Ward) Date: Wed, 14 Nov 2001 10:42:56 -0500 Subject: Optik 1.0 In-Reply-To: <20011112175357.F26476@phd.pp.ru> References: <20011112175357.F26476@phd.pp.ru> Message-ID: <20011114104256.A22700@gerg.ca> On 12 November 2001, Oleg Broytmann said: > Or mix options and arguments? > > --file outfile infile -q OK, this is now implemented and tested, but not yet documented. You can get the code (via CVS) from optik.sf.net. I still want to add a "store_many" action, then document these changes. That'll be Optik 1.1. Greg -- Greg Ward - Linux weenie gward at python.net http://starship.python.net/~gward/ "Question authority!" "Oh yeah? Says who?" From sholden at holdenweb.com Fri Nov 16 10:51:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 10:51:30 -0500 Subject: Databases References: <200111161329.fAGDTiv17156@smtp.wineasy.se> Message-ID: <015401c16eb6$8f951560$9f0aa8c0@holdenweb.com> [posted & mailed] ----- Original Message ----- From: "Gustavo Campanelli" Newsgroups: comp.lang.python Sent: Friday, November 16, 2001 9:21 AM Subject: Databases This is a really newbie question, I just started with Python 3 days ago, and I?m finding it quite fascinating. I don?t know how this works for you, but I usually learn faster when I?m trying programs, and programs come out easier when I?m actually doing something and not only trying to test a comand. So I?m trying to access a database from python. Where should I look for documentation about using python as interface for MySQL or PostgreSQL? Of course, that is under Linux. ----- End Original Message ----- No "of course" about it ... I currently use MySQL (with Python) under Windows, and it's excellent. I understand that PostgreSQL has also been ported. However ... You first need to understand the Python DB API, as most useful database modules try to confirm with this. The DB Sig's pages at http://www.python.org/sigs/db-sig/ include a database topic guide which references this. If it all seems too complicated, then go seek out some sample database code in Python. One such can be seen at http://support.magma.ca/vws/unix/python.cfm and you can find lots of others by visiting www.google.com and entering a search string such as "Python MySQLdb example code" or something similar. "MySQLdb" is a crucial resource for you, since this is the module you will need to download and install to provide MySQL support. (There's also MyODBC, but that will represent unnecessary complexity when you are starting out). The DB SIG pages should link you to where you can download that module. After that, comp.lang.python is one of the friendlier newsgroups, and further questiosn will usually elicit a helpful response. It helps to know what you're talking about, but even when you don't you rarely require the "asbestos underwear"! Good luck with MySQL! regards Steve -- http://www.holdenweb.com/ From jgardn at alumni.washington.edu Mon Nov 12 19:32:36 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Tue, 13 Nov 2001 09:32:36 +0900 Subject: Python Vim Module - works In-Reply-To: <01111302002607.00632@linux> References: <01111302002607.00632@linux> Message-ID: <01111309323600.00630@linux> On Tuesday 13 November 2001 02:00 am, Jonathan Gardner wrote: > It's 2:00 AM here in Seoul, so I won't be getting any answers out for a > few hours... =) > If you can get it to compile (just edit the Makefile to make it point to > the right place...) try this with Vim 6.0: > Now it's 9:30 AM in Seoul, and somebody told me that I didn't attach anything. Sorry all! Here is the software attached. Jonathan -------------- next part -------------- A non-text attachment was scrubbed... Name: python_vim.tar.gz Type: application/x-gzip Size: 5815 bytes Desc: The stuff URL: From amitabh_jain at yahoo.com Mon Nov 12 18:03:47 2001 From: amitabh_jain at yahoo.com (Amitabh) Date: 12 Nov 2001 15:03:47 -0800 Subject: Obfuscator for Python? Message-ID: Hi, I wanted to know if there are any products which obfuscate the python byte code so that it cant be reverse engineered easily? TIA Cheers Amitabh From niemeyer at conectiva.com Thu Nov 1 16:00:19 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Thu, 1 Nov 2001 19:00:19 -0200 Subject: Python 2.2 release schedule? In-Reply-To: <1f5252d4.0111011201.15fab7bf@posting.google.com>; from nbecker@fred.net on Thu, Nov 01, 2001 at 12:01:11PM -0800 References: <1f5252d4.0111011201.15fab7bf@posting.google.com> Message-ID: <20011101190019.A3653@ibook.distro.conectiva> > Any rough idea of expected Python 2.2 release date? Please, have a look at: http://python.sourceforge.net/peps/pep-0251.html Best regards! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From skunkteeth at focuslost.com Fri Nov 30 23:39:39 2001 From: skunkteeth at focuslost.com (Kyle Thompson) Date: Fri, 30 Nov 2001 20:39:39 -0800 Subject: Just started, need help! Message-ID: Hi, When I do an input command, I hit enter so I may then do the if and else command but when I hit enter it try's to run the input command. How do I make it not run when its being made and just run when I'm done with a part and want to run it? -Thanks From quinn at chunder.ugcs.caltech.edu Fri Nov 30 15:07:25 2001 From: quinn at chunder.ugcs.caltech.edu (Quinn Dunkan) Date: 30 Nov 2001 20:07:25 GMT Subject: A modest indentation proposal References: Message-ID: On Fri, 30 Nov 2001 14:25:12 +0000, phil hunt wrote: >If I ever design a Python-like language, there will be 2 alternate syntaxes, >one with and one without semantic indentation. So people will be able to >write > > if x > 3: > a := b + c > print a > >or: > > if x > 3: { > a := b + c; > print a; > } > >(Though why anyone would prefer the second way is beyond me). > >The language would be stored internally in a form resembling the upper >of the two, and there would be automatic translators so everyone could >see it the way they liked, with {} or not, with whatever number of >characters per indentation they liked, spaces/tabs, etc. http://www.haskell.org/onlinereport/lexemes.html#lexemes-layout I don't entirely like it because error messages can be confusing ("missing close brace" when you mess up indentation) and code that uses both at once can be confusing. I'd rather have only indentation or only delimiters. Having both and a rule to magically transform from one to the other is too complicated. From bernie at pacific.net.hk Mon Nov 19 04:40:35 2001 From: bernie at pacific.net.hk (Bernie) Date: Mon, 19 Nov 2001 09:40:35 GMT Subject: Question on default value of __init__ Message-ID: <3BF8D3BC.105F0536@pacific.net.hk> Hello all, When I run test.py, an instance of foo is created. Is this the default behavior in Python for default value? i.e. The value must be exist as an object. Are there any way to delay the creation of foo() until bar() is created. Bernie test.py: class foo: def __init__( self, param=None): print 'executed!' self.__param = param def __nonzero( self): if self.__param: return 1 else: return 0 class bar: def __init__( self, param=foo()): assert isinstance( param, foo), '"in" must be an instance of foo' pass From gmcm at hypernet.com Wed Nov 28 19:42:43 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 29 Nov 2001 00:42:43 GMT Subject: Problem with inetd & Python References: <3C056DA8.4020001@xs4all_nospam.nl> Message-ID: iwk wrote: [...] > According to the little information I found, a process being started by > (x)inetd could use stin & stout to transfer data from and to the > client. And when I telnet to a script which justs writes data to > sys.stdout it works: al data is being displayed on the screen of the > telnet client > > However, when I try to *read* data from sys.stdin, nothing works > anymore, not even the writing to sys.stdout Try starting Python with -u (unbuffered). - Gordon From dgrisby at uk.research.att.com Fri Nov 9 06:31:52 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 9 Nov 2001 11:31:52 GMT Subject: CORBA client & server with Python References: <01c168fd$978fe8d0$06d1178b@mvn40020> Message-ID: <9sger8$4ud$1@pea.uk.research.att.com> In article <01c168fd$978fe8d0$06d1178b at mvn40020>, Murat Demir wrote: >did someone try to write CORBA client and server applications with Python? >Can you offer me a "hello world" application about it? I wrote a little example here: http://groups.google.com/groups?selm=9jrfva%24dhj%241%40pea.uk.research.att.com Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From montanaro at tttech.com Wed Nov 7 10:50:12 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Wed, 07 Nov 2001 16:50:12 +0100 Subject: Non-Indented python In-Reply-To: <9sbd8i$680$1@wanadoo.fr> References: <9sbd8i$680$1@wanadoo.fr> Message-ID: Samuel> I figure it should be quite simple to implement a program Samuel> that translates scripts where blocks are expressed by Samuel> traditionnal block markers like '{' and '}' (or whatever Samuel> else..) into a well indented python script. Samuel> Is there such a program ?? Yes, there is, and it's delivered with Python! It's Tools/scripts/ pindent.py in the standard distribution. It only needs a block end delimiter (# end). You already have ":" as the opener... guido's-time-machine-strikes-again-ly, y'rs, -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From jeff at ccvcorp.com Thu Nov 8 15:23:51 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 08 Nov 2001 12:23:51 -0800 Subject: Help Help Help References: <3be77f95@152.65.161.36> <3BEA27D7.9050405@yahoo.com> Message-ID: <3BEAE9D6.FB010420@ccvcorp.com> Jp Calderone wrote: > def isInteger(x): > """Checks if argument can be made to represent an int > Returns 1 if so, 0 otherwise""" > try: > int(x) > return 1 > except: > return 0 > ............. > while 1: > x = sys.stdin.readline() > if isInteger(x): > return int(x) > else: > print 'That is not an integer, please try again:', Why do the int() conversion twice?? By rewriting your while loop as follows, you eliminate the need for your isInteger() function.... while 1: x = sys.stdin.readline() try: return int(x) except ValueError: print "That is not an integer, please try again:", I also wonder why you use sys.stdin.readline() in place of raw_input(), but you still use print and not sys.stdout.write() .... but I suppose that's just a trivial bit of inconsistency with only aesthetic significance.... :) Jeff Shannon Technician/Programmer Credit International From deoradh at yahoo.com Wed Nov 7 06:55:31 2001 From: deoradh at yahoo.com (Keith Farmer) Date: 7 Nov 2001 03:55:31 -0800 Subject: C-extension in Python -- returning results Message-ID: Any help on the following would be appreciated. After all -- it's for science. I've got an extension that I'm writing -- a specialized math/database package for a project of mine. I'm not the most well-practiced when it comes to C, so I'm having some difficulty picking out the problem. While I could use Numpy for this, I'd rather for efficiency's sake do this directly, to avoid having to repackage the data to and from Python several times. The gist: the database represents a several-thousand term equation giving planetary positions in time, returning the positions in spherical polar coordinates. It's possible (I've done so in Numpy) to sample this equation and fit smaller-period slices (~weeks, year at most) to a set of 5th degree polynomials. This involves solving a set of linear equations using standard techniques. My error lies somewhere in the linear equation solver. PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32. Portions Copyright 1994-2001 Mark Hammond (MarkH at ActiveState.com) - see 'Help/About PythonWin' for further copyright information. >>> import AstroMath >>> AstroMath.mkqvsop(2448976.5,2449076.5,10,3) [-1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND, -1.#IND] mkqvsop samples the positions and performs the matrix math to yield the polynomial fit. I've already verified that the function providing the coodinates already works(it's used at http://www.thuban.org/astro). I don't understand what the '-1.#IND' returns indicate. Following is the VC++ source code for the dll: /* astromath.cpp -- astronomical calculations */ #import "c:\program files\common files\system\ado\msado15.dll" \ rename ( "EOF", "adoEOF" ) no_namespace #include "Python.h" #include #include #define SUCCESS 0 #define FAIL 1 #define PI 3.141592653589 #define RAD(x) (x*180/PI) int linsys6x3(double [6][6], double [6][3]); int calcVsop(double, int, double []); int makeQVsop(double, double, int, int, double [3][6]); static PyObject *AstroMathError; static PyObject *AstroMath_version(PyObject *, PyObject *); static PyObject *AstroMath_vsop(PyObject *, PyObject *); static PyObject *AstroMath_mkqvsop(PyObject *, PyObject *); // Initialize OLE #define VERSION 2001.0904 #define TINY 1.0e-20 struct InitOle { InitOle() { ::CoInitialize(NULL); } ~InitOle() { ::CoUninitialize(); } } _init_InitOle_; // Python init static PyMethodDef AstroMathMethods[] = { { "vsop", AstroMath_vsop, METH_VARARGS }, { "mkqvsop", AstroMath_mkqvsop, METH_VARARGS }, { "version", AstroMath_version, METH_VARARGS }, { NULL, NULL } /* Sentinel */ }; #ifdef MS_WIN32 __declspec(dllexport) #endif void initAstroMath() { PyObject *m, *d; m = Py_InitModule("AstroMath", AstroMathMethods); d = PyModule_GetDict(m); AstroMathError = PyErr_NewException("AstroMath.error", NULL, NULL); PyDict_SetItemString(d, "error", AstroMathError); } // Python stubs static PyObject *AstroMath_version(PyObject *self, PyObject *args) { return Py_BuildValue("d", VERSION ); } static PyObject *AstroMath_vsop(PyObject *self, PyObject *args) { double results[3] = {0, 0, 0}; int body; double t0; if (!PyArg_ParseTuple(args, "di", &t0, &body)) return NULL; if (calcVsop(t0, body, results) == FAIL) /* Error */ return AstroMathError; else /* Return value */ return Py_BuildValue("[ddd]", results[0], results[1], results[2]); } static PyObject *AstroMath_mkqvsop(PyObject *self, PyObject *args) { double results[3][6] = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}}; int N, body; double startJD, endJD; if (!PyArg_ParseTuple(args, "ddii", &startJD, &endJD, &N, &body)) return NULL; if (makeQVsop(startJD, endJD, N, body, results) == FAIL) /* Error */ return AstroMathError; else /* Return value */ return Py_BuildValue("[dddddddddddddddddd]", results[0][0], results[0][1], results[0][2], results[0][3], results[0][4], results[0][5], results[1][0], results[1][1], results[1][2], results[1][3], results[1][4], results[1][5], results[2][0], results[2][1], results[2][2], results[2][3], results[2][4], results[2][5] ); } // Main functions int calcVsop(double t0, int body, double results[]) { char sql[200]; double storage[3][6] = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}}; long cnt = 0; long tot = 0; /* Define return variable */ double a, b, c = 0; int coord; int powerOfT; t0 = (t0 - 2451545.0) / 365250; sprintf( sql, "SELECT [a], [b], [c], [coord], [powerOfT] FROM vsop WHERE [body] = %d", body ); HRESULT hr = S_OK; _RecordsetPtr Rs = NULL; _bstr_t Connect("DSN=Astronomy"); hr = Rs.CreateInstance(__uuidof(Recordset)); Rs->Open( sql, Connect, adOpenForwardOnly, adLockReadOnly, adCmdUnknown ); Rs->MoveFirst(); while ( VARIANT_FALSE == Rs->GetadoEOF() ) { a = (double) Rs->Fields->GetItem( _variant_t("a"))->Value; b = (double) Rs->Fields->GetItem( _variant_t("b"))->Value; c = (double) Rs->Fields->GetItem( _variant_t("c"))->Value; coord = (long) Rs->Fields->GetItem( _variant_t("coord"))->Value - 1; powerOfT = (long) Rs->Fields->GetItem( _variant_t("PowerOfT"))->Value; storage[coord][powerOfT] += a * cos(b + c*t0); Rs->MoveNext(); } for (coord = 0; coord < 3; coord++) { results[coord] = 0; for (powerOfT = 0; powerOfT < 6; powerOfT++) results[coord] += storage[coord][powerOfT]*pow(t0,powerOfT); } Rs->Close(); Rs = NULL; /* Return value */ return SUCCESS; } int makeQVsop(double startJD, double endJD, int N, int bodyID, double results[3][6]) { int X = 0; int YX = 1; int i = 0; int j = 0; int coord = 0; int parity = 0; double sumsX[11] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; double sumsYX[6][3] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} }; double xarray[6][6] = { {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0}, {0,0,0,0,0,0} }; double stepJD = (endJD - startJD)/(N-1); double t = startJD; int c = 1; double t0 = 0; double tpow[] = {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; double vsop[3] = { 0, 0, 0 }; while (t <= endJD) { for (coord = 0; coord < 3; coord++) vsop[coord]=0; if (calcVsop(t, bodyID, vsop) == FAIL) return FAIL; vsop[0] *= 180.0/PI; vsop[1] *= 180.0/PI; t0 = (t - startJD)/365.0; sumsX[0]++; for (j = 1; j < 11; j++) tpow[j] = tpow[j-1] * t0; /* tpow[j] = t0^j = tpow[j-1] * t0 */ sumsX[j] += tpow[j]; /* sumsX[j] = Sum(t0^j) */ for (coord = 0; coord < 3; coord++) { for (j = 0; j < 6; j++) sumsYX[j][coord] += tpow[j] * vsop[coord]; /* sumsYX[j][c] = vsop[c] * t0^j */ } t += stepJD; c += 1; } for (i = 0; i < 6; i++) for (j = 0; j < 6; j++) xarray[i][j] = sumsX[i+j]; /* xarray = Sum(t0^...): index of sumsX 0 1 2 3 4 5 1 2 3 4 5 6 2 3 4 5 6 7 3 4 5 6 7 8 4 5 6 7 8 9 5 6 7 8 9 10 */ if (linsys6x3(xarray, sumsYX) == FAIL) return FAIL; else { for (coord = 0; coord < 3; coord++) for (i = 0; i < 6; i++) results[coord][i] = sumsYX[i][coord]; return SUCCESS; } } int linsys6x3(double a[6][6], double b[6][3]) { int m = 3; /* cols in b (# coordinates) */ int n = 6; /* rows in a and b (# terms) */ int i, j, k; double d; /* reduce to upper triangular form */ for(i = 0; i < n; i++) /* for each row */ { /* find maximal element */ j = i; /* store row index i in j as default */ for(k = i+1; k < n; k++) /* k = row index */ if(fabs(a[k][i]) > fabs(a[j][i])) /* use i as column index */ /* for shortcut */ j = k; /* update j with new row index */ /* j contains row index containing max element */ /* swap row i and j in both a and b */ for(k = i; k < n; k++) { d = a[i][k]; a[i][k] = a[j][k]; a[j][k] = d; } for(k = 0; k < m; k++) { d = b[i][k]; b[i][k] = b[j][k]; b[j][k] = d; } /* check if the system is singular */ /* if(fabs(a[i][i]) < 0.001) { // (void) fprintf(stderr,"Singular matrix, column %d\n", i+1); return FAIL; } */ /* elimination of column below diagonal */ for(j = i+1; j < n; j++) /* for each row j > i */ { d = a[j][i]/a[i][i]; /* row subtraction factor */ a[j][i] = 0.; /* zero the element (result of exact subtraction) */ for(k = i+1; k < n; k++) /* for each col k > i */ a[j][k] -= d*a[i][k]; /* subtract factored row from a */ for(k = 0; k < m; k++) /* for each col k */ b[j][k] -= d*b[i][k]; /* subtract factored row from b */ } } /* normalization */ for(i = 0; i < n; i++) /* for each row */ { for(j = i+1; j < n; j++) /* for each column right of the diagonal */ a[i][j] /= a[i][i]; /* divide by the diagonal */ for(j = 0; j < m; j++) /* for each col in b */ b[i][j] /= a[i][i]; /* divide by the diagonal */ a[i][i] = 1.; /* diagonal divided by itself is 1 */ } /* reduction from upper trigonal form to diagonal form */ for(i = n-1; i >= 0; i--) /* for each row in reverse order */ { for(j = 0; j < i; j++) /* for each row above i */ { for(k = 0; k < m; k++) /* for each column in b */ b[j][k] -= b[i][k]*a[j][i]; /* subtract the row, factored by a */ a[j][i] = 0; /* exact subtraction */ } } return SUCCESS; /* a is identity matrix, b is solution */ } From mlh at idi.ntnu.no Mon Nov 12 14:39:41 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 12 Nov 2001 20:39:41 +0100 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> Message-ID: <9sp8ht$obt$1@tyfon.itea.ntnu.no> "Skip Montanaro" wrote in message news:mailman.1005148279.5189.python-list at python.org... > > Samuel> I figure it should be quite simple to implement a program > Samuel> that translates scripts where blocks are expressed by > Samuel> traditionnal block markers like '{' and '}' (or whatever > Samuel> else..) into a well indented python script. > > Samuel> Is there such a program ?? > > Yes, there is, and it's delivered with Python! It's Tools/scripts/ > pindent.py in the standard distribution. It only needs a block end > delimiter (# end). You already have ":" as the opener... It messes up multiline strings, though. (or, rather -- it messes up the indentation in multiline strings.) > guido's-time-machine-strikes-again-ly, y'rs, -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From James_Althoff at i2.com Wed Nov 28 16:34:30 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 13:34:30 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: David Eppstein wrote: >If the goal is to make it easy to avoid range() in for loops, I'd prefer to >see it done in a way that makes sense semantically and not just because >it's a short previously-unused syntax. Hence my continued contribution to >the discussion of alternatives. Nothing wrong with new ideas! Keep those suggestions coming. :-) Jim From mlh at idi.ntnu.no Thu Nov 1 21:12:07 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 2 Nov 2001 03:12:07 +0100 Subject: Freeware Python editor References: Message-ID: <9rsvdn$mk9$1@tyfon.itea.ntnu.no> "Delaney, Timothy" wrote in message news:mailman.1004662323.18460.python-list at python.org... > > FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS > > The PSU failed! A post about the PSU escaped to the world in its entirety! > > We are fre No, no... We are ope From p.vrijlandt at aig.azn.nl Tue Nov 6 03:00:41 2001 From: p.vrijlandt at aig.azn.nl (Patrick Vrijlandt) Date: Tue, 6 Nov 2001 09:00:41 +0100 Subject: Python kernel32 exception on Win9x while using DDE extensions References: Message-ID: <9s85bf$5qd$1@odysseus.uci.kun.nl> > I am running on Win98 SE with the latest DCOM installed. > When I try to run the following script fragment from python.exe or > pythonw.exe I get a “page fault exception” in > kernel32.dll > > import win32ui > import dde > import sys > > def send_string(str): > # ….. > pass > > print "Starting DDE v1.02" > cESC = chr(27) > cF11 = cESC + '[23~' > > server = dde.CreateServer() > > # The problem is in the following line > server.Create("ERTestClient") should be: server.Create('') > conv = dde.CreateConversation(server) then: conv.ConnectTo("ERTestClient", service) # service might be "System" > > while 1: > str = raw_input("Enter String: ") > if str == "EXIT": break > str_all = cF11 + str > ## send_string(str_all) > > print "DONE" > > > > Thanks > Nic I'm afraid dde leaks memory, but Mark H hasn't confirmed this yet. Think of this if your app fails after a few thousand dde calls. -- Patrick Vrijlandt From eppstein at ics.uci.edu Wed Nov 21 22:32:46 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 21 Nov 2001 19:32:46 -0800 Subject: Indenting with tabs vs spaces References: Message-ID: In article , "Peoter Veili" wrote: > Indenting with tabs can be done such that it will look the same on every > editor that uses fixed-width fonts, meaning everything will line up > correctly, it least in the sense that really matters. Here's an example of > what I mean: > > > > function helloThere("hello", > "there"){ > } I viewed your message with fixed-width fonts, and it came out unaligned as you see above. So I think your claim that "it will look the same on every editor" is false, and it is safer to stick with spaces only. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From s713221 at student.gu.edu.au Sat Nov 3 18:49:24 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sun, 04 Nov 2001 09:49:24 +1000 Subject: Freeware Python editor References: <3be2c653.1205904380@news> Message-ID: <3BE48284.36F4D0AD@student.gu.edu.au> "David C. Ullrich" wrote: > > On Wed, 31 Oct 2001 08:08:22 -0600, Kemp Randy-W18971 > wrote: > > >Check out the free Python editor at www.crimsoneditor.com. > > Not that it matters to me, but it seems like someone > should ask: What does it do that other free(?????????) > Python editors don't do? > > David C. Ullrich *chuckles* Oh dear, I'm gonna have to add you to my "Voices of Sanity"-list now David! "pointedly-ignoring-voices-of-insanity-(except-for-DeepBlue-who-seems-kinda-nutty)"-ly y'rs, -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From jason-dated-1007831845.6c6a51 at mastaler.com Fri Nov 30 12:17:24 2001 From: jason-dated-1007831845.6c6a51 at mastaler.com (Jason R. Mastaler) Date: Fri, 30 Nov 2001 10:17:24 -0700 Subject: problems with DBM nonuniformity In-Reply-To: <15366.57929.747462.677279@beluga.mojam.com> (Skip Montanaro's message of "Thu, 29 Nov 2001 19:35:05 -0600") References: <15366.57929.747462.677279@beluga.mojam.com> Message-ID: Skip Montanaro writes: > Seems to me the natural thing to do would be to add > "get_data_filename" and "get_index_filename" methods (or something > similar) to the underlying modules (dbhash, bsddb, dbm, etc) and > expose them through anydbm. I see. So you agree that with the current implementation, there isn't a reliable way to do what I'm trying to do with DBM? > It's too late for 2.2, but I suspect if you implemented something > and method name(s) could be settled on it would make it into CVS > early in the 2.3 cycle. This seems like a small enough change that > you just file a bug report on SourceForge with the proposal and add > an implementation when you have something workable. I'm not sure when I'll be able to get to this, but I'll put it on my TODO list. In the meantime, I think I'll just support the auto regeneration feature I mentioned with CDB[1] instead of DBM since its file interface is consistent across platforms. Footnotes: 1. python-cdb extension module (http://pilcrow.madison.wi.us/) -- (TMDA - http://tmda.sourceforge.net) (Python-based SPAM reduction system) From mwh at python.net Thu Nov 8 09:08:47 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 8 Nov 2001 14:08:47 GMT Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> <3BEA8B0F.E594BE84@snakefarm.org> Message-ID: Carsten Gaebler writes: > Well, where exactly is the bug? Should the docs read 'If _real_ is a > string, _imag_ is ignored and defaults to zero', or should the > implementation raise an exception because it violates the docs? I'd > prefer the latter. That what the patch I just submitted to sf does :) Cheers, M. -- Make this IDLE version 0.8. (We have to skip 0.7 because that was a CNRI release in a corner of the basement of a government building on a planet circling Aldebaran.) -- Guido Van Rossum, in a checkin comment From max at alcyone.com Sun Nov 11 00:17:01 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 10 Nov 2001 21:17:01 -0800 Subject: IsPython really O-O? References: Message-ID: <3BEE09CD.FFC433CC@alcyone.com> kentsmith at dxsys.com wrote: > A Smalltalk guru in our organization looked at Python last weekend > (after I > had made a big scene saying that it may be a solution to some of our > cross-platform issues) and came away saying that it was no more > object-oriented than Java. Java _is_ object-oriented, so I don't see how this is a negative. Note that object orientation looks a little different in message-oriented languages (such as Smalltalk or Objective C) rather than in call-oriented languages (like C++, Java, or Python). Those on either side of the fence can sometimes be languagist; some Smalltalk users in particular can be extremely purist about what makes an object-oriented language. Perhaps your Smalltalk fan is referring to the fact that Python (like Java) is not the same type of object-oriented language as Smalltalk, but that doesn't mean that Python (again, like Java) is not object oriented. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From emile at fenx.com Thu Nov 1 18:45:17 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Nov 2001 15:45:17 -0800 Subject: List transpose method References: <3BE1DD41.C58238FE@home.com> Message-ID: <9rsn3s$vjpde$1@ID-11957.news.dfncis.de> "Don O'Donnell" wrote in message news:3BE1DD41.C58238FE at home.com... > Tom Harris wrote: > > > > Hi, > > > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > > only come up with an ugly multiliner. > > > >>> lst = [(1,2), (3,4), (5,6)] > >>> trn = apply(zip, lst) > >>> trn > [(1, 3, 5), (2, 4, 6)] > > Cheers, > Don Cool. I hadn't realized that zip could be used for more than two sequences. -- Emile van Sebille emile at fenx.com --------- From barry at zope.com Tue Nov 13 01:01:21 2001 From: barry at zope.com (Barry A. Warsaw) Date: Tue, 13 Nov 2001 01:01:21 -0500 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> <15344.43730.821724.769885@monster.linux.in> Message-ID: <15344.46897.223437.983547@anthem.wooz.org> >>>>> "PR" == Prabhu Ramachandran writes: PR> (1) Re-nesting a package is a pain. What I mean by PR> re-nesting is that say I have a package, A, that is separate PR> (and that has its own sub packages) and now I want it as part PR> of another package, B. Why would you want to do that? Why not just keep them separate top-level packages that cooperate? Or export A's names in B's modules? I think distutils helps out here because it's now easy to install A in a way that B could just use, or add to. FWIW, we knit things together as well, e.g. with StandaloneZODB. It's got a bunch of top-level packages that are treated as a single entity via a figment of CVS's imagination. So what if it installs a bunch of separate top-level package names that aren't all treed under a single package? PR> Lets further suppose that the module which re-nests the PR> package, B, tracks the development of A and keeps their copy PR> updated. Okay. PR> In this case A is developed as a standalone package and B adds PR> something to it that A cannot/refuses to use. Okay. PR> With the current approach B would be forced to modify A every PR> time A changes in some significant way simply because A was PR> re-nested. Yes, this is contrived but such situations do PR> occur. Why does B have to add packages to A's namespace? Why can't the B author simply use distutils to ensure that vanilla A is installed, import the bits and pieces of A that you want to expose, overriding what you want to change, and export an interface through B that clients can use instead of A? I.e. through the use of "from foo import bar" and "from foo import bar as baz", you can present whatever public interface you want, through B's namespace, and mimic as much or as little of A's as you want. PR> Its not the application that I'm concerned about - an PR> application is typically a single/few file(s) and editing them PR> to suit things is certainly not an issue. Well, not /all/ applications! JH> I expect there is more to the issue than just wanting to avoid JH> some extra typing. A short PEP that describes the specific JH> problems being solved and discussing alternatives would help. BAW> Indeed. We've been here before (perhaps, several "befores" BAW> :). Every time this comes up I get the feeling like there BAW> are easy ways to accomplish what you want if you think of the PR> So do I need to write a PEP? Is there some special PR> formality/format I need to keep in mind? PEP 1 and PEP 9 are your guidelines to proper PEP form and procedure. BAW> Are the needs of application authors different than library BAW> authors? PR> I would think so. That would be good to outline in your PEP then . -Barry From LLoeffler at home.com Fri Nov 30 15:03:02 2001 From: LLoeffler at home.com (Luke) Date: Fri, 30 Nov 2001 14:03:02 -0600 Subject: Converting an integer to base 2 References: <3C07CFED.C7F7CA38@motorola.com> Message-ID: <3C07E5F6.10108@home.com> print int.__doc__ int(x[, base]) -> integer Convert a string or number to an integer, if possible. A floating point argument will be truncated towards zero (this does not include a string representation of a floating point number!) When converting a string, use the optional base. It is an error to supply a base when converting a non-string. --- The second argument tells python of what base the string argument is. From katz at Glue.umd.edu Fri Nov 30 01:16:40 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Fri, 30 Nov 2001 01:16:40 -0500 Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: References: <3bfd7f87@news.airtel.net> Message-ID: On Thu, 29 Nov 2001, David Eppstein wrote: > Head Waiter (Michael Palin): This is a vegetarian restaurant only, we [snip] ah, cool, the promised veg*n crack. There's always one to follow up :) Another side question: is there any page listing what kind of crazy patches people have applied to their local distributions of Python? (things such as ternary operators, stuff from PEPs that were rejected, etc..) Roey From ejohnso9 at earthlink.net Sat Nov 24 03:59:54 2001 From: ejohnso9 at earthlink.net (Erik Johnson) Date: Sat, 24 Nov 2001 08:59:54 GMT Subject: (off-topic humor) While browsing google for python and turtle References: Message-ID: <3BFF6245.436F64CB@earthlink.net> Syver Enstad wrote: > (I was intersted in turtle graphics for python) > > From http://www.geocities.com/~chicagoturtle/tips.html: > > Elmer says, > > Attach the Python valve to your faucet, connect the > plastic hose from the valve to your turtle tank. In the down position > with the water faucet turned on, the Python generates a powerful > suction which quickly drains the tank's water (and "vacuum" cleans any > debris) into your sink's drain. By pushing the Python valve in the up > position, water will flow from the faucet quickly filling the tank > with clean water. Please be sure to adjust the water temperature to > the proper temperature for your turtle before filling the tanks. > > With the Python, one can easily drain and refill over 150 gallons in > less than an hour without lugging a bucket or sucking on a hose. > > *The Python siphon system with hose and connectors is available at > most larger pet stores, $35 -$50 depending on hose length.* > Yeah, I use essentially the same thing to fill and empty my waterbed. You can get one without the nifty Python brand name for only about $15. :) -ej From dale at riverhall.NOTHANKS.co.uk Sun Nov 4 05:04:05 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Sun, 04 Nov 2001 10:04:05 +0000 Subject: Exception holes, again. References: <9s1sen$1sdd$1@feed.teaser.net> Message-ID: "Olivier Deckmyn" wrote: >Did you look in the C sources ? > I don't have the C source. I shouldn't need it. -- Dale Strickland-Clark Riverhall Systems Ltd From nicbar at mail.com Mon Nov 5 13:06:33 2001 From: nicbar at mail.com (Nic) Date: 5 Nov 2001 10:06:33 -0800 Subject: Python kernel32 exception on Win9x while using DDE extensions Message-ID: I am running on Win98 SE with the latest DCOM installed. When I try to run the following script fragment from python.exe or pythonw.exe I get a “page fault exception” in kernel32.dll I tried using ActivePython 2.1 and also on pythonlabs distribution with the win32 extensions and I get the same results. Running the script from inside the pythonwin environment works fine. I need the script to run automatically (preferably as an exe file). Can anybody help me? Is there a way to start PythonWin so it loads the script and runs it without user intervention (maybe a .BAT file)? import win32ui import dde import sys def send_string(str): # ….. pass print "Starting DDE v1.02" cESC = chr(27) cF11 = cESC + '[23~' server = dde.CreateServer() # The problem is in the following line server.Create("ERTestClient") conv = dde.CreateConversation(server) while 1: str = raw_input("Enter String: ") if str == "EXIT": break str_all = cF11 + str ## send_string(str_all) print "DONE" Thanks Nic From m94511 at kornet.net Tue Nov 20 02:08:40 2001 From: m94511 at kornet.net (=?ks_c_5601-1987?B?wKW5zLXwvu69usTw?=) Date: Tue, 20 Nov 2001 16:08:40 +0900 Subject: =?ks_c_5601-1987?B?s6ogvu62pz8/Pw==?= Message-ID: ::::: ???? ?? ??? ??? ?? ?? ::::: ???? ???? ???,???? ???? ?? ???? ??? ok! ??? ?? ?????!! ???? ! ? ?? ???? ????. ?? ??? ??????.??? 2,000?? ?? ?? 02-3147-0261 ?????? ??? ?? ?? ?? OK ??? ?? ???? ?? ??? ????!! ???? ??? ???? ?? ???? ????? ?? ???? ???? ??? ???? ???? ??? ???? ???? ???? ?????? ??? ????? ???? ?? ???? ??? ??,???? ??,????? ???? ???? ?? ??? ??? ???? ??? ??? ??? ????,???? ?? ??? ????? ????? ??? ? ?? ???? ???? ??? ??? ??? ??? ??? ?! ??? ?? ??? ???? ?? ???? ??? ??? ????? ????? ???? ?? ??? ???? ??? ??? ???? ??? ?? ,???? ??? ??? ???? ?????? ???? ??? ????? ?? ??? ??? ??? ??? ? ????. ????? ??? ???? ??? ?? ??? ??? ???? ????? ???? ??? ??? ????? ?? ??? ? ?? ?? ????? ?? ???? ????? ??? ? ?? ???? ??? ??? ?? ??????? ??,??? ???? ??? ???? ?? ?? ? ????.? ??? ?,???? ??? ?? ????? ??????. ?? ??? ???? 72% ?? ???? 1,280,000 ? 488,000 ??? ??????? 1:1? ???? 2001? ???? ???? ?? NO ?? NO! ???? ?? ?? ????? ?? ???? ??? ? ? ?? ??? ??? ?? ?? ??? ? ??? ??? ??? 1:1? ???? 2001? ???? ???? ??? ???? ????? ?? ???? CD ?? ?? ?? ?? ????? 1? 6?? ??? ?? ???? ?? ??? ?????? ??? ?? ???? ??? ? ?? *.????,???? 1.????? ?? 2.???? ??/?? 3.????,???? ???? ??? ???? ??? ??? ??? ? ? ?? ? ??!! ??????? ??? ??,??,????? ?? ?? ?? OK ? ??? ???? ??? ?? ??? ?? ??? ???? ?????? ???? -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim at vegeta.ath.cx Mon Nov 12 23:22:32 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 13 Nov 2001 04:22:32 GMT Subject: OT: Mobile Internet Toolkit EULA References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Guido Stepken graced us by uttering: [ snipped excerpt from MS MIT EULA ] > Thanx lots for checking this out ! Hmmm, that means, that it is forbidden > to produce (distribute) code, consisting of (L)GPL Software and Microsoft > OpenSource. One is not allowed to mix code. BSD License + Microsoft Code, > that's OK ! > Any ideas, why ? The BSD license is unrestrictive. I can take an entire BSD-licensed file, cut-and-paste it into my own project, sign, seal, and deliver...and not even have to mention where I got it. This is fine by Microsoft because it means if they find anything they want somewhere inside a Berkeley Quality Software project, they can just take it. What I think was even more appalling was the restriction on : (ii) not using Potentially Viral Software (e.g. tools) to : develop Recipient software which includes the Software, : in whole or in part. This means I can't - test a script using a perl binary that falls under the (default) Artistic License. - test a script using a Python binary that falls under the GPL compatible license. - _use_ Vim or Emacs to edit _any_ file in the project I'm developing. - make a tarball of a directory tree using GNU tar or GNU gzip. - ...and so on Limitations on the product distributed is nothing new. OTOH, Microsoft has just attempted to make it _ILLEGAL_ to use a python binary I've compiled myself (though ActivePython is probably alright). _This_ is what a _huge_ number of people are upset about. Opinions? Rebuttals? Tim Hammerquist - -- There's something to be said for returning the whole syntax tree. -- Larry Wall in <199710221833.LAA24741 at wall.org> -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE78KHt8vyBPhAeHacRAjQkAJ0ThoHmEb+edkRyibQBXh/Lsbx0pQCdFxt/ zk6p9bOHMWfhBRXo8/F9PWI= =nzLy -----END PGP SIGNATURE----- From tim at bladerman.com Fri Nov 2 13:40:06 2001 From: tim at bladerman.com (Tim Gahnström /Bladerman) Date: Fri, 02 Nov 2001 18:40:06 GMT Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> Message-ID: "Leo Lipelis" > On Thu, 01 Nov 2001 22:03:42 -0500, Paul Rubin wrote: > > "Leo Lipelis" writes: > >> I'd like some help with an issue I have with Python. Simply put, I > >> think having an exception mechanism is a waste if there is no tool that > >> will let you know which unhandled exceptions exist at point foo.... > >> > >> Considering that in Python exceptions are matched by identity instead > >> of equivalence, it's possible to track all the exception flows, right? > > > > Of course not. Since you can execute arbitrary strings, you can create > > new exception classes at runtime and throw them. > > This is a non-argument. It's like saying, you can access anything with a > pointer in C, thus you shouldn't use any tools that can warn you about > possible segfaults. I think this is a verry interesting subject and havn't yet decided wich side to team up with sp please keep the discussion rolling :-) Anyway, what I wanted to say is: Wouldnt it be fairly easy to track those possibly exeptions? I imagin that it might be hard to see that there canot be an endOflList axception in this case: a=[1,2,3,4,5] for i in range 3: a[i]=2 But if this is supposed to generate a message that it can possibly be an end of list exception then it shouldnt be to hard to implement right? Anyway I think that, since Python is such a light weight language, this kind of thing fits better into an extension module wich those who really need it can import rather then "forcing" the overhead on everyone... maybe. ...Kind of new to Python so I havnt had any problem with this yet... But I like typing :-) Tim From jlh at home.com Thu Nov 29 19:34:25 2001 From: jlh at home.com (Jeff Hinrichs) Date: Thu, 29 Nov 2001 18:34:25 -0600 Subject: How can i get values from a init - file References: <3c0602a8.2703951@news.tuwien.ac.at> Message-ID: <091001c17936$c3686c40$6702a8c0@gato> Check out the ConfigParser class. http://www.python.org/doc/current/lib/module-ConfigParser.html ----- Original Message ----- From: "martin z" Newsgroups: comp.lang.python To: Sent: Thursday, November 29, 2001 3:52 AM Subject: How can i get values from a init - file > > I want to make a init - file, where i can set value for variables in > my programm. > now i have in my programm a class : > > class TEST: > def __init__(self): > self.a = 12 > self.b = 13 > self.c = 14 > self.d = 15 > > > I want to make a init- file like (or a other style. It is free; But i > do not want write self.a = 12 because. other peoble should also use) > : > a 12 > b 13 > c 14 > d 15 > > I need a init file to save the settings of my programm. > How can i read the values of the init file into my programm without > asking all cases. ? e.g: > If s == a then > self.a = s1 > > > I hope you understand my problem. > > martin > -- > http://mail.python.org/mailman/listinfo/python-list From Gareth.McCaughan at pobox.com Wed Nov 28 05:08:52 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 28 Nov 2001 10:08:52 +0000 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> Message-ID: Rainer Deyke wrote: [Greg Ewing proposed:] > > > > for 0 <= i < 5: > > > > ... ... > +666 if it understands arbitrary expressions: > > for 0 <= i < 5 and i % 0 == 0: # possible > pass [etc] I wondered about suggesting it should understand for 0 <= i < j < 10: ... which would be useful to me about once a month, but I think that would be entirely excessive. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From sholden at holdenweb.com Wed Nov 7 08:59:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Nov 2001 08:59:54 -0500 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: "David Andreas Alderud" wrote ... [...] > The fact that Ada is the only language that truly was designed, [...] Please. This sweeping generalisation lays all your other arguments waste. regards Steve -- http://www.holdenweb.com/ From gmfawcett at operamail.com Thu Nov 22 11:33:57 2001 From: gmfawcett at operamail.com (Graham Fawcett) Date: 22 Nov 2001 08:33:57 -0800 Subject: Passing object as param to Python COM server References: Message-ID: <3d799735.0111220833.57b005e0@posting.google.com> Following up to my own message, in case anyone else needs the answer (or, more likely, I forget it and end up back at Google...) You need to wrap the argument using win32com.client.Dispatch: def QueryApp(self, app): #Name should be a valid attribute of a PowerPoint.Application app = win32com.client.Dispatch(app) print app.Name # or whatever else you want to do. > Hi folks, > > I've got a COM server written in Python, and it's running great (thank you to > EVERYONE who made this marvellous tech possible). But I've got a question > about passing parameters in method calls on my server. > > I have a VB script in PowerPoint that creates an instance of my server. I'd > like to pass a reference to the PowerPoint application to my server, for > example: > > 'in the PowerPoint macro, > sub PassExample(pptapp as Application) > Set myserver = CreateObject("UWindsor.MyServer") > myserver.QueryApp pttapp > end sub > > # in the server, > def QueryApp(self, app): > #Name should be a valid attribute of a PowerPoint.Application > print app.Name > ... > > Running the VB macro incurs an AttributeError: Name when the QueryApp method > is called. > > The object (app) passed to my server is a PyIDispatch object. What do I have > to do to make my server recognize this as a PowerPoint.Application object so > that I can access its attributes (and hopefully invoke its methods)? > > Apologies for my lack of what is probably basic COM knowledge. Thanks, > everyone. > > -- Graham From m.faassen at vet.uu.nl Thu Nov 1 18:53:32 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Nov 2001 23:53:32 GMT Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> <9rrtud$ff8$1@nntp6.u.washington.edu> Message-ID: <9rsn9s$cvu$3@newshost.accu.uu.nl> Russell E. Owen wrote: > Personally, I prefer the effect of double underscore for this case, as > well. I can easily get to the variables by applying the name mangling > myself, yet cannot accidentally stomp on the variables in a subclass. > To each his/her own. That's a good point. I haven't done this because I've never remembered the name mangling rule. I'm not even sure if it's really part of the Python standard, but I'd guess it should be. What if you don't know what superclass your variable or method might be coming coming from? I suppose this would not be a common event, though. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From debl2NoNoSpammy at bellatlantic.net Sat Nov 10 17:31:19 2001 From: debl2NoNoSpammy at bellatlantic.net (David Lees) Date: Sat, 10 Nov 2001 22:31:19 GMT Subject: doc generator References: Message-ID: <3BEDAAC7.204732A8@bellatlantic.net> You might look at Happydoc at: http://happydoc.sourceforge.net/ david lees David B?langer wrote: > > Looking for software to generate doc from source. > Tried pythondoc 0.7 but was unable to make it > run on freeBSD. Looks that it was more made for > Windoz. > > Thanks, > David From ws-news at gmx.at Fri Nov 16 13:16:40 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 19:16:40 +0100 Subject: Unicode and string conversions References: <9t3ijd$1lr$1@netnews.upenn.edu> Message-ID: <3bf558cb$1@brateggebdc5.br-automation.co.at> Hi, you can convert (encode) an unicode string to an 8 bit encoding (a string) with the encode() method of the unicode string object. The reverse is possible with the builtin function unicode() e. g. >>> us=u'\u0621\u0622' >>> s=us.encode('utf-8') >>> s '\xd8\xa1\xd8\xa2' >>> >>> nus=unicode(s, 'utf-8') >>> nus u'\u0621\u0622' >>> print unicode.__doc__ unicode(string [, encoding[, errors]]) -> object Create a new Unicode object from the given encoded string. encoding defaults to the current default string encoding and errors, defining the error handling, to 'strict'. >>> print us.encode.__doc__ S.encode([encoding[,errors]]) -> string Return an encoded string version of S. Default encoding is the current default string encoding. errors may be given to set a different error handling scheme. Default is 'strict' meaning that encoding errors raise a ValueError. Other possible values are 'ignore' and 'replace'. >>> You need to specify which encoding should be used. The available encodings reside in the package 'codecs' of the Python distribution. hth Werner From timothyrandolph at yahoo.com Wed Nov 14 09:07:55 2001 From: timothyrandolph at yahoo.com (Tim Randolph) Date: 14 Nov 2001 06:07:55 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> Message-ID: <7f2b571b.0111140607.26b08d1b@posting.google.com> adamspitz at bigfoot.com (Adam Spitz) wrote > I'd be interested to see the current state of Python development > environments. That's where Smalltalk really shines, and I've never > seen an environment for any other language even come close. That's > understandable, because Smalltalk's whole, um, paradigm is optimized > for that kind of thing. Holding everything inside a monolithic image > makes it really easy to create spectacular tools (but, of course, also > costs Smalltalk a lot, like the ability to use Smalltalk for small > scripts). In particular, I'd like to see the Python Refactoring > Browser efforts bear fruit. This is robably a good time to point out the new meta-IDE put out by IBM as open source at eclipse.org. It was developed by the smarties at UTI who built the original VA for Smalltalk. Not only is it open source, but its got a very open plug-in architecture, that to my mind is yearning for Python editors, debuggers, Class Browsers, Zope builders, etc. Using the eclipse framework and tools, I don't think it would be *that* hard to get to a VA for Python experience. Check it out. It's one of the coolest things that has come down the road for quite some time. --Tim From wurmy at earthlink.net Thu Nov 15 10:57:53 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Thu, 15 Nov 2001 15:57:53 GMT Subject: scope question References: <9t0j1i02oob@enews1.newsguy.com> Message-ID: <3BF3E5ED.DA7BACCE@earthlink.net> Choco wrote: > > I am re-working a program to abstract some elements of a set of cgi's into > a shared library. One thing I'm looking to abstract is the database > connection code. To do so, I've created a connect() method and a close() > method. The connect() method returns a cursor which the cgi then uses to > execute a series of sql statements. To close out the cursor and the > database connection the cursor is passed to the close method. How do I get > this to work? I find that I cannot simply do this: > > def close(cursor): > cursor.close() > db.close() > > This fails with a NameError: global name 'db' is not defined. > > I'm searching for the solution to this at the moment, but thought I'd post > here to see if anyone had any tips. How about passing both the database and the cursor to the close function? def close(cursor, db): cursor.close() db.close() Since I don't know your code, I don't know if this is possible in your situation. You say that connect() and close() are methods... of what? Of the database object? Where does db come from? Normally I would connect to a database like this: db = .connect(...) c = db.cursor() c.execute(...some SQL...) c.close() db.close() I don't know much about the database API, but under at least one database module I know (mssql.pyd) it's possible to get the database through the cursor: db = cursor._owner db.close() HTH, --Hans From stepken at little-idiot.de Mon Nov 5 09:24:06 2001 From: stepken at little-idiot.de (Guido Stepken) Date: Mon, 5 Nov 2001 15:24:06 +0100 Subject: Teaching python (programming) to children References: <7xvggph61y.fsf@ruckus.brouhaha.com> Message-ID: <9s67gd$874$00$2@news.t-online.com> Paul Rubin wrote: > Brian Elmegaard writes: >> So, any comments are appreciated, especially on: Are there good reasons >> for advocating python being a language one could teach children >> programming with and are there perspectives in translating python to many >> different languages in order to facilitate this, or will children not be >> ready for learning programming before they have learnt English after all? > > The best-known attempts to teach children programming have been with > the Logo language. See the book Mindstorms, by Seymour Papert. He > has another book out called "The Children's Machine: Rethinking School > in the Age of the Computer", but I haven't seen it yet. > I have had great success in making children (12-15) having fun programming python .... before the were only interested in playing gameboy...with pygame, SLT they are now trying to programm a simple game for windows .... For Mindstroms there is a python module in work..... have fun, Guido Stepken From QnickQm at alum.mit.edu Mon Nov 5 18:45:50 2001 From: QnickQm at alum.mit.edu (Nick Mathewson) Date: Mon, 05 Nov 2001 23:45:50 GMT Subject: How would I write this perl script in python? References: Message-ID: In article , Aaron Ginn wrote: > > I rarely use Perl except in cases where it is not obvious how to do > something in Python that I already know how to do in Perl. I'm curious > what the best way to rewrite the following Perl script in Python is. > > -------------------------------------------------- > #!/usr/bin/perl -w > use strict; > use diagnostics; > > my $val = 0; > > while (<>) { > if (/^(\w+\s+)(\-*\d+\.\d+)(\s+)(\-*\d+\.\d+)$/) { > $val = $2 - 0.775; > printf "%s%s%s%s\n", $1, $val, $3, $4; > } > else { > print; > } > > } #!/usr/bin/python # # Untested and maybe buggy; use at your own risk. import fileinput, re # Note: this pattern is overly verbose; you don't need to escape a # '-' character. pattern = re.compile(r'(\w+\s+)(\-*\d+\.\d+)(\s+)(\-*\d+\.\d+)') for line in fileinput.input(): m = pattern.match(line) if m: val = float(m.group(2)) - 0.775 print "%s%s%s%s" % (m.group(1), val, m.group(3), m.group(4)) else: print line [...] > I'm not sure how to isolate the different parts of the regexp in > Python as I have done in Perl by using parentheses and then referring > to the parts as $1, $2, $3, etc. I've used Python's re module many > times, but mostly only for searching. It seems I always revert to > Perl when I have a complicated (or not so complicated) search and > replace task to perform. I recommend that you check out the section of the documentation for the re module that talks about match objects. Briefly, the re.match and re.search functions return an object that contains (among other things) the sections of the string matching the parenthesized groups in your regexp. You may access them one-at-a-time by calling m.group(grpnumber) or m.group(groupname); or you can get a list of them by calling m.groups(). Yrs, -- Nick Matthewsen aa 1011011011 Remove Q's to respond. No spam. From peterb at cortland.com Sun Nov 25 12:26:03 2001 From: peterb at cortland.com (Peter Bismuti) Date: Sun, 25 Nov 2001 09:26:03 -0800 Subject: python compiler compiler google results References: Message-ID: <3c009440$1@207.229.64.20> Ok, I know, Google 1. Post 2. I found PLY (Python Lex-Yacc). I also found PyLR -- Fast LR parsing in python. Any Others? One with a wide range of languages already implemented is important. I'm interested in Java, Python, Perl, but not C or C++. From katz at Glue.umd.edu Thu Nov 29 17:39:40 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Thu, 29 Nov 2001 17:39:40 -0500 Subject: The Editor Poll results are in! In-Reply-To: References: <3bfd7f87@news.airtel.net> <9u4cbu$2ts$1@news.xmission.com> Message-ID: Right on. I'm vegan so I drink soymilk anyway. (and I find that Python fits in with my youthful ideals nicely among others such as Esperanto & being vegan) I remember a long thread about Esperanto and Python ideals. I rather enjoyed that. In fact there are some Esperantists here (Bill Harris of the Python Tutorial in Esperanto, Erik Max Fancis, Peter Hansen (?), Konrad Hinsen); I wonder if there any vegens here, too. it'd also be cool to see the relative age of new pythonistas -- I suspect that they're young, but this is completely unfounded. Roey assiduous JED user, but, more generally, Whatever Works (tm). On Thu, 29 Nov 2001, Paul Winkler wrote: > On 29 Nov 2001 04:08:30 GMT, Kaden wrote: > >ALRIGHT! Who's gonna pay for this pepsi ruined keyboard now?! > > That's what you get for drinking that crap! I'm currently using > granola with soymilk. It's much more visually disgusting, which helps > enhance the comic experience, but it doesn't corrode things nearly as > badly. It's still a bitch to clean up. > > --PW From malcolm at commsecure.com.au Mon Nov 19 08:57:44 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Mon, 19 Nov 2001 21:57:44 +0800 Subject: pygtk In-Reply-To: ; from syt@gemini.logilab.fr on Mon, Nov 19, 2001 at 01:44:50PM +0000 References: Message-ID: <20011119215744.J9858@Vetinari.home> On Mon, Nov 19, 2001 at 01:44:50PM +0000, Sylvain Thenault wrote: > this is a little off topic, but does anybody knows how to give the > focus to a particular window using pygtk ? (I wish the designed window > to take focus and to come to the foreground if another window hided > it). Not that you won't get an answer on this list (I can't think of how to do it right now, but Skip or somebody possibly can), but ... The best responses to questions about pygtk are likely to come from the pygtk list. See http://www.daa.com.au/mailman/listinfo/pygtk for more info. Cheers, Malcolm -- Quantum mechanics: the dreams stuff is made of. From kevin at cazabon.com Thu Nov 15 01:34:37 2001 From: kevin at cazabon.com (Kevin Cazabon) Date: 14 Nov 2001 22:34:37 -0800 Subject: Extending with C/C++ Message-ID: <5a4226f0.0111142234.33ea1590@posting.google.com> I'm trying to wrap a C/C++ DLL with a Python interface to one function... I'm not much of a C programmer, so I was using the "cookbook" approach listed in the Python docs. However, the link to David Ascher's "compile.py" that is supposed to be able to generate a MSC project file is broken (so are the links on David's Starship Python page). Any suggestions? Does that module still work with Python 2.1.1? Are there easier ways to do it? Or better yet, has anyone already wrapped the driver interface for Aladdin's HASP library? (doubtful) Any suggestions are appreciated! Kevin Cazabon kevin at cazabon.com From emile at fenx.com Fri Nov 2 20:27:11 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 2 Nov 2001 17:27:11 -0800 Subject: Getting started References: <3BE34358.8819E585@ix.netcom.com> Message-ID: <9rvhf4$vjrgr$1@ID-11957.news.dfncis.de> "Jive Dadson" wrote in message news:3BE34358.8819E585 at ix.netcom.com... > Okay, easy question: How do I write a Python module and load it into > the interactive console application? MS Windows. For example, if I put > the script in a directory called, 'D:\\my python hacking', how do I tell > the interactive console window I want to load the module 'hacking.py' > from that directory? > > BTW, I tried putting setting a MS Windows system variable PYTHONSTARTUP > to "print 'Hello, world.'", but it had no effect. If you're just getting started on windows, I'd suggest getting and installing the ActiveState distribution. Much better OOB experience for newbies. ;-) Once you've done that, you should be able to: D: cd 'my python hacking' python hacking.py HTH, -- Emile van Sebille emile at fenx.com --------- From fredrik at pythonware.com Wed Nov 7 02:30:16 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 07:30:16 GMT Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> Message-ID: Edy Lie wrote: > Hi I have setup a class but in the code i could not use it. Anyone care to > explain ? hint: it's usually easier to for the readers of this forum to figure out what's wrong if you include the error message. > class DataBase: > def __init__(self, Plan, Domain, Email, Name): > self.UserPlan = Plan > self.UserDomain = Domain > self.UserEmail = Email > self.UserName = Name > if choice == 1: > print 'Adding New User\n' > add = DataBase() did you get this message? Traceback (most recent call last): File "\qq.py", line 19, in ? add = DataBase() TypeError: __init__() takes exactly 5 arguments (1 given) this means pretty much what it says: the __init__ method (which is called automatically when you create the object) expects five arguments, but only got one (the implied self argument). > class DataBase: > def __init__(self, Plan, Domain, Email, Name): you can either modify the call to something like: # pass in None as default for all attributes; we'll # set them below anyway add = DataBase(None, None, None, None) > add.UserPlan = input("Username: ") > add.UserDomain = raw_input("Domain: ") > add.UserEmail = raw_input("Email: ") > add.UserName = raw_input("Name: ") or read in the values before creating the object: plan = input("Username: ") domain = raw_input("Domain: ") email = raw_input("Email: ") name = raw_input("Name: ") add = DataBase(plan, domain, email, name) or perhaps modify the class in some way. hope this helps! From johnroth at ameritech.net Mon Nov 5 18:49:23 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 5 Nov 2001 15:49:23 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com><3BE534B7.F0F56060@chello.nl><3BE5F306.446480AD@ix.netcom.com><3BE623BF.9F4EA0F2@seebelow.org><7x4ro94uuh.fsf@ruckus.brouhaha.com> Message-ID: "Prabhu Ramachandran" wrote in message news:mailman.1004964308.19260.python-list at python.org... > >>>>> "PR" == Paul Rubin writes: > > >> Therefore, this simple but powerful idea gives you nearly all > >> of the benefit of variable declarations, yet none of the > >> baggage. > > PR> Of course it doesn't. If you misspell a symbol in some rarely > PR> used path through the code, it's quite possible your testing > PR> will miss it. Compile time checking wouldn't. > > To catch these, maybe you should look at: > > http://pychecker.sourceforge.net/ > > prabhu Or PyCover, at the Vaults if you want to insure that your unit tests were sufficiently comprehensive. John Roth > From thomas.heller at ion-tof.com Thu Nov 15 13:55:16 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 15 Nov 2001 19:55:16 +0100 Subject: (automatically) reloading changed modules into a running program Message-ID: <9t132f$160s9n$1@ID-59885.news.dfncis.de> I wrote a script which - automatically reloads changed modules depending on their timestamp - updates existing objects in a running program: classes, functions, bound and unbound methods The purpose is to speed up the development process, not to update long running programs on the fly. The script is not yet finished, however, I believe it is working. Eventually I plan to submit it into the Python Cookbook. I post it here to get early comments and suggestions for improvements. Cheers, Thomas ---- autoreload.py ---- # # autoreload.py - automatically reload changed source # code into a running program # # You may want to place the following two lines # into your sitecustomize.py: # # import autoreload # autoreload.run() # # or you can use the superreload() function # instead of the standard reload() function. # # Created: Thomas Heller, 2000-04-17 # # $Id: autoreload.py,v 1.9 2001/11/15 18:41:18 thomas Exp $ # # $Log: autoreload.py,v $ # Revision 1.9 2001/11/15 18:41:18 thomas # Cleaned up and made working again before posting to c.l.p. # Added code to update bound (or unbound) methods as suggested # by Just van Rossum. Thanks! # # ... # # Revision 1.1 2001/10/04 16:54:04 thomas # Discovered this old module on my machine, it didn't work too well, # but seems worth to continue with it... # Checked in as a first step. version = "$Revision: 1.9 $".split()[1] # ToDo: # # Cannot reload __main__ - explain why this cannot work, # and explain a workaround. # # Optimize - the number of watches objects (in old_objects) # grows without limits. Think if this is really necessary... import time, os, threading, sys, types, imp def _get_compiled_ext(): for ext, mode, typ in imp.get_suffixes(): if typ == imp.PY_COMPILED: return ext # the official way to get the extension of compiled files (.pyc or .pyo) PY_COMPILED_EXT = _get_compiled_ext() class ModuleWatcher: running = 0 def __init__(self): # If we don't do this, there may be tracebacks # when shutting down python. import atexit atexit.register(self.stop) def run(self): if self.running: print "# autoreload already running" return print "# starting autoreload" self.running = 1 self.thread = threading.Thread(target=self._check_modules) self.thread.setDaemon(1) self.thread.start() def stop(self): if not self.running: print "# autoreload not running" return self.running = 0 self.thread.join() print "# autoreload stopped" def _check_modules(self): while self.running: time.sleep(0.01) for m in sys.modules.values(): if not hasattr(m, '__file__'): continue if m.__name__ == '__main__': # we cannot reload(__main__) First I thought we # could use mod = imp.load_module() and then # reload(mod) to simulate reload(main), but this # would execute the code in __main__ a second # time. continue file = m.__file__ dirname = os.path.dirname(file) path, ext = os.path.splitext(file) if ext.lower() == '.py': ext = PY_COMPILED_EXT file = os.path.join(dirname, path + PY_COMPILED_EXT) if ext != PY_COMPILED_EXT: continue try: if os.stat(file[:-1])[8] <= os.stat(file)[8]: continue except OSError: continue try: superreload(m) except: import traceback traceback.print_exc(0) def update_function(old, new, attrnames): for name in attrnames: setattr(old, name, getattr(new, name)) def superreload(module, reload=reload, _old_objects = {}): """superreload (module) -> module Enhanced version of the builtin reload function. superreload replaces the class dictionary of every top-level class in the module with the new one automatically, as well as every function's code object. """ ## start = time.clock() # retrieve the attributes from the module before the reload, # and remember them in _old_objects. for name, object in module.__dict__.items(): key = (module.__name__, name) _old_objects.setdefault(key, []).append(object) # print the refcount of old objects: ## if type(object) in (types.FunctionType, types.ClassType): ## print name, map(sys.getrefcount, _old_objects[key]) ## print "# reloading module %r" % module module = reload(module) # XXX We have a problem here if importing the module fails! # iterate over all objects and update them count = 0 # XXX Can we optimize here? # It may be that no references to the objects are present # except those from our _old_objects dictionary. # We should remove those. I have to learn about weak-refs! for name, new_obj in module.__dict__.items(): key = (module.__name__, name) if _old_objects.has_key(key): for old_obj in _old_objects[key]: if type(new_obj) == types.ClassType: old_obj.__dict__.update(new_obj.__dict__) count += 1 elif type(new_obj) == types.FunctionType: update_function(old_obj, new_obj, "func_code func_defaults func_doc".split()) count += 1 elif type(new_obj) == types.MethodType: update_function(old_obj.im_func, new_obj.im_func, "func_code func_defaults func_doc".split()) count += 1 ## stop = time.clock() ## print "# updated %d objects from %s" % (count, module) ## print "# This took %.3f seconds" % (stop - start) return module _watcher = ModuleWatcher() run = _watcher.run stop = _watcher.stop __all__ = ['run', 'stop', 'superreload'] ---- EOF ---- From DeepBlue at DeepBlue.org Thu Nov 1 13:36:48 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Thu, 1 Nov 2001 12:36:48 -0600 Subject: Why 'self' ? References: Message-ID: no, you have to pronounce it as el-lam-duh otherwise 'spelled' will have to be pronounced as 'spaid' (speyd) or 'spade'. unless, naturally, there is a rule for this in which case I'll be merri.ll.y wrong! DeepBlue wrote in message news:mailman.1004637301.1483.python-list at python.org... > > Tim wrote: > >plus-llambda-will-be-spelled-with-two-els-ly y'rs - tim > > Finally! BTW, do we pronounce that "yam-duh" ? > > Jim > > > From cjensen at bioeng.ucsd.edu Mon Nov 5 13:29:33 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Mon, 05 Nov 2001 10:29:33 -0800 Subject: Freeware Python editor References: <3be2c653.1205904380@news> Message-ID: <3BE6DA8D.8401193F@bioeng.ucsd.edu> "David C. Ullrich" wrote: > > On Wed, 31 Oct 2001 08:08:22 -0600, Kemp Randy-W18971 > wrote: > > >Check out the free Python editor at www.crimsoneditor.com. > > Not that it matters to me, but it seems like someone > should ask: What does it do that other free(?????????) > Python editors don't do? > > David C. Ullrich That was my question. One difference I see is that other free editors are portable. I'm NOT free to find out the differences for myself, because I'm not running Windows. Until there is a crossplatform version, I'll just sette on not finding out the differences. -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From mwh at python.net Fri Nov 23 05:01:51 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 23 Nov 2001 10:01:51 GMT Subject: Colored console on Windows References: <1712.011122@storm.ru> <9tjflj$j08$1@peabody.colorado.edu> Message-ID: Fernando P?rez writes: > quick question: does your readline module handle multi-line edits? That is, > if I have a multi-line statement, does it bring it back as a single editable > entity (which would be great) or as the 'real' readline does, as a series of > single-line statements (clumsy). My pyrepl package http://starship.python.net/crew/mwh/hacks/pyrepl.html does that. It's unix only, and a bit rough around the edges. I have a new version sat on my irritatingly internet-disconnected home box which I'll release as soon as I remember to stick it on a floppy and bring it in to the department. Cheers, M. -- > Why are we talking about bricks and concrete in a lisp newsgroup? After long experiment it was found preferable to talking about why Lisp is slower than C++... -- Duane Rettig & Tim Bradshaw, comp.lang.lisp From gaya at infomail.lacaixa.es Tue Nov 20 08:58:39 2001 From: gaya at infomail.lacaixa.es (Toni Gaya) Date: 20 Nov 2001 05:58:39 -0800 Subject: Python to compile to Java-bytecode Message-ID: <61f6bfa8.0111200558.2f52ad44@posting.google.com> There is any project that allows compile a Python program to Java bytecode, as py2exe does compiling a python program to a .exe? I know that there is Jython.. but.. It is a python interpreter writen in Java, not a compiler of python source to Java bytecode (Althought it implies compile source itself and support libraries, I think it is the interesting thing). Does not someone more think about compile a python program to Java byte code, and the possibility of merge python and java using soap? I think it is a important thing to compete against .NET Or it is obvious to use a python interpreter in any platform, a java interpreter in same platform, and comunicate them using Soap?! From thomasNO at SPAM.obscure.dk Thu Nov 15 05:04:36 2001 From: thomasNO at SPAM.obscure.dk (Thomas Jensen) Date: Thu, 15 Nov 2001 10:04:36 GMT Subject: Threading References: Message-ID: David Bolen wrote in news:ur8r024it.fsf at ctwd0143.fitlinxx.com: > Thomas Jensen writes: > When in doubt, that's the right approach. You might be able to > eeek a little more performance out of hand tuning some "safe" > scenarios, but I don't think the potential downsides are worth it > in general. I guess you're right :-) >> Is there any "rule-of-thumb" (or doc) regarding which operations >> are atomic, for example is the following safe: > > An operation would be atomic with respect to Python interpreter > threads if it executes while holding onto the GIL (global > interpreter lock). Generally speaking this must (a) be something > written in C, either as part of the interpreter or an extension > module, and (b) not release the GIL to provide for threading > execution around a long running or blocked activity, such as I/O. Ahh, the GIL, thought I'd heard about such a beast. > Generally, it's just safer to lock more conservatively. I'll do that. >> thread 1: >> mylist.reverse() >> >> thread 2: >> for item in mylist: ... >> >> (silly example perhaps) > > This doesn't appear as it would be safe if the goal of thread 2 was > to iterate through every item in the list consistently. If mylist That would most probably be the goal. > was a builtin list type object (and at least in the CPython > implementation) then you are guaranteed that once it begins, the > reverse() method call in thread 1 will run to completion before any > other Python thread continues execution. What you aren't > guaranteed is how that reverse call's timing will occur with > respect to thread 2. > > So if thread 1 managed to transfer control to the reverse() method > prior to thread 2 hitting that for loop, you'd get a consistent > (reverse) list. > > But if thread 1 didn't make it into the call until thread 2 was > partially through the loop, then the list would be reversed, and it > would be equivalent to having Python code that mutated the list > within the for loop, in which case behavior is non-deterministic > (at least in general, since it depends on the type of mutation). > > Since the mutation in this case keeps the list the same length but > just reverses the contents, I expect you'd have entries processed > in the for loop up until the thread context switch, and then you'd > get the entries in the remaining positions of the list but for the > reversed copy. That would probably not be the goal. > I'd definitely protect something like this - you've clearly got > higher level processing (the iteration over the list) that needs > the list to remain intact during the work. Either that, or protect > the act of making a copy of the list, and then iterate over that > copy. The copying is one of those potential tuning points - I'd > have to double check, but I bet that an operation like "newlist = > mylist[:]" would be atomic, so you could probably get away with not > protecting that. At least until mylist happened to end up a user > class with its own __getslice__. Thank you for the detailed explanation, I guess the reason I asked was that I didn't quite know how the GIL worked. I thought that perhaps the for loop would lock the specific list for modification. The more I think about it, the more unreasonable it seems. Especially since the lock is global, it would not only block access to the list. I'll keep up the paranoia :-) -- Best Regards Thomas Jensen From peter at engcorp.com Wed Nov 28 19:10:12 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 19:10:12 -0500 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <3C057CE4.9E39D69D@engcorp.com> James_Althoff at i2.com wrote: > > And this might be handy in common situations where you could write, for > example: > > if index not in len(mylist): > print 'index out of range' > > instead of > > if index not in xrange(len(mylist)): > print 'index out of range' What am I missing here? Is the above not just a far less sane way of writing the following? if index >= len(mylist): print 'index out of range' -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sasoft at gmx.de Mon Nov 19 18:43:47 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Mon, 19 Nov 2001 18:43:47 -0500 Subject: context-sensitive help from editor In-Reply-To: <9tbetv$e92$1@netnews.upenn.edu>; from maxwell@ldc.upenn.edu on Mon, Nov 19, 2001 at 12:19:08PM -0500 References: <9tbetv$e92$1@netnews.upenn.edu> Message-ID: <20011119184347.A11363@cruciatuz.de> On Mon, Nov 19, 2001 at 12:19:08PM -0500, Mike Maxwell wrote: > Is there a .HLP or .CHM file out there somewhere? Or is there an easy way > to turn a .HTML file into a .CHM file? (Or a way of passing a keyword to > Adobe Reader or GhostView, so it goes directly to the relevant place in the > doc.) I saw python on windoze last time at school, it was an activestate version of python ( http://www.activestate.com/ ). I think it contained a chm version of the python helpfiles (i am not 100% sure). I clicked my way to the download-page: http://www.activestate.com/Products/ActivePython/download.plex hope-this-helps -- Stefan Antoni ---------------------------- Mon Nov 19 18:30:23 EST 2001 _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \ From kragen at canonical.org Tue Nov 20 06:41:47 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 20 Nov 2001 06:41:47 -0500 Subject: How to marshal a function? References: <01111413063906.04702@logiplex1.logiplex.net> Message-ID: <83adxhu0sk.fsf@panacea.canonical.org> Cliff Wells writes: > On Wednesday 14 November 2001 15:10, Fran?ois Pinard wrote: > > Besides, I feel a bit safe as I channel these Python services through > > `ssh', which provides enough user authentication for us, so I presume. > > Well, that's a different story altogether =) If you weren't using ssh, it > would be a huge security hole. Not necessarily. You need to know more about his setup than whether or not he is using ssh to know whether some process trusting data it receives over a network is "a huge security hole". For example, if his intended security policy is that anyone on the network should be able to run arbitrary Python code on the server, it is not a security hole, ssh or no ssh. This is a reasonable security policy for many networks, like the one in my bedroom. (In today's virus-prone world, perhaps it isn't the best security policy, but it's a reasonable one.) On the other hand, if the machine he's sending the arbitrary code from is poorly secured (relative to whatever his threat model is), allowing a program on that machine to run arbitrary code on the other machine is a security hole, ssh or no ssh. (Although if ssh is permitting him to run arbitrary code anyway, it's not his program's fault if it's insecure.) It irks me when people have such a glib attitude about security; it reminds me of newspaper agony aunts who are happy to recommend that a woman leave her husband on the basis of two ambiguous sentences of complaints. To know whether something is "a security hole" requires, at least, that you know what threats you want to defend against and what threats might actually exist. From usenet at NOSPAM-irmen.cjb.net Wed Nov 14 17:46:36 2001 From: usenet at NOSPAM-irmen.cjb.net (Irmen de Jong) Date: Wed, 14 Nov 2001 23:46:36 +0100 Subject: Sockets and messaging services References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> Message-ID: <9sus8c$5st$1@news1.xs4all.nl> [...] > proper message queue server. Alternatives might be Pyro/CORBA/etc > but I don't think they deal with the queueing aspect. As far as Pyro is concerned, all message passing is transparent and synchronous. No queueing is ever attempted. As far as I know CORBA 3.0 specifies message oriented (i.e. queueing/asynchronous) message passing, but I don't know if any Python bindings support this. Irmen de Jong From emile at fenx.com Thu Nov 8 06:34:42 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 03:34:42 -0800 Subject: HOWTO execute an external program? References: Message-ID: <9sdqtk$127dt6$1@ID-11957.news.dfncis.de> "Patrick Guio" wrote in message news:Pine.LNX.4.30.0111081151190.5102-100000 at fyspc-rp18.uio.no... > > Dear all, > I would like to use python as a scripting language to run my simulation > code. I would like to know how do I do that ? There are lots of ways. If you provide more details of where you're starting from and what you want to get done I'm sure you'll get responses to help you get there. > Is there a way to evaluate how long it took to run the command (make a > kind of summary/log of the run)? Yes. The how of that depends. -- Emile van Sebille emile at fenx.com --------- From david.abrahams at rcn.com Thu Nov 1 13:45:27 2001 From: david.abrahams at rcn.com (David Abrahams) Date: Thu, 1 Nov 2001 13:45:27 -0500 Subject: [ANN] Python and C++ - Support Available Message-ID: Is combining Python and C++ code essential to your work? Python and C++ complement one another wonderfully, but interfacing them using Python's 'C' API can be tedious and error-prone. Boost.Python (http://www.boost.org/libs/python/doc/index.html) is a popular tool for interfacing Python to C++, allowing you to easily expose C++ classes in Python as though they were regular Python classes. As it's author, I have recently begun offering commercial support for Boost.Python, ensuring that it will receive continued attention. I would be happy to discuss additional support contracts with interested parties. The Boost Python Library is distributed under the Boost License Requirements (http://www.boost.org/more/lib_guide.htm#License), which are as follows: a.. Must be simple to read and understand. b.. Must grant permission to copy, use and modify the software for any use (commercial and non-commercial) for no fee. c.. Must require that the license appear on all copies of the software source code. d.. Must not require that the license appear with executables or other binary uses of the library. e.. Must not require that the source code be available for execution or other binary uses of the library. f.. May restrict the use of the name and description of the library to the standard version found on the Boost web site. -- =================================================== David Abrahams, C++ library designer for hire resume: http://users.rcn.com/abrahams/resume.html C++ Booster (http://www.boost.org) email: david.abrahams at rcn.com =================================================== From not.this at seebelow.org Fri Nov 2 15:03:33 2001 From: not.this at seebelow.org (Grant Griffin) Date: 2 Nov 2001 12:03:33 -0800 Subject: Freeware Python editor References: Message-ID: <9ruu6l09ah@drn.newsguy.com> In article , "Tim says... > >>> FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS > >[Delaney, Timothy] >> The PSU failed! A post about the PSU escaped to the world in its >> entirety! >> >> We are fre > >In case the intended word was "free", I'd like to point out that there are >different philosophies about free software, only one is correct, and >c.l.py's mission is to educate the world about which one that is. Don't >forget that extremism in defense of freedom is no vice. Can one likewise conclude that freedom is defined as defense of extremism in vices? (Just wondering .) And BTW, I'd just like to take this opportunity to address the concept of "free beer"--a subject which, in these periodic debates of "free software", invaribly comes up, but then passes by without receiving a level of thoughtful critical thinking commensurate to that given to the other freedom-related subjects. Specifically, I think we need to re-examine the concept of free beer itself; then, we will have a more solid footing for the rest of our arguments--if not for our feet. Can free beer itself truly be free in a "free beer" sense? I'm not sure. For one thing, one's freedom to consume free beer is severly limited by one's physiology. In the most obvious sense, one is limited in one's freedom to consume beer at least by the rate at which one can pee. But in a somewhat more abstract (though still physiological sense), one's freedom to consume beer is limited by the beer's potential lethality if consumed too quickly. (Admittedly, this point probably applies to free liquor more than free beer, but freedom is freedom.) Further, one's freedom to consume beer comes in direct opposition to one's freedom to operate a motor vehicle--not just in the legal sense, or even in the more important menace-to-society sense, but also, in the limit, in the physiological sense: at some point, one's freeedom to drink beer leaves one no longer free to use one's motor skills to exercise one's freedom to drive motor vehicles--even if one were legally and morally free to do so at such times. Clearly, then, even in a free society, we all have to accept limits on our freedom. Or, as a wise man once said, "the freedom to swing your fist stops at the the tip of my nose". Likewise, the freedom we have to speak freely leaves us _unfree_ to be unoffended by the free speech of others. At best, then, freedom is a cage of liberation. Is The Glass of Freedom half-empty, or half-full? Neither. And both. We must consider freedom as a tradeoff, not as an absolute. Our discussions of freedom should therefore center on _where_ to make the trade, not on what the absolute should be. In that vein, we might consider the constitution of the United States of America as a practical example which manifests a balance between fist-swinging and noses. We see that, although it preserves a variety of essential specific freedoms, it also specifically establishes authority in Congress to create patent laws. Thus, paradoxically, it both protects "freedom" and limits it in the same stroke of a pen. But in so doing, it makes a tradeoff which most of us who fall under its jurisdiction find quite satisfactory. In summary, then, we see that even free beer is not free in a "free beer" sense; that freedom is not an absolute; and that intellectual property in particular is not--and need not--be free in a "free beer" sense--even if free beer itself were. That being said, I am not trying to limit anyone's freedom to focus on, then discuss free beer as a serious intellectual and philosophical endeavor; quite the contrary: if some folks have consumed free beer freely enough to freely conclude that the terms spelled out in the Gnu Public License which limit their use of the applicable intellectual property somehow protect their freedom (if not in a "free beer" sense, even assuming that free beer itself were free in a "free beer" sense), then I freely respect their right to consume freely, so long as, in the process, they don't drive their motor vehicle into the tip of my nose. I hope, though, that such folks never succeed in their evident campaign to force _all_ who provide free beer to give away their recipe. Personally, I am more interested in the beer than the recipe--assuming it's good beer. Also, of course, many beer recipes are already freely available--more than I can count. But more importantly than the question of recipes itself, I suspect that any such restrictions on the freedoms of those who provide free beer will, if anything, reduce the aggregate quantity of beer freely available, rather than accomplish their (purported) purpose of engendering more free beer. And speaking as someone who has occasionally enjoyed a little free beer (though who more often ends up paying for it), that can't a good thing. OK-now-you-guys:-hand-over-your-keys-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 kerstin.dressler at web.de Fri Nov 9 08:34:43 2001 From: kerstin.dressler at web.de (Kerstin Dressler) Date: 09 Nov 2001 15:34:43 +0200 Subject: Calling Ghostscript from Python References: <3BEBE6AE.C7A33CF4@pallas.com> Message-ID: <3bebe987$1@netnews.web.de> Georg Bisseling wrote: >Kerstin wrote: >> >> Hi, >> >> I'm trying to call the ghostscript to convert some PS to PDF. I'm >> working on Win95, so the os.system() always returns '0'. >> When the cmd is running, the DOS-Box opens and I get the error message >> "File or directory not found". >> I also checked if the PS are readable; and when I change the cmd to >> something else (like "md new_dir") it works. >> >> ghost_dir = 'c:\ghost\gs\gs7.00\lib' >> cmd = ghost_dir + '\ps2pdf13.bat ' + ps_file + ' ' + pdf_file >> os.system(cmd) >> >> I think there must be something wrong with the pathname or rather the >> ghost environment. How can I check this? >> I'm using full pathnames for 'ps_file' and 'pdf_file' too! Might this >> cause problems? >> >> Can anybody help me? >> Thanx, >> Kerstin > >ghost_dir = 'c:\\ghost\\gs\\gs7.00\\lib' >cmd = ghost_dir + '\\ps2pdf13.bat ' + ps_file + ' ' + pdf_file > >should do the trick. > >You should use os.path.join to join pathnames platform independent. That's not working. Also I have another file with full pathname ("c:\python21\programs\ps2pdf\input. txt") where it was working before. At the moment I don't need to be platform independent, it's a script for WinNT. But anyway, would this be right then: path_ghost = os.path.join('c:\\ghost\\gs\\gs7.00\\lib') ? Kerstin -- __________________________________________________________ News suchen, lesen, schreiben mit http://newsgroups.web.de From aaldv97 at student.remove-this-part.vxu.se Thu Nov 8 10:57:34 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Thu, 8 Nov 2001 16:57:34 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: <9sea3o$1ue$1@news.lth.se> > If you're judging the demand by studying job ads, you should be > aware that light-weight tools like Python and Perl are often hidden > under labels like "various scripting languages" or "rapid development > tools" or "script programming". Those are not specific Python programming jobs. > Most companies don't mention them at all, even if they use them > a lot. Why would they? Any programmer worth hiring can pick up > a light-weight language in a day or two. True, but those are just programming jobs, not specific Python programming jobs. Any programming language is good to know about when starting a job, so fear the ancient might of COBOL! From mwh at python.net Wed Nov 14 06:35:00 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 11:35:00 GMT Subject: Python .elc and /etc/magic References: Message-ID: pinard at iro.umontreal.ca (Fran?ois Pinard) writes: > Hi, friends. I notice that the standard `file' program fails to recognise > that `.pyc' files are compiled Python codes, and is not always clever even > for `.py' files, witness the third line below: > > /usr/local/lib/python/Local/commun.py: a python script text > /usr/local/lib/python/Local/commun.pyc: data > /usr/local/lib/python/Local/defs.py: ISO-8859 Java program text > /usr/local/lib/python/Local/defs.pyc: data > /usr/local/lib/python/Local/machines.py: a python script text > /usr/local/lib/python/Local/machines.pyc: data > /usr/local/lib/python/Local/make.py: a python script text > /usr/local/lib/python/Local/make.pyc: data Dunno about .py files, but consider: [mwh at starship mwh]$ cat get_magic.py import imp, struct, sys print sys.version[:3], hex(struct.unpack('l',imp.get_magic())[0]) [mwh at starship mwh]$ python1.5 get_magic.py 1.5 0xa0d4e99 [mwh at starship mwh]$ python2.0 get_magic.py 2.0 0xa0dc687 [mwh at starship mwh]$ python2.1 get_magic.py 2.1 0xa0deb2a [mwh at starship mwh]$ python2.2 get_magic.py 2.2 0xa0ded2d > Is there any standard `/etc/magic' entries that would work better for Python? > Here is the Python relevant code in the copy from Linux SuSE 7.2. Well, the above would do for the .pycs/.pyos (I can't remember if the magic is different for .pyos -- I don't think so). You should be able to do $ file /path/to/foo.pyc Python bytecode for version 2.1 or whatever. Identifying Python source sounds like an altogether harder game. Searching for ":\n "? > # often the module starts with a multiline string > 0 string """ a python script text > # MAGIC as specified in Python/import.c (1.5.2/1.6) > # 20121 ( YEAR - 1995 ) + MONTH + DAY (little endian followed by "\r\n" > 0 belong 0x994e0d0a python compiled > > It probably matters to know that Python 2.0 is the default on this system. Where did they get that number from? Doesn't seem to match anything I can find. > And even, if one knows the proper incantations, how do we proceed then > for having that `/etc/magic' file more universally modified? I have no idea. I hope it's not a case of badgering each distro separately... Cheers, M. -- Java sucks. [...] Java on TV set top boxes will suck so hard it might well inhale people from off their sofa until their heads get wedged in the card slots. --- Jon Rabone, ucam.chat From andymac at bullseye.apana.org.au Thu Nov 1 06:45:55 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Thu, 1 Nov 2001 22:45:55 +1100 (EDT) Subject: Running phyton on 50Mips RISC doable? In-Reply-To: <9rovil$fei$1@news1.xs4all.nl> Message-ID: On Wed, 31 Oct 2001, Cor wrote: > It is an application with 50Mips Risc processor, with little > (and slow) memory. So when I want to run the python interpreter > on this machine, will it be terrible slow? And more inportant: how > mauch memory will I need? a few K? a few hondred K? > Is it difficult to port the code such that it will run on this machine? > (It uses gcc compiler) IIRC an i486 @ 100MHz is of this order or less. I run Python on a FreeBSD box with such a processor quite satisfactorily. It is built in that environment using gcc, and the base interpreter uses about 1.5MB of VM IIRC (which can probably be trimmed somewhat). Python is quite portable, with just some support modules being fairly specific to particular architechtures. In its current form, Python is very attached to a file system for storing library modules. There is also Pippy - a port of Python to PalmOS, which might give you some ideas. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From prabhu at aero.iitm.ernet.in Tue Nov 6 07:52:04 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 18:22:04 +0530 Subject: Python packages - problems, pitfalls. In-Reply-To: <23891c90.0111060325.4c2ec924@posting.google.com> References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> <23891c90.0111060325.4c2ec924@posting.google.com> Message-ID: <15335.56564.796413.95322@monster.linux.in> >>>>> "PB" == Paul Boddie writes: >> pkg_root/ __init__.py app.py # app is the application that is >> not part of the package PB> There's something about this which intrigues me, too, but more PB> on that below. PB> I've been reorganising some package structures recently, and I PB> found a number of issues which may be of interest to PB> you. Firstly, that remark I made above: let's say we run PB> app.py from outside pkg_root... PB> python pkg_root/app.py PB> What would you expect to happen if app.py contained the line PB> given below? PB> import pkg_root.common_module PB> What seems to happen is that unless the current directory (the PB> parent of pkg_root) resides on your PYTHONPATH, this will not PB> work - it's as if app.py is part of the package and should be PB> using... PB> import common_module Indeed, that is correct. PB> I found this slightly confusing, but it is related to what you PB> want to do in your example, because I agree that it can make PB> some sense to include the test, demonstration or main PB> application program within the package directory, even though PB> it isn't strictly part of the package - it's a user of the True, but lets say I want to freeze the package without installing it. Or I have a user who doesnt want to/cannot install (for instance because (s)he is not root on the machine) it but wants to still run the package. PB> package. Of course, in Java one uses an explicit package PB> keyword to exclude or include "modules" from/in packages, PB> whereas in Python it's implicit. PB> This is really an aside, though, because your main issue is PB> with the way importing of "super-package" members is PB> done. What happens if there's a package called common PB> somewhere else on your system outside (and unconnected with) PB> this package, and then in a.py you do use the following PB> statement? PB> import common.foo True, but then even sibling packages wont work. If you have name clashes you are in trouble anyway since python makes all global modules available without std.. If you have a module one important rule is that you should not make the name the same as a standard module (or another globally availabe module). For instance one is asking for trouble if one has a module string.py! There is nothing you can do about this. Name clashes are a problem and my approach does not address them neither does it make matters worse because the current scheme is no better anyway. pkg/ sub/ b.py subsub/ b.py: import subsub.foo is valid and has the same problem you mention (i.e. if subsub is another package's name you are in trouble). PB> In the scheme you propose, access to the external common PB> module is likely to be restricted in some way by the presence PB> of the common subpackage of the new package. With the existing PB> mechanisms, however, this ambiguity is avoided entirely in PB> this case - you have to do the following: PB> import pkg_root.common.foo Not really. See above also if you *truly* want to avoid ambiguity we'd all have to explcitly name *everything* which is a bigger pain. Actually, one good way to allow access to global names would be to introduce a std or a main name that is global always (or atleast not to be used (officially) by anyone). then to resolve names in case of ambiguity one would do: import std.string to get the local string module you'd do: import string PB> I do see your point, though. In one of my works, I use PB> packages to maintain a sort-of logical structure as follows: PB> XMLForms __init__.py Accessor.py ... DOM __init__.py PB> DOMAccessor.py # Yes, I could have called this Accessor, # but PB> I did say that I just reorganised # the package! ... [snip] PB> Now, DOMElementTypes is related to ElementTypes through their PB> "nature" - they perform similar activities. However, I have PB> chosen to group define subpackages according to implementation PB> technology. As a result, I would have to do the following kind PB> of import from within XMLForms.DOM.DOMElementTypes.BaseTypes: PB> import XMLForms.ElementTypes.BaseTypes PB> You might want to know why I can't do this: PB> import ElementTypes.BaseTypes PB> Well, I don't really see the need to do that unless I consider PB> ElementTypes to be independent of XMLForms. Moreover, if I PB> decided to give in and rename DOMElementTypes to ElementTypes, True, I'll admit that ElementTypes arent really independant of XMLForms but all this is a matter of convenience. If you really wanted to force explicit package imports then sibling packages should not work. And coding would be painful esp. if you wanted to avoid things like from XMLForms.ElementTypes.BaseType import * or import XMLForms.ElementTypes.BaseType as BaseType which are both not recommended and are not reload safe. In which case to access any single function you'd have to type way too much. I think a well defined package import structure is necessary and once defined people can work around it depending on their needs. PB> because it lives in a separate namespace to the other PB> ElementTypes, then I would still be compelled to do a "full" PB> import under any import scheme which isn't "really clever". PB> import DOM.ElementTypes.BaseTypes import PB> ElementTypes.BaseTypes # What does this import? I'd expect that this imports the closest match depending on where you do it. If you do it inside the DOM dir it would refer to the XMLForms/DOM/ElementTypes/BaseTypes.py If you wanted explicitly something else - you'd have to ask for it. But the default would be (1) first check in current dir, (2) if no match go up to parent (3) if 2 fails till you are out of the package look for global matches. PB> One could insist that the first statement always be used to PB> access the DOM version, and that the second statement always PB> accesses the higher-level version, but how is the import PB> mechanism supposed to know what you mean? It depends on the implementation. Once defined and documented it can be used. Without a specification its hard to tell what the import should do. PB> So, to summarise, perhaps there's no simple way of introducing PB> what you want without introducing some of the consequences PB> outlined here. Explicit package specifiers might help in PB> certain cases (the app.py or test.py cases), but they could PB> promote a package structure which isn't obvious from browsing PB> the filesystem. Unions of packages (which could be done using PB> either explicit specifiers or import magic) could potentially PB> introduce side-effects as modules start to co-exist with PB> modules they were never meant to co-exist with. There are always consequences to what is done. But some approaches seem to make more sense than others. I think the current approach is broken. The more i think about it, the more convinced I am of this. BTW, is it possible to do what I specified using something like knee or imputil? thanks, prabhu From loewis at informatik.hu-berlin.de Mon Nov 5 04:13:12 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Nov 2001 10:13:12 +0100 Subject: Gadfly and regsub with Python 2.1 References: <3BE2B29B.1E714B89@noaa.gov> <3BE4A172.1020808@nospam.adelphia.net> Message-ID: Oleg Broytmann writes: > The author is very busy working for Reportlabs, and silently dropped > kjbuckets, kwprsing nd gadfly projetcs :( I've collected some bits of the > dust, but not gadfly. > IWBN if someone who uses one of these projects popped up and announced > himself as a new maintainer. I thought up-to-date versions of these had been incorporated into Zope? Regards, Martin From skip at pobox.com Fri Nov 9 17:55:21 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 9 Nov 2001 23:55:21 +0100 Subject: Module for reading CSV data In-Reply-To: References: Message-ID: <15340.24281.198465.22518@beluga.mojam.com> David> Is there a module for reading CSV files into a dictionary? Or is David> there a builtin that is used in conjunction with readlines()? >From just a few days ago in this newsgroup: From: Dave Cole Sender: python-list-admin at python.org To: python-list at python.org Subject: csv-0.5 released Date: 06 Nov 2001 16:40:28 +1100 The CSV module provides a fast CSV parser which can split and join CSV records which have been produced by Microsoft products such as Access and Excel. On Python 2.x the module outperforms string.split(). Of course the CSV parser can handle much more complex records than string.split()... This is a bugfix release. The changes in this release are: 1- Fixed bug in memory allocation of internal parser buffer - thanks to John Machin for pointing this out. 2- Fixed compile warning on Solaris - thanks to Adam Goucher for reporting this. The module homepage: http://www.object-craft.com.au/projects/csv/ For people who do not have a C compiler on Windows I have put a Python 2.1 binary up here: http://www.object-craft.com.au/projects/csv/csv.pyd - Dave Google is your friend... -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From loewis at informatik.hu-berlin.de Sat Nov 24 06:24:53 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Nov 2001 12:24:53 +0100 Subject: Keeping Python loaded References: <9tndpi$qbe$1@slb0.atl.mindspring.net> Message-ID: "Matt Gerrans" writes: > Is there some existing facility for keeping Python running in memory > at all times, ready to execute scripts, rather than having it load > each time a script runs? I think I can figure out a way to do this, > but I wanted to check first and see if a clever solution (probably > better than what I'm brewing) already exists... There are a number of specialized solutions, like mod_python or mod_snake for Apache, or like Zope. Likewise, the CGIHTTPServer.py only forks, instead of exec'ing. The tricky part is how to tell Python to load and execute another script. If that is solved, execfile may be all you need. Regards, Martin From tim at vegeta.ath.cx Thu Nov 29 21:09:15 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 30 Nov 2001 02:09:15 GMT Subject: python editor poll References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> Message-ID: J?rgen A. Erhard graced us by uttering: > "Tim" == Tim Hammerquist > "Jonathan" == Jonathan Gardner > > Tim> You wanna start a flame war? Say you're a Vimmer _and_ a > Tim> Perler! I learned my lesson! > > So why do you say it again? ;-) Why? Does it threaten you? ;) Python has nothing to worry about from Perl, so neither do any of you. > BTW, do you know how "vimmer" sounds to a German? :-) A lot closer to (English pronunc.) IIRC. Reminds me of my thigh bone, but nothing comes to mind. German isn't among the languages I study. > Tim> Yes, I use the mutt+vim combo, myself. You couldn't _pay_ > Tim> me to change. > > And in my case... Emacs, since I happened to run across uEmacs > in my Amiga days (first editor that felt *good*). (As if anyone > wanted to know that ;-) Right on! FS has saved the day again, granting to each his own favorite editor! Tim Hammerquist -- Any sufficiently advanced technology is compatible with magic. -- The Doctor, Seeing I From dcinege at psychosis.com Thu Nov 22 19:14:43 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Thu, 22 Nov 2001 19:14:43 -0500 Subject: Non-Indented python In-Reply-To: <3BFD3804.3020502@movilogic.com> References: <3BFD3804.3020502@movilogic.com> Message-ID: On Thursday 22 November 2001 12:38, you wrote: > time to find out. i had unzipped the source with winzip (which uses > \r\n) and tried to compile it with cygwin. of course, it couldnt do it, Commandment #2 Thou shalt terminate thy line with but one byte. Let he who hath understanding recognize the number of the byte, 0xA0. Death to thee who terminates thine with any other byte! You use a defective OS built with defective editors. REPENT! Dave -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From not.this at seebelow.org Sat Nov 3 01:11:03 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sat, 03 Nov 2001 00:11:03 -0600 Subject: Freeware Python editor References: <9rv6ga0108t@drn.newsguy.com> Message-ID: <3BE38A77.55F31F77@seebelow.org> Cliff Wells wrote: > > On Friday 02 November 2001 14:25, Grant Griffin wrote: > > > About which part? (And no fair saying "all" .) > > Due to PSA restrictions, I'm not "free" to divul In that case, let me help--as I am undeniably free to do. First of all, let me say that, clearly, I miss the point of "free beer" by freely intermingling the concepts of "free speech" (meaning "free" in a freedom sense) and "free beer" (meaning "free" in a cost sense). It is unclear whether I do this accidentally or deliberatly--but that's just the sort of thing people like me tend to do. In fact, "free" and "free" are actually two different words, though their meanings certainly are related. It is an accident of the English language that these two words happen to be spelled (and, some would even argue, pronounced) the same. As a card-carrying American, I confess that I speak only one language (having failed at learning two others: although one technically is free to learn other languages in America, it's nearly impossible to do so in practice). However, my guess is that certain other languages both spell and pronounce these two words very differently because, in fact, their meanings are quite different. Still, confusing "free" (in a speech sense) with "free" (in a beer sense) is a great gimmick--just the sort of thing we advocates of free speech and free beer might seize upon in our unending attempts to further confuse the gifted college-age slaves we enlist in the noble cause of Free Software (capital "F", capital "S"). First, we get them interested in the beer sense of it--after all, isn't that what it sounds like, and--like free beer itself--isn't that all they wanted in the first place? Then, we tell them, "No, no, no--think 'free speech', not 'free beer'". They're puzzled for a moment, but then the light bulb goes on, and--eureka!--we have a new convert. "_Ohhh_...", they say knowingly. You see, convincing people to create Free Software in a Beer sense is a pretty hard sell--after all, writing commercial-quality software (which, notably, is almost invariably _not_ free in a beer sense) takes a lot of hard work. And why should they just _give_ their hard work away when lots of folks make their living _selling_ software? And heck, they probably got bills to pay. But Free Software in a Speech sense--now *that's* a Cause: something Noble, Just, and True; the sort of thing the youthful idealists of the world are just itching to get involved in--especially after a Free Beer or two. Yes, it's a classic bait-and-switch--get 'em interested in Free Beer, then sell 'em Free Speech, to get 'em to write Free Software for free. Or at least that's what they _think_ they're doing. Just between us girls...they're actually doing something they don't even realize: they're reproducing and copying the greatest Free Software work of all, the GPL itself. And they're doing it for free--at least in a beer sense. You see, the whole purpose of Free Software is to create attractive hosts which will allow the GPL to reproduce itself. (Marketing, Benjamin--marketing.) Whatever you do, don't conduct the following experiment. Don't convince a friend to buy you a free beer at your favorite pub. Then, when it's delivered, don't demand that you also be given the recipe before you drink it. Then, when your friend complains, perplexed at the fact that you aren't happy with just the beer, you also need its *recipe* for some silly reason, don't tell him, "Think 'free speech', not 'free beer'". Because I don't think he'll buy that. free-to-not-speak-for-Richard-Stallman's-guilty-conscience--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 rxg218 at psu.edu Thu Nov 22 13:23:51 2001 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 22 Nov 2001 13:23:51 -0500 Subject: Using Numeric arrays to store different datatypes References: <9tj9jq$sm4@r02n01.cac.psu.edu> Message-ID: <9tjfpc$sjo@r02n01.cac.psu.edu> On Thursday 22 November 2001 12:52 in comp.lang.python Phil Austin wrote: > Rajarshi Guha writes: > >> Hi, >> Is it possible to store say a list variable in a Numeric array? >> Or even a class in a Numeric arry? >> > > use Numeric.PyObject, but note there's a bug with > multidimensional indexing with this type: > >>>> testArray=Numeric.zeros(16,Numeric.PyObject) >>>> testArray[10]=[1,2,3.4] >>>> testArray > array([0 , 0 , > 0 , 0 , > 0 , 0 , > 0 , 0 , > 0 , 0 , > [1, 2, 3.3999999999999999] , 0 , > 0 , 0 , > 0 , 0 ],'O') I get the expected 0's. I'm using Active State Python 2.1 >>>> testArray[1,1]=[1,2,3] If you do testArray[1][1] = [1,2,3] it works fine Thanks for pointing it out ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 152 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- Got Mole problems? Call Avogadro at 6.02 x 10^23. From keiichi at yggdrasil.maisel.enst-bretagne.fr Sat Nov 3 15:40:54 2001 From: keiichi at yggdrasil.maisel.enst-bretagne.fr (Defresne Sylvain) Date: 3 Nov 2001 20:40:54 GMT Subject: [BUG ?] Slicing a 'struct_time' can crash Python interpreter References: Message-ID: Tim Peters wrote: > This is a bug in 2.2b1 that was fixed last week (it works fine in current > CVS Python). Thanks for the reply ! Bye From ws at mystrobl.de Sun Nov 11 08:14:57 2001 From: ws at mystrobl.de (Wolfgang Strobl) Date: Sun, 11 Nov 2001 14:14:57 +0100 Subject: Get file owner in Windows References: <8a27e309.0111081046.5bafb354@posting.google.com> <9selkh$12bvbo$1@ID-11957.news.dfncis.de> <8a27e309.0111100653.c3e304d@posting.google.com> Message-ID: On 10 Nov 2001 06:53:40 -0800, ny_r_marquez at yahoo.com (R.Marquez) wrote : >Someone named Itamar posted this same question to the Python-win32 >mailing list: >http://mail.python.org/pipermail/python-win32/2001-May/000053.html >Here is what it says: > > lets say I want to get the security information on a > file. So I do: > > >>> o = win32security.GetFileSecurity(r"c:\mingc.pyd", > win32security.OWNER_SECURITY_INFORMATION) > >>> o > > > > So what do I do with 'o' now in order to get the > owner? I tried: > > >>> s = win32security.SID(o) > >>> win32security.LookupAccountSid(None, s) > Traceback (innermost last): > File "", line 1, in ? > api_error: (1332, 'LookupAccountSid', 'No mapping > between account names and security IDs was done.') > > What am I doing wrong? > >No one responded to his post. I get the same results that he does. I >have also looked through Mark's "Pyhton Programming on Win32" (good >book, by the way), but it does not seem to have this information >either. Does anyone have the knowhow to make Itamar's code work? Hmm. Well, the following snippet printed PySID:S-1-0x008014000000 for every file I tried on my home machine, independent of the real ower. This looks like a bug in win32security.GetFileSecurity to me. PythonWin 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on win32. ------- for f in glob.glob("d:/*.*"): try: o = win32security.GetFileSecurity(f,win32security.OWNER_SECURITY_INFORMATION) s = win32security.SID(o) print str(s), except: print "n/a", print " ",f ---------- Interestingly, def prsid(name): import string print string.rjust(name,20), try: sid,box,what=win32security.LookupAccountName(None,name) print str(sid),box,what except: print "oops" prsid("wolfgang") works well, so it doesn't seem to be a problem with PySIDs. For reference: there is an entry "Finding the Owner of a File Object" in the August 2001 MSDN library, which contains sample code. The function GetTextualSid code from Q131320 isn't necessary for displaying the sid in textual form, anymore, at least on Win2000, there now is API function ConvertSidToStringSid. Addings this to the aforementioned sample codes resulted in little utility "lookupsid" which produces the following output on my system: H:\e\c\security\lookupsid\Debug>lookupsid myfile.txt SID=S-1-5-21-436374069-854245398-842925246-1004 Account owner = nobody Somebody should have a look into the source for win32security.GetFileSecurity, I guess. -- Wir danken f?r die Beachtung aller Sicherheitsbestimmungen From joost_jacob at hotmail.com Wed Nov 28 09:21:52 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 28 Nov 2001 06:21:52 -0800 Subject: list math for version 1.5.2 without Numeric Message-ID: <13285ea2.0111280621.3da71a55@posting.google.com> List comprehension in the later Python versions is fun but i need to get this piece of code to run as quickly as possible on Python version 1.5.2 and no NumPy available (not allowed to install extra things on the computers here alas). This is the code as it is now, it works allright but the profiler says we spend a lot of time here: for j in range(self.nh): sum = 0.0 for i in range(self.ni): sum = sum + self.ai[i] * self.wi[i][j] the .nh and .ni values are correct I have been trying things like import operator reduce(operator.add, map( operator.mul, ... )) but i am not at all used to optimization wizardry so i have no idea if i can find a good solution. Any expert wants to help ? From tdelaney at avaya.com Sat Nov 10 22:07:49 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Sun, 11 Nov 2001 14:07:49 +1100 Subject: I just got in! Message-ID: > From: John S. Yates, Jr. [mailto:john at yates-sheets.org] > > On Sat, 10 Nov 2001 03:49:51 GMT, grante at visi.com (Grant > Edwards) wrote: > > > and people start to roll > >their eyes when you tell stories about PDP-11s and paper > >tape... > > Grant, > > My PDP-8 experience followed a first addictive exposure > to computers via PDP-11 assembly language. I always > love it when the PDP-11 gets mentioned. So many fond > memories... Are you kidding? The Nova II was a *much* better machine than the PDP-11. (The Nova line was also a descendent of the PDP-8, but went off in a different direction). No - I'm *not* old enough to have used one ... I wrote a software simulator for a Nova II for my final uni software project. It was a lovely machine though - flat memory space, etc. I had a front panel with switches, tape loader, teletype ... all implemented in software. You needed to enter your boot loader through the front panel switches before you could do anything with it ... :) Tim Delaney From jeff at ccvcorp.com Thu Nov 15 19:05:25 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 16:05:25 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <3BF45845.82334FD3@ccvcorp.com> Lulu of the Lotus-Eaters wrote: > David Eppstein wrote: > > You seem to be inconsistent here about whether you want these ranges to be > > open or closed on the right. I think closed is the only reasonable > > choice for this syntax. > > Jeff Shannon wrote: > |Which is exactly why I think that the Haskell-ish syntax is a bad idea. This > |syntax cries out to be a closed interval, and it would be very confusing if > |used as a half-open interval. But that would make it the *only* case of > |Python using a closed interval. > > Well, not the -only- case. '[1,2,3,4,5]' looks like a closed interval > to me... one whose ends are 1 and 5. No, this is an explicit constant. You're not asking anything to be interpolated, therefor the interval idea doesn't really apply. Currently, any time you ask Python to give you "all the numbers from X to Y", it treats it as a half-open interval. Of course you can explicitly list each number that you want, but that's a totally different procedure. Jeff Shannon Technician/Programmer Credit International From opengeometry at yahoo.ca Thu Nov 8 16:17:56 2001 From: opengeometry at yahoo.ca (William Park) Date: Thu, 08 Nov 2001 21:17:56 GMT Subject: HOWTO change user on UNIX for os.system References: <2rBG7.27968$LD.1025113@e3500-atl2.usenetserver.com> Message-ID: <8ECG7.1655$NE2.9751@news.eol.ca> Tom Higgins wrote: > Is there any way to su or login as a different user > within a python script? I mainly need to discover a > method which accepts a password from with the script. Lookup 'telnetlib', 'getpass', 'pwd', 'crypt' for examples. -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From sholden at holdenweb.com Fri Nov 30 00:57:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 00:57:02 -0500 Subject: Why Python? References: <0nDN7.14999$WC1.1783701@newsread2.prod.itd.earthlink.net> Message-ID: "Patrick K. O'Brien" wrote ... > I've added a Python advocacy page to our company website and I'm looking for > suggestions for improvements or additional material. Take a look at > http://www.orbtech.com/why_python.htm and let me know what you think. The > intended audience is a business person who wants to know why they should > support Python in their organization. So the writing needs to be as > non-technical as possible. Thanks. > Patrick: I really like the page. I think it summarizes a lot of what we (the Python community) appreciate about our chosen tool. About the only improvement I would suggest relates to your remarks about the intended audience. We technical types have a tendency to concentrate on features, which we understand because of our enormous brains :-). The business person, however, is more concerned with the benefits ("what's in it for me?") - hence their enormous wallets :-(. I would therefore suggest that in your "What Makes Python Special?" section you lead with the benefits rather than the features. Mostly this just requires a change of emphasis, so rather than saying """ Interpreted: Compiling programs is painfully time-consuming. Python programs are interpreted, allowing individual program files to be modified and used immediately, without a lengthy and error-prone compilation. """ you might consider """ Faster testing and development: Many other commonly used languages must be "compiled" into machine instructions each time they have been changed, making testing a time-consuming process. Python programs use "interpretation", allowing much faster testing and reducing overall development times considerably. """ for example. and-of-course-add-steve-holden-to-the-list-of-users-ly y'rs - steve -- http://www.holdenweb.com/ From brian at rk-speed-rugby.dk Fri Nov 9 02:17:06 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 09 Nov 2001 08:17:06 +0100 Subject: Teaching python (programming) to children References: <3BE88DAD.D29B72DD@svs.com> <3BEAB073.3AE0EACC@mindspring.com> Message-ID: "Dr. David J. Ritchie, Sr." writes: > "Dr. David J. Ritchie, Sr." wrote: > > > With regard to your question and general topic... > > > > Well, I don't want to take issue with anyone so I'll > just reply to my own post. David, I have read this and your first reply with interest. Thanks for the input. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From p.vrijlandt at aig.azn.nl Tue Nov 6 03:20:56 2001 From: p.vrijlandt at aig.azn.nl (Patrick Vrijlandt) Date: Tue, 6 Nov 2001 09:20:56 +0100 Subject: Exception holes, again. References: Message-ID: <9s86hd$65u$1@odysseus.uci.kun.nl> > I want to trap the specific 'api_error' exception raised by win32api. > > I can't find where that exception is defined so how do I catch it? > import win32api try: blabla except win32api.error: print 'caught an exception' HTH -- Patrick Vrijlandt From phr-n2001d at nightsong.com Tue Nov 6 02:03:33 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 23:03:33 -0800 Subject: python-mode for Emacs 21.1? References: Message-ID: <7x7kt48jp6.fsf@ruckus.brouhaha.com> barry at zope.com (Barry A. Warsaw) writes: > RS> * I wonder why python-mode not in standard Emacs distro... > > Stupid licencing issues. :( > > Grab it from > > http://www.python.org/emacs/python-mode/ Are you serious about the licensing issues? I just looked at that url and found no license mentioned. Since it's at python.org I'm guessing it's under the Python license which is GPL-compatible since 2.0.1 or something like that, I thought. From mwh at python.net Sat Nov 10 09:47:47 2001 From: mwh at python.net (Michael Hudson) Date: Sat, 10 Nov 2001 14:47:47 GMT Subject: type(__builtins__) strangeness References: Message-ID: tavis at calrudd.com (Tavis Rudd) writes: > Hi, > why does type(__builtins__) return when called in the > __main__ scope and when called inside an imported > module? Beause it's specially designed to confuse people who are too inquisitive :) Seriously, I don't know, but I know that I don't need to know. Obscure implementation detail. Ignore it. Cheers, M. -- Finding a needle in a haystack is a lot easier if you burn down the haystack and scan the ashes with a metal detector. -- the Silicon Valley Tarot (another one nicked from David Rush) From prabhu at aero.iitm.ernet.in Tue Nov 6 06:48:55 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 17:18:55 +0530 Subject: Python packages - problems, pitfalls. In-Reply-To: References: Message-ID: <15335.52775.141354.978905@monster.linux.in> >>>>> "TR" == Tim Roberts writes: >> Say in b.py I do >> import a >> This will not work! TR> But this will: TR> import os os.path.append('..') import a TR> That's what I've used in a similar situation. Is that really TR> so horrible? Two problems: (1) os.path is a module and you can't do os.path.append. (2) In case you meant 'sys' and doing sys.path.append, this is not a good solution because now the parent dir is in the _global_ search path and other modules might run into bad problems when this happens. prabhu From montanaro at tttech.com Mon Nov 12 07:48:39 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Mon, 12 Nov 2001 13:48:39 +0100 Subject: Post HTML checkboxes? In-Reply-To: <9soc2i$ch$1@green.tninet.se> References: <9soc2i$ch$1@green.tninet.se> Message-ID: Gustaf> For some reason, my the values of my (X)HTML checkboxes won't Gustaf> show up in the CGI dictionary of name + values. I have a form Gustaf> with these two checkboxes: Gustaf> Gustaf> Gustaf, You need a "name" attribute in there somewhere. I don't recognize "id". I suspect it should be "name" instead. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From montanaro at tttech.com Thu Nov 8 11:08:32 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Thu, 08 Nov 2001 17:08:32 +0100 Subject: Reading a comma delimited file In-Reply-To: References: Message-ID: Kristen> Here's what it looks like when I'm done: Kristen> [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1, Kristen> 20.0, 0.0, 167.30000000000001), Kristen> ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0, Kristen> 6.0999999999999996, 13.9, 0.0, 239.0)] Kristen> Just what I need except I don't want all those decimal places. You're being victimized by floating point (im)precision. Details here: http://python.sourceforge.net/devel-docs/tut/node14.html http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From kragen at canonical.org Mon Nov 26 15:40:35 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 15:40:35 -0500 Subject: Keeping Python loaded References: <9tndpi$qbe$1@slb0.atl.mindspring.net> Message-ID: <83r8qls1to.fsf@panacea.canonical.org> William Park writes: > If you want Python in the memory, then just do that: > python some_dummy_never_ending_file & > This will avoid the time it takes to load the Python executable. But, > on my Linux, the subsequent loads are pretty fast even without this. If your dummy file doesn't do anything, it will cause much of Python to be paged in when it starts, but won't keep it from being paged back out when the memory is needed later on. From gb at cs.unc.edu Thu Nov 29 21:13:50 2001 From: gb at cs.unc.edu (gb at cs.unc.edu) Date: 29 Nov 2001 21:13:50 -0500 Subject: Access input line on NameError? Message-ID: Can I get access to the offending text line of the input when I take a NameError exception? I see that it is available on a SyntaxError but I can't seem to find it on a NameError. Thanks gb From me at mikerobin.com Fri Nov 9 11:51:05 2001 From: me at mikerobin.com (Michael Robin) Date: 9 Nov 2001 08:51:05 -0800 Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <52e5ab5f.0111090851.2d4e023d@posting.google.com> There's a subtle off-by-one bug lurking for beginners if this syntax is allowed. Usually for loops are inclusive to the ranges given, so it would be tempting to write: >>> lst = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] >>> # this works, or gives "list index out of range" >>> for i in len(lst): print lst[i] or >>> # this works, or really calls the fn eleven times >>> for i in 10: doSomethingTenTimes() Only one of these can work - the above are either equivalent to the interval [0..9] or [0..10] - assuming it's understood that the start is 0 and not 1. Using (x)range makes it explicit that we're talking about [0..n-1], i.e., [0..n). (Well, it doesn't really make that explicit at all - what it makes explicit is that range(len(s)) will "just work" for whatever sequence is given.) I'd like to see (x)range take a sequence, as in: >>> for i in range(lst): print lst[i] which seems like a natural thing for range to do - polmorphic and pythonic. (At lot more natural than an implicit conversion from an integral type to a sequence.) I think this has been discussed before. mike James_Althoff at i2.com wrote in message news:... > [jim] > for i in 10: > doSomething(i) > > [Rainer and Emile] > I like it. > Sounds good. > > [Steve] > If "for i in 10:" was legal, I'ld guess it meant the same thing as > "for i in [10]:" or "for i in (10,):" > > A file *IS* a sequence -- although you could just as easily slice it > by characters as lines -- or by any arbitrary object for binary files, > as Pascal does. If the integer 10 suggests any sort of sequence, it's > the singleton sequence containing: 10. > > [jim] > On the other hand, 2.2 takes us away from the concept of "suggesting a > sequence" in the context of for-loops. Instead, the new for-loops are > *iterator*-protocol based (not *sequence*-protocol based). They iterate > over something that *is* or *can return* an iterator object. > > So under the proposed scenario, if one looks at 10 and asks "if 10 were to > return an iterator, what would that iterator iterate over?", then it seems > that range(10) would be a more *useful* answer than a sequence of one > element 10. > > Jim From db3l at fitlinxx.com Tue Nov 6 16:46:25 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Nov 2001 16:46:25 -0500 Subject: win32print.Enumjobs References: <3BE7A509.A03DD6C9@nchc.gov.tw> Message-ID: "T. C. Huang" writes: > How to use win32print.EnumJobs() function? The documention has too > little information to > be useful. As it true for most of the win32all package documentation, it only highlights any uniqueness to the Python interface or wrappers, since they are thin wrappers over the underlying Win32 API calls. For more complete documentation you want to reference the documentation for the wrapped function, such as in MSDN (either locally or via http://msdn.microsoft.com). The MS official documentation should give you all the information you need. -- -- 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 nospam at bigfoot.com Fri Nov 30 15:19:36 2001 From: nospam at bigfoot.com (Gillou) Date: Fri, 30 Nov 2001 21:19:36 +0100 Subject: Brain dead with urllib2 Message-ID: <9u8p8g$15mh$1@norfair.nerim.net> Hi, I did not get at all how to use urllib2. I need to go beyond the limited (but easy) urllib. Are there some tutorials ? Thanks in advance. --Gillou From matt at mondoinfo.com Fri Nov 9 16:15:49 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 09 Nov 2001 21:15:49 GMT Subject: Tkinter scrollbar question References: <200111091608.fA9G8ju3009597@ratthing-b246.strakt.com> Message-ID: <9IXG7.1478$H7.774590@ruti.visi.com> On Fri, 09 Nov 2001 19:16:48 +0100, Laura Creighton wrote: >Depending on what I did to cause it to be called, I am going to get >called with a varying number of very different arguments. Which >Fredrik Lundh _did_ tell me, but I didn't understand until I had made >the function tell me what was going on. My experience is that doing your own scrolling in Tkinter is a nuisance at best. I recommend avoiding it if possible. It's often possible to stuff everything into a Pmw.ScrolledFrame and have done with it. In case you're not familiar with Pmw, it's at: http://pmw.sourceforge.net/ If you have a use for some example scrolling code that uses static labels and shuffles data around among them, you're welcome to steal from the MUA that I'm working on. It's at: http://www.visi.com/~mdc/swallow/ You'll find the scrolling code if you download it and search for PITA <0.01 wink>. Regards, Matt From pinard at iro.umontreal.ca Wed Nov 14 15:28:55 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 14 Nov 2001 15:28:55 -0500 Subject: How to marshal a function? Message-ID: Hello, my friends. Earlier today, I wondered how to marshal a function, in view of transmitting it to a remote machine and executing it there. The idea was to not transmit Python source, when the byte-compilation has already been done on this side. I quickly found out that, for a given `function f(...) ...' I should transmit marshal-ed `f.func_code' instead of `f'. The resulting code could even be eval'ed or exec'ed on the remote side, if the function does not require arguments. I did not saw that I could usefully return something from the function, and surely many other properties are missing. Moreover, the manual suggests that this is all internal things, subject to change at any time. The result of marshal-ing is not guaranteed to work between Python versions, either. So, I gave up and returned to transmitting Python sources, and am happy. Nevertheless, I still wonder a bit if there is some clean solution to avoid shuffling sources around, when byte code is already available, here, and am hereby sharing this wondering with you. :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From tatebll at aol.com Mon Nov 12 08:48:08 2001 From: tatebll at aol.com (Bill Tate) Date: 12 Nov 2001 05:48:08 -0800 Subject: Python in a hospital application please help References: Message-ID: geraldol at uai.com.br wrote in message news:... > Hi, > > I want to write an application for the hospital I'm working to. > > I'm newbie in python, and I want to hear some opinios about what are > the options I have.. > > The structure I have in mind is : At Server we will have an > application that handles business rules, connects to databases, and > send objects to the clients . > > At client we will have an wxPython application that will talk to the > server application > > Some things this application must provide > > * Ability to change the database > I think one way tho achieve this is via Object Relational mapper. > Have anyone implemented a library like this in python ? > > * Pool of connections. > In the application I have today all clients have their own > connections to the database. Today I'm using Interbase (free one) but > what if the hospital need a commercial database in the future ? With > a pool of connection we can spent less money, and this is issue in a > hospital in little city of Brazil. > > * The communication between the server and the client must be > encrypted. > Personal information of the patients can't run unencrypted over the > wire. > > > I know that this is difficult application to write, so I want to hear > some design hints, what are the difficulties I'm going to face. What > libraries I can use. > > > Sorry my english and thanks in advance > > Geraldo Lopes de Souza Geraldo - You might check out Webware for Python for some examples on connection pooling. Webware employs a very convenient "plugin" architecture that separates tasks pretty cleanly. I know they have working examples there that you should be able to use. Geoff Tavola has a step-by-step example there you might useful on using ADO (if you are running windows). As far as DB's go, suggest you look at PostgreSQL from the beginning. There are numerous advantages with this product not the least of which is that does have declarative referential integrity (DRI). If a database doesn't have DRI - IMHO, then it shouldn't be used to hold sensitive business information especially patient data. While DBA's tend to disagree on a lot things, DRI is not usually one of them. I think you will also find it convenient to use Postgre's PL/pgSQL module to store some of your business rules. It's preferable to having a lot of embedded SQL spread out across your application and I think you'll find it much more convenient to developing a full blown ORM layer particularly for medical/patient information. I don't know how strong your encryption needs to be, but you may want to check out M2Crypto. From db3l at fitlinxx.com Fri Nov 2 18:00:15 2001 From: db3l at fitlinxx.com (David Bolen) Date: 02 Nov 2001 18:00:15 -0500 Subject: win32 - create/access file properties on NTFS References: <446d315.0111020046.2fc5c1d1@posting.google.com> Message-ID: datalim at email.com (Data) writes: > How do I create/access the extra information while > we right click a file on NTFS at the "Summary" tab? > > I checked ActivePython documentation > but the win32file.CreateFile seems doesn't provide > such feature. Those are file resources, which you have to use separate APIs to create and/or change. The win32api module wraps the appropriate functions (e.g., LoadLibrary, BeginUpdateResource, EnumResourceNames, FindResource, LoadResource, UpdateResource), with constants (e.g., RT_VERSION) in the win32con module. MSDN has info (if you don't have a local copy it's available at http://msdn.microsoft.com - the resources page is at http://msdn.microsoft.com/library/en-us/winui/resource_0jsj.asp), as I'm sure other information sites around would. Also, Gordan McMillan's installer package (http://www.mcmillan-inc.com) has a VersionInfo module used to set versions on final executables that may prove useful as some working code. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From david.abrahams at rcn.com Sat Nov 3 16:25:14 2001 From: david.abrahams at rcn.com (David Abrahams) Date: Sat, 3 Nov 2001 16:25:14 -0500 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> <7xn1257h0d.fsf@ruckus.brouhaha.com> Message-ID: <9s1n66$co7$1@bob.news.rcn.net> "Leo Lipelis" wrote in message news:pan.2001.11.02.09.15.54.147.704 at myspamrealbox.com... > Besides, I am not looking to duplicate Java by enforcing exceptions. Even > Java itself doesn't enforce *all* exceptions. Java has the unenforced > RuntimeException. Although you could *only* throw RuntimeException's if you > wanted, it would be bad programming practice. Thus, Java is not a fascist > dictator. Java does it's own thing, and it's fine. Python has a different > flavour. I think Python should provide a standard tool that gives warnings > about unhandled exceptions (maybe not all, but as many as possible). > Invoking this tool would be up to the programmer. For small scripts it > wouldn't even make sense to use it. But for a large code base, it would be > a great tool. We in the C++ world have learned a lot about what it takes to make a robust program that uses exceptions. Python's EH mechanism is almost identical to that of C++, and most of the same rules apply. In general it is not so important to know exactly which exceptions can be thrown -- you can always handle anything with except: (or catch(...) in C++); all that's lost is the ability to report errors accurately. That's a loss, but not as serious a loss as what you give up when you don't know: A. Exactly which operations can fail. B. What you can count on about the program state in case of a failure. For example, if I run out of memory when appending to a list, is the list unmodified? Empty? Unspecified? Java's specification goes to great lengths to enumerate (some of) the exceptions that can be thrown, but never says whether or how the program state has changed in case of a failure. That, combined with the fact (IIRC) that an "asynchronous exception" can appear magically at any point in your program's execution makes true exception-safety in Java next to impossible. Python in general tends to be underspecified, but if you want to add rigor in the area of exception-handling, I suggest concentrating on dividing operations according to one of three distinctions: 1. basic guarantee -- all invariants of the object(s) being operated on are preserved; no resources are leaked. This is the bare minimum. 2. strong guarantee -- if an exception is thrown, the program state is unchanged 3. nothrow guarantee -- the operation can't fail With these 3, you have the tools you need to construct programs that can effectively and reliably recover from error conditiions. -Dave -- =================================================== David Abrahams, C++ library designer for hire resume: http://users.rcn.com/abrahams/resume.html C++ Booster (http://www.boost.org) email: david.abrahams at rcn.com =================================================== From ktilton at nyc.rr.com Sun Nov 11 16:58:07 2001 From: ktilton at nyc.rr.com (Kenny Tilton) Date: Sun, 11 Nov 2001 21:58:07 GMT Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: <3BEEF4FF.28F6D300@nyc.rr.com> The Strout piece is pretty bad. First, the whole idea of arbitrarily picking assessment categories and then arbitrarily picking numbers 0 to 10 and then arbitrarily assigning weight...fuggedaboutit. Second, looks like the assessment was done by someone trying to justify a switch to Python. Third, no mention of performance, and "OO is outside the scope of this evaluation"?! fourth, Python syntax wins by 10 to 2 on syntax,producing half the difference in the numeric ranking? Puh-leaze. fifth, 30 points for open source? hello, CMUCL? Python wins on expressiveness? Without macros? I would go with the Norvig piece. kenny clinisys "Morten W. Petersen" wrote: > > Hello, > > I'm currently doing some research, to see if it could be an advantage to > use Common Lisp instead of Python (currently Python and Zope [1] are used > to build web applications). > > While doing this, Google has provided two interesting documents (search > for 'lisp vs python'): > > http://www.strout.net/python/pythonvslisp.html > http://www.norvig.com/python-lisp.html > > First off, to save everyone some time, I'm wondering if there are more > papers documenting the difference between the two; if there aren't any, > I'd like to continue the discussion and summarize the findings in a paper > accessible on the net. > > Regards, > > Morten > > [1] http://www.zope.org From thomasNO at SPAM.obscure.dk Thu Nov 22 07:23:19 2001 From: thomasNO at SPAM.obscure.dk (Thomas Jensen) Date: Thu, 22 Nov 2001 12:23:19 GMT Subject: question on __dict__ References: Message-ID: Markus Jais wrote in news:pan.2001.11.22.12.52.34.97867.2869 at web.de: > hello > can somebody tell me, what the difference is between > > self.__dict__('foo') = 'bar' You mean self.__dict__['foo'] = 'bar' right ? > and > self.foo = 'bar' > > or is there no difference? In most cases there is no difference (except I suspect the former is somwhat slower). All Python objects has an attribute __dict__ which contains the object's attributes. When assigning to 'foo' you are actually refering to the 'foo' key of the object's __dict__ dictionary. It is possible to override this behaviour by defining the method __setattr__ in the class in which case differences might occur. http://www.python.org/doc/current/ref/attribute-access.html Generally, I don't think you should access __dict__ unless you have a specific reason. If you need to get 'foo' from a string, have a look at setattr(). http://www.python.org/doc/current/lib/built-in-funcs.html -- Best Regards Thomas Jensen From alexis.layton at post.harvard.edu Sat Nov 17 13:37:30 2001 From: alexis.layton at post.harvard.edu (Alexis Layton) Date: Sat, 17 Nov 2001 18:37:30 GMT Subject: enhancing dictionary update method and the dict type constructor Message-ID: <3BF6AF04.5000209@post.harvard.edu> This message proposes two minor enhancements. Since I've missed the feature freeze for Python 2.2, this would be for the next version. The first enhacement improves the definition of the dictionary "update" method, the second enhancement broadens the dictionary type constructor. In Python 2.2, the new dictionary type factory function "dict" (previously known as "dictionary" in 2.2b1) takes either a mapping object or a sequence of key, value pairs as its argument. I would like to propose that the dictionary method "update" be broadened to take a similar argument type. In addition, I believe it would be generally useful if the sequence form allowed singleton sequences to represent keys that should be omitted from the dictionary, thus: d = {'a': 1, 'b': 2} d.update([('a',), ('b', 0), ('c', 3)]) print d {'c': 3, 'b': 0} I propose that non-existant keys specified in such an update sequence be silently ignored. Given such an expansion of update, it seems to me the more useful constructor for dictionaries would be something more akin to: def dict(*mss): d = { } for map_or_sequence in mss: d.update(map_or_sequence) return d This permits several useful idioms, such as the common case in environment binding where a dictionary represents a symbol table and one must construct a subsidiary dictionary in which one binding has changed: d2 = dict(d, ('v', 3)) It also permits the "union" of two or more dictionaries: dict(d1, d2). ASIDE: what is the proper term for this, since keys in d2 can override those in d1? Finally, for years I've had a little utility function (called "dict" by the way) which constructs dictionaries in which all the keys are identifiers anyway using the keyword syntax: def dict(**kw): return kw The reason is mostly to pre-load certain stupid little look-up tables using a more convenient syntax: dict(a=1, b=2, c=3), etc. The type constructor could also have a **kw behavior which is the final update into the new dictionary, as if dict was defined to be: def dict(*mss, **kw): d = { } for ms in mss: d.update(ms) d.update(kw) return d Alexis Layton alexis.layton at post.harvard.edu From brueckd at tbye.com Thu Nov 29 17:51:38 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Thu, 29 Nov 2001 14:51:38 -0800 (PST) Subject: Python evangelists unite! In-Reply-To: Message-ID: > Okay, I was extolling the benefits of Python to a friend of mine. He > took strong exception to Python's OO model. ... > FRIEND: Besides, that's awful Object Orientation. I'd ask, "according to whom?" This is a pretty typical knee-jerk reaction to something new. "Aargh! This is a different way of doing things! MUST BE BAD!" There are definite cases where both dynamic classes and instances is useful, but before getting to defensive in answering the "why?" I'd personally push back a little more with "why not?" (also I'd point out that just because classes and instances can be so dynamic does not mean that most or even a lot of them are. It just means that the programmer has that power available, if needed.) > If I start adding attributes to an instance of a class, it ceases to > be an instance of that class. That's silly. If I put on a hat, do I cease to be an instance of the Person class? In truth, all less dynamic languages *wish* they had this feature. Since they don't developers instead have two additional pieces of work when creating a new class: (1) they have to figure out up front the total collection of possible attributes/properties instances can have, and (2) they have to set them to some null-like value if those attrs/props are not present. So instead of an instance simply not having a property, all other instances have to have a property with a value that means they don't have that property. Wow. > FRIEND: And another thing! What's with encapsulation? There's no > private!?!?!? Yawn. ;-) Python provides enough protection against accidental private-member usage. Unlike, say, Java, Python does not assume you are an imbecile. IMO your friend probably has not really pondered the true benefits (if any) of 'private'. For a huge class of negative reactions to something different, the first response should often be, "well, have you actually tried it yet?" It's so common to hear people say that some feature is bad because they can imagine a case where supposed harm could come from using that feature. Interesting that you rarely hear people say stuff like "well, I came from using C++. Now that I've used Python for awhile I can honestly say that those publicly-accessible members caused all sorts of problems." Instead you hear, "uh, yeah, I guess it *could* cause a problem. Never has happened to me though." -Dave From R.Brodie at rl.ac.uk Fri Nov 2 04:43:38 2001 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Fri, 2 Nov 2001 09:43:38 -0000 Subject: references ??? References: Message-ID: <9rtpsc$13j2@newton.cc.rl.ac.uk> "Thomas Weidner" wrote in message news:pan.2001.11.01.17.30.27.280.2271 at gmx.net... > I think anybody here knows what references,like in java,c++ or perl, are. > How can i use references in python ? Implicitly. Consider the following: >>> a = [1,2,3] >>> b = a >>> b[1] = 20 >>> print a [1, 20, 3] From sholden at holdenweb.com Fri Nov 30 18:37:15 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 18:37:15 -0500 Subject: A modest indentation proposal References: Message-ID: "Erann Gat" wrote ... > wrote: > [ ... ] > > Now from here on how the story goes is up to you. If you simply insist > that the problem doesn't exist you will lose, at least in the short run, > because for the moment "they" *just know* that it's a problem (in much the > same way that they *just know* that C++ *isn't* a problem). If, on the > other hand, you can show that the community recognizes the problem and has > a solution then you win. You are the community. It's up to you. > Interesting that these engineering choices are made on the same irrational grounds there that they are in many other less competent organizations. Clearly all US citizens using Python should ask their congressperson to withdraw support for further funding for NASA until it starts using Python! Given the high visibility of the missions I suspect I'd rather have someone else's favorite language up on that pedestal :-) regards Steve -- http://www.holdenweb.com/ From SNeelakantan_C at zaplet.com Fri Nov 2 03:08:17 2001 From: SNeelakantan_C at zaplet.com (Shankar) Date: 2 Nov 2001 00:08:17 -0800 Subject: Problem with imported variable References: <3BE1A256.E93D0BE5@home.net> Message-ID: <4a0341c8.0111020008.5f924dcb@posting.google.com> Hello > > I have a little question: > > I have 2 classes "Class1" and "Class2" and several > > functions in each class. The Class1 is in the file > > "File1" and the Class2 is in another file "File2". At > > the beginning of the File1, I import the File2: > > from File2 import * > > > > In the Class2, I create a variable with a specific > > value. When the program is running, I modify the value > > of this variable in the other class (Class1) and then > > I want to read the new value of the variable farther > > in the code of the Class2. > > The problem is that the value does not change in the > > File2 (Class2). Moreover, as the 2 classes are not in > > the same files, the global statement does not change > > the problem. > > Does someone have an idea? > > Thanks for your help! > > Someone else may be able to figure out what you want to do, but I'm > lost. Try posting a very small version of your attempt to do what you > want, and we'll probably be able to help you. > Actually, I too faced the same problem today. I struggled for nearly an hour. If I all code in the same file, everything seems to work. But, in the name of modularity, when I tried to split my code neatly into 2 different classes, variables of class2 set by methods of class2, but accessed from methods of class1 seem not to get updated. > One question: when you say "I modify the value of this variable in the > other class (Class1) and then I want to read the new value of the > variable farther in the code of the Class2" are you talking about > changing a class variable or an instance variable? > Could someone clarify if my notion of class and instance variables is correct? Myclass.a --> class variable Myclass.f() --> class method h = Myclass.Myclass() h.a --> instance variable h.f() --> instance method Also, if this differences were correct, how do they change behaviour of scope of variables and methods ?? -Shankar From ylee12 at uiuc.edu Mon Nov 26 16:30:19 2001 From: ylee12 at uiuc.edu (Young-Jin Lee) Date: Mon, 26 Nov 2001 15:30:19 -0600 Subject: [Q] weighted graph in python Message-ID: <0uyM7.333$Nz1.6079@vixen.cso.uiuc.edu> Hi, I am looking for some help in implementing a weighted graph in python. I want to collect all possible paths between two nodes. Is there any example of this? Any comment would be of great help. Thanks in advance. Young-Jin Lee From tanzer at swing.co.at Fri Nov 30 01:55:19 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 30 Nov 2001 07:55:19 +0100 Subject: Design tips requested for OOP forum system (using pickle) In-Reply-To: Your message of "29 Nov 2001 13:59:34 PST." Message-ID: cs1spw at bath.ac.uk (Simon Willison) wrote: > User - an object representing a single forum user account > Forum - an object representing a forum (e.g "General Chat" or "Site > Suggestions") > Thread - an object representing a thread > Post - an object representing an actual post (snip) > One thing I haven't quite figured out yet is how to relate posts to > the user object for the user that posted that post. Should I look at > storing some kind of user ID and then searching through my user > objects for an object with that ID stored within it every time I > display a post? That sounds horribly inefficient - performance is not > a major concern for this software as it's intended for personal small > scale use but I don't want to write something that's virtually > unusable due to performance problems... How about: - Post_by_User.post(u) --> returns list of all (post, user) links for user `u` - Post_by_User.user(p) --> returns list of all (post, user) links for post `p` - Post_by_User.link(p, u) --> return (post, user) link for `p` and `u` or None - Post_by_User.add(p, u) <-- adds a new link for `p` and `u` Of course, the links could also contain additional attributes relevant to a specific (post, user) combination. If you use dictionaries, performance shouldn't be an issue. -- 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 tim at vegeta.ath.cx Wed Nov 21 05:36:09 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 21 Nov 2001 10:36:09 GMT Subject: how to express the following regular expression? References: Message-ID: Stephen graced us by uttering: > I want to search the following formats: > > ([1234567890]*)R So... this will match all of the following: '1234R', '123R', '12R', '1R', 'R' Is this what your want? (ie, 0 or more digits followed by an 'R'?) Or did you mean '+' instead of '*'? > or > > P([1234567890]*) Again: 'P1234', 'P123', 'P12', 'P1', 'P' > this means there must be a 'P' before the number or a 'R' after the > number. However, I think I can't use this: > P?([1234567890]*)R? > because the number without P and R is also matched! Yes, this is also a bad choice, as this matches, well, nothing. Since the above regex doesn't require that *anything* is present in the string, it tests true for the following: '1234', 'P1234', '1234R', 'P1234R', 'PR', 'P', 'R', '', 'arbitrary string' > How can I express it? You need to know exactly what you want the regex to match before you can write a well-crafted regex. Assuming you want one of the two following: - the character 'P', followed by 1 or more digits ([0-9]) or - 1 or more digits ([0-9]) followed by the character 'R' ...you can use the following: #!/usr/local/bin/python import re my_regex = re.compile(r'(P\d+|\d+R)') > thx! > > Stephen HTH, Tim Hammerquist -- A diplomat is man who always remembers a woman's birthday but never her age. -- Robert Frost From steven.smith at level3.com Thu Nov 8 16:27:29 2001 From: steven.smith at level3.com (steve) Date: 8 Nov 2001 13:27:29 -0800 Subject: python path - pdflib Message-ID: I am trying to set a program to use a path in python. I see that I can set my environment variable PYTHONPATH or set the sys.path in python to the dir I want. I am having problems getting python to find the files I want in this path. I am using the pdflib to create a pdf file. I need things that are in the fonts directory. If I do a sym-link in the dir I am running my script from, everything works fine. When I don't try to open up a file from a different directory, the fonts are loading correctly. When I open a file, then set the font type, it can't find the font, unless it is in the directory the script is being run from, even though I do a print sys.path and the directory is the first path listed. Has anyone seen this problem or know a fix for it? I'm somewhat stumped. It seems to me that it is a python/sys problem, because why would the sys module be affected by another module? Maybe I'm wrong on this assumption. As a note, I was using python 2.0 as this is what pdflib wants to use, but I have tried with 2.1. From jeff at ccvcorp.com Tue Nov 6 20:02:18 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 06 Nov 2001 17:02:18 -0800 Subject: COM objects and Python References: <3BE3F6F5.1020605@libero.it> Message-ID: <3BE8881A.55B3AD45@ccvcorp.com> Riccardo Trocca wrote: > Hello, just a simple question. I've just started learning some COM and > Com under Python concepts. I'd like to know, before going on with Pure > Python, if it is possible to create a DirectShow Graph with Python or > not. I've made some attempts, but they were fruitless. Do I need to > spend more time studying the problem, or switch to writing some > extension to Python? > > Riccardo PythonCOM is (IIRC) currently only capable of using COM Automation objects--in other words, objects that implement the IDispatch interface. If DirectShow implements IDispatch, then you're set. If not... there *might* be some way around that, but it would be ugly and contorted. Jeff Shannon Technician/Programmer Credit International From huaiyu at gauss.almadan.ibm.com Wed Nov 7 15:39:20 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 7 Nov 2001 20:39:20 +0000 (UTC) Subject: Q: Feature Wish: "%" Extension References: Message-ID: On Tue, 6 Nov 2001 23:58:30 -0500, Tim Peters wrote: > >No threads on c.l.py end up being about Hitler. Not even this one! Indeed, >I expect this one to veer into transfinite cardinals before I finish this >sentence. > >python-needs-a-transfinite-cardinal-type-ly y'rs - tim Is there a way to bound the computational resources needed for such beasts? I would think a type of algebraic numbers would be much more useful than transfinite cardinals, but to do it properly perhaps requires a whole computational algebra package. On a related issue: How practical would the proposed rational type be for serious computation considering that the results of simple operations are likely to grow in size for both numerators and denominators? just-trying-to-keep-the-thread-alive-ly y'rs Huaiyu From john.thingstad at chello.no Sun Nov 25 20:02:45 2001 From: john.thingstad at chello.no (John Thingstad) Date: Mon, 26 Nov 2001 02:02:45 +0100 Subject: Does rotor follow a cross-language encryption algorithm ? Message-ID: <20011126011419.TXKG20719.mta01@mjolner> Lance Ellinghaus said: > PKI is great and much > stronger than the rotor module, but as you stated, it works when you > need "just enough" encryption. I strongly disagree with the above statement. To me false security is worse than no security. To demonstrate my point I wrote a expert system to crack rotor code earlier this year. True, the job is not a trivial endavor. But a experienced programmer should be able to do this in a month or two. If I chose to share the code over the net the every script ciddy could use it too. An average message takes about 10 minutes to decrypt. (The code is in python. I run Win98 on a Pention Mmx II 400 with 64 Mb of ram.) I used Booch crypto analysis spec as a starting point and elaborated. So what is just enough encryption. If you don't have anything to hide then why encryt it. My recomendation is to use the Blowfish algorithm for encrypting files. If you need to send data over the net use RSA or DSA. (DSA being the better choice.) PyCrypt should take care of this From fperez528 at yahoo.com Fri Nov 9 14:42:24 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 10 Nov 2001 19:10:24 +2328 Subject: Online tutorials References: Message-ID: <9skmo7$9ar$1@peabody.colorado.edu> Ryan Wendt wrote: > Does anyone know of any good tutorials? I have gone through all the > tutorials on the python.org site, so I know the basics, but I would like > to learn more than that. More tutorial-type: http://diveintopython.org/toc.html Just a language reference, but super-useful: http://www.brunningonline.net/simon/python/PQR2.1.html >From D. Beazley's (the guy who wrote Swig and the Python Essential Reference book, the most useful python book IMO) page at http://systems.cs.uchicago.edu/~beazley the following are good (the first two are also pdf's, go to his main page for the links): - tutorial: http://systems.cs.uchicago.edu/~beazley/tutorial/beazley_intro_python/Slides/SLIDE001.HTM - more advanced: http://systems.cs.uchicago.edu/~beazley/tutorial/beazley_advanced_python/Slides/SLIDE001.HTM - new stuff in 2.0, nice summary (no pdf that I can see): http://systems.cs.uchicago.edu/~beazley/tutorial/newfeatures/SLIDE001.HTM There's also always google (type python tutorial and you'll get a ton of links). f. From loewis at informatik.hu-berlin.de Mon Nov 19 07:07:45 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Nov 2001 13:07:45 +0100 Subject: ssl error References: <%yJJ7.1850$7b2.60534@news1.mts.net> Message-ID: Laura Creighton writes: > We've got a working version. You can have our code if you like. > You too Gerhard H?ring, if you like. Goodness gracious, a discussion > about this on python-devel. We're all too damn busy writing code > to be an advocate for our own code, and besides, somebody may have > done it better. Would it be possible to give our code to somebody > competant who can make sure that we either get to be the new > standard (unlikely but possible) or any good ideas we came up > with that nobody else has makes it into the new standard? As the saying goes: publish early, publish often. It's unlikely that anybody will step forward *right now* (except Gerd perhaps), so it would be better if you put what you have somewhere public, and link it from the Vaults. Regards, Martin From philh at comuno.freeserve.co.uk Thu Nov 29 23:01:31 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 30 Nov 2001 04:01:31 +0000 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> <20011129.151831.971899228.1845@hp.com> Message-ID: On Thu, 29 Nov 2001 15:18:32 -0700, Bill Anderson wrote: >In article , "Suchandra Thapa" > wrote in part: >... >>>Furthermore PHP kind of forces you to write web-apps in one way with >>>presentation and logic mixed. Also when your web-apps can do all the >>>standard fare that is the staple of PHP you will suddenly need some >>>feature that's not available in PHP. Then it is much easier to use the >>>Python standard library to roll your own solution. >> >> Actually, there are template based packages for php, and it isn't >> too difficult to create a new template handling class if you don't like >> the existing ones. To be fairly, a standard python cgi will also force >> you to mix presentation and logic since all your html will be in print >> or stdout.write statements inside your script. > >Not true. There are likewise a number of templating packages for Python that >allowing you to "keep 'em separated". And in any case it is trivial to write your own in python; the %(varName)s syntax is your friend. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From guuge at localhost.localhost Sun Nov 18 11:01:48 2001 From: guuge at localhost.localhost (guuge) Date: 18 Nov 2001 16:01:48 GMT Subject: something Evil happens when large hashes destroyed Message-ID: <9t8m1c019qd@enews1.newsguy.com> I was trying to sort about 100,000 items by splitting them into groups (using a python dictionary type) and then successively splitting these groups until they were small enough to use a brute force method. My test program, which used only two or three keys to create the first split, worked fine. When I tried the real thing, using 256 keys, the program slowed to a crawl. The python interpreter took forever to destroy the dictionaries. Here's a little program that will place X number of elements into Y number of bins and gives the time used to do the placement and the time used to destroy the dictionary. ----------------------------------------------------- #!/usr/bin/env python import os, sys, string, time class Element: def __init__ (self, val): self.val = val def usage (): print "%s " \ % os.path.basename(sys.argv[0]) sys.exit (1) def main (): if len(sys.argv) < 3: usage () numKeys = string.atoi (sys.argv[1]) numElements = string.atoi (sys.argv[2]) bigHash = {} createStartTime = time.time () for i in range(numElements): key = i % numKeys e = Element (i) if bigHash.has_key(key): bigHash[key].append (e) else: bigHash[key] = [e] print "created %d elements and placed into %d bins in %d seconds" % \ (numElements, numKeys, time.time() - createStartTime) destroyStartTime = time.time () return destroyStartTime if __name__ == "__main__": destroyStartTime = main () print "hash destroyed in %d seconds" % (time.time() - destroyStartTime) ----------------------------------------------------- Here is some timing data for 100,000 elements on a pentium 166 MMX with 140 MB of ram. Time is in seconds. First column is the number of keys to use. Second column is the time used to place the elements in the dictionary. The third column is the time used to destroy the dictionary. python 1.5.2: 1 34 1 2 36 2 3 37 2 4 38 3 5 37 2 6 38 122 <---- over 2 minutes to destroy a Dict !!! 7 38 189 8 36 126 9 37 110 python 2.0.1: 1 50 2 2 51 2 3 53 2 4 55 3 5 52 156 <---- :( 6 23 100 7 51 218 8 52 289 9 53 177 python 2.2b2: 1 34 2 2 36 2 3 35 2 4 36 319 <---- Ouch ! Five minutes!!! 5 37 209 6 36 147 7 36 117 8 36 91 9 34 62 From rxg218 at psu.edu Thu Nov 1 10:20:57 2001 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 01 Nov 2001 10:20:57 -0500 Subject: question regarding dictionaries Message-ID: <9rrp75$qai@r02n01.cac.psu.edu> Hi, I have a question regarding dictionaries. When I compare them as if (dict1 == dict2): print 'ok' Where dict1 and dict2 shoudl have the same key and corresponding key values. It seems to work. Is it meant to work, or am I just being lucky. And secondly why won't thjis work: for i,j in list1,list2: #do something with i and j TIA -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 152 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- A man is known by the company he organizes. -- Ambrose Bierce From jbell at iinet.net.au Mon Nov 12 19:22:39 2001 From: jbell at iinet.net.au (John Bell) Date: Tue, 13 Nov 2001 08:22:39 +0800 Subject: Indirect Class Instance Invocation Message-ID: <3BF067CF.520F8E5C@iinet.net.au> I feel that this should be do-able, but can't see how. If I have some class foo and string s='foo', can I invoke bar as an instance of foo given only the string s? (ie. bar=(something on s)() )A kind of setattr for classes rather than attributes. John From era_akost at yahoo.de Wed Nov 14 10:19:09 2001 From: era_akost at yahoo.de (Era Akost) Date: 14 Nov 2001 07:19:09 -0800 Subject: Pmw.ScrolledListbox Message-ID: <6749bb94.0111140719.15db2737@posting.google.com> When one selects an item of Pmw.ScrolledListbox, it gets underlined. How to disable the underlining? Tkinter.Listbox that is the component of this widget doesn't show this property. This question was also posted one year ago, but there were no answers. Thanks, Era From marcoxa at cs.nyu.edu Mon Nov 19 10:18:31 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 19 Nov 2001 10:18:31 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: <9t93vi$6gi$1@slb7.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > Marco Antoniotti: > >Within CL, it turns out that `identity' is useful in a number of > >cases, especially when dealing with sequence operators. E.g. the > >`sort' function is really defined as > > > > sort &key (key #'identity) > > > >So that you can write things like > > > > * (sort '(2 3 4 1) #'<) > > '(1 2 3 4) > > * (sort '((1 3) (3 0) (33 9) (19 5)) #'< :key #'second) > > ((3 0) (1 3) (19 5) (33 9)) > > > >All in all a good thing. > > I've been staring at this trying to figure out what it does, > and I think I got it. What threw me off, I think, was the > '*'. It's a prompt, and the indented one on the 3rd line is > a misindent -- it should be 7 characters to the left, and there > are actually two different one-line expressions evaluated here. I am sorry. Yes, the '*' is CMUCL default prompt and I assume that newsreader hell broke out. > > Then in the "sort &key (key #'identity)" > line the '&key' says that field is 1) optional and 2) a keyword > argument, and that if not given the identity function is used. > Finally, the "#'" syntax is used to get a reference to a special > symbol, and ':key' is how to specify a keyword argument. > > Am I right so far? Yes, almost. The #' is used as a way to get the actual function out of a symbol. I could have written the above as cl-prompt> (sort '(2 3 4 1) '<) '(1 2 3 4) cl-prompt> (sort '((1 3) (3 0) (33 9) (19 5)) '< :key 'second) ((3 0) (1 3) (19 5) (33 9)) But the compiler would have had either to do more work or to compile a dereferencing of the symbols `cl:<' and `cl:second'. &key is used to introduce keyword parameters. Most sequence operations in CL have a keyword parameter called :key. (Other nice argument list markers are &optional, and &rest). > Python only uses one function for this, which means the field > extraction and data comparison must be composed into one function, > > >>> a = [(1, 3), (3, 0), (33, 9), (19, 5)] > >>> a.sort(lambda x, y: cmp(x[1], y[1])) > >>> a > [(3, 0), (1, 3), (19, 5), (33, 9)] > >>> In CL you have it both ways. I could have written the above as cl-prompt> (sort '((1 3) (3 0) (33 9) (19 5)) (lambda (x y) (< (second x) (second y)))) ((3 0) (1 3) (19 5) (33 9)) It is just a nice comvenience. Where it comes handy is in things like the following Define a class with a slot that contains a vector (defclass just-a-test () ((v :accessor v-of :initarg :v))) Now suppose that you have a bunch of classes (defvar v1 (make-instance 'just-a-test :v (vector 1 2 3 4))) (defvar v2 (make-instance 'just-a-test :v (vector 2 -8 4 6))) ... (defvar vn (make-instance 'just-a-test :v (vector 1 9 -2 9))) (defvar vs (vector v1 v2 ... vn)) ; The ... are not part of CL. ... and that you want to sort them based on the i-th element of the vector in the slot. (loop for i from 0 below 4 collect (sort vs #'< :key (lambda (the-v) (aref (v-of the-v) i)))) This effectively returns a list of the different sorted vectors (assume all vectors have length 4). Of course you could have written the test and forgotten about the :key parameter (it would have defaulted to `identity' - which is where all of this started from). I feel that in this case it is clearer to write out the :key parameter. > The sort function is (was) also defined in terms of C-style > three-way sorting. It's been changed so that only '<' comparison > is needed, but I don't know how that change affects the comparison > function used. > > In CL it looks like you'll have to do the same sort of thing > for data values which don't have a 1D sorting, like > > >>> a = [(1, 3), (100, 5), (33, 9), (19, 5)] > >>> a.sort(lambda x, y: cmp(x[1], y[1]) or cmp(x[0], y[0])) > >>> a > [(1, 3), (19, 5), (100, 5), (33, 9)] > >>> Of course. (sort (lambda (x y) (or (cmp (first x) (first y)) (cmp (second x) (second y)))) '((1 3) (100 5) (33 9) (19 5)) Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From mal at lemburg.com Mon Nov 26 07:34:04 2001 From: mal at lemburg.com (M.-A. Lemburg) Date: Mon, 26 Nov 2001 13:34:04 +0100 Subject: ANN: eGenix.com mx COMMERCIAL Extension Package 2.0.4 Message-ID: <3C0236BC.DC4B692@lemburg.com> ________________________________________________________________________ ANNOUNCING: eGenix.com mx COMMERCIAL Extension Package for Python Version 2.0.4 Full Source Python extensions providing important and useful services for Python programmers. ________________________________________________________________________ WHAT IS IT ?: The eGenix.com mx COMMERCIAL Package for Python is part of the eGenix.com mx Extension Series for Python, a collection of professional quality software tools which enhance Python's usability in many important areas such as ODBC database connectivity, fast text processing, date/time processing and web site programming. This commercial package includes the popular mxODBC extension which allows users to connect from Python to just about any database on the market today, on Windows, Unix and Linux. By providing a consistent interface on all supported platforms, mxODBC serves as perfect base for writing cross-platform database programs and utilities. ________________________________________________________________________ WHAT'S NEW ? Compatibility to Unicode-aware ODBC drivers such as the latest MS Access and MS SQL Server ODBC drivers was enhanced in mxODBC. It is now possible to exchange native Unicode data with these Unicode-capable databases using mxODBC. As always we are providing precompiled versions of the package for Windows and Linux as well as sources which allow you to install the package on all other supported platforms. ________________________________________________________________________ SPECIAL OFFER theKompany.com has licensed the eGenix.com mx Commercial Package (which includes mxODBC) for inclusion in their brand new Qt-based Python IDE BlackAdder. It allows developing portable GUI-based database applications which run on Windows and Linux platforms without any change to the source code. BlackAdder includes a 1 CPU license for this package at no extra cost, so you may want to check out their great new product. See http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#BlackAdder for details. ________________________________________________________________________ EGENIX.COM MX COMMERCIAL PACKAGE OVERVIEW: mxODBC - Generic ODBC 2.0-3.5 interface for Python mxODBC is an extension package that provides a Python Database API compliant interface to ODBC capable database drivers and managers. In addition to the capabilities provided through the standard DB API it also gives access to a rich set of catalog methods which allow you to scan the database for tables, procedures, etc. Furthermore, it uses the mxDateTime package for date/time value interfacing eliminating most of the problems these types normally introduce (other in/output formats are available too). mxODBC allows you to interface to more than one database from one process, making inter-database interfacing very flexible and reliable. The source version includes a varity of preconfigured setups for many commonly used databases such as MySQL, Oracle, Informix, Solid, SAP DB, Sybase ASA and ASE, DBMaker and many more. The precompiled versions for Windows and Linux include the interfaces to the standard ODBC manager on these platforms to allow for a more easily configurable setup. More details are available at: http://www.lemburg.com/files/python/mxODBC.html ________________________________________________________________________ WHERE CAN I GET IT ? The download archives and instructions for installing the packages can be found at: http://www.lemburg.com/files/python/ Note that in order to use the eGenix.com mx COMMERCIAL package you will also need to install the eGenix.com mx BASE package which can be downloaded from the same location. ________________________________________________________________________ WHAT DOES IT COST ? mxODBC comes with a licenses which allows non-commercial use at no charge, but places a moderate fee on commercial users. Special licensing setups are available for commercial product developers. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#mxCOMMERCIAL for details. The package comes with full source code. ________________________________________________________________________ WHERE CAN I GET SUPPORT ? Commercial quality support for these packages is available from eGenix.com Software GmbH. Please see http://www.lemburg.com/files/python/eGenix-mx-Extensions.html#Support for details about the eGenix support offerings. ________________________________________________________________________ REFERENCE:

eGenix.com mx COMMERCIAL Package 2.0.4 - eGenix.com mx COMMERCIAL Interface 2.0.4 with distutils support and precompiled binaries for Windows and Linux. (26-Nov-2001) ________________________________________________________________________ Enjoy, -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Consulting & Company: http://www.egenix.com/ Python Software: http://www.lemburg.com/python/ From claird at starbase.neosoft.com Thu Nov 29 15:14:27 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 29 Nov 2001 14:14:27 -0600 Subject: pyplets References: <655abd4a.0111290417.4b28a0f2@posting.google.com> Message-ID: In article , Oleg Broytmann wrote: >On Thu, Nov 29, 2001 at 04:17:55AM -0800, e toffi wrote: >> i was thinking (which i dont do often), and came up with an idea >> (which i *do* do often -- dont ask me how). the idea is pyplets -- the >> analogue to java applets with a fittingly silly name. anyway the >> premise is to define an api that lets programmers write small programs >> that execute in a browser. >> >> whatdyathink? > > Do you suppose to alter ALL major browsers to support Python? (You can >alter Mozilla, but not Netscape, and certainly not M$IE). . . . Well, Netscape has a plugin architecture, and Internet Exploder also exposes a programmability interface (a new one every year!), but it takes a lot of motivation before *I*'ll involve myself with either. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From phr-n2001d at nightsong.com Wed Nov 14 19:15:59 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 14 Nov 2001 16:15:59 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <7x3d3gc2io.fsf@ruckus.brouhaha.com> James_Althoff at i2.com writes: > If not 3), then there is the issue of having to do an extra computation for > the common case of indexing a sequence as in, e.g., > > for i in 0 .. len(sequence)-1: > > OTOH, would it be transparent for "0 .. 5" to mean "0,1,2,3,4"? 0..5 = 0,1,2,3,4 would be awful. Better would be introduce a new function, say maxindex(sequence), equal to len(sequence)-1. Then you'd say for i in 0..maxindex(sequence): I guess using len instead of maxindex in this construction would become a common bug that pylint could check for. From husalwan at sci.kun.nl Sat Nov 10 11:24:34 2001 From: husalwan at sci.kun.nl (husam) Date: Sat, 10 Nov 2001 17:24:34 +0100 Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> Message-ID: <3BED54C2.1010608@sci.kun.nl> Terry Reedy wrote: > "husam" wrote in message > news:3BED344B.5050703 at sci.kun.nl... > >>hi, >>im trying to learn programming with python. one of the things >> > confusing > >>me is the difference between data structures and data bases. so, can >> > you > >>tell me what the difference is between them? >> > > Examples of data structures: set, list (stack, queue, deque are > specialized examples), dictionary, tree, heap, matrix. A particular > organization of data with associated methods of operation upon them. > An abstract data structure is defined by the interface of the > methods -- what you can do -- rather than by the bit-by-bit > organization of any particular implementation of that structure. > > Database: a collection of data on a particular topic using some data > structures. > Example: phone book, address book, a business database of suppliers > and customers, product and services, purchases and sales. > Relational database: a set of tables, each of which is a set/list of > records, each of which is a set/list or association of named fields. > > Hope this help a bit. > > Terry J. Reedy > > > > yes, i understand the general defenition of data bases and of data structures. i should in fact put the question like this: is a given dictionary or list of a set of data, a data base? From neil at cxchange.co.za Wed Nov 14 08:42:12 2001 From: neil at cxchange.co.za (Neil Fryer) Date: Wed, 14 Nov 2001 15:42:12 +0200 Subject: Shell commands from within a script Message-ID: Hi All I'm really new to python so if you could please let me know how to execute a command like say, ftp, from within a script it really would be appreciated. As I'm only about half way through my first Python tutorial. Thanks Kind Regards Neil Fryer neil at cxchange.co.za From jeffs at construx.com Wed Nov 7 12:07:43 2001 From: jeffs at construx.com (Jeff Schroeder) Date: Wed, 07 Nov 2001 17:07:43 GMT Subject: Returning a python value to the calling bat file Message-ID: I have a NT Shell bat file that calls a python script to do some processing, then want that python to return the value to the calling bat file. How do I do that? Thanks in advance, Jeff From hungjunglu at yahoo.com Tue Nov 6 17:28:26 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 6 Nov 2001 14:28:26 -0800 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> <9s9949$hm5$1@news.service.uci.edu> Message-ID: <8ef9bea6.0111061428.28c46fc0@posting.google.com> I believe I have said time and again about namespace and dictionary. The examples I have given ('from xyz import *' and the 'global') are just, examples. The root of the problem is not the 'from' statement nor the 'global' statement. Python mailing list has tons and tons of other examples of beginners running into namespace troubles. #--------------------- def flipflop(x): if x == []: x.append(1) else: x = [] a = [] flipflop(a) print a flipflop(a) print a #--------------------- output: [1] [1] In the above example, the 'global' statement plays no role. Nested scope is not the problem. Not understanding the namespace mechanism is the problem. The root of the non-trivialness is the namespace structure, not any particular Python statement or keyword. If you think you can explain to beginners the above example, more than a few dozen times, without getting exhausted, then I think you will be highly admired. :) Hung Jung From tim at vegeta.ath.cx Tue Nov 27 04:14:39 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Nov 2001 09:14:39 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3c029caa.260513688@news.laplaza.org> Message-ID: Tim Hammerquist wrote: > I've learned, however, never to dog on Emacs in this ng. Courageous graced us by uttering: > Emacs is inspired by Satan. I largely say this for having used > Lisp, where I became forever alienated by the concept of linking a > language which requires (or comes close to requiring) a specific > editor. *steps slowly away* =) I've found Lisp interesting. I'm not making drastic plans to switch my entire workload of projects over to it at the moment, but to say it's inspired by Satan is a bit overkill, IMO. =) Besides...everyone knows the only language endorsed by Mista Satan-san is VB. ;) Tim Hammerquist -- Let's say the docs present a simplified view of reality... :-) -- Larry Wall in <6940 at jpl-devvax.JPL.NASA.GOV> From kragen at canonical.org Mon Nov 26 16:11:33 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 16:11:33 -0500 Subject: Become References: <3c028dfc$0$26362$7a628cd7@news.club-internet.fr> Message-ID: <83oflps0e2.fsf@panacea.canonical.org> Skip Montanaro writes: > Jiba> Here is a module that reproduce the Smalltalk "become" capability. > Jiba> Become can replace (quite) all references to an object by a > Jiba> reference to another object. It relies on gc.get_referents(). > > Can you motivate this with an example that shows where it would be useful? E-style promises are one example; see http://www.erights.org/ for details. Autoloading of code or other objects from on-disk files are another. Lazy evaluation is a third: once an object has been fully evaluated, it would be nice to replace the lazy object with its non-lazy version. Just-in-time optimization of code is a fourth: once the optimized version of a callable routine is ready, you'd like to replace the unoptimized version with it, so that all the callers will run the optimized version. A fifth application is a saner set of semantics for reload(), which currently doesn't play well with 'from x import y'. With 'become', reload() could work better. In Python 1.5.2, 'become' for class instances is fairly straightforward: you set __class__ and __dict__ to the right values and you're done. But 'become' for built-in types is tough; you can't even write a Proxy object that supports all the protocol a number supports (there's no way to override three-argument pow(), for crying out loud! And various C functions complain when given an argument that acts like an int or a float instead of actually being one). I haven't looked at trying to write 'become' in Python 2.x. I suspect it will be more difficult already, even for class instances, and it will get more difficult over time. Jiba's approach is very interesting, although it's inherently somewhat inefficient, and I don't think it can work well without cooperation from CObject authors. (You need to be able to find out which slots in the CObject refer to PyObjects and which contain character data or integers; otherwise, you're liable to change things other than PyObject pointers.) From jae at jerhard.org Sat Nov 10 17:43:18 2001 From: jae at jerhard.org (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sat, 10 Nov 2001 23:43:18 +0100 Subject: Monty Python (was: Freeware Python editor) In-Reply-To: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> (message from Anthony Baxter on Fri, 02 Nov 2001 14:42:03 +1100) References: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> Message-ID: >>>>> "Anthony" == Anthony Baxter writes: >>>> Quinn Dunkan wrote >> I'd also like to see what they do to the opening credits in the >> Swedish translation. Anthony> obofftopic: I seem to recall [...] ^^^^^^^^^^ This is the best joke I saw today. (And it's *so* c.l.py :-) Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sf.net) MARS http://mars.jerhard.org Bill Gates brought you Windows. Linus brought you the whole DAMN HOUSE! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From mwh at python.net Thu Nov 22 05:45:52 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 22 Nov 2001 10:45:52 GMT Subject: bug in emacs python mode with long documents? References: <9thhib$3kp$1@peabody.colorado.edu> Message-ID: Fernando P?rez writes: > Has anyone else noticed the following problem? I have a long class (about > 1000 lines). When working on code towards the bottom, opening new lines, > indenting or deindenting takes forever. Xemacs will go crazy backtracking up > the code, and my cpu usage will go to 100% for up to 10 seconds, freezing > emacs completely (800 Mhz PIII). > > I know it's a long class and in fact I need to reorganize it, but that's > besides the point. I can't see an editor which is incapable of handling > classes longer than 1000 lines! And certainly not 'the beast' Xemacs :) > > For reference, I'm using: [version 21.4; April 2001] on a Mandrake box. > > If anyone knows of a bugfix to the python mode, I'd greatly appreciate > hearing about it. Are you sure you're using the latest version of python-mode? Get it from http://www.python.org/emacs/python-mode/ or CVS (it's Misc/python-mode.el). Other than that, you may be able to fiddle some font-lock parameters to stop XEmacs bothering to hilight the bits it can't cope with. No idea which ones though (and I use GNU emacs, so they might not be same for you anyway). Not much help, I know... 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 core.lists.python at core-sdi.com Mon Nov 19 13:05:36 2001 From: core.lists.python at core-sdi.com (core.lists.python at core-sdi.com) Date: Mon, 19 Nov 2001 15:05:36 -0300 (ART) Subject: (no subject) Message-ID: <20011119180536.44E5F5E3801@mail.servers.core-sdi.com> confirm 244847 From peter at engcorp.com Wed Nov 21 00:02:33 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 21 Nov 2001 00:02:33 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> <3BF3378B.8030205@altavista.com> Message-ID: <3BFB3569.C3044BD9@engcorp.com> (Accidentally sent, and I believe cancelled, partially written version... dang strange how Ctrl-Enter can be hit accidentally! :-( ) Michael Kelly wrote: > > I've been checking out Python and already there are many things > I like about it, but I'm starting to get paranoid about indentation > issues with code pasted out of other scripts. Seems when the > parser takes it into its head that "expecting indented block > at line #" when it sure as hell looks indented, it gets into a > thing where there's no way other than retyping lots of stuff > and praying to get it to parse the code. > > Is there a utility to "clean" foreign scripts so that tabs/spaces > issues and other stuff invisible to the programmer can be > weeded out? There's any detabbing utility on the planet, or the Python utility Tools/Scripts/pindent.py. If you stop using tabs it really won't be a problem. A good editor should be able to do this properly (when properly configured) without the slightest trouble. Maybe you have an editor which saves files with tabs representing only four spaces instead of the correct eight? > What do you guys use esp. when cutting and pasting > snippets from other files etc.?? Never had a problem, since we've turned off all tabs everywhere. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fredrik at pythonware.com Tue Nov 6 20:05:53 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 01:05:53 GMT Subject: RE Module Question. References: Message-ID: Adonis Vargas wrote: > i have tried looking into the RE module but it just is written > in hebrew oh. I could have sworn it was written in a mix of Python and C. no wonder I've had a hard time tracking down the +? bug. From joonas at olen.to Thu Nov 1 12:35:06 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 01 Nov 2001 19:35:06 +0200 Subject: references ??? References: <9rrv24$vk148$1@ID-11957.news.dfncis.de> Message-ID: <3BE187C9.64241DF2@olen.to> Emile van Sebille wrote: > > "Thomas Weidner" wrote in message > news:pan.2001.11.01.17.30.27.280.2271 at gmx.net... > > Hi, > > > > I think anybody here knows what references,like in java,c++ or perl, are. > > How can i use references in python ? > > > > 2.Question: > > l=[1,2,3,4,5,6] > > for i in l:i=0 > > print l > > > > l is still [1,2,3,4,5,6]. How to make changes made to i also apply to l ? > > for i in len(l): > l[i] = 0 Shouldn't that be for i in range(len(l)): l[i] = 0 From provvisorio100 at yahoo.com Mon Nov 12 06:23:36 2001 From: provvisorio100 at yahoo.com (provvisorio) Date: 12 Nov 2001 03:23:36 -0800 Subject: cygwin compilation... Message-ID: my cygwin compiler hangs up con win98 after compiling all objects (i modified THREAD.C n other STUFF...) . After make bash hangs with the message: PYTHONPATH= ./python.exe ./setup.py build I use a recent release of cygwin n i can compile quite well many sources.. What i could check fisrt???? thanks.. From loewis at informatik.hu-berlin.de Sun Nov 11 08:01:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Nov 2001 14:01:57 +0100 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> Message-ID: Amit Weisman writes: > But with a string that contains "< bla bla bla>" or " " > I get an error message -> Please, PLEASE, report the actual content of the document you are trying to parse (exact URL, if possible), instead of making an example up. sgmllib has no problems with parsing "< bla bla bla>", since this is treated as opening the "bla" element, with two bla attributes with no value. I don't believe you when you say that you get an error in this case. It *does* have a problem with " ", since it does not allow a space character between the exclamation mark and the first character of the directive. I believe you must not have a space in there, in SGML, either, so this is not a problem with Python, but an error in the document. If you still want to process this very document, it is likely that you have to redefine parse_declaration. I recommend to study the source of sgmllib.py to find out how to do this, since parsing non-SGML documents with sgmllib is not supported. Regards, Martin From ursus_horibilis at hotmail.com Tue Nov 27 13:41:24 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Tue, 27 Nov 2001 13:41:24 -0500 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: "Michael Hudson" wrote in message news:u8zcst6uj.fsf at python.net... > "Ursus Horibilis" writes: > > > Okay. My next project was to do the same thing with 64-bit > > numbers. > > This makes a difference how, exactly? It doesn't make a difference; that was the point! > > > So how do I disable trapping for integer overflow? > > You can't, in the way you want anyway. > > You could always write a class that uses longs and chops off all but > the first n bits of the result. This wouldn't do performance any > favours, I uspect. It sounds like such algorithms must be written in C or some other language and then integrated into the Python program. > > Not that in 2.1: > > >>> 2*sys.maxint > Traceback (most recent call last): > File "", line 1, in ? > OverflowError: integer multiplication > > but in 2.2: > > >>> 2*sys.maxint > 4294967294L > At the moment, I'm working with 2.0. Is it legal to assign a (long) to an (int) if the long contains a number that is bigger than the (int) can store? From brucehapman at hotmail.com Fri Nov 9 22:13:13 2001 From: brucehapman at hotmail.com (brucehapman at hotmail.com) Date: 9 Nov 2001 19:13:13 -0800 Subject: Strange __str__ behavior References: Message-ID: "Tim Peters" wrote in message news:... > > I am defining a class w/ method __str__. If I put a print statement > > inside __str__, and if I then use the print statement to display an > > instance of the class, I get an extra space in the output. > > Please see: > > 05470> Thanks Tim! b. From zope at thewebsons.com Wed Nov 21 16:36:08 2001 From: zope at thewebsons.com (Ben Ocean) Date: Wed, 21 Nov 2001 13:36:08 -0800 Subject: Problems with Installation Message-ID: <5.1.0.14.0.20011121133556.00a01ac0@thewebsons.com> Hi; I just configured Tcl--itworks--and I went to configure tk (both latest stable distros) on my RH71 box and ran into all sorts of errors on *make*. Both installations are in /usr/lib and I'm in as root. It exits with Error 1. Here's how the errors start: [root at hermes unix]# make gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED /usr/lib/tk8.4a3/unix/../generic/tk3d.c In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or directory In file included from /usr/lib/tk8.4a3/unix/../generic/tkPort.h:32, from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:27, from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: /usr/lib/tk8.4a3/unix/../generic/../unix/tkUnixPort.h:77: X11/Xlib.h: No such file or directory etc. etc. etc. etc. etc. etc. etc. etc. etc. Any ideas? TIA, BenO From wtanksle at dolphin.openprojects.net Wed Nov 14 16:34:34 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 14 Nov 2001 21:34:34 GMT Subject: PEP 276 Simple Iterator for ints References: Message-ID: On Tue, 13 Nov 2001 17:00:29 -0800, James_Althoff at i2.com wrote: >William Tanksley wrote: >>On Tue, 13 Nov 2001 13:31:21 -0800, James_Althoff at i2.com wrote: >>I'm not sure I like this aspect anyhow. "5" just doesn't seem similar to >>"0,1,2,3,4". A single integer isn't a range. >>> - Possible ambiguity >>> for i in 10: print i >>> might be mistaken for >>> for i in (10,): print i >>> Response: The predicted ambiguity was not readily apparent to >>> several of the posters. >>You'll have to do better than that. This is the same problem as issue 1 >>(immediately above). An important point. "for i in 10,:" is an enormously different thing under this proposal that "for i in 10:" >>> - It would be better to reuse the slicing literal syntax attached >>> to the int class, e.g., int[0:10] >>No. I said that would be better to implement __getslice__ as a >>sequence-returning class method of the int class, e.g. int[0:10]. I'm not >>interested in proposing syntax changes. >Got it. But can __getslice__ be changed from an instance method to a class >method for types.IntType and still work without special casing? I don't >know about this. Chris posted a quick and dirty hack which works, or appears to work. At any rate, it demonstrates the concept. >In any case, presumably the returned sequence would be auto-converted to a >lightweight iterator in the for-loop (as lists are). Seems that PEP 276 >has the advantage of directly creating an iterator without the need of >first creating a sequence object. My intention was to have this __getslice__ return a generator, not a tuple. It's clear that I'm proposing occasionally infinite slices, so generating a sequence would be phenominally foolish :-). I would also like to have the returned object implement __getitem__, since it's relatively easy, but that's a different topic. >>I claim that it's better because your method because your method doesn't >>_look_ like a range and doesn't act like other Python usages. In essence, >>it makes Python integers behave differently in scalar context versus array >>context -- and we can't have people comparing us to that OTHER P*** >>language <0.4 wink>. Python already has one expression which behaves differently in a loop context: "in". >However, I'm still unclear on the notion of __getslice__ being sometimes >an instance method and sometimes a class method. The code generated from >the slicing syntax would have to try to call it both ways or something, I >guess? I don't see why -- you just call the __getslice__ method of the object you're thrown at. Aren't builtin types also objects? >Agree with you that a PEP would be good. ;-) Here's a place I wish people would stop agreeing with me. :-) >Jim -- -William "Billy" Tanksley From frederic.giacometti at arakne.com Wed Nov 14 21:39:56 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Thu, 15 Nov 2001 02:39:56 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> <6SvI7.12665$Sx.4243655@news1.elcjn1.sdca.home.com> Message-ID: <0WFI7.13158$Sx.4373234@news1.elcjn1.sdca.home.com> "Michael Hudson" wrote in message news:uzo5pl5g4.fsf at python.net... > "Frederic Giacometti" writes: > > > "Michael Hudson" wrote in message > > news:u8zdaodu4.fsf at python.net... > > > "Frederic Giacometti" writes: > [...] > > > So when Python code executes > > > > > > sock.recv(data) > > > > > > the interpreter would take a thread form the pool, and in effect say > > > "here, run this function". Then the interpreter thread would go off > > > and execute pending Python threads, and when the sock.recv call > > > returned, it would add the thread that called it back to the set of > > > pending interpreter threads? (I think this would be easier to discuss > > > with paper and pencil...) > > > > > > What does this buy us again? It still makes writing C code that calls > > > Python code a bit of a pain, doesn't it? Oh, maybe not. More > > > thinking required... > > > > A possible implementation would consist in using the method flag to mark C > > python methods/functions to run outside the interpreter thread. This way, > > the entire function runs in a separate thread. > > method flag? The 3rd field of the PyMethodDef structure (the one on which METH_VARARGS is used...) FG From logiplexsoftware at earthlink.net Fri Nov 9 13:36:23 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 10:36:23 -0800 Subject: Special celebration event for Orlijn? In-Reply-To: <15339.52401.804587.544175@beluga.mojam.com> References: <3BEBA01A.2C5B468D@student.gu.edu.au> <15339.52401.804587.544175@beluga.mojam.com> Message-ID: <01110910362300.02170@logiplex1.logiplex.net> On Friday 09 November 2001 04:31, Skip Montanaro wrote: > Hmmm... Perl van Rossum. Has a kind of nice ring to it, don't you think? Yes, but he might be subjected to teasing at school, Perl being a rather girlish name. Python sounds much tougher =) -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From ws-news at gmx.at Mon Nov 19 05:15:49 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 19 Nov 2001 11:15:49 +0100 Subject: Question on default value of __init__ References: <3BF8D3BC.105F0536@pacific.net.hk> Message-ID: <3bf8dc9a$1@brateggebdc5.br-automation.co.at> Hi, yes, this is the default behaviour of Python. The default value you provide is stored and passed to every invokation of the function/method. This means, the _same_ instance of foo will be passed for every call to bar.__init__() To get what you probably want, use None as the default and handle that special case by creating a new instance explicitely. This also prevents an instance of foo being created, before you create bar. hth Werner "Bernie" wrote in message news:3BF8D3BC.105F0536 at pacific.net.hk... > Hello all, > > When I run test.py, an instance of foo is created. Is this the default behavior > in Python for default value? i.e. The value must be exist as an object. Are > there any way to delay the creation of foo() until bar() is created. > > Bernie > > test.py: > > class foo: > def __init__( self, param=None): > print 'executed!' > self.__param = param > > def __nonzero( self): > if self.__param: > return 1 > else: > return 0 > > class bar: > def __init__( self, param=foo()): > assert isinstance( param, foo), '"in" must be an instance of foo' > pass From roger.millington at barclaycard.co.uk Thu Nov 29 09:05:33 2001 From: roger.millington at barclaycard.co.uk (roger.millington at barclaycard.co.uk) Date: 29 Nov 2001 14:05:33 GMT Subject: a question of using regular expression References: Message-ID: <9u5fbd$o2h$1@news.netmar.com> Stephen, If I understand you right then what follows should do what you want but I would not use jakarta-regex-1.2 because it has serious flaws. IBM Regex4j is my favourite, Jakarta ORO is very good and gnu-regexp is very easy to use but significantly slower than Regex4j, ORO and jakarta-regex. Roger import org.apache.regexp.*; public class Test291101 { public Test291101() { try { m_re = new RE("^good[ ]+(.*)"); } catch (RESyntaxException e) { // Cannot happen for the above RE but the compiler needs something! System.err.println("Problem creating RE, exception = " + e); } } public String extract(String subject) { // Extract the term contained in '(.*)' // or null if we didn't get a match return m_re.match(subject)?m_re.getParen(1):null; } public static void main(String args[]) { Test291101 tester = new Test291101(); // This should match and return a String. String s1 = tester.extract("good morning!"); System.out.println("[" + s1 + "]"); // Thus should match and return 'null' String s2 = tester.extract("morning! you are very good!"); System.out.println("[" + s2 + "]"); } private RE m_re; } ----- 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 mwh at python.net Tue Nov 20 08:54:50 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 20 Nov 2001 13:54:50 GMT Subject: Try block problem References: <9tcnls$42k$1@news1.ucsd.edu> <3bf9eacb$0$79564$6e49188b@news.goldengate.net> <9td60p$g15$1@news1.ucsd.edu> Message-ID: Jeff Davis writes: > I am not sure you understood my question. I wanted to know why the > "finally" could not be used with "try", i.e. why did the developers > of python choose to make the language that way. Because explicit is better than implicit (or guessing). Here, read this thread: http://groups.google.com/groups?hl=en&threadm=LNBBLJKPBEHFEDALKOLCMEONGIAA.tim_one%40email.msn.com&rnum=1 and I hope this link to google groups works better than the last one I tried to post... Cheers, M. -- GAG: I think this is perfectly normal behaviour for a Vogon. ... VOGON: That is exactly what you always say. GAG: Well, I think that is probably perfectly normal behaviour for a psychiatrist. -- The Hitch-Hikers Guide to the Galaxy, Episode 9 From chrishbarker at home.net Fri Nov 30 15:12:35 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 30 Nov 2001 12:12:35 -0800 Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: Message-ID: <3C07E833.76A3D0A0@home.net> This all looks like an argument for NaN, Inf, -Inf to me. What happened to talk of IEEE compliance? -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From wpmelcher at snet.net Mon Nov 26 20:41:02 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Tue, 27 Nov 2001 01:41:02 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> <83u1vhs2j2.fsf@panacea.canonical.org> Message-ID: "Kragen Sitaker" wrote in message news:83u1vhs2j2.fsf at panacea.canonical.org... > "Bill Melcher" writes: > > > "Kragen Sitaker" wrote in message > > news:83r8qmtgu9.fsf at panacea.canonical.org... > > > "Bill Melcher" writes: > That stuff gets written to stderr for no particularly good reason, so > redirecting stdout won't help. I don't think MS-DOS gives you a way > to redirect stderr. I had got around to thinking that way. > > (You know there's a 'Copy' on the DOS console window's menu, right? > Under Edit?) No I did not know that. Actually there is no menu of the usual windows type (the one that has File Edit View etc.) However, right click on the title bar and along with the usual stuff, there is an Edit entry that allows one to mark the area to copy then allows copy to the clipboard. Capture that to an editor, hit enter to break out of pause, pause again and capture the next batch -- beats manually typing into the editor even if a little clean up is required. > > > > Well, running it in a console window will save the last > > > scroll-buffer-full. You can set your scrollback buffer size (on > > > better versions of Windows) with some Properties dialog --- I can't > > > remember where. > > > > I'll see if I can track this down. > > I think you might have to create a shortcut and set the shortcut > properties, but I'm not sure Win98 supports it at all. I can't see anything about scroll-buffer in the shortcut's properties. Maybe it is in some other stupid place like system.ini or win.ini. > In Pythonwin or Idle, you might have a scrollbar on your evaluation > window. (I don't know what ppm is, and I don't use Pythonwin or > Idle.) In that case, maybe you could just run the execfile line. I should have said PYPPM. It is called the 'ActivePython PPM interactive shell'. I think that it is the DOS equivalent (more or less) of Pythonwin. > > > The whole situation is made more confusing because I have very > > little Unix understanding while you guys tend to be weak on Win98. > > Yes, and with good reason. :) You Unix bigots are all the same. :-) > > PySol, obviously. I just type 'sudo apt-get install pysol', and I > have... a pysol command that tells me 'bad .pyc magic number'. So I > delete /usr/share/pysol/pysol.pyc, which is the file strace pysol > tells me python is accessing right before it dies, and... 'can't open > /usr/share/pysol/pysol.pyc'. Well, sure. And there's no apparent way > to create it. > > So I sudo apt-get remove pysol, apt-get source pysol, discover apt-get > source is missing 'dpkg-source', figure out that dpkg-source is in the > 'dpkg-dev' package, sudo apt-get install dpkg-dev, then apt-get source > pysol again. Hey man, translate that to Pig Latin and it just might begin to make sense! :-) > > Now Python still complains about a bad magic number in pysol.pyc, but > I also have a src directory, and when I cd src and python pysol.py, > everything works. The belly ache I get from PySol is 'GameInfoException: duplicate game ID xxx', lots of them! Then, of course, a windows message complaining about the lack of cardsets which makes sense since I have no cardsets hanging off the stuff I am compiling and since I don't know how to just compile (as opposed to the compile&run gig), the PySol that runs can't find all the other needfulls to actually run. Basicly no stuff about bad magic numbers that I have seen. > > (Turns out pysol ships with a .pyc file built for Python 1.5.2, and I > have Python 2.1.1 installed.) PySol 4.72 (pysol-4.72.tar.bz2) ships with pysol_15.pyc and pysol_20.pyc and pysol_21.pyc - so pick your poison. Which brings up my latest problem: I managed to re-compile all the bits and pieces (except I see no pysol.pyc) but the pysol_xx.pyc modules are some kind of concatenation of all those bits and pieces and I don't know how to build that sucker. In my situation I could build only pysol_21.pyc since I have only python21 installed, but that's OK, I don't need the others in any event. (I think). I have seen Py2exe but I don't think that's what I'm after. Any ideas? -- Cheers, Bill TANSTAAFL! From chrishbarker at home.net Thu Nov 29 13:29:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 10:29:18 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> <9u21ch$bonls$1@fido.engr.sgi.com> <3C0562F4.7EE7D682@home.net> <3C059F84.6333@zeusedit.com> Message-ID: <3C067E7E.BA841EF2@home.net> Jussi Jumppanen wrote: > Chris Barker wrote: > > Frankly, I wouldn't even care which, > > although tabs may be a better choice because while "any decent editor" > > can be taught to insert N spaces when a tab key is pressed, apparently > > not all editors are "decent". I have found that using tabs for indenting > > is the only viable option for me on the Mac, and I have to change to all > > spaces when I move code to *nix/Windows, because the editors/IDEs I use > > there assume spaces. A real pain. > > You are just using the wrong Windows editors/IDEs :) Actually, I hardly ever use Windows, so I have yet to find the bet editor for me, or figure out how to configure it. When I was doing a lot of Mac/Linux work, I set up Xemacs to use only tabs. Unfortunately all spaces is now the "official" standard, so using all tabs as my personal standard ended up being a pain. The real problem here is with the Mac. Anyway, that's why I advocate only one option being available. Let's face it, indentation is part of Python syntax. Allowing spaces and tabs (which really are different things, as Huaiyu so elequently pointed out) be mixed is like a language allowing either {} or [] or a mixture of the two to be used to delimit blocks. If you used a font that displayed them the same way, you wouldn't have problem with that, but who would think that was a good idea? -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From zeitlin at seth.lpthe.jussieu.fr Tue Nov 13 09:37:12 2001 From: zeitlin at seth.lpthe.jussieu.fr (Vadim Zeitlin) Date: Tue, 13 Nov 2001 14:37:12 +0000 (UTC) Subject: [Q] wxPython from newbie References: Message-ID: On Mon, 12 Nov 2001 22:41:59 -0600, Young-Jin Lee wrote: > My problem is that I couldn't know the exact return type of CreateToolBar() > method because it is a virtual function. It returns a wxToolBar object. > Then I got another problem in the following code. > toolBar.AddSimpleTool( 10, images.getNewBitmap(), "New", "Long help for > 'New'" ) > I looked up the online help, but I couldn't find any method named > AddSimpleTool in wxToolBar and I found nothing when I tried to search > "AddSimpleTool" in the online help. This is a wxPython-specific method, it doesn't exist in wxWindows itself. But it seems quite clear to me what it does: it adds a new tool (i.e. button) to the toolbar at the position 10 (which is ignored more often than not anyhow as toolbar usually positions its buttons itself) with the given bitmap, tooltip and status bar help string. > getNewBitmap() method of images.py calls getNewData() method. I guess this > method tried to read a image file for tool bar icon. Yes, it reads a [compressed] image embedded into the program itself. > But I don't understand > why we should use this kind of method. I expected there is a method whose > input parameter is a image file name and it would return the pointer (or > reference or whatever) of it. There is such method in wxBitmap. But here the image is embedded right into the program code and there is no separate file containing it. > Is this the only way to use an image for a tool bar icon? No, not at all. You can create the bitmap in any way you like (loading it from file, creating it dynamically, whatever). 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 sholden at holdenweb.com Fri Nov 2 08:03:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 08:03:00 -0500 Subject: List transpose method References: Message-ID: "Tom Harris" wrote in message news:mailman.1004650983.10335.python-list at python.org... > Hi, > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > only come up with an ugly multiliner. > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81190 works with lists, as the subject line requested. Turning them into tuples is left as an exercise for the reader ... regards Steve -- http://www.holdenweb.com/ From uwe at rocksport.de Fri Nov 9 03:29:16 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 9 Nov 2001 08:29:16 GMT Subject: variable function call References: Message-ID: <9sg44s$9b3cv$1@hades.rz.uni-sb.de> Hi, thanks a lot for your answers. I knew there is a method to solve my probelm, but forgot how to do it. Greetings, Uwe. -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From jeff at ccvcorp.com Fri Nov 23 13:31:10 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 23 Nov 2001 10:31:10 -0800 Subject: Passing object as param to Python COM server References: <3d799735.0111220833.57b005e0@posting.google.com> Message-ID: <3BFE95EE.5D9BFBE7@ccvcorp.com> Graham Fawcett wrote: > Following up to my own message, in case anyone else needs the answer > (or, more likely, I forget it and end up back at Google...) > > You need to wrap the argument using win32com.client.Dispatch: > > def QueryApp(self, app): > #Name should be a valid attribute of a PowerPoint.Application > app = win32com.client.Dispatch(app) > print app.Name # or whatever else you want to do. > I don't recall specifics, but you may want to look into the wrap() and unwrap() functions as well--I believe these add (and remove) the python wrapper-classes around existing COM objects. I *think* that Dispatch() does a bit more than what you want, here.... but I'm not really sure. :) Jeff Shannon Technician/Programmer Credit International From phd at phd.pp.ru Tue Nov 20 06:33:03 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 20 Nov 2001 14:33:03 +0300 Subject: Steering novices in the right direction In-Reply-To: <15354.15702.45793.736531@beluga.mojam.com>; from skip@pobox.com on Tue, Nov 20, 2001 at 05:24:06AM -0600 References: <3BF9D800.E4A88559@engcorp.com> <15354.15702.45793.736531@beluga.mojam.com> Message-ID: <20011120143303.E1343@phd.pp.ru> On Tue, Nov 20, 2001 at 05:24:06AM -0600, Skip Montanaro wrote: > I've lately been thinking since the correct response to many "where can I > find ...?" questions is, "have you tried google?" or at least "have you > searched yet?" that perhaps the footer added to the end of all > python-list at python.org mailings should include a line like > > Ask here first: http://www.python.org/search/ > > or > > Before asking where something is, check Google: http://www.google.com/ > > Even better would be if Mailman could pick a random line out of a file to > use as the footer. That way you could have all sorts of interesting > subliminal messages. > > Any thoughts on the general idea of embellishing the footer? > > -- > Skip Montanaro (skip at pobox.com - http://www.mojam.com/) Good idea. Something like this: -- Python mailing list (Un)Subscribe: http://mail.python.org/mailman/listinfo/python-list Other mailing list on python.org: http://www.python.org/psa/MailingLists.html Search: http://www.python.org/search/ Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From clpy at snakefarm.org Thu Nov 8 08:39:27 2001 From: clpy at snakefarm.org (Carsten Gaebler) Date: Thu, 08 Nov 2001 14:39:27 +0100 Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> Message-ID: <3BEA8B0F.E594BE84@snakefarm.org> Michael Hudson wrote: > > Carsten Gaebler writes: > > > >>> complex('1', '1') > > (1+0j) > According to the docs, this is in error: > > ,--http://python.sourceforge.net/devel-docs/lib/built-in-funcs.html--- > I read that to mean that if the first arg is a string, it should be > the only arg. The code simply ignores imag if real is a string. Do > you want to open a bug, or shall I? Well, where exactly is the bug? Should the docs read 'If _real_ is a string, _imag_ is ignored and defaults to zero', or should the implementation raise an exception because it violates the docs? I'd prefer the latter. cg. --- 'In iteger arithetric divsion is no the oposite of multiplication.' From nospam at bigfoot.com Tue Nov 27 06:51:17 2001 From: nospam at bigfoot.com (Gillou) Date: Tue, 27 Nov 2001 12:51:17 +0100 Subject: vCard parser anywhere ? References: <9trh93$o1e$1@norfair.nerim.net> Message-ID: <9tvub6$1ude$1@norfair.nerim.net> Many thanks... Got it and most of the job I need is done here. I just need to "unZope" the code. --Gillou "Alastair Burt" a ?crit dans le message news: vg667wy0di.fsf at mastiff.dfki.uni-sb.de... > "Gillou" writes: > > > I'm looking for a vCard parser that changes a vCard stream into a Python > > object. > > WorldPilot has code for handling the vCard format: > > http://sourceforge.net/projects/worldpilot/ > > --- Alastair From gb at cs.unc.edu Wed Nov 7 16:14:25 2001 From: gb at cs.unc.edu (gb at cs.unc.edu) Date: 07 Nov 2001 16:14:25 -0500 Subject: Fatal Python error: ceval: tstate mix-up Message-ID: I just started (sporadically) getting the above message followed by "The instruction at "0x77a7b0fc" referenced memory at "0x0000000c", the memory could not be "read" in my python/wxpython-based imap email client. I recently added a thread to handle posting messages to the smtp server in the background. I'm careful not to touch the GUI from the sending thread. This is with python 2.1 on Windows 2000 with wxpython 2.3. Any clues on how to track this down? The "Fatal Python error" part makes it sound like an internal bug... Thanks gb From luecking at uark.edu Mon Nov 5 13:08:04 2001 From: luecking at uark.edu (Dan Luecking) Date: 5 Nov 2001 10:08:04 -0800 Subject: Problem formatting Python docs with MikTeX References: Message-ID: <66e0420f.0111051008.11b30844@posting.google.com> Michael Abbott wrote in message news:... > (C:\texmf\tex\latex\nassflow\manual.cls > Document Class: manual 1997/02/05 v2.0 CAWCS manuals > Unfortunately, the import of manual.cls shows that I have a serious > problem: the TEXINPUTS path is evidently being searched (by MixTex) in the > wrong order. MiKTeX doesn't officially have a TEXINPUTS path. If it uses it at all (and I have never tried it) it probably puts it after the default (search localtexmf and then texmf). It would seem you have two choices: 1. Edit texmf\miktex\config\miktex.ini, looking for "Input Dirs" under the [LaTeX] section. Prepend you TEXINPUTS path to the one there. 2. Use a command line option. Quoting from the MiKTeX 2.1 manual: The command-line option --include-directory=folder allows you to extend the input search path for one invocation of TeX. For example, C:\> tex --include-directory="C:\My TeX" foo.tex prepends C:\My TeX to the input search path, i.e. C:\My TeX will be searched first, when TeX opens any input file (including foo.tex). You can specify either absolute paths (as in the example above) or relative paths. I can't immediately check if this option was available before version 2.1. Dan Luecking From r.b.rigilink at chello.nl Sun Nov 4 05:47:44 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Sun, 04 Nov 2001 10:47:44 GMT Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> Message-ID: <3BE51CD5.6B8CFC72@chello.nl> Hi Fred, I'm pretty sure this is a problem with the garbage collector, I did some measurements showing bad (O(n**2)) performance when collecting large numbers of objects at once (as happens when your dicts are deleted at the end of your program). I filed a bug report (#477963) on it. See: http://sourceforge.net/tracker/index.php?func=detail&aid=477963&group_id=5470&atid=105470 for more details Roeland Fred wrote: > > I'm dealing with about 100Gb of data that I first just need to > characterize. So, since the slowest part will be simply reading the > data, I'm testing various languages and methods on a 10 line subset, a > 32 Mb subset and a 750 Mb subset. > > The following python program prints out the results in about 30 seconds, > however it doesn't finish for another minute with the 32 Mb set of > data! At first I thought it was stuck and killed it; however I finally > let it run on the smaller data set and all was well. > > Is this a garbage collection issue? Is there a better way to count the > individual values than dictionaries? I put the sys.exit call in while > trying to figure out what was happening but it didn't make a difference. > [snip code] -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From paustin at eos.ubc.ca Fri Nov 9 12:23:24 2001 From: paustin at eos.ubc.ca (Phil Austin) Date: 09 Nov 2001 09:23:24 -0800 Subject: Two way communication between a python class and a C++ class References: <0r0mut8npqtk8cfp1nato7fmslfkqcv0ki@4ax.com> <9sf3cd$13oo$1@nntp6.u.washington.edu> Message-ID: Donn Cave writes: > You may also find something interesting at http://www.boost.org/. > Yes, it's quite easy with boost -- scan the documentation for "callback". Phil From joeoptics at hotmail.com Thu Nov 15 16:41:04 2001 From: joeoptics at hotmail.com (David Lees) Date: Thu, 15 Nov 2001 16:41:04 -0500 Subject: Unable to make regular expression match on multiline files Message-ID: <3BF43670.E2B6958A@hotmail.com> I am trying to use a simple regular expression to extract some digits which are tagged with ascii text. Everything works fine on a single line, but when I use text that has the '\n' character it fails. Here is a sample. Thanks in advance. david lees >>> p=re.compile('.*Number States: (\d+)',re.MULTILINE) >>> a=' End: -1STATS:\nNumber States: 6\njunk' >>> m=p.match(a) >>> m.groups() Traceback (most recent call last): File "", line 1, in ? AttributeError: 'None' object has no attribute 'groups' -- debl From gh_pythonlist at gmx.de Mon Nov 5 12:35:07 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Mon, 5 Nov 2001 18:35:07 +0100 Subject: find network drives, win In-Reply-To: <3be6c267.21367859@news.easynews.net> References: <3be6c267.21367859@news.easynews.net> Message-ID: <20011105183507.A1888@lilith.hqd-internal> On Mon, Nov 05, 2001 at 04:51:10PM +0000, Marcus Stojek wrote: > Hi, > > under windows I have to find out for a given path whether the drive is local > or a network drive (is "mounted" the right word for this?) > I tried: > ----------------------------------------------- > import string > import os.path > [...] I think you cannot find that out with the standard Python libraries. I propose you get the ActivePython distribution from ActiveState or install their Windows-Extensions, named win32all on top of your existing Python installation. Then, check out the win32file module, and especially the GetDriveType() function there. Btw. the Windows extensions are *very* useful on Windows. They give you access to a large part of the Windows API and you can use them to access most ActiveX controls and do COM-automation of applications, such as MS Excel. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From wpmelcher at snet.net Mon Nov 26 19:21:51 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Tue, 27 Nov 2001 00:21:51 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> Message-ID: "Neil Hodgson" wrote in message news:tTyM7.376657$bY5.1619445 at news-server.bigpond.net.au... > Bill Melcher: > > Standard error can be captured on Windows 2000 with 2>: > python --help 2> p.txt > and should be passable through more with 2|: > python --help 2| more > although the output is too short to see it happen. > > This worked on some earlier versions of Windows but unsure which or how > well. Doesn't work for me. The --help option causes an error (-h works fine) but the usage stuff comes out OK but will not redirect or pipe. Apparently Python console output is directed to stderr which will not redirect - I'm talking version 2.1.1. The Traceback errors also are sent to stderr. There are, however, some error messages I get that look as though they come from PySol that are sent to stdout, these do redirect and pipe OK. > One of the more recent features of my SciTE editor > (http://www.scintilla.org/SciTE.html) is to allow typing command lines into > the output pane making it easy to retrieve the combined text from the output > and error streams. It can't handle running interactive scripts, though. Yet. I'm waiting! :-) -- In the mean time I have downloaded the three windows packages and will play a bit with them. -- Cheers, Bill TANSTAAFL! From taw_usenet at yahoo.com Wed Nov 7 13:24:47 2001 From: taw_usenet at yahoo.com (ToddW) Date: 7 Nov 2001 10:24:47 -0800 Subject: A-Life or E-life References: <3BE8E3C3.E8A0ACBE@easystreet.com> Message-ID: <84a8bdbe.0111071024.250b7847@posting.google.com> Bill Spears wrote in message news:<3BE8E3C3.E8A0ACBE at easystreet.com>... > Is anybody using Python to do a-life or virtual economics, like > sugarscape? Hmm... I wrote an interesting flocking/herding/swarming simulator quite some time ago. The code is a bit of a mess (my first python program), but it shows a bit of what python can do (GUI, threading, etc.). I posted it to the web... figured others would find it interesting. In a nutshell. Python makes a great general purpose programming language if speed is not everything. http://www.dma.org/~tw/pyboids/ From ws-news at gmx.at Sat Nov 24 17:10:37 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Sat, 24 Nov 2001 23:10:37 +0100 Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> <3BFEC93C.78DB7D98@ccvcorp.com> <29AL7.2768$nK1.269290698@newssvr14.news.prodigy.com> <3BFEE0A1.973356BB@engcorp.com> Message-ID: <3c001ba4@brateggebdc5.br-automation.co.at> "Peter Hansen" wrote in message news:3BFEE0A1.973356BB at engcorp.com... ... > Sorry, not under Win98. And under Win2K it's not really DOS... _Fortunately_, Win2K is not really DOS :-) regards Werner From ee_fhw at stu.ust.hk Thu Nov 22 09:40:39 2001 From: ee_fhw at stu.ust.hk (Calvin) Date: Thu, 22 Nov 2001 22:40:39 +0800 Subject: Programming Rayleigh-Ritz method Message-ID: <3BFD0E67.9080106@stu.ust.hk> Greetings, Did anyone have the experience of programming the Rayleigh-Ritz method using Python. The Rayleigh-Ritz method is a numerical approximation for solving energy minimizing problem. If you have program FEM in Python. Could you teach me how to write the algorithm? -Calvin From tim at vegeta.ath.cx Mon Nov 12 09:27:56 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Mon, 12 Nov 2001 14:27:56 GMT Subject: OT: Mobile Internet Toolkit EULA (was: IsPython really O-O?) References: <9smovs$cbu$02$1@news.t-online.com> <9snugr$bbc$06$1@news.t-online.com> Message-ID: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Guido Stepken graced us by uttering: [ snip ] > IMHO they do forbid the use of > their software together with GPL ....but i have no evidence (i dont't use > M$ !). I there anybody out there, who has a copy of this M$ license ? I tried to follow the links from a slashdot.org article, but MS seems to have moved the page. A search for 'MIT EULA' on msdn.microsoft.com returned four URLs, the third of which follows: http://msdn.microsoft.com/Downloads/eula_mit.htm Some interesting excerpts: The Restriction: [ snip ] : (c) Open Source. Recipient's license rights to the Software are : conditioned upon Recipient : (i) not distributing such Software, in whole or in part, in : conjunction with Potentially Viral Software (as defined : below); and : (ii) not using Potentially Viral Software (e.g. tools) to : develop Recipient software which includes the Software, : in whole or in part. [ snip ] The Definition: : Recipient shall not distribute the Software, in whole or in part, : in conjunction with any Publicly Available Software. [ snip ] : Publicly Available Software includes, without limitation, software : licensed or distributed under any of the following licenses or : distribution models, or licenses or distribution models similar to : any of the following: : (A) GNU's General Public License (GPL) or Lesser/Library GPL (LGPL), : (B) The Artistic License (e.g., PERL), : (C) the Mozilla Public License, : (D) the Netscape Public License, : (E) the Sun Community Source License (SCSL), and : (F) the Sun Industry Standards License (SISL). [ snip ] The rest of the EULA adds more legalspeak, but it doesn't get any more lenient. I believe MS was trying to see how this would go over in the community and decided to test it with a pre-release version of software in case users raised too much of a fuss. Cheers! Tim Hammerquist - -- You know, we've got armadillos in our trousers. It's really quite frightening. -- Nigel Tufnel, "This is Spinal Tap" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE7795R8vyBPhAeHacRAqCoAJ4kDHQnnxtvt6XhZw/9tZTN05q4OQCfXTgC xJDr6FUNbB0ETA5t04QpNJI= =pAsi -----END PGP SIGNATURE----- From walter at livinglogic.de Fri Nov 16 14:41:17 2001 From: walter at livinglogic.de (Walter =?ISO-8859-1?Q?D=F6rwald?=) Date: Fri, 16 Nov 2001 20:41:17 +0100 Subject: [Q] Printing color strings on stdout without using escape sequences ? References: <3BF4F588.9010500@edf.fr> Message-ID: <3BF56BDD.3060805@livinglogic.de> Ivan DUTKA-MALEN wrote: > Hello, > > for my application to be a bit more friendly, I want to show some > colored strings on the standard output but I don't want to use ugly > escape sequence like '\033[1m;' or so... > > I'd prefer use a module (if one exists) that encapsulate all those > things and that allows me to be portable on various Unix-like systems > (especialy Linux, Solaris, HP-UX, IRIX). > Does anyone know such a module ? > > For information, I tried to use curses but I think it doesn't make what > I want in the sense that it uses the full screen and I just want to use > the standard output stream. I may be wrong and I surely misuse it. Some > help will be much appreciated :-)). You might want to take a look at ANSIStyle: http://www.livinglogic.de/Python/ansistyle/ HTH, Walter D?rwald From BPettersen at NAREX.com Thu Nov 29 13:56:43 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 29 Nov 2001 11:56:43 -0700 Subject: PEP 276 Simple Iterator for ints Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192158C58@admin56.narex.com> > From: Kerim Borchaev [mailto:warkid at storm.ru] > > Hello James, > Thursday, November 29, 2001, 5:18:43 AM, you wrote: > Jic> Peter Hansen wrote: > >>Or just: > >> > >>if not 0 <= index < len(mylist): > >> print 'index out of range' > > Jic> Right. Which has the added advantage of not repeating index. > > Why not just _use_ that index on the list to check whether it's valid? > > try: > mylist[index] > except IndexError: > print 'index out of range' Because a negative index doesn't give an IndexError, and presumably we wanted to make sure the list was accessed through a positive index... -- bjorn From fredrik at pythonware.com Fri Nov 16 04:04:43 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 16 Nov 2001 09:04:43 GMT Subject: PIL Installation on windows98 - from newbie References: Message-ID: "Tech" wrote: > Hello all, I would love to try to write an imaging app using the PIL, > but I can even get it installed. I try reading all the documentation > I could find on the subject, but nothing helped. Would some please > help me. so, what did you do, and what didn't work. From sholden at holdenweb.com Wed Nov 28 08:36:20 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 08:36:20 -0500 Subject: windows to linux pickled objects? References: Message-ID: "Stephen Boulet" wrote... > Oleg Broytmann wrote: > > > On Tue, Nov 27, 2001 at 11:05:08PM -0600, Stephen Boulet wrote: > >> I pickled a list in windows but couldn't open it in linux without first > >> running the handy dos2unix program on it. > > > > Always write binary data to binary files: > > > > outfile = open(filename, 'wb') > > outfile.write(pickle) > > outfile.close() > > > > Oleg. > > Thanks to you both for the responses. > > But is writing in binary mode supported under linux? The tutorial says: > > << > On Windows and the Macintosh, 'b' appended to the mode opens the file in > binary mode > >> > > I tried it on linux and the program did run, but the size of the pickled > file only went down from 8183905 bytes to 8180057 bytes, and the file > wasn't binary at all. Maybe the size difference can be explained by the > lack of carriage returns. ;) > > It would be nice if the binary option worked on linux... > >From Python 2.0 Library Reference: """A binary format, which is slightly more efficient, can be chosen by specifying a nonzero (true) value for the bin argument to the Pickler constructor or the dump() and dumps() functions. The binary format is not the default because of backwards compatibility with the Python 1.4 pickle module. In a future version, the default may change to binary. """ So the binary option you require isn't the file open argument (which you should use as well, because otherwise the file code might mangle things it thinks are line endings). It's the binary argument to the pickle methods. regards Steve -- http://www.holdenweb.com/ From anthony.rangecroft at philips.com Fri Nov 2 10:14:27 2001 From: anthony.rangecroft at philips.com (Anthony Rangecroft) Date: Fri, 02 Nov 2001 15:14:27 +0000 Subject: Objects for shell Message-ID: <3BE2B853.1B552F0B@philips.com> I was wanting to use objects with shell programming and started on a script that lets me write things like: $ Object child Disks $ Disks child system $ system device: /dev/dsk/c0t4d0 $ Disks @free: 'df `$self device` | awk {print\ \$4}' $ system free 599896 Is there a prototyping/parenting (rather than class based) OOP capability available for any of the main shells? Alternatively are there any interpreters supporting parenting? As I understand it both Perl and Python are class based, and the Sather newsgroup seems to be asking what happened to Sather... Anthony.Rangecroft at philips.com From robert at folkerts.net Fri Nov 30 17:59:02 2001 From: robert at folkerts.net (Robert Folkerts) Date: 30 Nov 2001 14:59:02 -0800 Subject: Python evangelists unite! References: Message-ID: tanzer at swing.co.at (Christian Tanzer) wrote in message news:... > "Peter Milliken" wrote: > > > I use Python as a good, quick and dirty hacking language. For real (rea > d > > production) stuff that I expect a customer to run or will require more > than > > a single person working for a couple of hours, I look elsewhere :-). > > Like what? > > > They could have been more productive with other languages that provide > > better support for generic software engineering principles/standards. > > What other languages? What principles/standards? Perhaps this is a reference to generic programming, as exemplified by the C++ Standard Template Library. In Python, you don't have data types and you don't have the same level of control that you have in C++ to declare const's that allow a complier to better optimze code. If your client needs to get the most out of each clock cycle, I would choose C++ over Python. However, my first choice would be to use C++ 'under' Python. There are some great examples of using Python and C++ together: sip and the boost python libraries allow C++ and python to co-exist nicely Qt & PyQt are a great example of this synthesis. (Play with theKompany's BlackAdder, I found it a rush to write Python that inherits & oeverides behavior defined in C++.) PySTL is another (still rough ) indication of how C++ and Python can coexist. I find PySTL very exciting, because templates are a powerful tool, but they are an incredible pain to use. The STL is an intellectual masterpiece and there are other examples fo fine generic programming using templates. If we can leverage this 'deep' programming in Python, great! With C++, you have a powerful OO tool, with Python you have a very agile OO tool. Python Programmers will run circles around C++ programmers. But a C++ application will (after a long wait while the coders deliver) run circles around the Python application. In my ideal project, you deliver version 1.0 in pure python, the client will have a bunch of changes and a desire to get better performance. Use the very agile Python to make most of the changes and get the code refactored into a stable, well-designed OO system. Now, use the C/C++ to replace a few performance limiting pieces of code. Zope is a great example of this. It is almost all Python with a very limited use of C. The C++ programmers will only write code when there is hard evidence from profiling that you have a bottleneck. A development team should be able to deliver a mixed language app that can be developed almost as fast as the Python app, while executing nearly as fast as the C++ app. Overtime, 'framework' code might migrate toward C++ (like in the Qt library), while application programming (the bread and butter for must of us) will migrate to Python (or a python-like langauge). In summary, I feel that Python and C/C++ go together like branches and roots. Attacking one only harms both. From brian at rk-speed-rugby.dk Fri Nov 9 02:41:53 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 09 Nov 2001 08:41:53 +0100 Subject: Teaching python (programming) to children References: Message-ID: "Arthur Siegel" writes: > The problem with this slant is that there is little justification to bring > the > necessary resources to bear for "teaching programming languages to all > (or most) schoolchildren" if the end result is scripts cataloging mp3s. Math is taught even though everyone doesn't have to be a scientist. My original question was based on that I think that with an easily written and understood, running pseudo code language, learning programming may be much easier. > CP4E boat when we focus on one hand on training computer scientists > starting at age 12, or, on the other, believing that the educational value > of > the context of the programming-related curriculum is not of the essence. Good point but I believe the problem can be handled. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From david at dataovation.com Fri Nov 9 14:20:32 2001 From: david at dataovation.com (David A McInnis) Date: Fri, 9 Nov 2001 11:20:32 -0800 Subject: Module for reading CSV data Message-ID: Is there a module for reading CSV files into a dictionary? Or is there a builtin that is used in conjunction with readlines()? The first row of my csv file contains field names. Thanks, David From dale at riverhall.NOTHANKS.co.uk Thu Nov 1 05:51:49 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Thu, 01 Nov 2001 10:51:49 +0000 Subject: XML can't read Unicode shock horror. News at 11. References: Message-ID: Paul Prescod wrote: >Dale Strickland-Clark wrote: >> >> ... >> >> Is there any chance that this might be elevated? >> >> Non-unicode XML is a bit restrictive. :-( > >I think Martin was trying to make the point that this works okay: > >dom = xml.dom.minidom.parseString(u''.encode("utf-8")) > >I agree with you that minidom should probably do this automatically. > > Paul Prescod That's not much good if my XML document happens to start with: To quote from the O'Reilly book, "XML In A Nutshell" p71: "An XML parser is required to handle the UTF-16 and UTF-8 encodings or Unicode." And I expect similar is stated in the XML DOM spec if I had time to look for it. -- Dale Strickland-Clark Riverhall Systems Ltd From crispiewm at hotmail.com Sun Nov 11 04:10:15 2001 From: crispiewm at hotmail.com (Kevin Christie) Date: Sun, 11 Nov 2001 03:10:15 -0600 Subject: mapping a statement over all list items Message-ID: <3BEE4077.8070407@hotmail.com> Hello all! I have list Foo, of strings. Each string has a special character '-' within the string. What I want is for Python to split each string list item by '-' and assign the resulting lists to the original list item. Basically, I want to apply: Foo[x] = Foo[x].split('-') over all items x in Foo, in one clean statement. Thus if Foo was ['abc-xyz', 'black-blue', '123-987'], the result after mapping to Foo would be: Foo = [ ['abc', 'xyz'], ['black','blue'], ['123','987'] ] It seems as if there should be a way to map the function over all items in one elegant statement, but map() requires an explicit function, not a python statement, and I'm not sure if what I want is possibly through the use of lambda forms. Any help? Sincerely, Kevin Christie Neuroscience Program University of Illinois at Urbana-Champaign crispiewm at hotmail.com From altis at semi-retired.com Mon Nov 12 01:58:28 2001 From: altis at semi-retired.com (Kevin Altis) Date: Sun, 11 Nov 2001 22:58:28 -0800 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> Message-ID: <0pKH7.859$Au5.304844@news.uswest.net> "Ron Stephens" wrote in message news:3BEF0436.33D7F2A5 at earthlink.net... > As someone else said, pleas einlcude anygui. Also, it woudl be nice if you could > include PythonCard, as an application frmaework on top of wxPython. While I would like to see PythonCard and anygui covered in a book, it doesn't make sense for either project right now. The APIs are in flux and by the time a book went to print the information would be completely wrong. PythonCard is likely to change quite a bit between now and the end of the year and anygui probably won't be usable for anything but the simplest projects until early next year or later. ka > > > Michael 'Mickey' Lauer wrote: > > > Hi group, > > > > I'm currently writing a Python GUI book, where several toolkits > > (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... > > of course... Tkinter) are presented and explained. > > My idea is that besides going into some detail of every Toolkit I > > construct _one_ application scenario with a skeleton, which I > > later complete with each of the toolkits. > > This should give the reader the means to choose the toolkit > > which matches their personal taste & programming philosophy. > > > > Given this approach, the main question I'm currently trying to > > figure out is: What application shall I present? It must be complicated > > enough to show some advanced topics (not only presenting a tour of > > the widgets and voila...) but at the same time small enough to cover > > it within 50 pages or so (remember: for each toolkit!). > > > > I first thought of some contact application - in outlook style - or > > some kind of presentation program - powerpoint style - ... here's a plea > > for your input. > > > > What do you think would be a good application to show the basics and a few > > more sophisticated topics in programming GUI applications with Python? > > > > Apart from this concrete question do you have some topics which you > > think should be a _must_ in such a book? Imagine you're a not a total newbie > > in python GUI programming... what did you want to read in such a book? > > > > thanks for your input! > > > > Yours, > > > > Mickey. > > > > From fperez528 at yahoo.com Mon Nov 12 11:06:43 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 13 Nov 2001 15:34:43 +2328 Subject: Problem with .pth files under linux Message-ID: <9ss77q$7d7$1@peabody.colorado.edu> I'm sure this is simple and stupid, but I still don't know what's going on. I have some modules without a package structure (no __init__.py) but which have a .pth file. Specifically, Numeric. It comes in its own directory: site-packages/Numeric, and in site-packages I have a file Numeric.pth whose contents is simply 'Numeric' (no quotes). Yet import Numeric doesn't work! I solved it by hand-coding Numeric into sys.path, but it annoys me and I have the same problem with other modules I'll need to use soon. Could anyone tell me what I'm missing or doing wrong? (Python 2.1.1 under Linux, Mandrake 8.0). Thanks, F. From hfoffani at yahoo.com Thu Nov 15 06:20:23 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Thu, 15 Nov 2001 12:20:23 +0100 Subject: Tidy HTML, was: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> Message-ID: <20011115062102.925$Y5@news.newsreader.com> "David Bolen" escribi? en el mensaje news:ubsi7zc8x.fsf at ctwd0143.fitlinxx.com... > David Eppstein writes: > > > Sure. But if you want to parse HTML that you don't control, you are going > > to have to be ready to handle invalid input and do something reasonable > > with it. > > Yep - although "reasonable" could be declare it invalid depending on > the problem space :-) > > I do think in this case the right thing is actually happening - the > document is generating an SGMLParseError due to bad syntax. But true, > I expect the original poster needs to determine how best to handle the > problem document since I expect just rejecting it is not desirable. The fact that with Python is soooo easy to grab and extract data from remote pages that annoys a lot when such pages aren't valid HTML. It's unfair to require that htmllib &co parses invalid HTML though. This problem can be solved with a simple routine that calls tidy through a pipe before calling the parser. Regards, -Hern?n From jjl at pobox.com Thu Nov 29 09:22:32 2001 From: jjl at pobox.com (John J. Lee) Date: Thu, 29 Nov 2001 14:22:32 +0000 Subject: std. python from cygwin: the final word (?) In-Reply-To: References: Message-ID: On Wed, 28 Nov 2001, Jason Tishler wrote: [...] > On Wed, Nov 28, 2001 at 12:22:05PM +0000, John J. Lee wrote: > > After several, surprising long, threads, the collective brain power of > > c.l.python and the cygwin mailing list has produced the following magical > > shell incantations: [...] > If you are willing to use rxvt, then the following trigger is a simpler > alternative: > > #!/usr/bin/env pythonw Thanks, but: 1. why does it help to use pythonw? 2. why does your solution require rxvt (rather than the std. windows terminal used by cygwin)? Just to make sure we're not talking at x-purposes: the shell script I sent was intended to be run instead of python, so that it can munge the (possibly cygwin-style) path of the script before passing it to the real python, while still getting sys.argv right at the same time, so you can type ./script.py or python /home/john/script.py or ./script.py /foo/bar or python script.py ./foo etc, and have everything work as expected, even though you're using MSVC-compiled python with no cygwin support. John From James_Althoff at i2.com Thu Nov 15 13:14:18 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 15 Nov 2001 10:14:18 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: David Eppstein wrote: > > Skip Montanaro wrote: > >> I think I would still write the above as >> >> for rowcount in [0, step, ... table.getRowCount()]: >> >> That would get you the sequence >> >> 0, 1*step, 2*step, ... (table.getRowCount()-1)*step >> >> and is more flexible than your proposal. There's no reason you couldn't >> have >> >> for f in [0.0, 1.0, ... sys.maxint]: >> >> to enumerate floats up to but not including sys.maxint (care needs to be >> taken to not to compound errors). >> >> You could also build character sequences I think: >> >> for c in ["a", "b", ... "z"]: > >You seem to be inconsistent here about whether you want these ranges to be >open or closed on the right. I think closed is the only reasonable choice >for this syntax. I agree with David that the syntax above probably sets one's expectation that the interval is closed on the right. Unfortunately, that interpretation would necessitate a "subtract 1" idiom for indexing sequences. Jim From slinkp23 at yahoo.com Tue Nov 6 00:33:25 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 06 Nov 2001 05:33:25 GMT Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: On Mon, 05 Nov 2001 22:09:04 -0800, Cliff Pruitt wrote: >I guess my main concern what that I'd get into Python and find out >that I couldn't develop a full application without getting into C++ >or something. No need to worry. You can do quite large applications in Python. The two I use most often are Reportlab (41k lines of python plus 4k lines of C for speed-intensive parts), Zope (157k lines of python plus 40k lines of C for speed-intensive parts). Also interesting is Sketch - a full-featured vector drawing program (43k lines of python plus 22k lines of c for speed-critical stuff). Remember that these are *large* projects developed over years. C or C++ projects are often much, MUCH larger. e.g. Gimp is 540k lines of C, not even counting header files. You'll notice a pattern here - all of these apps (not Gimp) are developed in python and have gradually moved the biggest time-wasting loops into small bits of C code. (Most C files in the above projects are quite short - anywhere from 50 lines to (rarely) 4k lines). But don't get the wrong idea - you do *not* need C to do anything useful in Python. Far from it. All of the applications I mentioned require fast performance, and have gradually been tuned for speed. Such optimizations usually should be postponed until the project is pretty mature (as Zope, Reportlab, and Sketch all are). And it's VERY important to realize that a slow python program can VERY often be made "fast enough" without bothering with C. Here's some optimization tips for pure python - file these away for later: http://www.python.org/doc/FAQ.html#4.7 http://www.python.org/doc/essays/list2str.html >Admittedly C++ is probibly a lot more powerful, but this is just a hobby to >tinker with for me. You want it to be fun? Then you don't want python - you *need* python. :) > Am I correct in understanding that Python will let you create GUI elements >(windows, buttons, dialogue boxes, ect...)? Yes. You have many, many choices here - again, check the FAQ, question 4.13. Also worth a look: http://www.onlamp.com/pub/a/python/2001/08/16/pythonnews.html >Thanks so much! This seems like a very friendly newsgroup. We have our moments. :) --PW From david at dataovation.com Mon Nov 26 11:35:23 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 26 Nov 2001 08:35:23 -0800 Subject: smtplib help In-Reply-To: <000501c17693$8e8cd970$d9e1c3c1@pbrian> Message-ID: Actually, I am using imail from IPSWITCH. Anyway, it was a speed issue. When I called time.sleep(2) from the time module giving me a 2 second sleep, I was able to process the messages. I don't like being able to send only one msg every 2 seconds. Any help would be appreciated. Sincerely, David McInnis -----Original Message----- From: Paul Brian [mailto:paul1brian at yahoo.com] Sent: Monday, November 26, 2001 8:01 AM To: david at dataovation.com Subject: Re: smtplib help David I seriously doubt it - however there is no reason you cannot add in a wait function eg #assume listofmessages is list of 3 element lists; (from, to, msg) for msg in listofmessages: server = smtplib.SMTP('smtp.wibble.com') server.sendmail(msg[0], msg[1], msg[2]) server.quit() # truly crude wait function for x in range(1,1000000,1): pass however I suspect that the thing will still crash - I doubt there is any implementation of an SMTP server that will go wrong on a few hundred messages a second. What is the smtp server you are using BTW? I assume it is on windows? Exchange perhaps? Failing that perhaps you could put the code out to the group, or even try a different smtp server and see if it still fails. sorry I cant be more help P ----- Original Message ----- From: David A McInnis To: Paul Brian ; Sent: Monday, November 26, 2001 3:45 PM Subject: RE: smtplib help > I do call quit(). Is is possible that the script is moving too fast for the > smpt server to keep up? If so, how can I slow it down? > > David > > -----Original Message----- > From: python-list-admin at python.org > [mailto:python-list-admin at python.org]On Behalf Of Paul Brian > Sent: Monday, November 26, 2001 6:55 AM > To: python-list at python.org > Subject: Re: smtplib help > > > David, > > its hard to comment, but I suspect that the error you are getting comes from > the SMTP server. > > Basically line 222 in smtplib calls on the socket module, which has an error > code: > errorTab[10048] = "The network address is in use." (line 79) > (I am using 2.1.1 - Your version presumably has a different error msg ) > > So I suspect that the server is keeping alive sessions - I would check by > quiting the session each time (xxx.quit()) you send a message. > > Hope that helps > > David A McInnis wrote in message > news:mailman.1006768891.31431.python-list at python.org... > Any ideas why smtplib would crash on me after about sending 150 email msgs > (i did not count, but that is a good estimate)? > > This is the error that I am getting. > > File "C:\Python21\mm_mime.py", line 93, in Send > server = smtplib.SMTP(host) > File "C:\Python21\lib\smtplib.py", line 187, in __init__ > (code, msg) = self.connect(host, port) > File "C:\Python21\lib\smtplib.py", line 222, in connect > self.sock.connect((host, port)) > File "", line 1, in connect > error: (10048, 'Address already in use') > > David McInnis > > > -- > http://mail.python.org/mailman/listinfo/python-list _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From grey at despair.dmiyu.org Fri Nov 30 19:01:35 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Sat, 01 Dec 2001 00:01:35 -0000 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: On Fri, 30 Nov 2001 14:06:55 -0800, Erann Gat wrote: > No, it would not become "illegal" under my proposal. Please go back and > re-read what I wrote, and pay particular attention to the word "optional". What was written: ---- SNIP ---- 2) Parser support. It would be enough to simply give a warning if there is a discrepancy between the block structure defined by indentation and that defined by the semicolon-at-end-of-line convention (i.e. "Warning: end of block detected without trailing semicolon"). Making this optional so that die-hard indentation fans could turn it off would also be fine. ---- SNIP ---- What you said was that there would be a warning and that the /warning/ would be optional. You did not address the valid concern that... if x: foo(); bar(); baz(); ...has to be parsed and under your rules foo(); is the end of the block. IE, if we take your proposal as it was presented, that a line that ends with a semicolon denotes the end of a block, the above is invalid. If a line that ends with a semicolon does not denote the end of a block, your proposal is moot as it doesn't change a thing. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From grey at despair.dmiyu.org Fri Nov 30 16:24:02 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 30 Nov 2001 21:24:02 -0000 Subject: A modest indentation proposal References: Message-ID: On Fri, 30 Nov 2001 10:38:48 GMT, Michael Hudson wrote: > Steve Lamb writes: >> Hogwash, plain and simple. Either you know it because it is visually >> different or you know it when you test the application and it fails >> spectacularly. You /do/ test your mission-critical applications, don't you? > Erann works at NASA, so I'd hope so... Now, now, I left out the obligatory jab at metric versus imperial measurements in mission critical applications for a reason. :P -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From loewis at informatik.hu-berlin.de Mon Nov 5 14:09:50 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 05 Nov 2001 20:09:50 +0100 Subject: newbie: Standard Module documentation References: Message-ID: chorg writes: > I am wondering if there is a standard place to find documetation of > modules -- kind of like Perl's perldoc. Or, how can I find out what > methods and properties are in an instance of a class? With Python 2.1, you can use pydoc. For example, 'pydoc httplib.HTTP' gives something that starts Python Library Documentation: class HTTP in httplib class HTTP | Compatibility class with httplib.py from 1.5. | | __init__(self, host='', port=None, **x509) | Provide a default host, since the superclass requires one. | | close(self) | | connect(self, host=None, port=None) | Accept arguments to set the host/port, since the superclass doesn't. | Of course, for a full reference, you should read the Python library reference, http://www.python.org/doc/current/lib/lib.html Regards, Martin From jjl at pobox.com Sat Nov 3 15:44:34 2001 From: jjl at pobox.com (John J. Lee) Date: Sat, 3 Nov 2001 20:44:34 +0000 Subject: 2.1 nested scope SyntaxWarning Message-ID: Upgrading to Python 2.1, I find my old 2.0 code works fine, but I'm getting warnings like the following: /usr/local/lib/python2.1/site-packages/ls_fit/utils/graph.py:355: SyntaxWarning: local name 'grace_np' in 'define_grace_np' shadows use of 'grace_np' as global in nested scope 'GracePlotter' def define_grace_np(): /usr/local/lib/python2.1/site-packages/ls_fit/utils/graph.py:668: SyntaxWarning: local name 'qt' in 'QwtPlotter' shadows use of 'qt' as global in nested scope 'hardcopy' class QwtPlotter(BasePlotter): This is with code like the following (no from __future__ import x statements): [...] def define_grace_np(): import grace_np class GracePlotter(BasePlotter): [...] def _ensure_init(self): [...] if self._initialised == 0: self._g = grace_np.GraceProcess() [...] return GracePlotter Now that I come to think about it, I'm not entirely sure what's going on when you run this in 2.0, or in 2.1 without from __future__ import nested_scopes. I don't see why grace_np should be visible as a local variable in the GracePlotter class, given that the following: def foo() a = 1 def bar(): print a bar() foo() causes a NameError on 'print a', as does this: def foo(): a = 1 class bar: def baz(s): print a return bar bar = foo() b = bar() b.baz() However, the GracePlotter class works fine. Why? Thanks for any help. John From lyongu at ailab.pku.edu.cn Tue Nov 27 11:18:45 2001 From: lyongu at ailab.pku.edu.cn (Yong Lu) Date: 28 Nov 2001 00:18:45 +0800 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> Message-ID: "Max M" writes: > "Yong Lu" wrote in message > news:n118xmrp.fsf at ailab.pku.edu.cn... > > A newbie question. Where can I find documentation of this usage? > > I've searched a bit in the Python manual, but the only section > > on print doesn't mention this. > > Python library reference: > 2.1.5.2 String Formatting Operations Thanks! > > regards Max M > > (I had to search long and hard for it too. Sometimes the manual could be a > bit more cross referenced.) Agree, and maybe the index should be a little more comprehensive. Regards, Yong From skip at pobox.com Wed Nov 14 03:33:47 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 09:33:47 +0100 Subject: Threading In-Reply-To: References: Message-ID: <15346.11371.513447.894344@beluga.mojam.com> Ciobanu> class DataBase: Ciobanu> def __init__( self): Ciobanu> self.__dictionary = {} Ciobanu> def __getitem__( self, key): Ciobanu> return self.__dictionary[key] Ciobanu> def __setitem__( self, key, value): Ciobanu> self.__dictionary[key] = value Ciobanu> Now, consider that this DataBase class is to be used in a real Ciobanu> world program, specifically in a threaded world. This would Ciobanu> imply I use locks, which brings me to the actual Ciobanu> question. Unfortunately the Python Library Reference isn't Ciobanu> clear enough ( to me, at least) about this particular detail: Ciobanu> Is it safe to call __getitem__ without placing locks ? No. Presuming a value associated with key exists, you will get a consistent value (not a garbage half-old/half-new value), but it might be an old one (__setitem__ could sneak in and change it on you). The code for your __getitem__ method compiles into several bytecode instructions: 0 LOAD_FAST 0 (self) 3 LOAD_ATTR 1 (__dictionary) 6 LOAD_FAST 1 (key) 9 BINARY_SUBSCR 10 RETURN_VALUE The global interpreter lock can be released after any of them, allowing another thread to run, and possibly change things behind your back. More importantly, you might lose the key altogether. Suppose your code looks like this: db = Database() ... fill it up with interesting stuff ... for key in db.keys(): print db[key] You have to secure a lock before the for loop begins and only release it after the loop terminates to guarantee that the list of keys you got at the start is still valid while the loop body executes. So, it's worse than you thought. Not only must you lock __getitem__, you have to lock at a higher level than that. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From syring at email.com Thu Nov 29 11:14:42 2001 From: syring at email.com (Karl M. Syring) Date: Thu, 29 Nov 2001 17:14:42 +0100 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <9u5d00$6aald$1@ID-59885.news.dfncis.de> Message-ID: <9u5mti$69rn5$1@ID-7529.news.dfncis.de> "Thomas Heller" schrieb > "Laura Creighton" wrote in message news:mailman.1007037345.11725.python-list at python.org... > > Does anybody have any favourite alternatives to CVS? I'm constantly > > looking for something which is not file oriented, or which is better > > able to handle multiple people editing the same file on the same day. > > Just a way to insist 'I just moved that class into its own file. > > Nobody gets to reinsert their old hacked versions of this class _back_ > > into this file -- if you are changing this class you now need _that file_' > > would be incredibly useful. > > Sometimes I hear some rumour about Perforce, but I never tried it. There is a whole slew of stuff (http://www.cmtoday.com/yp/free.html). (Fightin' with CVS to completely remove a cancerous side branch) Karl M. Syring From ungrzr2 at ubatxbat.pbz Wed Nov 14 03:27:35 2001 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 14 Nov 2001 08:27:35 GMT Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: Michael 'Mickey' Lauer wrote in news:3beedf26 at nntp.server.uni-frankfurt.de: > > What do you think would be a good application to show the basics and a > few more sophisticated topics in programming GUI applications with > Python? > You can demostrate how to realize a MVC model with python and all the toolkits. It's powerful and useful. Many applications fit well with MVC. Better have the backend seperated from the frontend from the beginning. From warkid at storm.ru Thu Nov 29 06:45:32 2001 From: warkid at storm.ru (Kerim Borchaev) Date: Thu, 29 Nov 2001 14:45:32 +0300 Subject: PEP 276 Simple Iterator for ints In-Reply-To: References: Message-ID: <2614.011129@storm.ru> Hello James, Thursday, November 29, 2001, 5:18:43 AM, you wrote: Jic> Peter Hansen wrote: >>Or just: >> >>if not 0 <= index < len(mylist): >> print 'index out of range' Jic> Right. Which has the added advantage of not repeating index. Why not just _use_ that index on the list to check whether it's valid? try: mylist[index] except IndexError: print 'index out of range' Best regards, Kerim mailto:warkid at storm.ru From akupries at shaw.ca Thu Nov 22 22:26:56 2001 From: akupries at shaw.ca (Andreas Kupries) Date: Fri, 23 Nov 2001 03:26:56 GMT Subject: extracting html table rows into a list References: <9aadf0f.0111220750.719466de@posting.google.com> Message-ID: <874rnm9od0.fsf@bluepeak.home> "Peter Campbell" writes: > I have something that does this (sort of), I extract data from a web > site for stock prices. The main code revolves around the regexp > function, I am looking for SPAN tags here but you will want to > change so you are looking for TR or TD tags plus any other stuff as > appropriate. Note the 'htmlparse' module of 'tcllib' for a more structured way of extracting information from a HTML document. Examples are available too (examples/oscon2001) -- Sincerely, Andreas Kupries Developer @ Private ------------------------------------------------------------------------------- } From djc at object-craft.com.au Tue Nov 6 00:40:28 2001 From: djc at object-craft.com.au (Dave Cole) Date: 06 Nov 2001 16:40:28 +1100 Subject: csv-0.5 released Message-ID: The CSV module provides a fast CSV parser which can split and join CSV records which have been produced by Microsoft products such as Access and Excel. On Python 2.x the module outperforms string.split(). Of course the CSV parser can handle much more complex records than string.split()... This is a bugfix release. The changes in this release are: 1- Fixed bug in memory allocation of internal parser buffer - thanks to John Machin for pointing this out. 2- Fixed compile warning on Solaris - thanks to Adam Goucher for reporting this. The module homepage: http://www.object-craft.com.au/projects/csv/ For people who do not have a C compiler on Windows I have put a Python 2.1 binary up here: http://www.object-craft.com.au/projects/csv/csv.pyd - Dave From wtri at wtresearch.de Fri Nov 2 05:09:37 2001 From: wtri at wtresearch.de (wtr) Date: Fri, 2 Nov 2001 11:09:37 +0100 Subject: MemoryError under 2.2b1 Message-ID: <1004688073.78898@lix-049dz-008.inside.impress.com> The following little script ends in a MemoryError hello world! Traceback (most recent call last): File "C:/Python22/HelloWorld.py", line 4, in ? for j in range(99999999,1000000001): MemoryError There seems to be a strange dependancy between the two range parameters; ranges (99999999,100000000) and (999999999,1000000099) work. ----------------------------------------------------- print "hello world!" import time for j in range(99999999,1000000001): null= 0 print null t1=time.time() print t1 ---------------------------------------------------- Greetings, wolfgang teschner From fgeiger at datec.at Mon Nov 12 02:13:02 2001 From: fgeiger at datec.at (F. GEIGER) Date: Mon, 12 Nov 2001 08:13:02 +0100 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <9snspt$3ja$1@newsreaderg1.core.theplanet.net> Hi Michael, I think you should try to consider anygui, which is still in an early stage. > Apart from this concrete question do you have some topics which you > think should be a _must_ in such a book? Imagine you're a not a total newbie > in python GUI programming... what did you want to read in such a book? I consider Design Patterns a must (GoF and successors). Show how to use them to build flexible GUI designs. Good luck and all the best for your project! Best regards Franz "Michael 'Mickey' Lauer" schrieb im Newsbeitrag news:3beedf26 at nntp.server.uni-frankfurt.de... > Hi group, > > I'm currently writing a Python GUI book, where several toolkits > (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... > of course... Tkinter) are presented and explained. > My idea is that besides going into some detail of every Toolkit I > construct _one_ application scenario with a skeleton, which I > later complete with each of the toolkits. > This should give the reader the means to choose the toolkit > which matches their personal taste & programming philosophy. > > Given this approach, the main question I'm currently trying to > figure out is: What application shall I present? It must be complicated > enough to show some advanced topics (not only presenting a tour of > the widgets and voila...) but at the same time small enough to cover > it within 50 pages or so (remember: for each toolkit!). > > I first thought of some contact application - in outlook style - or > some kind of presentation program - powerpoint style - ... here's a plea > for your input. > > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? > > Apart from this concrete question do you have some topics which you > think should be a _must_ in such a book? Imagine you're a not a total newbie > in python GUI programming... what did you want to read in such a book? > > thanks for your input! > > Yours, > > Mickey. > From java at dejazzd.com Thu Nov 15 10:21:48 2001 From: java at dejazzd.com (Choco) Date: Thu, 15 Nov 2001 10:21:48 -0500 Subject: scope question Message-ID: <9t0j1i02oob@enews1.newsguy.com> I am re-working a program to abstract some elements of a set of cgi's into a shared library. One thing I'm looking to abstract is the database connection code. To do so, I've created a connect() method and a close() method. The connect() method returns a cursor which the cgi then uses to execute a series of sql statements. To close out the cursor and the database connection the cursor is passed to the close method. How do I get this to work? I find that I cannot simply do this: def close(cursor): cursor.close() db.close() This fails with a NameError: global name 'db' is not defined. I'm searching for the solution to this at the moment, but thought I'd post here to see if anyone had any tips. Thanks! Glenn From thomasNO at SPAM.obscure.dk Wed Nov 14 16:45:21 2001 From: thomasNO at SPAM.obscure.dk (Thomas Jensen) Date: Wed, 14 Nov 2001 21:45:21 GMT Subject: Threading References: Message-ID: "Tim Peters" wrote in news:mailman.1005755427.14226.python-list at python.org: > In this case, being sure about the answer is much easier than being > sure about the question . If you run *any* sequence of dict > operations without benefit of locks (get, set, update, clear, > whatever), the outcome will be "sequentially consistent", meaning > the outcome will be the same as if you had run the dict operations > one at a time with benefit of exclusion, for *some* intervleaving > of dict operations across threads: each dict operation is atomic > (e.g., once a dict.update() starts, it completes before another > thread is allowed to run). In particular, if there are no > mutations going on, any number of threads can read simultaneously > without locks without surprises. That's very interesting, I'm usually quite paranoid about wrapping such stuff in locks. Is there any "rule-of-thumb" (or doc) regarding which operations are atomic, for example is the following safe: thread 1: mylist.reverse() thread 2: for item in mylist: ... (silly example perhaps) -- Best Regards Thomas Jensen From zope at thewebsons.com Sun Nov 25 05:51:59 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sun, 25 Nov 2001 02:51:59 -0800 Subject: How To Kill a Python Message-ID: <5.1.0.14.0.20011125024815.009f4ca0@thewebsons.com> Hi; I continually run into problems adding new software to my server that is dependent on Python because I have 2 versions, one of which is completely unnecessary; namely, 1.5.2. I want to kill it, or at least make it so that when Python is called it automatically calls 2.1 instead of 1.5.2, but I don't want to screw anything else up on the server. How should I go about this? TIA, BenO From tim at vegeta.ath.cx Wed Nov 28 01:03:57 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 28 Nov 2001 06:03:57 GMT Subject: python editor poll References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> Message-ID: Jonathan Gardner graced us by uttering: > I am curious as to what editors are being used to edit python. I get the > feeling that most people who post here, especially the gurus, use *ahem* > Vim *ahem*. I'd actually gotten the opposite impression. Most gurus who mention their editors seem to use Emacs, and I believe Guido himself uses Emacs, so... I believe Emacs' superior python-mode may be due to this preference. > Send an email with a subject of "python editor poll" and I'll do a quick > tally and post the results tomorrow. Um, Vim. =) > Please don't post your preference to this list, it tends to get exciting. You wanna start a flame war? Say you're a Vimmer _and_ a Perler! I learned my lesson! > * In case you're wondering what editor I use, let me just say that it works > really well with the email client that sucks less than all the others. Yes, I use the mutt+vim combo, myself. You couldn't _pay_ me to change. > * If you are still wondering, one of my projects at sourceforge is called > python-vim. (http://sf.net/projects/python-vim). I haven't uploaded > anything because I am waiting for some advice from Bram on licensing. I'm watching that project with great interest, especially after trying the code you posted to vim-dev and comp.editors. BTW, when you figure out which license to you, would you either post the result to vim-dev or email me? I'd appreciate it. And, again, my deepest apologies for confusing you with "Simon." All the best, Tim Hammerquist -- Pride gets no pleasure out of having something, only out of having more of it than the next man. -- C. S. Lewis From rdsteph at earthlink.net Wed Nov 7 22:55:53 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Thu, 08 Nov 2001 03:55:53 GMT Subject: WWW::Search References: <2c4b750e.0111070554.1e5c16d8@posting.google.com> Message-ID: <3BEA03B0.EE9277CF@earthlink.net> Yosefa Schwartz wrote: > Are there any python modules that provide an API to search engines on > the world wide web. Search engines such as Yahoo and Alta Vista. The > API that I am looking for would parallel the WWW::Search package that > perl has. > > Thanks. Hey, I dont know if it seven close to the perl module, but urllib will let you go out and do web searches effortlessly. From loewis at informatik.hu-berlin.de Sat Nov 10 08:22:02 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 10 Nov 2001 14:22:02 +0100 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> Message-ID: Amit Weisman writes: > SGMLParseError: unexpected char in declaration: '<' > > I can only guess The parser met a "< " and not a " enough to be sure . > What should I do to avoid it ? > What is it ? Hard to tell, since you never cared to report what data are following the or is it rather ??? Python expects a name after the Hi, I'd like to write a wrapper-function which takes a function and a variable parameter-list like this: def wrapper(fun, *args): ... do some checks ... fun(args) ... do some update of states ... But if I use the function def sum(a,b): return a+b and do wrapper(sum,1,2) I get an errormessage "sum() takes two arguments ( 1 given) " because sum() gets one tuple of two values instead of two seperate values. Is there any trick to circumvent this error ??? The problem is, that I'm not able to manipulate the calling-syntax of the functions transmitted to the wrapper... Yours, Uwe -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From virus_catcher at oceanic.com Thu Nov 29 15:05:51 2001 From: virus_catcher at oceanic.com (virus_catcher at oceanic.com) Date: Thu, 29 Nov 2001 10:05:51 -1000 Subject: InterScan NT Alert Message-ID: Receiver, AntiVirus Catcher has detected virus(es) in the e-mail attachment. The Sender has been notified. Date: Thu, 29 Nov 2001 10:05:51 -1000 Method: Mail From: <_dragonax at infinito.it> To: File: images.DOC.pif Action: clean failed - deleted Virus: WORM_BADTRANS.B From nospam at bigfoot.com Sat Nov 10 16:07:11 2001 From: nospam at bigfoot.com (Gillou) Date: Sat, 10 Nov 2001 22:07:11 +0100 Subject: Python in a hospital application please help References: Message-ID: <9sk4hq$2hcg$1@norfair.nerim.net> Hmmm... Not easy but You can compile python with SSL support for security but dunno if your app can connect to the database through SSL (not a pythonic issue). If your application (clients + server) are in a firewalled Intranet, you don't need more than classical user/password security. Encryption should not add sensitive security to your data. Using DB API 2.0 compliant Python adapters, you'll loose less time porting your application than transfering *safely* data between (say) Interbase and MySQL ;-) Look at http://www.python.org/topics/database/ Same thing with Zope, you can change the Database DA with few adapttion effort as long as your app plays with standard SQL. In addition, Zope enables to use its objects through a browser as well a through a client app that talks XML-RPC Dunno for the pool of database connections (depends on technologies) but AFAIK some Zope DAs are supposed to deal with it (distributing dynamically a live db connection to client threads) Make your shopping here http://www.zope.org/Products/external_access (free) But open source database engines like MySQL and Postgresql scale very well. You'd better use one of those and keep your money for a good data server an backup device than giving all these $$$ to Oracle or Microsoft. Hope this helps --Gillou a ?crit dans le message news: mailman.1005415299.17379.python-list at python.org... > Hi, > > I want to write an application for the hospital I'm working to. > > I'm newbie in python, and I want to hear some opinios about what are > the options I have.. > > The structure I have in mind is : At Server we will have an > application that handles business rules, connects to databases, and > send objects to the clients . > > At client we will have an wxPython application that will talk to the > server application > > Some things this application must provide > > * Ability to change the database > I think one way tho achieve this is via Object Relational mapper. > Have anyone implemented a library like this in python ? > > * Pool of connections. > In the application I have today all clients have their own > connections to the database. Today I'm using Interbase (free one) but > what if the hospital need a commercial database in the future ? With > a pool of connection we can spent less money, and this is issue in a > hospital in little city of Brazil. > > * The communication between the server and the client must be > encrypted. > Personal information of the patients can't run unencrypted over the > wire. > > > I know that this is difficult application to write, so I want to hear > some design hints, what are the difficulties I'm going to face. What > libraries I can use. > > > Sorry my english and thanks in advance > > Geraldo Lopes de Souza > > From DeepBlue at DeepBlue.org Fri Nov 2 10:47:40 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Fri, 2 Nov 2001 09:47:40 -0600 Subject: Freeware Python editor References: Message-ID: "Kemp Randy-W18971" wrote in message news:mailman.1004711165.22435.python-list at python.org... > I think of the whole concept of free having many facets. Imagine a cake was > baked and I was free to eat it. Now the cake can be made according to the > following methods: > 1. The cook makes the cake, gives it to us to eat, and doesn't share the > recipe. I am afraid it is not that simple. Let me demonstrate Oleg's point where he mentiones Tivo and replay TV, by a more refined example :O to show that the exchange of information is much more complex: Back in the Eigthies a French Physicist, Alain Aspect, conducted an experiment that came to be known as The Aspect Experiment - Let two elementary particles interact (the cook, and a consumer); then the particles go on their merry way; Aspect discovered, in a very distrubing way, that even though the particles are gone each on its way, that if you change the state of one of these particles, the other particle reacted **instantaneously** to reflect the change of state of the latter particle. In addition to the fact that The Aspect Experiment wrecks havoc on Einstein's notion of Locality, it shows beyond doubt that the exchange of information is much more complicated than the sheer notion of a cook not sharing the recipe with a user. On the contrary, the cook may not share the recipe, but he/she will always keep in touch with the unsuspecting user. The lease one can say is that the world of elementary particles is a nasty Orwellian World :) DeepBlue > 2. The cooks makes the cake, gives it to us to eat, and hands out copies of > the recipe. > 3. Several cooks try a variation of the cake, based on the original recipe, > and give it to us to eat. > Now there are probably other variations above, but from the philosophy of > pragmatism, I can have my cake, and eat it to. > > -----Original Message----- > From: Tim Peters [mailto:tim.one at home.com] > Sent: Thursday, November 01, 2001 11:37 PM > To: python-list at python.org > Subject: RE: Freeware Python editor > > > >> FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS > > [Delaney, Timothy] > > The PSU failed! A post about the PSU escaped to the world in its > > entirety! > > > > We are fre > > In case the intended word was "free", I'd like to point out that there are > different philosophies about free software, only one is correct, and > c.l.py's mission is to educate the world about which one that is. Don't > forget that extremism in defense of freedom is no vice. > > just-following-orders-but-don't-feel-good-about-it-ly y'rs - tim > > > From casinosoftw at mail.com Mon Nov 5 22:41:59 2001 From: casinosoftw at mail.com (CasinoBuildingSoftware.com) Date: Tue, 6 Nov 2001 04:41:59 +0100 (MET) Subject: you won't believe this Message-ID: OWN YOUR VERY OWN CASINO AND SPORTSBOOK! - NO PROGRAMMING skills necessary! - OPEN for business 24 hours per day - NO INVESTMENT required! - CUSTOM BRANDED website design! - Offer over 20 extremely popular and exciting games including: Blackjack Bacarrat Craps Roulette Pai Gow Slots ...and much more "...Internet Gambling is by far the fastest growing and most profitable business on the Internet today!" according to Steve Wynn, CEO of Mirage Resorts. With our state-of-the-art, easy to use software, you can now build your own Internet gambling website instantly and start capitalizing on a multi-bullion dollar industry which is still in its relative infancy. Unlike conventional dot com businesses, online gambling is a fast-growing, cash-rich business. Just imagine if you captured a fraction of 1% of the bets placed online. As the number of internet users increases exponentially, so will the amounts wagered online. The time to establish an online presence is now, before the next big surge in internet growth. You will receive 50% of all net winnings - the highest commission payout in the online gambling industry! You can expect to earn $3,000 - 5,000 plus a week! Best of all, this is 100% LEGAL. Don't believe it? Check out the web site http://www.CasinoBuildingSoftware.com for more details. ####################################################################### We strongly oppose the use of SPAM email and do not want anyone who does not wish to receive our mailings to receive them. As a result, we have retained the services of an independent 3rd party to administer our list management and remove list (www.removeyou.com). This is not SPAM. If you do not wish to receive further mailings, please click below and enter your email at the bottom of the page. You may then rest-assured that you will never receive another email from us again. http//www.removeyou.com The 21st Century Solution. I.D. # 032950 ####################################################################### From wtanksle at dolphin.openprojects.net Mon Nov 12 18:22:39 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Mon, 12 Nov 2001 23:22:39 GMT Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Message-ID: On Sat, 10 Nov 2001 01:30:38 +0000 (UTC), Huaiyu Zhu wrote: >On Fri, 09 Nov 2001 23:30:25 GMT, William Tanksley > wrote: >>What if slicing/indexing the "int" builtin resulted in a generator with >>the desired behavior? >>for x in int[10]: >>for x in int[1:11]: >>for x in int[1:11:2]: >Best proposal so far. Very kind of you. Of course, it's faint praise -- the previous proposals didn't look like they had any chance either. >># now some hard ones >>for x in int[0:]: # all the natural numbers >>for x in int[0::2]: # all the even naturals >>for x in int[:0]: # illegal >>for x in int[:0:-1]: legal, all negative numbers >The negative steps are tricky. The last one should be int[0::-1]. Ah. Unfortunately, you're right. An interesting special case. >But what would x[a:b:-1] do if x is an iterator? Maybe that's useful for a >"bidirectional iterator"? A unidirectional iterator would raise exception >and say "no attribute 'prev'" and the like. Setting up a starting point on an iterator is not a very clear concept, nor is setting a negative skip. Many iterators can handle it easily; others clearly can't. I seem to recall that the bytecode, and therefore function call, for [x], [x:y], and [x:y:z] are different. It's likely that the solution is to use the difference: if the iterator doesn't handle that type of "slicing", it shouldn't implement that method. >It might be useful to abstract out the slicing objects itself, which is used >in NumPy arrays. So 1:10:2 would be the syntax for creating a slicing >object. No, that's the same as the already-rejected PEP. It has no chance to survive. >To enable steps of other integers, you'd need an optional argument in next >class someiterator: > def next(self, step=1): No, you really wouldn't; I mean, it might be nice, but all you NEED is to call next() repeatedly. >>Wait -- a question. Do slices act on generators? That is, can I slice >>out every other item of a generator (as I just did above)? If not, could >>that be added? Once that's added, what's to stop me from annoyingly >>demanding to be able to slice out every 'n'th item (keeping the rest as >>part of the generated sequence)? Such a thing would feed my hunger for an >>interesting prime # sieve... >What would be the semantics? Is it iterate and discard, or simply jump? Jump would be ideal. Iterate and discard is the only currently generally possible semantics. I would suggest that just as all iterators have a next() method, so also some iterators could have a __slice_range__ and __slice_gap__ methods. If they don't have those methods, you can't use that type of slicing on them (just as if they don't have __getitem__ you can't do indexing on them). >>Wait, I'm hearing a voice. It tells me, "WRITE A PEP." >Well, go for it. :-) I can't right now -- I'm too busy resisting the temptation to write a PEP. Must ... resist ... >Huaiyu -- -William "Billy" Tanksley From rnd at onego.ru Wed Nov 7 13:24:54 2001 From: rnd at onego.ru (Roman Suzi) Date: Wed, 7 Nov 2001 21:24:54 +0300 (MSK) Subject: Creating a list of files in a directory In-Reply-To: Message-ID: On Wed, 7 Nov 2001, Jeff Klassen wrote: >Hello, > >I am new to Python. As a non-programmer I am encouraged by the level of >'success' I feel I have had, relative to similar learning attempts in other >languages. > >I would like to simply do the following: >- read all of files of a particular form (e.g. *.cev) from a particular >directory >- manipulate them with a series of re.sub expressions >- write each file to its own output file with a certain form (e.g. *.out). > >I have been able to create the re stuff, and process individual files. >However, I cannot get a for loop to do everything in a directory. > >Here is the code I came up with. (I am wanting to create a list of all files >that conform to *.cev) > >---------------------------- >import dircache >import re > >workingdir=dircache.listdir('/jobs/python/learning/') >filespec = re.compile(r'.*?\.cev') >filestoprocess = [] > >for allfiles in workingdir: > matchedfile=filespec.match(allfiles) > filestoprocess.append(matchedfile.group()) > >print filestoprocess >---------------------------- > >When I run this script I am returned: >AttributeError: 'None' object has no attribute 'group' There is glob module which allow to do it simpler: ------------------------------------------------------- from glob import glob filestoprocess = glob('/jobs/python/learning/*.cev') ------------------------------------------------------- Maybe, you will also need os.chdir(), os.path.basename() and os.path.dirname() functions to change into specific dir and analize file names. Also, do not forget map() capability to eval function for each list member. It could be useful while solving your problem. Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Wednesday, November 07, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "I used to be indecisive. Now I'm not so sure." _/ From shalehperry at home.com Fri Nov 16 21:41:31 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Fri, 16 Nov 2001 18:41:31 -0800 (PST) Subject: CGI output In-Reply-To: <63343bfd.0111161819.14263d83@posting.google.com> Message-ID: > > but I still can't manage to do it... How would I call my command so > that the output is displayed "continuously" to my user on the web page > ? > you can't, web pages don't work that way. From prabhu at aero.iitm.ernet.in Mon Nov 12 07:46:59 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 12 Nov 2001 18:16:59 +0530 Subject: Running program off CD In-Reply-To: <20011112110040.T11733@software.plasmon> References: <20011112110040.T11733@software.plasmon> Message-ID: <15343.50371.429963.434706@monster.linux.in> >>>>> "DS" == Dave Swegen writes: DS> I'm currently working on a project where I'd like to be able DS> to put python for various platforms on a CD and run it DS> directly off that, without actually installing anything on the DS> host computer. DS> As far as I can tell py2exe is what I want for win, but is DS> there anyhting similiar for un*x/linux? Is it enough to use DS> distutils and setting python path to point to the CD? Look at Gordon McMillan's installer. http://www.mcmillan-inc.com/install1.html It definitely works under Linux but you might need to work on it a bit to get things perfectly. How easy your task is going to be really depends on how complex your application is. Good luck. prabhu From arthur.siegel at rsmi.com Mon Nov 26 12:52:30 2001 From: arthur.siegel at rsmi.com (arthur.siegel at rsmi.com) Date: Mon, 26 Nov 2001 12:52:30 -0500 Subject: A permutation on permutations Message-ID: Phil writes - >BTW, if you change the 1st if statment to > if len(current) == len(source): >you can get rid of the (done) variable. But actually the 'done' variable is useful. By setting 'done' to 2 as an argument - if 'source' is 6 elements, I get back a list of the 4 element permutations of the 6 elements - excluding reversals as dups, of course. Happens to be useful functionality for what I'm playing with. Thanks again. Art From bmstroh at cavtel.net Sun Nov 25 19:45:33 2001 From: bmstroh at cavtel.net (Brent Stroh) Date: Sun, 25 Nov 2001 19:45:33 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> Message-ID: Hans Nowak wrote: >There's such a thing >as WinCVS, but the whole process strikes me as clumsy... checking >in and out and committing every time something changes... what is >the point of this? As someone who has spent some time in software configuration management, let me suggest that it might seem less clumsy if you rework your definition of when to commit. If you're in the middle of ongoing development, you don't need to commit after every line of code. You only need to commit when you feel it's a good idea to have a copy of a particular stage of development. Once you release this code to testers, the universe, whatever, you'll want to be sure you check in (and tag) each release level, to be sure you know what folks will be asking questions about. Bottom line: You only need to commit what you need to get back to. On projects with multiple developers, that changes a bit, but I've found my personal CVS repository for all of my tools and toys to be invaluable. >What happens if you forget a step? Does it have >substantial benefits over versioning your files by hand, aside from >having a repository through which you can undo changes? Letting the tool do versioning eliminates a lot of housekeeping and wasted disk space. It also removes a potential source of human error. IMO. From romany at actimize.com Tue Nov 20 13:14:42 2001 From: romany at actimize.com (Roman Yakovenko) Date: Tue, 20 Nov 2001 20:14:42 +0200 Subject: How to implement and call C++ class static function Message-ID: <7647A9F4B298E74DB6793865DA67285004B2F6@exchange.adrembi.com> For example class CBlaBla { static int Foo(){ return 0; } }; .... CBlaBla::Foo(); Thanks for the help. Roman. From michael.g.abbott at ntlworld.com Mon Nov 5 13:46:38 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Mon, 05 Nov 2001 18:46:38 GMT Subject: Problem formatting Python docs with MikTeX References: <66e0420f.0111051008.11b30844@posting.google.com> Message-ID: Michael Abbott wrote in news:Xns9150BE43AA185michaelrcpcouk at 62.253.162.108: > luecking at uark.edu (Dan Luecking) wrote in > news:66e0420f.0111051008.11b30844 at posting.google.com: > >> >> It would seem you have two choices: ... >> 2. Use a command line option. Quoting from the MiKTeX 2.1 manual: >> The command-line option --include-directory=folder allows you >> to extend the input search path for one invocation of TeX. > > Aha! I should have spotted that (I can't find *anything* in Windows > help file format documents...) > >> I can't immediately check if this option was available before version >> 2.1. > > Well, 2.1 will do just fine for me, thanks very much! Hmm. Well, now I have to hack mkhowto. This begs an interesting question: how do I detect whether I'm running MikTeX or something else? Seems a pity that key command line options aren't also standard for TeX programs. From mwh at python.net Wed Nov 14 05:34:12 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 10:34:12 GMT Subject: Stopping exception unwinding at exit References: Message-ID: "Sean 'Shaleh' Perry" writes: > On a related note, is there a way to tell python to NEVER drop a trace? Assign to sys.excepthook? It's fairly new. > Even if I have a global exception handler I find I can hit control-C > in the time between starting a script and the script executing. > This of course leads to a trace and looks quite ugly. Or you could install a handler for SIGINT. Of course, if you can hit ^C *really* quickly, you can do it before you can do either of these things. I don't think there's a startup option that suppresses tracebacks by default. If for some reason this is really important you could probably write a C wrapper that plays sigaction games. Cheers, M. -- In case you're not a computer person, I should probably point out that "Real Soon Now" is a technical term meaning "sometime before the heat-death of the universe, maybe". -- Scott Fahlman From walter at livinglogic.de Wed Nov 14 06:21:23 2001 From: walter at livinglogic.de (Walter =?ISO-8859-1?Q?D=F6rwald?=) Date: Wed, 14 Nov 2001 12:21:23 +0100 Subject: PEP proposal: enhanced string functions References: Message-ID: <3BF253B3.1010702@livinglogic.de> Stephen Ferg wrote: > PEP: XXX2 > Title: Optional argument for string strip functions An implementation of this is available as SF patch #424606 (http://sourceforge.net/tracker/?group_id=5470&atid=305470&func=detail&aid=424606) and has been rejected by Guido. Bye, Walter D?rwald From heiner.steven at nexgo.de Fri Nov 2 20:48:57 2001 From: heiner.steven at nexgo.de (Heiner Steven) Date: Sat, 03 Nov 2001 02:48:57 +0100 Subject: Objects for shell References: <3BE2B853.1B552F0B@philips.com> Message-ID: <3BE34D09.18467ADE@nexgo.de> Anthony Rangecroft wrote: > I was wanting to use objects with shell programming > and started on a script that lets me write things like: [...] The "shoop" project implemented object orientation using shell scripts: ftp://ftp.sourceforge.net/pub/mirrors/debian/pool/main/s/shoop/shoop_0.1.tar.gz and there is I book called "Unix Shell Objects" by Christopher A. Jones: http://www.amazon.com/exec/obidos/ASIN/0764570048 Heiner -- ___ _ / __| |_ _____ _____ _ _ Heiner STEVEN \__ \ _/ -_) V / -_) ' \ Shell Script Programmers: visit |___/\__\___|\_/\___|_||_| http://www.shelldorado.com/ From cliechti at gmx.net Thu Nov 29 16:16:46 2001 From: cliechti at gmx.net (Chris Liechti) Date: 29 Nov 2001 22:16:46 +0100 Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Message-ID: [posted and mailed] bigredlinux at yahoo.com (Dan Allen) wrote in news:28d73ad6.0111291249.6fb9b6eb at posting.google.com: > Say I have > > mylist = ['one','two','three'] > > which I presume is a "tuple" as I have been scanning the manual. Now, no thats a list. a tuple is is that: mytuple = ('one','two','three') the tuple can not be change, but a list can be changed. > is there a way to run the php-like function in_array() on this. > Consider this, I want to know if one of the values in that tuple is > exactly equal to "four". The answer of course is no, but how would I > find it. Here is what I have so far, which works, but it is ugly.. > > d = {} > for value in mylist > d[value] = 1 > try: > if d['four']: > print "your value was found" > except: > print "your value was not found" well thats a very long way to it... just type if 'four' in mylist: print "found" > Two question here, is that a bad use of try/except? Second is, is no, but you should specify the exception, otherwise you'll catch other exceptions that have nothing to do with the existence of a key too. except KeyError: ... in this case there is a solution without exceptions too: if d.has_key('four'): print "found" > there an array_flip, or do you just have to do what I did above? I > would imagine there is a way to search down the tuple. as sayed above use "in" chris > > Thanks! > > Dan > -- Chris From kzander at hot.rr.com Thu Nov 8 12:42:19 2001 From: kzander at hot.rr.com (Kristen Zander) Date: Thu, 08 Nov 2001 17:42:19 GMT Subject: Reading a comma delimited file References: Message-ID: <%tzG7.2971$qK.174060@typhoon.austin.rr.com> That cleared up alot becuase it was really becoming frustrating. I just figured it out. import fpformat a = 97.33532356246 b = fpformat.fix(a,2) print b 97.33 Great! Thanks. Skip Montanaro wrote in message news:E161rjE-00027T-00 at ttt17.tttech1.ttt... > > Kristen> Here's what it looks like when I'm done: > > Kristen> [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1, > Kristen> 20.0, 0.0, 167.30000000000001), > Kristen> ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0, > Kristen> 6.0999999999999996, 13.9, 0.0, 239.0)] > > Kristen> Just what I need except I don't want all those decimal places. > > You're being victimized by floating point (im)precision. Details here: > > http://python.sourceforge.net/devel-docs/tut/node14.html > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ From sfam at mailandnews.com Wed Nov 28 23:08:30 2001 From: sfam at mailandnews.com (Kaden) Date: 29 Nov 2001 04:08:30 GMT Subject: The Editor Poll results are in! References: <3bfd7f87@news.airtel.net> Message-ID: <9u4cbu$2ts$1@news.xmission.com> On Thu, 29 Nov 2001 12:45:50 +0900, Jonathan Gardner wrote: > On Thursday 29 November 2001 12:27 pm, marduk wrote: >> I move for a recount! > Yeah, right, I'm on to your scheme! This is what'll happen. First hthe > lawyers will swarm c.l.p, tying up traffic for months to come. Then the > counters will be dropping chads like dandruff. And then what about the > military absentee ballots? > > At the end of this mess, the mess that is to be your proposed recount, I > predict the winner will be: > > George W. Bush, c.l.p's favorite editor. ALRIGHT! Who's gonna pay for this pepsi ruined keyboard now?! From prabhu at aero.iitm.ernet.in Sun Nov 11 03:08:18 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 11 Nov 2001 13:38:18 +0530 Subject: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <3BED5AD8.24350.78407262@localhost> References: <033301c16a1a$59c1c690$c300a8c0@ericlaptop> <3BED5AD8.24350.78407262@localhost> Message-ID: <15342.12786.547708.67405@monster.linux.in> >>>>> "GMcM" == Gordon McMillan writes: [snipped off other issues raised] >> The current runtime overhead isn't so bad. GMcM> Under anything near normal usage, no - packages structures GMcM> are nearly always shallow. It wouldn't be much work to GMcM> construct a case where time spent in import doubled, GMcM> however. But that can be said of almost anything. A nicer question to ask is -- for most circumstances (99%) is the import mechanism fast enough? GMcM> When the "try relative, then try absolute" strategy was GMcM> introduced with packages, it added insignificant GMcM> overhead. It's not so insignificant now. When (and if) the GMcM> standard library moves to a package structure, it's possilbe GMcM> it will be seen as a burden. Yes, which is why maybe adding an 'rimport' keyword (which you suggested) would be a more conservative option? prabhu From weismann at netvision.net.il Sat Nov 10 09:34:51 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Sat, 10 Nov 2001 16:34:51 +0200 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> Message-ID: <003101c169f4$dc0dc070$3891003e@rashome> I don't know what comes after the "<" . It's not " Newsgroups: comp.lang.python To: Sent: Saturday, November 10, 2001 3:22 PM Subject: Re: " Amit Weisman writes: > > > SGMLParseError: unexpected char in declaration: '<' > > > > I can only guess The parser met a "< " and not a " > enough to be sure . > > What should I do to avoid it ? > > What is it ? > > Hard to tell, since you never cared to report what data are following > the > > > or is it rather > > > > ??? Python expects a name after the error. > > Regards, > Martin > > -- > http://mail.python.org/mailman/listinfo/python-list > From syver-en at online.no Thu Nov 22 13:03:36 2001 From: syver-en at online.no (Syver Enstad) Date: 22 Nov 2001 19:03:36 +0100 Subject: locale.setlocale not working anymore? python 2.1 Message-ID: Or is it just my machine? (win2k) Running locale.py as a standalone script produces Locale settings after calling resetlocale(): ------------------------------------------------------------------------ Traceback (most recent call last): File "", line 732, in ? File "", line 695, in _print_locale File "", line 384, in resetlocale locale.Error: locale setting not supported -- Vennlig hilsen Syver Enstad From mind.tech at verizon.net Sun Nov 25 15:19:46 2001 From: mind.tech at verizon.net (Power-Tech) Date: Sun, 25 Nov 2001 20:19:46 GMT Subject: WINDOWS USERS???? Message-ID: <3C0152F1.6541D8C2@verizon.net> Hello, I've downloaded the regular Python and had some problems running the .py files, today I found that "ActivePython" should be the best download for windows users.... Can anyone throw some light on this? I am also a first time programmer (which means my only previous experience was with HTML, and some scripting language), does anybody knows about a good tutorial online for someone in my situation? Is this group too advanced for me? I appreciate your attention Willie From jeremy at zope.com Mon Nov 12 11:33:19 2001 From: jeremy at zope.com (Jeremy Hylton) Date: Mon, 12 Nov 2001 11:33:19 -0500 (EST) Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <15343.61552.414932.44100@monster.linux.in> References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> Message-ID: <15343.63951.137972.487852@slothrop.digicool.com> >>>>> "PR" == Prabhu Ramachandran writes: PR> Ummm doing an 'import os' will import the package1/os.py and PR> *not* the standard one. This will happen even though os.py was PR> imported earlier by site.py. This is what Gordon was objecting PR> to in the first place and why he proposes using rimport, PR> rrimport etc. to make things more explicit. Of course, you can use the existing mechanism to do this: 'from package1 import os'. The use of an explicit name seems like the clearest route when you have a package-local module that shadows a top-level module -- no need to understand details of relative imports, no question about what is intended by the code. I haven't followed this thread closely. Is there some reason that explicit names in imports is not sufficient? Jeremy From babu at mail.premiertechnologygroup.com Thu Nov 8 06:53:46 2001 From: babu at mail.premiertechnologygroup.com (babu) Date: Thu, 8 Nov 2001 17:23:46 +0530 Subject: Help! Message-ID: <001f01c1684c$096790f0$1900a8c0@ptgdomain.com> I need a help from you. Currently i am working with Pyhon and done some windows programming using Tk. How can i write a program to interact with IIS using Python. (i.e) Creating ASP pages using Python Script. I seached lot of site, but all will give in Unix Platform. So Please some related links about web programming in Python Thanking You From logiplexsoftware at earthlink.net Thu Nov 1 14:58:26 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 1 Nov 2001 11:58:26 -0800 Subject: python development practices? In-Reply-To: References: Message-ID: <01110111582600.08187@logiplex1.logiplex.net> On Wednesday 31 October 2001 15:57, Chris Tavares wrote: > This scenario is precisely why the two underscore name mangling scheme was > added to python. Rewrite your example as: > > class Base: > def __init__(self, x): > self.__x = x > > def print_base_x(self): > print self.__x > > class Derived( Base ): > def __init__(self, base_x, dev_x): > Base.__init__(self, base_x) > self.__x = dev_x > > def print dev_x(self): > print self.__x > > d = Derived( 5, "hi there!" ) > > d.print_base_x() > prints 5 > > d.print_dev_x() > prints Hi There! > > So, the mechanism you're asking for is already there. Wether it's pretty or > not is a different question. But it does work, and it's implemented now. Admittedly this is true. Unfortunately, it requires double underscores on _every_ attribute you want protected (that is, when using the "black box"/every-attribute-changes-by-get/set-methods). Not only ugly, but rather non-Pythonic (IMHO). All I'm saying is it would be *nice* to have a statement specifying that all the attributes within a certain scope are private (in effect, doing the double underscore behind the scenes). Others have suggested that since you can read the source for a class you are deriving from, this is a non-issue. However, if I derive from some class (perhaps from the standard library), I don't want to be burdened with verifying that there are no collisions between the base class's attributes and any attributes I may have added in my derived class. Especially since a new version of the base class may introduce new attributes that cause the collision. Unless _every_ class distributed for public consumption has all of it's attributes prefixed with double underscores, this is bound to happen. As far as people who want to derive from a class and have access to those protected attributes, they will obviously need to read the source for the base class anyway, so really, it doesn't place any additional burden on them (except perhaps, having to make a few attributes public in the base class - not a big deal). Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From rupole at hotmail.com Thu Nov 8 07:49:33 2001 From: rupole at hotmail.com (Roger Upole) Date: Thu, 8 Nov 2001 07:49:33 -0500 Subject: Disk explorer from python with COM References: <3BE91448.5020809@ulb.ac.be> Message-ID: <3bea78df_5@corp-goliath.newsgroups.com> Don't know if this is exactly what you want, but it opens a standard Windows browse for file dialog. import win32com.client dlg = win32com.client.Dispatch('{F9043C85-F6F2-101A-A3C9-08002B2F49FB}') def getfile(initdir,initfilename,mustexist=0,dlgtitle=''): dlg.DialogTitle=dlgtitle dlg.MaxFileSize=256 dlg.InitDir=initdir dlg.FileName=initfilename if mustexist: dlg.Flags=0x1000 ####cdlOFNFileMustExist else: dlg.Flags=0 dlg.ShowOpen() return dlg.FileName HTH Roger Upole "Benoit Lagrange" wrote in message news:3BE91448.5020809 at ulb.ac.be... > Hi all > I am wondering wether it is possible to browse the disk from a python > application by using COM. > And if it is possible, how to use it? > Any help would be great. > Thanks > > Benoit Lagrange > ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net From loewis at informatik.hu-berlin.de Fri Nov 2 13:02:11 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 02 Nov 2001 19:02:11 +0100 Subject: fcntl semantics References: <9rsgg902rct@drn.newsguy.com> Message-ID: buzmeg at newsguy.com writes: > All the information from the C function fcntl is accessible without > any of the nasty OS/compiler dependence. It is not. Systems vary in what "cmd" args they accept for fcntl(2), so Python would need to know in advance what all possible commands for fcntl are, and also know what the corresponding args are (fcntl really is a varargs function). If Python was changed to expose a set of well-known commands, you'd lose flexibility: if you use a system that offers an unsupported command, you could not invoke this command. Currently, you can. Regards, Martin From stephen at stephencox.org Sat Nov 24 14:33:52 2001 From: stephen at stephencox.org (stephen cox) Date: Sat, 24 Nov 2001 19:33:52 GMT Subject: Newbie question References: <1puL7.12600$MI2.1847665@typhoon.jacksonville.mediaone.net> Message-ID: > Zope comes along with its own http server. However you can use Zope also > via a cgi which is called *pcgi* or by hiding Zope behind a proxy. >From my reading I get the impression that as long as I can get Python to run as a CGI under IIS5 then Zope will run. After downloading Zope I realized that it too came with Python.. I'd rather just have one copy of Python on my machine... is it just a matter of running Zope with my version of Python? -- Stephen Cox web.net geek for non-profits, political campaigns, and a few socially conscious businesses. stephen at stephencox.org From gb at cs.unc.edu Fri Nov 9 08:36:18 2001 From: gb at cs.unc.edu (gb at cs.unc.edu) Date: 09 Nov 2001 08:36:18 -0500 Subject: Fatal Python error: ceval: tstate mix-up References: Message-ID: "Robin Dunn" writes: > It is safe, and is called from within the wxPostEvent function as well. > > Are you by chance on a SMP box? There was a long standing bug that only > showed up when using threads on an SMP machine that manifested as a tstate > problem. The bug has been squashed in the 2.3.2 beta version. > Hey! Hey! I bet that is it. I'm running on a dual-processor at work and a single processor at home. I never see this problem on the uni-processor. So, if I set the processor afinity mask I should be able avoid this problem. Or, I can upgrade to 2.3.2beta. Is there already an interface to set processor afinity mask? Or will I need to write one? Thanks gb From not.this at seebelow.org Fri Nov 2 17:25:14 2001 From: not.this at seebelow.org (Grant Griffin) Date: 2 Nov 2001 14:25:14 -0800 Subject: Freeware Python editor References: <9ruu6l09ah@drn.newsguy.com> Message-ID: <9rv6ga0108t@drn.newsguy.com> In article , Cliff says... > >On Friday 02 November 2001 12:03, Grant Griffin wrote: >[snip] free [snip] free [snip] .... [snip] > >Since you mentioned the word "free", I'd like to take this moment to disagree >with you. About which part? (And no fair saying "all" .) trying-desperately-to-rehabilitate-my-trolling-efficiency-ratio-ly y'rs, =g2 _____________________________________________________________________ Grant R. Griffin g2 at dspguru.com Publisher of dspGuru http://www.dspguru.com Iowegian International Corporation http://www.iowegian.com From tim at vegeta.ath.cx Fri Nov 16 08:06:42 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 16 Nov 2001 13:06:42 GMT Subject: OT: Mobile Internet Toolkit EULA References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> <9t1lr3$adu$1@newshost.accu.uu.nl> Message-ID: Tim Hammerquist graced us by uttering: > Martijn Faassen graced us by uttering: >> [free software, open source, licenses, microsoft, oh my, oh my] >> >> Excellent work folks -- we're adding centuries to the lifetime of the >> universe this way. >> >> The PSU thanks you. > > Would it help if I called Microsoft a bunch of fascists? > > Or would I actually have to call them nazis to end the thread? > > Damn! I went and jinxed it! Tim Hammerquist -- Nothing so needs reforming as other people's habits. -- Mark Twain, "Pudd'nhead Wilson's Calendar" From tim.one at home.com Tue Nov 6 00:32:19 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 6 Nov 2001 00:32:19 -0500 Subject: Program very slow to finish In-Reply-To: Message-ID: [Tim] > This does everything the DECREF macros did *except* to call the platform > free() on the now-dead string-object keys. [Rainer Deyke] > It also doesn't call the destroyed objects' destructors. In the test program, the dict keys were string objects, and the string object destructor consists solely of calling the free(). From phr-n2001d at nightsong.com Thu Nov 15 19:53:54 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 16:53:54 -0800 Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> Message-ID: <7xg07fwn6l.fsf@ruckus.brouhaha.com> "Stuart D. Gathman" writes: > I have been putting my thoughts toward the elusive goal of making python > as fast as some LISP dialects. The way to do that is with a compiler. Speeding up access to globals may help a little, but probably not nearly as much. From h.jehadalwan at student.kun.nl Sun Nov 4 06:59:56 2001 From: h.jehadalwan at student.kun.nl (Husam) Date: Sun, 04 Nov 2001 12:59:56 +0100 Subject: How can i retrieve a key from a dictionary? References: <3BE519E0.34312B48@student.kun.nl> Message-ID: <3BE52DBC.724B1C6F@student.kun.nl> Prabhu Ramachandran wrote: > >>>>> "HJ" == Husam writes: > > HJ> how can one retrieve or select a key from a dictionary? > HJ> dict={} dict[1]='one' dict[2]='two' > > HJ> dict.keys() will gets all the keys. but, i need to select > HJ> explicitly one key for printing along its value. > > Try this: > > dict.keys()[dict.values().index('one')] > > prabhu it works, but wat does the -index- means? From headroom02 at gmx.de Wed Nov 7 16:36:58 2001 From: headroom02 at gmx.de (Gernot) Date: Wed, 7 Nov 2001 22:36:58 +0100 Subject: Capturing screen on MS-Windows References: <3BE988A4.94B8760B@olen.to> Message-ID: <9sc9lm$cds$02$1@news.t-online.com> "Joonas Paalasmaa" schrieb im Newsbeitrag news:3BE988A4.94B8760B at olen.to... > Is it possible to somehow capture screen on Windows with Python? Ctrl + Alt + PrintScreen then open Windows Paint, and paste (use the menu), then you can save the file. Gernot From prabhu at aero.iitm.ernet.in Mon Nov 19 02:56:26 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 19 Nov 2001 13:26:26 +0530 Subject: No, not THAT Python, THIS Python! In-Reply-To: <5.1.0.14.0.20011118140515.00a0fec0@thewebsons.com> References: <5.1.0.14.0.20011118140515.00a0fec0@thewebsons.com> Message-ID: <15352.47914.377014.144821@monster.linux.in> >>>>> "BO" == Ben Ocean writes: BO> Hi; My server has 2 installations of python: 1.5 and BO> 2.1.1. Now that Zope uses 2+, I've switched everything BO> over. I'd like to install Tkinter, but when I try to install BO> the rpm for 2.1.1 I get an error instructing me that I need BO> Python 2.1.1 in order to proceed. How do I inform Linux (RH BO> 7.1) that I do indeed have python2-2.1.1? TIA, BenO I guess you installed Python-2.1.1 from a source tarball? If that is the case, you could simply rebuild/re-install 2.1.1 along with Tkinter support. If OTOH your Python-2.1.1 was installed from an RPM its likely that the rpm you installed is broken or the tkinter rpm you are trying to install is looking for a different rpm to be installed. You can try and search for an appropriate rpm from rpmfind.net. AFAIK, there is no way you can tell a packaging system about stuff you install outside of the system. prabhu From cliechti at gmx.net Fri Nov 9 17:37:49 2001 From: cliechti at gmx.net (Chris Liechti) Date: 10 Nov 2001 00:37:49 +0200 Subject: String Search. References: Message-ID: "Adonis Vargas" wrote in news:IwZG7.442$EL1.358521 at newsrump.sjc.telocity.net: > i posted a thread before asking help on how to find a specific string > within a line of string, i unfortunately did not get too specific on > what i was asking for. how can i do a search within a string using > wildcards? i.e.: > (pseudocode) > if "*something*is*" in "something is written here": return true return re.search("something.*is", "something is written here") is not None it returns a match object if the string was found or None otherwise. you dont need to care about the match object in your case but it can become handy when you add groups in the regular expression. the "." stands for "any character" and "*" for any number of the preceding object, so ".*" matches for a string of any length with any character in it you don't need the wildcard at the beginning or at the end as regexps have special characters for start ("^") and end ("$"). > ive looked into the re module and have been to the how-to pages, but i > cant seem to understand it. at first regular expressions may look strange but when you get used to them you won't understand how you could have lived so long without them ;-) chris > any help would greatly be appreciated. > > Adonis > -- Chris From gmuller at worldonline.nl Sat Nov 10 08:57:24 2001 From: gmuller at worldonline.nl (GerritM) Date: Sat, 10 Nov 2001 14:57:24 +0100 Subject: Teaching python (programming) to children References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> Message-ID: <9sjc1c$bei$2@nereid.worldonline.nl> "John Roth" schreef in bericht <...snip..>> Then possibly the decision to make exceptions classes was > wrong from a tutorial veiwpoint? Technically, it was the > right decision, but it does shove exception handling rather > late, after classes have been introduced. > > John Roth I didn't even realize exceptions are classes until reading this message... I am using Python for more than one year now and did not need this knowhow at all, even not when using exeptions. Regards Gerrit -- www.extra.research.philips.com/natlab/sysarch From cliechti at gmx.net Mon Nov 19 16:06:03 2001 From: cliechti at gmx.net (Chris Liechti) Date: 19 Nov 2001 22:06:03 +0100 Subject: conversing with the shell References: Message-ID: [posted and mailed] Michaell Taylor wrote in news:mailman.1006199365.9092.python-list at python.org: > I am looking to build a VERY simple load balance app for batch job > submission on several linux machines. The basic structure that I have > in mind is. > > For M in list_of_machines: > fm = 'rsh '+M+' "cat /proc/meminfo"' > fcpu = 'rsh '+M+' uptime' > freemem = SOMECOMMAND(fm) > freecpu = SOMECOMMAND(fcpu) > . > . > parse output of freemem and freecpu > . > . > . > select machine > submit job using rsh > > BUT... > > Problem is of course the SOMECOMMAND lines. I need to query the shell > for input and then read that input in as a variable. I could use the > shell commands to redirect the output to a file and then read the file > with python, but this seems like a waste. os.popen commands you could also make one rsh call out of it: fmcpu = 'rsh '+M+' "cat /proc/meminfo;uptime"' and i wouldn't run rsh on a machine that is connected to the internet. use ssh instead (and use at least passwords, best make a new account on these machines only for that purpose, RSH authentication is even better). chris > FYI, there are only 6-8 machines and fairly low frequency usage, so > larger load balancing seems like overkill. > > Thanks in advance > > Michaell > > > -- Chris From idot at vt.edu Mon Nov 12 17:54:26 2001 From: idot at vt.edu (Carl Banks) Date: Mon, 12 Nov 2001 22:54:26 +0000 (UTC) Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> Message-ID: <9spjv1$6h5$4@solaris.cc.vt.edu> Laura Creighton wrote: > One defect that most GUI books I am aware of suffer from is that they > are written almost exclusively from the point of view of providing > ways for users to provide _input_ to your program, database, or whatever. It's not just the GUI books. The GUIs often are written almost exclusively from that point of view, only tacking the external asynchronious stuff on as an afterthought. > This is easy to teach, and works well with the philosophy that the > user should be in complete control, and that nothing should happen > until the user asks for it, by clicking a button or whatever.... > > And then, on your first job, you have to write code that handles > real-time updates of a package tracking system. Many people need > to write applications where the user _is_ a passive receiver of > data. This is hard to do well, and worth a chapter all to itself, > in my opinion. I totally agree. I'm thinking a good example program would be something along the lines of an IM client. I would guess you don't want to use a black box library to handle the protocols (so that users can experiment), so maybe it's not that good an idea. Or maybe a flight simulator would be a good example. That shouldn't more than a few pages. ;-) -- CARL BANKS From tim.one at home.com Mon Nov 5 19:03:35 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 5 Nov 2001 19:03:35 -0500 Subject: Teaching python (programming) to children In-Reply-To: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: [Hung Jung Lu] > I have my doubts about Python being the first programming language to > teach. I see all too many newbies running into the problem of > namespaces. How do you explain to them that "from xyz import *" is a > bad thing, if they don't even understand what's going on behind the > scene? You don't teach them about "import *" at first. Neither metaclasses, nor that the result of adding two signed float zeroes can depend on the hardware rounding mode in effect . > Also, how in the world can beginners understand what a hash > table mean? There's a reason they're called "dictionaries" in Python instead of "hash tables": if a kid is old enough to look up a definition in a real-life dictionary, they're old enough to understand the essential nature of a Python dict. The ABC language (Python's closest predecessor) was specifically designed for first-time programmers, and testing with newbies confirmed that dicts (one of only two builtin ABC container types) weren't hard to master. Goodness, just picture having to teach one of the alternatives (I'm picturing teaching balanced AVL search trees ). > Are we going to tell them something like: "oh well, think of Python > dictionary as a magic black box, you'll understand it later > when you take a course in C/C++"? Of course! They don't need to study circuit design to add two integers effectively either. "An association" is an everyday concept, and how it's implemented is irrelevant to correct use (BTW, and unlike Python, ABC did use AVL trees under the covers -- but ABC dict *semantics* were much the same as Python's). even-a-"print"-statement-is-heavy-duty-stuff-if-look-deep-enough-ly y'rs - tim From sill at optonline.net Mon Nov 5 20:14:19 2001 From: sill at optonline.net (Andrei Kulakov) Date: Tue, 06 Nov 2001 01:14:19 GMT Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> Message-ID: On Mon, 5 Nov 2001 15:57:25 +0800, Edy Lie wrote: > Hi Everyone, > > I am totally a new python wannabe coder. I have been switching between > python and perl last few months. In Perl i could code some small scripts > which does the work i wanted to but somehow in my mind it has been telling > me that python is my choice. > > I have some doubts here > 1. I would really want to learn this lang (What should i do?) i know instead > of asking here i should start coding but i have no idea what should i code. > Is there anyone in here willing to conduct a small class or at least giving > out exercise to newbies to code ? > > 2. Another thing when doing coding if i am facing problem i tend to stop or > rather wanted to learn everything in a day or as fast as i could which i > believe is a wrong approach. Is there anyone kind enough to give me some > direction in order i could code something useful. > > Thanks for all the advices. > > Regards, > Edy Lie. Start with shell scripts, and when you're ready code some small app like a mail client.. or a window manager.. or a newsgroup reader. Something simple but useful to you. > > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From qrczak at knm.org.pl Mon Nov 19 16:58:20 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Mon, 19 Nov 2001 21:58:20 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> <3BF47762.4322913A@engcorp.com> Message-ID: Mon, 19 Nov 2001 20:07:42 +0000 (UTC), Huaiyu Zhu pisze: > What would such examples look like? I can only think of cases where the > problems are caused exactly by (a is b) and (a!=b) both being true. They > would dissappear if (a is b) implies (a==b). They would be hidden, but the buggy implementation of == is still there. It probably incorrectly says "inequal" also for some a,b where a is not b but they should be equal. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From philh at comuno.freeserve.co.uk Sun Nov 25 19:06:34 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 26 Nov 2001 00:06:34 +0000 Subject: A permutation on permutations References: Message-ID: On Sun, 25 Nov 2001 15:09:38 -0500, Arthur Siegel wrote: >Phil writes - > >>Can you have the same number appearing twice, e.g. [1,2,3,3] ? > >Actually I hadn't considered double points for what I'm doing. >But I believe that the universe of unique curves would >include curves with double point args. I'll play with it and see >if I can get a better criteria for unique curves. > >>>So am a looking for a function to return all >>>permutations, excluding duplicates as defined above. > >>Consider the following source: > >>def perm(source, done=0, current=[]): >> if done == len(source): >> if current[0] < current[-1]: #removes reversals >> print current >> else: >> for i in source: >> if i not in current: >> perm(source, done+1, current+[i]) > >Works nice, but I haven't found a great way to get a return >value. Using a global L=[] in the calling code and >an L.append(current) at "print current" in the perm func. That should do the job; or you could pass the list of all permutations as a second parameter. BTW, if you change the 1st if statment to if len(current) == len(source): you can get rid of the (done) variable. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From tjreedy at home.com Thu Nov 1 22:23:47 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 02 Nov 2001 03:23:47 GMT Subject: How to pass objects to a function? References: <4a0341c8.0111011723.53246ecd@posting.google.com> Message-ID: <7loE7.170585$5A3.63947299@news1.rdc2.pa.home.com> "Shankar" wrote in message news:4a0341c8.0111011723.53246ecd at posting.google.com... > I am a python newbie. OK > How do I pass a user defined object to a function? By, for instance, invoking a name bound to such as object, much as in any other language. > if I have something like > > def func(session, url): > ... > .... > > and session is supposed to be an object of httpsession class, how > would the interpreter know about it? When it compiles the function, it does not. Names, including argument names, do not have types. Only objects do. When you call the function, see below. > I suppose all arguments are treated as strings. NO<). *Every* Python object is knows what type it is. type(object) queries the object as to its type and returns the response. Every argument becomes a reference to an object which the function uses to get ahold of the object. > so, if I invoke a method such as session.getreply() or something I > would get an error. If session has method getreply() taking no args, why should it? (I doesn't) Terry J. Reedy From dalke at dalkescientific.com Tue Nov 13 09:22:20 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 07:22:20 -0700 Subject: How much is set in stone? References: Message-ID: <9sraco$35f$1@nntp9.atl.mindspring.net> Tim: >Oddly enough, cPickle rejects that pickle [which passes an arbitrary >string to os.remove] (it only deletes the file when >using pickle.py). I assume it's checking for a ClassType. By testing, yes. The following is a pickle of tempfile.TemporaryFileWrapper(StringIO.StringIO(""), "remove.me") "(itempfile\012TemporaryFileWrapper\012p1\012(dp2\012S'file'" + \ "\012p3\012(iStringIO\012StringIO\012(dp4\012S'closed'\012p5" + \ "\012I0\012sS'len'\012p6\012I0\012sS'buf'\012p7\012S''\012sS'" + \ "buflist'\012p8\012(lsS'softspace'\012p9\012I0\012sS'pos'\012" + \ "p10\012I0\012sbsS'path'\012p11\012S'remove.me'\012sb." [dalke at pw600a ~]$ touch remove.me [dalke at pw600a ~]$ cat remove.me [dalke at pw600a ~]$ ./python Python 2.2b1+ (#8, Nov 8 2001, 20:45:09) [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> s = "(itempfile\012TemporaryFileWrapper\012p1\012(dp2\012S'file'" + \ ... "\012p3\012(iStringIO\012StringIO\012(dp4\012S'closed'\012p5" + \ ... "\012I0\012sS'len'\012p6\012I0\012sS'buf'\012p7\012S''\012sS'" + \ ... "buflist'\012p8\012(lsS'softspace'\012p9\012I0\012sS'pos'\012" + \ ... "p10\012I0\012sbsS'path'\012p11\012S'remove.me'\012sb." >>> import cPickle >>> cPickle.loads(s) >>> 0 0 >>> ^D [dalke at pw600a ~]$ cat remove.me cat: remove.me: No such file or directory [dalke at pw600a ~]$ The '0' is to force '_' to get rid of the reference to a TemporaryFileWrapper, whose destructor closes the StringIO then removes the given filename, which is 'remove.me' >We'll try to repair that for 2.2. In particular, you can set a find_global >attribute on a cPickle Unpickler to supply your own function for resolving >names, and of special interest is that if you set it to None, the Unpickler >won't import modules or unpickle class instances at all. You could, of >course, also supply a function that accetps only a set of blessed names >(etc). Sure, and it was doable in pickle.py as well by making a subclass and overriding the find_class method (example shown elsewhere). But I didn't know I needed to do that, and it's hard to figure out which classes are okay to pickle safely. Some of my own classes have these sorts of filesystem cleanup code in __del__. So pickles are hard to use safely for insecure-but-non-trivial data. Hope this is all documented in nice friendly letters. Andrew dalke at dalkescientific.com From db3l at fitlinxx.com Tue Nov 6 16:43:54 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Nov 2001 16:43:54 -0500 Subject: Exception holes, again. References: Message-ID: Dale Strickland-Clark writes: > Traceback (most recent call last): > File "I:\BATCH\tests\testreg2.py", line 6, in ? > print win32api.RegQueryValueEx(key, 'Spam') > pywintypes.api_error: (2, 'RegQueryValueEx', 'The system cannot find > the file specified.') > > Doesn't tell you much, does it! Well, the error is clear, but yes, the error object name can be misleading. The confusing part I think is that the underlying object always displays itself as pywintypes.api_error, but is referenced as the "error" object from all of the win32 modules (including pywintypes itself) and not "api_error". Thus, if you import win32api, you can reference the error object with "win32api.error", but during a traceback it still prints as pywintypes.api_error. >>> import win32api >>> print win32api.error pywintypes.api_error But the object is also defined in pywintypes: >>> import pywintypes >>> print pywintypes.error pywintypes.api_error and you can use pywintypes.error as an exception class to trap errors in any of the win32 modules. I think (but haven't looked at the source for a while) that there's really only a single API error object, and the other modules just contain references to it, thus they all print as the same object, and it's primary existence is in the pywintypes module. Yep, that seems to be the case: >>> import pywintypes, win32api >>> print id(pywintypes.error), id(win32api.error) 8358240 8358240 > I've tried to find pywintypes but can't and I had a hunt through the > Python directories to see if I could find the definition but came up > with nothing. This and pythoncom is a strange case. Both exist as DLLs in your system directory, but based on a Python release (e.g., PyWinTypes15.dll or PyWinTypes21.dll). There is then a registry entry (under HKLM\Software\Python\PythonCore\#.#\Modules\pythoncom) that references the appropriate DLL module out of the system directory. It's the registry key name that is used as the module name, thus just "pywintypes" can be used rather than "pywintypes15". I'm not positive why things were structured this way (the win32 extensions are the only uses of that Modules key that I've seen, but I'm sure Mark had a good reason), but it may have something to do with how the code may be invoked via COM or services, or whatever. This also can confuse packagers like installer or py2exe too so it's sort of a pain. But it's this translation that occurs when pywintypes or pythoncom is imported. -- -- 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 kseehof at neuralintegrator.com Wed Nov 14 17:27:12 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Wed, 14 Nov 2001 14:27:12 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <014501c16d77$af505da0$7a93b23f@kens> If this was Perl, making an iterator for integers would be perfect. It allows for a minimalist expression regardless of consistency and intuitive appeal :-) for i in 10: print i - Ken From peter at engcorp.com Wed Nov 28 18:47:58 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 18:47:58 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> <3C053BF3.8B0CC128@ccvcorp.com> Message-ID: <3C0577AE.CAB70BDC@engcorp.com> Jeff Shannon wrote: > > Huaiyu Zhu wrote: > > > An easy and brutal solution is to mandate that tab is the only indent > > charactor. A better long term solution is to write a smarter > > python-mode for your editor. > > An easier and less brutal solution is to mandate that space is the only > indent character. It's easier to teach your editor to convert tabs to > spaces as you type them, than it is to teach every single person who might > ever want to write a short Python script that spaces don't work. I believe I like this approach a lot. Anyone know how to run a script on cvs checkin to reject .py files containing tabs? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fperez528 at yahoo.com Sun Nov 25 11:26:16 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 26 Nov 2001 15:54:16 +2328 Subject: IDLE improvement? References: <3C02AFA3.15D439FC@home.net> Message-ID: <9tuh83$c7o$1@peabody.colorado.edu> Chris Barker wrote: > forgotten gentleman wrote: >> - The interactive prompt's memory is cleared and restarted > > This is very difficult in an IDE that is running in the same interpreter > as the code. There is no easy way to "clear and restart" the interactive > prompt > > too bad, it's a feature I'd like to see. In a few days I'll announce IPython, a project I'm working on which is a replacement for the interactive prompt with a ton of enhancements. This is one of the features it supports (it may not be perfect, but seems to work for me). Something like IDLE could (if it wanted to) use IPython for its prompts. Cheers, F. From nbecker at fred.net Thu Nov 1 15:01:11 2001 From: nbecker at fred.net (N Becker) Date: 1 Nov 2001 12:01:11 -0800 Subject: Python 2.2 release schedule? Message-ID: <1f5252d4.0111011201.15fab7bf@posting.google.com> Any rough idea of expected Python 2.2 release date? From wurmy at earthlink.net Wed Nov 21 19:46:29 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Thu, 22 Nov 2001 00:46:29 GMT Subject: getting modules optionally References: <3BFC2647.D9692B49@gol.ge> Message-ID: <3BFC4AE3.F170D048@earthlink.net> Giorgi Lekishvili wrote: > What I can not do is to import the module, if I have its name as > string. > > modname='ThisModule' > > Of course, the code below doesn't work: > > from MyPackage.modname import * > > The question: is there something like eval function, which could > transfer the string as the real module name? In other words, how have > I to treat the modname to make this code running? Well, you can use exec: exec "from MyPackage.%s import *" % (modname) Since "from .. import *" is usually not recommended, you might want to use __import__: modname = __import__("MyPackage."+modname) HTH, From James_Althoff at i2.com Wed Nov 28 16:49:55 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 13:49:55 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Jim wrote: >Lulu wrote: >> >>> if i in 100: print 'even Natural' # I have no idea what this MEANS! > >Small point, but it would just mean the same as: > > >>> if i in xrange(100): > >as in, e.g., > > >>> i = 2 > >>> if i in xrange(100): > ... print 'spam' > ... > spam > >>> > >You just wouldn't have to read or write the xrange thing. :-) > >Jim And this might be handy in common situations where you could write, for example: if index not in len(mylist): print 'index out of range' instead of if index not in xrange(len(mylist)): print 'index out of range' Jim From sdurity at cornercap.com Tue Nov 6 13:40:51 2001 From: sdurity at cornercap.com (Sean R. Durity) Date: Tue, 06 Nov 2001 13:40:51 -0500 Subject: Plug-in for Eclipse? Message-ID: <3BE82EB3.1090100@cornercap.com> Does anyone know if there is a Python plug-in for IBM's newly Open Sourced Eclipse workbench? From mail at cliffpruitt.com Tue Nov 6 01:09:04 2001 From: mail at cliffpruitt.com (Cliff Pruitt) Date: Mon, 05 Nov 2001 22:09:04 -0800 Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: Well I thank you all for the great insight. The truth is I think it will be a very long time before I get anywhere with C++, at least farther than some kind of basic "hello world" stuff. I dont seem to be the best person arround at wrapping my head around syntax and all that (thats my nice way of saying I learn very slowly when it comes to programming languages). I guess my main concern what that I'd get into Python and find out that I couldn't develop a full application without getting into C++ or something. Admittedly C++ is probibly a lot more powerful, but this is just a hobby to tinker with for me. Does anyone know of a Database format I could use on a Macintosh? I know access willwork on my Win machine, but I'd liek to play with Mac OS primarily. Am I correct in understanding that Python will let you create GUI elements (windows, buttons, dialogue boxes, ect...)? Thanks so much! This seems like a very friendly newsgroup. -- C. Pruitt mail at cliffpruitt.com http://www.cliffpruitt.com > From: "Delaney, Timothy" > Organization: Baymountain > Newsgroups: comp.lang.python > Date: Tue, 6 Nov 2001 12:23:11 +1100 > Subject: RE: Considering getting into Python... Any Pros-Cons? > >> From: d_blade8 at hotmail.com [mailto:d_blade8 at hotmail.com] >> >> I agree with everything said here (for the most part), but I think it >> is all a bit biased (most readers of this newsgroup are python progs) > > Actually, only a few readers are python progs ... see the effbot, TimBot, > MartelliBot, etc. > > Tim Delaney > From robin at jessikat.fsnet.co.uk Thu Nov 15 15:07:56 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Thu, 15 Nov 2001 20:07:56 +0000 Subject: PIDDLE/SPING?? References: <7d38vt0br1abnvg30j9lettstbq6lh5k89@4ax.com> Message-ID: In article <7d38vt0br1abnvg30j9lettstbq6lh5k89 at 4ax.com>, Richard West writes > >I was looking into PIDDLE today and it seems the only web address I >could find is a little out dated: > >http://piddle.sourceforge.net/ > >Under the status section it reads, "with the 1.0 stable release coming >soon (4th quarter 2000 is the current best guess)". And the link to >the PIDDLE mailing list doesn't appear to work any longer. > >Is this a dead project? Are there any alternative competing projects? >Does anyone know if this will work bug free under Python 2.1 or 2.2, >and the latest version of PIL? Or do I just not have the latest web >address? > >-Rich ... I think PIDDLE is dead. ReportLab can generate to PIL using a pix map renderer, but that uses type 1 fonts only (for compatibility with the PDF renderer). -- Robin Becker From kragen at canonical.org Sun Nov 25 21:18:38 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 21:18:38 -0500 Subject: Win98 PySol problem References: Message-ID: <83r8qmtgu9.fsf@panacea.canonical.org> "Bill Melcher" writes: > What fun! After a few nanoseconds of thought, it occurred to me that what I > should do is invoke the Windows Run window type: > > python Q:\pysol-4.72\src\pysol.py > > and click OK. > > Wow! A ton of messages in the DOS/python window followed by a popup message > named "PySol installation error" that complains that "No cardsets were found > !!!". Cool! I think you should use the console window instead of the Run window. You can get a console window by typing 'cmd' or 'command' in the Run window, depending on your version of Windows. > I can get the cardsets from the Russian site and try to figure out where to > put them. Hung off src (AKA python Q:\pysol-4.72\src\) I would guess. > > However, the messages from the compile scroll away far to fast to read. Is > there a way to save these for debugging purposes or just, at this point in > my python education, out of curiosity. Well, running it in a console window will save the last scroll-buffer-full. You can set your scrollback buffer size (on better versions of Windows) with some Properties dialog --- I can't remember where. There's little bits of python you could do to save the messages to a file. I think you can say: import sys sys.stdout = file.open("output", w) sys.stderr = sys.stdout execfile "Q:\\pysol-4.2\\src\\pysol.py" > Also, where does the compiled PySol go? Our old friend src? Can I add an > option to direct the compiled out put elsewhere? python foo.py will run foo.py by compiling it into bytecode (P-code) and then running the bytecode; if possible, Python will also save the bytecode in foo.pyc. In the future, python will check to see if foo.pyc is newer than foo.py, and if so, it will run the bytecode from the file instead of recompiling foo.py. > I notice that the original PySol src archive does not contain any .pyc > files. This makes sense to me but the current directories do have .pyc > files last modified 11/24/2001 8:15 AM and I have run the python command > twice today. My problem is that I do not remember what I did to cause the > compile yesterday and do not understand why the compiles I did today did not > affect the time stamps in my on-disk src directory structure. See above. > More to the point: Where in the documentation do I find the syntax of the > python command itself? I use Unix, and I type 'man python', which won't work on Win98. Section 2 of the Python Tutorial has some of what you want; more of it is in section 6.1. > Another topic is a file called ".gdbinit" which contains: > > file python > set args -u -t pysol.py > > What the heck is this? Sounds like an initialization file for the GNU debugger, to set it up to run your Python command under the debugger. Dunno why Python recorded this. Mine sure doesn't. > Matt, I am sure the other guys who have responded mean well but they and, to > a lesser extent, you do not appreciate the depth of my ignorance of those > things that 'everybody' knows. The Python documentation goes into great > detail about the language itself and how to program in it. However, the > really fundamental mechanics of how to get stuff done (especially in Win98) > and who's doing what to whom appears to be missing. That's a problem for sure. I don't know where to point you now, because much of the information you seek is scattered in bits and pieces among the programming documentation. > Ah well, if I keep pestering you guys, sooner or later you will tell me what > I need/want to know or just get tired of me and go on to other things. Glad you're not giving up! > PS: I cut my programming 'eye teeth' on the IBM 701, then onto the 704, > 709x, 704x, Philco 2000, Univac 1108, Univac 494, then IBM 360, followed by > IBM XT and the subsequent IBM AT and IBM PC clones. Wow. > I think the most fun machine was the 494 and I had much more fun rewriting > portions of Fortran II (once I snagged the source) than writing code in any > higher level language. Assembly language hasn't changed *that* much since the 360. One of the more fun Python projects people are working on is Armin Rigo's psyco, which is a Python on-the-fly compiler that compiles Python bytecode into i386 machine code in core and then jumps to it. Dunno if it sounds like something you'd like to play with after you play PySol: http://homepages.ulb.ac.be/~arigo/psyco/ From thomas.heller at ion-tof.com Fri Nov 2 04:15:59 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 2 Nov 2001 10:15:59 +0100 Subject: Python extension modules References: <7fd99f9.0110311606.7e0a5836@posting.google.com> Message-ID: <9rto8g$vlvji$1@ID-59885.news.dfncis.de> [posted and mailed] "emdpek" wrote in message news:7fd99f9.0110311606.7e0a5836 at posting.google.com... > Howdy, > > I am working on a Python binding to a library, and wanted to > clear up some concepts involving extension modules (and, > more than likely, defining a new type). > > I need Python objects to contain and "represent" native C > structs. Is there a way to do this *without* defining a new > type? For example, my C binding functions call on library > functions which return pointer structs. I can't really > return these back to Python, as they are not "PyObject*", > and you can't, for example, convert and return a "void*" via > Py_BuildValue. Or can you? I'm currently working on a 'system' doing exactly this - defining, creating and manipulating native C structs in pure Python (with the help of an extension module). This is in a very early stage, but I'm working on it. http://lpfw.sf.net/ is the project page, the link on this page named 'Accessing and manipulating C data types' points to a description of the design. Although the goal of this project is windows specific, the 'C data types' stuff could probably be made to work cross platform. Thomas From logiplexsoftware at earthlink.net Mon Nov 26 19:59:18 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 26 Nov 2001 16:59:18 -0800 Subject: Clear screen In-Reply-To: <3c02e140.9008603@news.tesco.net> References: <9tqlu7$47pu5$1@ID-110600.news.dfncis.de> <59333ea6.0111250922.79a3e2bd@posting.google.com> <3c02e140.9008603@news.tesco.net> Message-ID: <01112616591800.14170@logiplex1.logiplex.net> On Monday 26 November 2001 16:46, seb wrote: > If you wanted to make it generic (not that i want to), would os.name > clarify this: > > if os.name == 'NT': > os.system('cls') > > or is this a Bad Thing? How about something like: import sys if sys.platform == 'linux2': CLEAR_SCREEN = "clear" elif sys.platform =='win32': # or whatever this is CLEAR_SCREEN = "cls" os.system(CLEAR_SCREEN) This way you avoid a test everytime you want to clear the screen. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From maxm at mxm.dk Fri Nov 2 10:00:54 2001 From: maxm at mxm.dk (maxm) Date: Fri, 2 Nov 2001 16:00:54 +0100 Subject: Python-equivalent of PHP addslashes/stripslashes functions? References: Message-ID: > I found a question from somebody else, in a similar situation to mine, and > like him, I also would like to know of any equivalent to PHP's nice > functions for stripping certain HTML Entitities out of a string. There is a function in squishdot, a zope product, which does what you want, called nice... something. regards Max M From martin.franklin at westgeo.com Thu Nov 15 05:11:58 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Thu, 15 Nov 2001 10:11:58 +0000 Subject: Pmw.ScrolledListbox References: <6749bb94.0111140719.15db2737@posting.google.com> Message-ID: <9t04c2$53ra$1@mail1.wg.waii.com> Era Akost wrote: > When one selects an item of Pmw.ScrolledListbox, it gets underlined. > How to disable the underlining? > Tkinter.Listbox that is the component of this widget doesn't show this > property. > > This question was also posted one year ago, but there were no answers. > > Thanks, > > Era > Era, Could you post some code I can't see this with the following code.... >>> from Tkinter import * >>> import Pmw >>> root=Tk() >>> lb=Pmw.ScrolledListBox(root) >>> lb.pack() >>> lb.insert(0, 'one') >>> lb.insert(0, 'two') >>> lb.insert(0, 'three') Oh and what platform/version etc.... Martin From jedi at group6.net Tue Nov 13 07:22:47 2001 From: jedi at group6.net (jedi) Date: Tue, 13 Nov 2001 04:22:47 -0800 Subject: help for beginner ! In-Reply-To: <01111311042007.02982@logiplex1.logiplex.net>; from logiplexsoftware@earthlink.net on Tue, Nov 13, 2001 at 11:04:20AM -0800 References: <9sr9g4$gik$1@wanadoo.fr> <20011113035327.O36699@group6.net> <01111311042007.02982@logiplex1.logiplex.net> Message-ID: <20011113042247.R36699@group6.net> opps... that's me. I'd like to apologize the list. I was doing three at once and it's been a hectic day. please accept my apology for spamming the list. won't happen again. On Tue, Nov 13, 2001 at 11:04:20AM -0800, Cliff Wells wrote: > On Tuesday 13 November 2001 03:53, jedi wrote: > > I saw these in the mall the last time I was in there. They do kick ass. > > but the female is the best. > > Okay, now _I'm_ confused. Do you mean the tall one? > > -- > Cliff Wells > Software Engineer > Logiplex Corporation (www.logiplex.net) > (503) 978-6726 x308 > (800) 735-0555 x308 > > -- > http://mail.python.org/mailman/listinfo/python-list -- j3di jedi at group6.net http://jedi.group6.net/ From maxwell at ldc.upenn.edu Tue Nov 20 17:49:02 2001 From: maxwell at ldc.upenn.edu (Mike Maxwell) Date: Tue, 20 Nov 2001 17:49:02 -0500 Subject: context-sensitive help from editor References: <9tbetv$e92$1@netnews.upenn.edu> Message-ID: <9temku$koe$1@netnews.upenn.edu> Thanks! (Python Shelf turned out to be the thing I needed.) -- Mike Maxwell Linguistic Data Consortium maxwell at ldc.upenn.edu From borcis at geneva-link.ch Sun Nov 4 09:53:47 2001 From: borcis at geneva-link.ch (Boris Borcic) Date: Sun, 04 Nov 2001 14:53:47 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: Message-ID: <3BE55C5E.4F12308E@geneva-link.ch> Steven D. Majewski a ?crit: > > Bland American Culture ??? -- how about (while we're on the subject of > humor): ... > George Bush (What other country has such a dedication to Humor!) filter(lambda x : x not in "ILLITERATE","BULLSHIT") (The unnamed function of course models the role of the pdt's PR team) BB From lbaker at hot.rr.com Sun Nov 25 19:19:32 2001 From: lbaker at hot.rr.com (The News) Date: Mon, 26 Nov 2001 00:19:32 GMT Subject: A newbie that needs some HELP Message-ID: First background on me. Since you'll probably be seeing me here alot. :) Ok. I bought a new computer this week and found..... (lo and behold while I was erasing the useless gunk manufacturers load 'for' you) it was pre-installed with Python v2.1.1. So I think to myself, "Cool! I've been wanting to get back into programming." Now, I do a little research on the web and find out what this "Python" is. I see that I like it alot as far as languages go (and I dig the Monty association ), so I D/L a web tutorial and get busy trying to self-teach. Languages I know: BASIC, Pascal, HTML, english, and some spanish (muy pequito) Now on to the problem. I'm working on lists. Trying to figure them out. So I decide to write this little algorithim for user inserted lists. My proto goes as follows: monty = [] number = input("How many Monty's are there?") for x in range(1,number): mln = input("Name a Monty?") monty.append(aln) print monty It gets through it but prints out some wierd stuff along with each listed monty. Can someone tell me what I'm doing wrong? Also, when I try to get it to repeat x at the end of "Name a Monty #", x it gives me an error. How could I get around that? Also, while learning HTML I found a program called Homesite (by Allaire) it was very helpful. Is there something like it for Python? Thanks in advance. Mish lbaker at hot.rr.com "No one expects the Spanish Inquisition!" From nikander at mindspring.com Sun Nov 11 17:59:40 2001 From: nikander at mindspring.com (Robert Nikander) Date: Sun, 11 Nov 2001 17:59:40 -0500 Subject: C modules with gcc 3.0.x References: <20011111.154717.381570572.10034@localhost.localdomain> Message-ID: <20011111.175938.805002726.10883@localhost.localdomain> In article , "David M. Cooke" wrote: > Well, I think that's pretty obvious :-) The loader can't find the > 'libgcc_s.so.1' library. GCC 3, instead of statically linking in a > runtime library libgcc.a, now links to a shared library instead. Check > to see if you have it somewhere (probably in /lib). Otherwise, you'll Doh! ldconfig makes an ass of me every time. (I had recently compiled and installed gcc 3.0.2 and as usual forgot to run it...) thanks, Rob From glauco.silva at iti.gov.br Tue Nov 6 12:12:15 2001 From: glauco.silva at iti.gov.br (Glauco Silva) Date: Tue, 6 Nov 2001 15:12:15 -0200 Subject: help - Create dll Message-ID: <003c01c166e6$2f3fb4e0$107290c8@iti.gov.br> Hi , How can i create a dll file ( C dynamic library) from windows to be imported by python . Thank you Glauco -------------- next part -------------- An HTML attachment was scrubbed... URL: From grey at despair.dmiyu.org Thu Nov 29 18:27:36 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Thu, 29 Nov 2001 23:27:36 -0000 Subject: A modest indentation proposal References: Message-ID: On Thu, 29 Nov 2001 14:09:28 -0800, Erann Gat wrote: > It also IMO makes the language unsuitable for mission-critical applications. > It's just too easy to screw up indentation (particularly when cutting and > pasting large blocks of code) without realizing it. Hogwash, plain and simple. Either you know it because it is visually different or you know it when you test the application and it fails spectacularly. You /do/ test your mission-critical applications, don't you? Furthermore this makes it ideal for mission-critical applications because it enforces a rather uniform style of coding making it easier for different people to read, understand and modify each other's code. > 1) Editor support for this convention so that a semicolon at the end of a > line causes the editor to unindent, and Given the choice of having disparate programming styles or having to hit backspace a few times at the end of a block, I'll take backspace. I'll spend less time smacking that key around than I will puzzling over someone else's, or even my own, code. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From pete at shinners.org Mon Nov 19 19:32:17 2001 From: pete at shinners.org (Pete Shinners) Date: Mon, 19 Nov 2001 16:32:17 -0800 Subject: Newbie-ish question References: <_ZeK7.505628$ME2.63350791@typhoon.kc.rr.com> Message-ID: <3BF9A491.2020006@shinners.org> Patrick Moorman wrote: > I have a directory containing a large number of files in the format xy.txt > where x is a string of numbers and/or letters and y is a sequential number > with either 2 or 3 digits. Example: 1foo23012.txt or foo12305.txt. How > would I go about identifying all of the files in a sequence and moving them > to their own sub-directory. I am slowly picking up on Python, but there is > a long ways to go. Thanks for any help. you've got one problem with your situation. if the first part of the filename includes letters and numbers, and the second numeric part is 2 _OR_ 3 numbers, how do you know where the name part ends and the number part starts?? is "1foo23012.txt" become "lfoo230, 12" or is it "lfoo23, 012" ?? you should start with the os.path functions to help you manage filenames. you can use string functions to determine if characters are letters or digits. From sholden at holdenweb.com Thu Nov 8 13:15:18 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Nov 2001 13:15:18 -0500 Subject: Reading a comma delimited file References: <%tzG7.2971$qK.174060@typhoon.austin.rr.com> Message-ID: "Kristen Zander" wrote in message news:%tzG7.2971$qK.174060 at typhoon.austin.rr.com... > That cleared up alot becuase it was really becoming frustrating. > > I just figured it out. > > import fpformat > a = 97.33532356246 > b = fpformat.fix(a,2) > print b > > 97.33 > > Great! Thanks. > Oops. It probably won't matter, as you seem to have values which are very close to 2DP anyway, but the example you give above would normally be expected to be shown as 97.34 (because 97.33532356246 is closer to 97.34 than to 97.33). The "%.2f" notation should provide this desired behavior, and indeed the documentation for the fpformat module states: """The fpformat module defines functions for dealing with floating point numbers representations in 100% pure Python. Note: This module is unneeded: everything here could be done via the % string interpolation operator.""" >>> "%.2f" % 97.3353 '97.34' >>> "%.2f" % 97.3333 '97.33' look-after-the-places-and-the-decimals-will-look-after-themselves-ly y'rs - steve -- http://www.holdenweb.com/ From thys at netsys.co.za Tue Nov 27 03:46:33 2001 From: thys at netsys.co.za (Thys Meintjes) Date: Tue, 27 Nov 2001 10:46:33 +0200 Subject: postgresql triggers to update GUI? In-Reply-To: <200111262049.fAQKnnda005432@lin2.andrew.cmu.edu> References: <200111262049.fAQKnnda005432@lin2.andrew.cmu.edu> Message-ID: Use the PostgreSQL LISTEN, NOTIFY commands, Add a rule to the table that you want notifications on, something like this: CREATE TABLE wmanlog ( file INT, line INT, type CHAR(10), ....... ); CREATE RULE wmanlogupdate AS ON INSERT TO wmanlog DO NOTIFY wmanlogentry;""" Check for NOTIFY 'events' by doing a query = """LISTEN wmanlogentry""" either from a thread, which in turn can raize a 'real' event or a timer, I use wxWindows's wxTimer to poll and PyGreSQL's getnotify() method to determine the type of notification (wmanlogentry) if any. greets On Monday 26 November 2001 10:49 pm, Brian E Gallew wrote: > "Robert Nikander" wrote ... > > > I am writing a python program that uses a postgresql db backend. I > > would > > > like to update the gui whenever a change in certain tables occurs, so > > it > > > would be nice to use triggers rather than generating the 'events' when > > I > > > update the db. That way I get cascading changes. Does anyone know of > > a > > > python module that supports postresql triggers? ie: you can create a > > trigger that calls a python function? Is there another solution here > > that I am missing? > > What you are looking for are asynchronous requests. Basically, you > make an async request, then in your GUI mainloop you peridically check > to see if you got any results (updating the GUI if necessary). There > is no way to make a database trigger talk to your GUI UNLESS you are > willing to open up a socket in the GUI, listen/process requests on it > and have your database trigger write to that socket (don't forget to > have error handling in there so that it doesn't crash when there's no > one listening). From kragen at pobox.com Wed Nov 28 16:47:04 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 28 Nov 2001 16:47:04 -0500 Subject: Super-newbie needs help! References: <70c31206.0111280950.7ebe06ae@posting.google.com> Message-ID: <83elmiva93.fsf@panacea.canonical.org> snowcrash3 at hotmail.com (SnowCrash) writes: > total = 100 > sum = input ("Enter your number.") > while sum < total: > print "You haven't reached 100 yet!" > sum = input ("give me another number") + sum > > print "Ok, you got me!" > > HUH? i don't think its right, i've changed it about 4 times before > posting it, Looks great! > and i've downloaded the Python 2.2 but can't seem to > figure out how to use the thing to check my code. What platform are you on? Method 1: Type 'python' at a command-line (shell, MS-DOS, MPW) prompt. Type in the correct code you gave above. Method 2: Save the correct code you gave above to a plain ASCII text file. Type 'python filename' at a command-line prompt. Hope this helps. From skip at pobox.com Thu Nov 29 18:35:20 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 29 Nov 2001 17:35:20 -0600 Subject: A modest indentation proposal In-Reply-To: References: Message-ID: <15366.50744.102752.323973@beluga.mojam.com> Erann> Personally I've found [indentation-based block structure] to be Erann> less of a problem than I thought it would be, but annoying Erann> nonetheless. It also IMO makes the language unsuitable for Erann> mission-critical applications. It's just too easy to screw up Erann> indentation (particularly when cutting and pasting large blocks Erann> of code) without realizing it. As has been demonstrated many a time, you're more likely to screw up a C block by omitting braces: if (cond) x = 1; y = 1; than you will screw up a Python block. In fact, it's such an insidious problem in C code that many groups mandate that all blocks use { & }, even for one-statement blocks. In Python, if it looks right, it is right. In practice, this has not proven to be a problem. I've been using Python as my primary programming language essentially full-time since 1994 with never a problem in this regard. I don't know. Maybe I'm just weird. I prefer to think not though. Erann> I propose to use a semicolon at the end of a line to denote the Erann> end of a block, e.g.: Erann> for i in l: # Colon signals beginning of block Erann> foo() Erann> baz(); boff() # Semicolon separating statements works as usual Erann> bar(); # Semicolon at end of line signals end of block Erann> biff() In my book trailing single-character punctuation should be avoided wherever possible. (That goes for single-element tuple literals as well.) I suggest you just use # end if # end while # end for as your block closers and apply Tools/scripts/pindent.py Erann> This convention is 100% backwards-compatible with current Erann> practice, that is, code written using this convention runs with Erann> no problems in Python as it currently stands. Not it's not. Semicolons can legitimately be used to end a statement now. was-that-troll-spit-i-just-stepped-in?-ly, y'rs, -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From stojek at part-gmbh.de Wed Nov 14 09:27:35 2001 From: stojek at part-gmbh.de (Marcus Stojek) Date: Wed, 14 Nov 2001 14:27:35 GMT Subject: open DOS window and start application Message-ID: <3bf27da9.14337531@news.easynews.net> Hi, I have written a little job manager that is monitoring and starting very time consuming simulation jobs (separate application). This application has to be started in a DOS window. How can I open such a DOS window? How can I start several jobs (one after the other) in THIS window? (not open new windows for each job) How can I change the current dir in this window? I tried: os.system("start application [-parameter] jobname") which works fine for one job. But i can't change directories and i can't start a second job in the same window. Thanks Marcus From max at alcyone.com Sun Nov 18 02:43:40 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 17 Nov 2001 23:43:40 -0800 Subject: What is Type Error? References: <3BF75BFF.7070107@stu.ust.hk> Message-ID: <3BF766AC.47C36402@alcyone.com> Calvin wrote: > I'm developing a simlator for LCD and get stuck with the Type > Error. The > attached is my LCD.py file, when compile I got the following error: > > Traceback (most recent call last): > File "", line 1, in ? > File "C:\Python21\LCDSim\start.py", line 5, in ? > lcd.elastic_energy() > File "C:\Python21\LCDSim\LCD.py", line 33, in elastic_energy > > self.__energy[n]=1/2(self.__lc.k1(self.__azimuth[n])*d_azimuth**2+self.__lc.k2(self.__azimuth[n])*d_twist**2 > +self.__lc.k3(self.__azimuth[n])*d_twist**2) > TypeError: object of type 'int' is not callable > > could anybody point out how can I solve it, I just got no ideas :( TypeError means that something is of the wrong type for what you're trying to do with it. This particular error means that you're trying to call something which is not a function. If f is a function you invoke it like this: f(...) where ... represents some arguments. So, in other words, Python is telling you that in that long expression there is something of that form, but where what's represented by f is not a function; it is instead just an integer. Looking at that expression I see ### things that could be responsible: self.__lc.k1 self.__lc.k2 self.__lc.k3 One of these guys is not what you think it is at the time that statement is executed. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From gh_pythonlist at gmx.de Sun Nov 4 16:51:03 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 4 Nov 2001 22:51:03 +0100 Subject: PyGreSQL for Windows In-Reply-To: References: Message-ID: <20011104225100.A618@lilith.hqd-internal> On Sun, Nov 04, 2001 at 04:10:42PM -0800, Daniel Rose wrote: > Howdy, > Does anyone know where i can get a copy of pygresql for windows and python > 2.1? highqualdev seems to point to some search site. My site moved to http://www.cs.fhm.edu/~ifw00065/ at my university account. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From fredrik at pythonware.com Sun Nov 18 15:32:13 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Sun, 18 Nov 2001 20:32:13 GMT Subject: RANSOM DEMAND: Image Held Hostage! References: Message-ID: Ben Ocean wrote: > I need a way to size up images via script. Now, in that inferior scripting > language known as PHP, *they* have such a tool: getimagesize(). Can it be > that God's gift to scripting languages, Python, can't compete here? if you spent as much time reading replies to your posts as you spend on your subject lines, you would have solved your problem days ago. but alright, here's another version of the same reply: def getimagesize(filename): # get size from one of 30+ image formats import Image return Image.open(filename).size width, height = getimagesize(filename) where the Image module is part of the Python Imaging Library: http://www.pythonware.com/products/pil/index.htm (you don't need to build the binary extension if all you need is the size. but it won't hurt) From sholden at holdenweb.com Mon Nov 26 08:13:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Nov 2001 08:13:46 -0500 Subject: list.remove for Novices References: Message-ID: "Arthur Siegel" wrote ... > Tim writes - > > >I expect every newbie gets bit by this at least once. This is the first > >time I've seen it called "apparent", though (nobody actually said that, > >right?). It's a subtlety, as the Reference Manual points out in a bold > >Warning. > > But the Reference Manual is for the Legal profession. I'd suggest a > tutorial warning. > Along the lines of "Sitting on the branch you are sawing off the tree is not a good idea"? > I would say, in fact, that whether I am working on the thing itself, or a > copy of the thing itself, and leaving the thing unchanged, is the #1 > issue of confusion for the novice - if I am typical (and I have always > posited that I am). Especially when there are few thing1=thing2 > thingies floating around. > Art, surely you've been using Python long enough to realise that assignment never creates copies? > >>>b=[1,2,3,4] > >>>a=b.reverse() > >>>b=a > >>>print b > None > > ??? > This behavior is very clearly documented for both reverse() and sort() , and is also in the FAQ. > I get it, but it takes a while - and errors were rampant, and this form > of confusion comes in many flavors. I have had occasion to savor > many of them already. > Isn't Python FUN? > The > > for p in x: > x.remove(p) > > surprise just being a new dessert topping. > Surprise? There you go, sawing away at that branch again. I realise I won't convince you, because you've been bitten, that this isn't a situation where further documentation is necessary. Seems obvious to me, but clearly I'm not typical of *all* users (thank heavens). > Is anyone aware of a reference where these issues are given > focus and covered clearly and comprehensively > for the Python novice?? > > Not that someone like me is likely to read it carefully. Just > so much damage one can do screwing up a bezier curve, and > I tend to live dangerously - and learn by messing up enough > times until something eventually clicks. > So you ADMIT that warnings wouldn't do you any good. I suppose they'd be useful for "other people", though? > > If you mutate a container while traversing its contents, every > >language supporting such a thing does something that will surprise someone > >(can't help it -- some people will be surprised if their mutations aren't > >visible during the traversal, while others will be surprised if they are, > >and the rest will complain if you raise an exception). > > Backwards compatibility issues aside (are there actually folks who > take advantage of the current behavior?) isn't it pretty clear that the > current behavior is probably the most surprising of the possibilities - > at least to the naive eye. > No. But the current behavior isn't something one would "take advantage of". It's something one needs an intelligent awareness of to avoid being bitten in the ass. In other words, one tries to avoid its taking advantage of you! > My first PEP? > I wouldn't even think about it, but of course the point of the PEPs is to encourage discussion. regards Steve -- http://www.holdenweb.com/ From R.Brodie at rl.ac.uk Thu Nov 22 11:20:26 2001 From: R.Brodie at rl.ac.uk (Richard Brodie) Date: Thu, 22 Nov 2001 16:20:26 -0000 Subject: syntax question References: <9tj7et$oi2@r02n01.cac.psu.edu> Message-ID: <9tj8kc$q8q@newton.cc.rl.ac.uk> "Rajarshi Guha" wrote in message news:9tj7et$oi2 at r02n01.cac.psu.edu... > def V(*vals): > return array(vals) > > I can see that the *vals takes in a tuple - is this orrect or are there any > other significances of this sytnax? *vals swallows the end of an argument list and produces a tuple - so can be used for printf/stdarg like functions: saves some extra brackets. >>> def a(*vals): ... print vals ... >>> def b(vals): ... print vals ... >>> a(1,2,3) (1, 2, 3) >>> b(1,2,3) Traceback (most recent call last): File "", line 1, in ? TypeError: b() takes exactly 1 argument (3 given) >>> b((1,2,3)) (1, 2, 3) From dale at riverhall.NOTHANKS.co.uk Fri Nov 9 05:51:07 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Fri, 09 Nov 2001 10:51:07 +0000 Subject: Exception holes, again. References: <9s6spi$ksk$1@newsreaderm1.core.theplanet.net> Message-ID: "Steve Holden" wrote: >"Dale Strickland-Clark" wrote ... >> Thanks that looks promising. >> >> This whole area is still a dogs breakfast, though. >> >> The fact that I have to spend 2 hours hunting around to find out how >> to catch an exception is a nonsense. > >No, it's an indication that PythonWin's documentation needs improving. > >The fact that you made this last posting is clearly an indication that you >are pissed off about it. Just remember all the *good* things you've got from >Python ;-) > >smile-and-the-world-smiles-with-you-ly y'rs - steve It shouldn't be down to documentation. I am becoming more convinced by the idea that the lanaguage should *allow* you to define a formal interface, even if only by convention. Something like: __raises__ = [exception list] In the class, method or function definition would be tacky but good enough if there was a convenient way to access the info from your favourite IDE. Although, that doesn't really address the problem of finding the exception definitions. -- Dale Strickland-Clark Riverhall Systems Ltd From paul1brian at yahoo.com Mon Nov 26 09:55:16 2001 From: paul1brian at yahoo.com (Paul Brian) Date: Mon, 26 Nov 2001 14:55:16 -0000 Subject: smtplib help References: Message-ID: <1006787411.9902.0.nnrp-08.c1c3e1d9@news.demon.co.uk> David, its hard to comment, but I suspect that the error you are getting comes from the SMTP server. Basically line 222 in smtplib calls on the socket module, which has an error code: errorTab[10048] = "The network address is in use." (line 79) (I am using 2.1.1 - Your version presumably has a different error msg ) So I suspect that the server is keeping alive sessions - I would check by quiting the session each time (xxx.quit()) you send a message. Hope that helps David A McInnis wrote in message news:mailman.1006768891.31431.python-list at python.org... Any ideas why smtplib would crash on me after about sending 150 email msgs (i did not count, but that is a good estimate)? This is the error that I am getting. File "C:\Python21\mm_mime.py", line 93, in Send server = smtplib.SMTP(host) File "C:\Python21\lib\smtplib.py", line 187, in __init__ (code, msg) = self.connect(host, port) File "C:\Python21\lib\smtplib.py", line 222, in connect self.sock.connect((host, port)) File "", line 1, in connect error: (10048, 'Address already in use') David McInnis From BgPorter at NOartlogicSPAM.com Tue Nov 6 09:44:11 2001 From: BgPorter at NOartlogicSPAM.com (Brett g Porter) Date: Tue, 06 Nov 2001 14:44:11 GMT Subject: Help Help Help References: <3be77f95@152.65.161.36> <7x3d3s8jo3.fsf@ruckus.brouhaha.com> Message-ID: <%GSF7.79257$ez.10214076@news1.rdc1.nj.home.com> "Paul Rubin" wrote in message news:7x3d3s8jo3.fsf at ruckus.brouhaha.com... > "Kojo Duncan" writes: > > Write a program that lists all prime numbers less than a prime number a user > > inputs. Post on site for all to see. > > Do your own homework ;-) (*sigh*) The unanticipated downside of Python being used more widely in education is that c.l.py is going to start feeling a little like c.l.c++. Except over there, the response would be filled with vitriol, not a smiley. Kojo, the main python site has some excellent tutorials (including Guido's, which should be most people's first stop). Paul Winkler has already pointed you to "How to Think Like a Computer Scientist." Also check Mark Pilgrim's site diveintopython.org -- in addition to his online book, he's got a great list of links under the heading "Learn Python" From Markus.Frank at cern.ch Fri Nov 2 11:48:23 2001 From: Markus.Frank at cern.ch (Markus Frank) Date: Fri, 2 Nov 2001 17:48:23 +0100 Subject: Using JPE: Problems with the java virtual machine Message-ID: Dear Python users, I have to execute a java class from a python module. JPE seemed to be the solution. But, of course, life is never that easy. I could start the java virtual machine from python, but as soon as java is loaded, python craps out i.e.. no command works anymore. Has anybody seen something similar? Any help is welcome. I use the sun jdk 1.3.0 and python 2.0. Cheers, Markus Frank EP Division, CERN LHCb Experiment CH-1211 Geneva 23 Telephone: 41 22 767 24 86 Fax: 41 22 767 94 25 E-mail: mailto:Markus.Frank at cern.ch WWW: http://www.cern.ch/~frankm J:\CMT\JPE\v1>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 java, sys, os, gc, javalib >>> gc.disable() >>> gc.set_debug( gc.DEBUG_STATS) >>> vmargs=['-verbose:jni,gc', '-Djava.library.path=%s' % os.environ[ 'PATH'], '-Djava.class.path=' + os.environ[ 'CLASSPATH']] >>> from java import jvm >>> print 'Hello world' Hello world >>> vm=jvm.JavaVM('jvm.dll', vmargs) ..\src\jpe.cpp:i Warning s_jcache_create(): s_jrlock is NULL; creating it >>> ..\src\jutil.cpp:172 take rlock 0x8a160c <<< ..\src\jutil.cpp:188 release rlock 0x8a160c >>> print 'Hello world' File "", line 1 print 'Hello world' ^ SyntaxError: invalid syntax >>> ^Z From niemeyer at conectiva.com Thu Nov 1 17:45:03 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Thu, 1 Nov 2001 20:45:03 -0200 Subject: pybot needs your help Message-ID: <20011101204503.B4023@ibook.distro.conectiva> Hello everyone! I need help. No, I'm not asking for money. :-) What I need is smart people with coding, documentation, and/or web designing abilities to join an ongoing project. I'm not thinking about leaving the project, but I don't have all the necessary time to maintain it alone. What it is about!? About pybot ----------- Pybot is a project I have developed to integrate many sources of information with IRC. Here at Conectiva we use IRC as the main company's communication channel. It's quite confortable to have a bot telling you about what's happening in the world outside, and also help in some related tasks. Note that it was not designed, and I'm not planning to implement, any "war" behavior. It's not supposed to be a replacement for channel control services. Characteristics of the project ------------------------------ - may join multiple servers and multiple channels at once; - full online control (just talk to him); - load, reload and unload modules at runtime (python is nice, isn't it? ;-); - nice API for inter-module communication; - object oriented; - hook system; - well designed (I'm suspect to say this, but it's true ;-); - auto recover from network errors; - flood protection; - auto timming of messages to avoid being kicked by the server. - message priority; - other stuff I probably forgot; - lots of functionalities trough available modules (see below). Modules already available ------------------------- - modulecontrol Takes care of loading, reloading, and unloading modules dynamically and when pybot starts up. - servercontrol Basic server control. Takes care of initial setup as well as joining and leaving channels on the fly. - options Provides user access to the global registry. Also takes care of maintaining it between runs (pickle, of course). - permissions Provides access control for pybot. Most of the other modules access exported functions from this module to verify if users have given privilege. - pong Answers ping requests (guess what happens if you disable it ;-). - ignore Allows ignoring given users/channels/servers. - uptime Shows pybot uptime (right now it's up for more than a month ;-). - infopack Uses external databases to add knowledge to the bot. Each database may add its own trigger, default messages (when the trigger was sucessful, but no keys were found), etc. Available infopacks are acronyms (extracted from GNU vera), tcp/udp ports, and airports (both extracted from infobot). - messages Allow users to leave messages to named users. These messages will be sent when the named user gets into some channel or talks (usefull if he was just away). - forward Forwards messages between choosen channels and/or servers. - notes Allows saving general information about given keys. - eval Evaluates python expressions in protected environment. - repeat Repeat given message for selected server/channel once, or in given intervals. - freshmeat Check for new freshmeat releases and post them into selected channels/servers. - appwatch Check for new appwatch (is it alive) releases and post them into selected channels/servers. - plock Provide simple colaborative locking mechanism. We use it to control locking of packages, avoiding two people changing it at the same time. - social Socialize pybot a little bit. - soap Uses SOAP.py to provide an API to easily export functions trough SOAP protocol. - timer Provides an API allowing modules to be called once in a while. - randnum Simple random number generator. - userdata Provides some general user data storage, and exports some functions providing this information for other modules. What's in TODO list right now ----------------------------- - A website for pybot. - Documentation!! Please, write documentation. :-) - Create a script to run pybot from outside of the build environment. It must detect somehow where pybot is installed and call it (notice it must be called from an outside program to reset work as expected). - Adapt distutils classes to install every necessary file in their respective directories. - Finish the conversion of msg.match to re.match and remove msg.match from the code. - Give users a chance to identify themselves to pybot when they are in other servers than their registered ones. Must discover some way to detect when the user has left and auto-logout him. - Develop a README explaining how to do the basic setup of pybot. Available infrastructure ------------------------ Pybot has a sourceforge home (source is not there yet, but I'm working on this). It's also registered at freshmeat.net and has it's own domain at pybot.org. How to join ----------- Contact me. Please, I don't have the necessary time to teach how to program in python. I need people with the necessary knowledge to join and *help*. Best regards!! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From kevin at cazabon.com Mon Nov 19 14:56:17 2001 From: kevin at cazabon.com (Kevin Cazabon) Date: 19 Nov 2001 11:56:17 -0800 Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> Message-ID: <5a4226f0.0111191156.42726e8f@posting.google.com> Try Komodo from ActiveState (www.activestate.com). You can get a free license for "non-commercial" use. I'd also suggest d/l-ing their Python installer (Perl too if you like). It's a pretty decent IDE, and I like that I can also use it well for Perl / HTML, and many other languages. I definately like it better than PythonWin, the tabbed layout is nice to flip back and forth between scripts. Kevin Cazabon. "Don Arnold" wrote in message news:<9t9qsb$4nd$1 at slb3.atl.mindspring.net>... > I'm new to python and am interested in developing apps with Tkinter. > However, every IDE I've come across for the Win32 platform experiences > lockups/aborts when running Tkinter code. So far I've tried IDLE, PythonWin, > and WING with little luck. Does anyone know of an IDE that successfully > executes Tkinter code? > > Thanks, > Don Arnold From deoradh at yahoo.com Fri Nov 16 05:25:00 2001 From: deoradh at yahoo.com (Keith Farmer) Date: 16 Nov 2001 02:25:00 -0800 Subject: C-extension in Python -- returning results References: Message-ID: tatebll at aol.com (Bill Tate) wrote in message news:... > Keith - now that was an interesting problem. Since you've found the > source of your problem this may be moot but I would definitely second > Jive's suggestion to consider using a neural network for this problem Got my degree in Physics and Astronomy -- I just wish there was better notational support for operator math, but really, that's probably not possible for a single-line style? How efficient would a neural network be in solving this problem? I achieve accuracies on the order of 1e-6 to 1e-7 (both rms and max error) in less than a second on a 1.2GHz Win2k Pro box accessing a remote database (data transfer of roughly 100k); quite possibly, I could achieve this within less than half a second, if I fiddle with the number of samples I take. Keep in mind that the motion described is more or less well-behaved (the earth/moon system being an annoying exception). As it is, one coordinate changes as a nearly constant rate, and the period of the other two is much larger (5x or more) than the time period of the sample. Another problem (which I won't tackle for this application, though it'd be interesting just to see how it'd behave) would be to see how changing the degree of the polynomial affects the accuracy of the fit, given a large sample size (~5k points) and a constant period of time (several months, at least). The benefit of exploring this would be to reduce the overall dataset even further (18 numbers * n periods versus a+b+c numbers for 1 combined period -- earth would still be a problem). .. this is what I do when I'm unemployed? Sheesh! From jae at jerhard.org Sat Nov 17 13:29:10 2001 From: jae at jerhard.org (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sat, 17 Nov 2001 19:29:10 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. In-Reply-To: (message from Michael Hudson on Wed, 14 Nov 2001 12:41:04 GMT) References: Message-ID: >>>>> "Michael" == Michael Hudson writes: Michael> DTSRV10-SA at dutchtone.nl writes: >> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Michael> And doesn't know what to do with Precedence: bulk. Hurrah. Which certainly instills confidence in its general abilities, doesn't it. Michael> Cheers, Yes, Microsoft software drove many a good man to drink. Cheers! Bye, J PS: Sometimes that .sig generator is psychic... -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sf.net) My WebHome: http://jerhard.org The 80-20 rule for an NT project: 20% time for real coding -- 80% time for working around NT bugs -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From hartanto at telusplanet.net Fri Nov 9 13:50:54 2001 From: hartanto at telusplanet.net (harry) Date: Fri, 09 Nov 2001 18:50:54 GMT Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: "Martin von Loewis" wrote in message news:j4k7x084sy.fsf at informatik.hu-berlin.de... > This is invalid syntax, I'll assume that you meant > > {"key1":[1,2,3,4], "key2": "hello", "key3": [1,2,3]} > > Notice that dict is now a collection of 11 objects: > - four strings > - four integers: 1,2,3,4 > - two lists: [1,2,3,4] and [1,2,3] > - one dictionary > > You may think that the integers should be counted twice, but you > actually have the same integer objects in each list. > > Do you want the siye of just the dictionary, or of all the objects > together? What Python version? What operating system/microprocessor? > What C library (to account for the overhead of malloc/free). I would like to know the size of all objects together (the dictionary and the contents). I am using Python 2.0 on Windows98 SE. And I don't think I use any C library. (or you're refering to something that i'm not aware of using) Thanks! From johnroth at ameritech.net Mon Nov 5 18:57:45 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 5 Nov 2001 15:57:45 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: "Tim Peters" wrote in message news:mailman.1004908205.3765.python-list at python.org... > [Tim] > > An odd thing is that, when this comes up, people complain that under > > Python's current rules it's not necessarily the case that > > > > (-i)/j == -(i/j) > > > > Across decades of integer numeric programming, I can't recall any > > *use* for that identity; but that i%j >= 0 whenever j>0 is endlessly > > useful, as is your identity relating int-div and int-mod. > > [John Roth] > > Useful as it is, it makes division not be the > > inverse of multiplication, so it's mathematically incorrect, > > and hence astonishing to people who don't know the score. > > What does "it" mean? Sorry, but I can't make sense out of your comment. I > was talking about truncating integer divsion versus flooring integer > division; i/j == k does not imply i == j*k under either of those. The basic sign rules for multiplication are so clear that I don't really need to repeat them here. If division is the inverse of multiplication, then the sign rules follow directly. Any definition of division which does not do that isn't an inverse of multiplication, but some other operation masquerading under the same name. This might be a much more useful operation in practice, but it is confusing to someone who expects the system to behave the way he was taught in grammer school. In other words, (-i)/j should -(i/j). John Roth > > From johnroth at ameritech.net Sat Nov 10 22:40:01 2001 From: johnroth at ameritech.net (John Roth) Date: Sat, 10 Nov 2001 19:40:01 -0800 Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> <3BED54C2.1010608@sci.kun.nl> Message-ID: "husam" wrote in message news:3BED54C2.1010608 at sci.kun.nl... > > yes, i understand the general defenition of data bases and of data > structures. i should in fact put the question like this: > is a given dictionary or list of a set of data, a data base? > In some respect, it depends on your point of view. All of the data structures quoted in the previous articles in the thread are in fact collections with different access policies. Data bases are also collections with different access policies (SQL being by far the most popular one). I normally think of a data structure as an abstract description of a way to organize a collection, a collection as a concrete example of a data structure with specific data that is in memory, and a data base as something that is managed by an external piece of software, called a 'data base manager.' John Roth From jeff at ccvcorp.com Mon Nov 19 15:07:46 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 19 Nov 2001 12:07:46 -0800 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> <3BF429F1.146759EA@ccvcorp.com> <9t9bk1$np2$07$1@news.t-online.com> Message-ID: <3BF96692.77666218@ccvcorp.com> Gernot wrote: > "Jeff Shannon" schrieb im Newsbeitrag > news:3BF429F1.146759EA at ccvcorp.com... > > > > Gernot wrote: > [deleted] > > > module which i have to "activate" first?? > > > > There is no bool() in Python. You'll have to build your own. > > But at least you've got a decent start on your homework. > > You are right, i mixed it up with something different. Thanks for your > comment. Actually, it's even more simple than you think, in Python. def bool(x): if x: return 1 else: return 0 Or, alternatively import operator def bool(x): return operator.truth(x) Jeff Shannon Technician/Programmer Credit International From radix at twistedmatrix.com Sat Nov 10 23:30:08 2001 From: radix at twistedmatrix.com (radix) Date: Sat, 10 Nov 2001 23:30:08 -0500 Subject: doc generator References: <9sku4g$egh$1@peabody.colorado.edu> Message-ID: On Fri, 09 Nov 2001 16:48:24 -0500, Fernando P?rez wrote: >> Itamar Trauring and Jurgen Hermann (sorry Jurgen, no umlaut key) are >> working on a "competitor" of HappyDoc's called Teud. It uses XSLT and >> lookes much better (IMO) than HappyDoc. >> >> http://twistedmatrix.com/users/jh.twistd/python/moin.cgi/TeudProject > > Pardon the ignorance, but in which ways does this add to pydoc's > functionality? I went to their website and looked at the example page, > and the output is the exact same content I get from running pydoc -g, > just with uglier formatting and poor nesting structure. Since pydoc is > already part of Python officially, and offers a very powerful object > introspection infrastructure (via the inspect module), I'd like to > understand what the contribution of this project truly is. > > I'm honestly not bashing its authors, I'm sure they've put a lot of work > into it. I'd just like to clarify in what areas it adds to something > that's already built into python, and which does a very good job. > > Cheers, You'll have to pardon _my_ ignorance, because the only thing that I know about Teud is "It looks better than HappyDoc". :) I'm generally not interested in documentation generators, and haven't touched PyDoc -- I just know the authors, and throught it'd be nice of me to plug their project ;) Anyway, that page is on a wiki -- I'd recommend you ask that question there, and I'm sure one of the authors will respond to it. (If you're not familiar with wikis, see http://twistedmatrix.com/users/jh.twistd/python/moin.cgi/WikiWikiWebFaq) -- It's just like a method call, but ON FIRE AND UPSIDE DOWN!!! -- Chris Armstrong <<< radix at twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/ From mgerrans at ix.netcom.com Wed Nov 28 17:00:50 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Wed, 28 Nov 2001 14:00:50 -0800 Subject: Super-newbie needs help! References: <70c31206.0111280950.7ebe06ae@posting.google.com> Message-ID: <9u3mrk$rgj$1@nntp9.atl.mindspring.net> Looks like the only problem is indentation, which is very important in Python. If you indent the two lines after the while, it should work fine. Like so: total = 100 sum = input ("Enter your number. ") while sum < total: print "You haven't reached 100 yet!" sum = input ("Give me another number ") + sum print "Ok, you got me!" - mfg From fperez528 at yahoo.com Wed Nov 14 13:47:40 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 15 Nov 2001 18:15:40 +2328 Subject: Scientific Libraries in Python References: <9t1iqq$es0$2@peabody.colorado.edu> <3BF45CAF.9983E26A@home.net> Message-ID: <9t1pfj$k1s$1@peabody.colorado.edu> Chris Barker wrote: > Nice Summary of the state of the art: Thanks. >> Visualization: > > I agree that Visulisation is key. You didn't mention it here, but the > problem I have with most of the available stuff is that it is all > wrappers around other external packages. To really get what I want, I > need to be able to access the primitives form Python. That means a lot > of the code should probalby be in Python, or at least written with this > kind if access in mind. > > I've been imagining a package built in Python that looks a lot like > MATLAB's handle graphics (although with OO, you wouldn't need the > handles). MATLAB's system makes it very easy to whip out a plot: > > plot(x,y) > > but you can also get access to all the properties of the plot, so that > you can customise things as much as you like. I think all plots are > created by a set of only three types of primitives, a line, a patch > (surface), and a text object. It really works pretty well. I also > believe that all plots are 3-d with 2-d plots being a special casse, > where z=0 everywhere, and the view is from the top. I was trying to keep that post tightly focused to a summary, but I agree 100% with you. In fact, in a previous post on the same thread, this is what I had said: 3) A true visualization framework, which has both high-level plotting routines and access to basic primitives. Mathematica's plotting system, while not the most convenient to use, is a good example of this idea. You can just 'plot' stuff, but you also have low-level access to the graphing primitives to program more complex stuff yourself. > Anyway, it's a pretty nifty system, and I think one like ot for Python > would be great. The Graphite project (http://Graphite.sourceforge.net/) > was a nice start to this, and I think the native SciPy one looks pretty > promising as well. I didn't mention graphite b/c it seems dead. I know Mayavi is active, it's based on a high caliber underlying toolkit (vtk) and it looks very nice. I think the underlying toolkit *has* to be written in C/C++. Volume rendering for large datasets is just way too intensive a task to be done in an interpreted language. But a well designed Python interface can provide low enough level access to be useful for programming while offering high-level functions for interactive use. > My main feeling is that we really do need something native to Python. A > wrapper around an external package will never be flexible enough to > really compete withe MATLAB or IDL. > >> MayaVi at http://mayavi.sourceforge.net >> ----- > > I agree. framework like what I suggest above, built on top of MayaVi, > or directly on VTK, or even more directly on OpenGL, would be great!! I tend to think mayavi has the right approach: OpenGl is too low-level. The vtk people have already done a lot of *very hard* work. It would be silly to ignore that, IMO. And from a recent post from mayavi's author, he seems to be working on providing full python access to the system (while also offering the gui). I don't want to seem biased, I don't even know the mayavi author and have only superficially looked at the stuff. I just have a hunch that he's going in the right direction, and that (perhaps with some modifications) that's the best bet for the graphical part at this point. > Another think I'd love to see is a "Scientific Python Distribution" this > would be all of Scientific Python all packaged up with Python itself, > all compiled and ready to go (with optimised BLAS, etc) for your > platform of choice. > > It would also support MacOS, along with *nix and MSW. Agreed 100% Well, let's keep it going. I don't like cross-posting and don't really know the Numeric and SciPy people, but if someone knows them and is willing to drop them a reference of this discussion it might be a good idea to hear what they think. Cheers, f From thomas at weholt.org Tue Nov 13 11:39:54 2001 From: thomas at weholt.org (Thomas Weholt) Date: Tue, 13 Nov 2001 17:39:54 +0100 Subject: Extract info from RPM-files Message-ID: Running on Mandrake 8.1, Python 2.1.1, trying to extract information from rpm-files using the rpmfile-module I get "RPM error: This is not a RPM file". Does anybody know of any other module to use for this purpose ? Best regards, Thomas Weholt From johnroth at ameritech.net Wed Nov 14 14:33:40 2001 From: johnroth at ameritech.net (John Roth) Date: Wed, 14 Nov 2001 11:33:40 -0800 Subject: Problem with .pth files under linux References: Message-ID: "Andrew MacIntyre" wrote in message news:mailman.1005760821.4088.python-list at python.org... On Tue, 13 Nov 2001, Fernando [ISO-8859-1] P?rez wrote: > I'm sure this is simple and stupid, but I still don't know what's going on. I > have some modules without a package structure (no __init__.py) but which have > a .pth file. Specifically, Numeric. It comes in its own directory: > site-packages/Numeric, and in site-packages I have a file Numeric.pth whose > contents is simply 'Numeric' (no quotes). > > Yet import Numeric doesn't work! I solved it by hand-coding Numeric into > sys.path, but it annoys me and I have the same problem with other modules > I'll need to use soon. Is site-packages in sys.path? (or added to sys.path by site.py?) I believe you have to move the .pth file into your python path. There's doucmentation somewhere about this, but it's well hidden, and it differs between xNIX and Windows. John Roth From list at icmerlin.com Wed Nov 14 13:19:20 2001 From: list at icmerlin.com (list at icmerlin.com) Date: Wed, 14 Nov 2001 10:19:20 -0800 Subject: Can Prophecy be Changed? Message-ID: Greetings, We found you on the Internet at http://www.fnorb.org/contact.html Prophecy -- what does it mean to you? Does it mean the prediction of momentous events, even dire events like catastrophic earthquakes and murderous acts of terrorism? Does it also mean the alternative predictions of a brilliant new golden age of peace, astounding innovation and high culture? On Tuesday, November 20, 2001 from 7 - 9 p.m. (CST) you can hear and participate in a free interactive worldwide internet broadcast called: PROPHECY FOR THE 21ST CENTURY: TURNING TERROR INTO TRIUMPH. This talk -- unlike any you have probably heard before -- covers all these aspects of prophecy for our times and many more. For example, in this address you will hear a review of the dramatic prophecies of Nostradamus, Edgar Cayce, Saint Germain, Mother Mary and others explained and compared. Far from a doomsday message, this address will cover the key idea of how to mitigate and transform dire predictions into positive new eras of history. To learn more about this event and how you can hear the FREE interactive Internet broadcast, visit http://www.icmerlin.com/prophecy ___________________ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * [To be removed from this list, please hit reply and type REMOVE. Please to not reply to this email with a message. To send a message: email prophecy at icmerlin.com.] From sheila at spamcop.net Sat Nov 10 14:42:29 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 10 Nov 2001 19:42:29 GMT Subject: Teaching python (programming) to children References: Message-ID: <9sj3mp.3vv92o3.1@kserver.org> On Sat, 10 Nov 2001 12:54:09 -0500, "Arthur Siegel" wrote in comp.lang.python in article : :Sheila writes - :>If you were in the classroom working with :>students, this wouldn't be important at all. : :Not sure what you are saying. I'm saying, that in the classroom, all the arguing about current fad theories is a distant clamoring, that the classroom practitioner need not deal with on a daily basis. :According to Paul, Piaget (and anything that invokes :the name) is a done deal. And Paul is the one who decides? I did have to study Piaget, Dewey and others for my credentialing courses (about 20 years ago), but the most I could tell you about Piaget today, is that he argued that students needed to have a concrete understanding of something before they could proceed to an abstract understanding. As for the high school teachers I worked with recently, I'd be surprised if even half of them could tell you that much. In all the time I worked at the high school, I can't remember Piaget ever coming up in discussion in the teacher's lounge, or in one of our Math Department or Business & Technology Department or Language Department meetings (I was members of all three departments at various times), nor at the general faculty meetings. Maybe it did come up, but apparently not often, nor was the mention particularly memorable nor important, as I don't recall it at all. :But, perhaps its more that the folks who see it otherwise :just got exhausted counter-arguing. To be honest, I haven't been following this whole thread. I've only read a select few messages. But I went back and read yours and Paul's after this post, and I'm not sure as to what the point is that is being argued and counter-argued. :Maybe teachers need to be exposed to some counter din. : :I volunteer. If you feel you have a good point about curriculum and/or teaching methods, put your point out there and be vocal about it. Give the teachers access to your ideas, and the reasons why you promote it. Then allow them to decide whether to adopt it or not. I think that change in the curriculum should be initiated by those who are the daily practitioners of it. Not by those sitting in administrative offices. I was fortunate to work in a school, where at least this much was under my control. I was allowed to choose my own textbooks, my own curriculum, etc... That part of the job I found very appealing. Where I worked, it was usually the "good" teachers who would become aware of new ideas, and present them to their department. If anything changed, it was as a result of this type of introduction of new methods and curriculum from those good teachers. And when the administration tried to impose top-down ideas upon us, that we did not agree with, we fought them on those ideas, and presented our opinions and evidence as to why we did not want to go along with it. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From adamspitz at bigfoot.com Thu Nov 15 11:00:43 2001 From: adamspitz at bigfoot.com (Adam Spitz) Date: 15 Nov 2001 08:00:43 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <87f44f44.0111141213.4778982c@posting.google.com> Message-ID: <87f44f44.0111150800.521a060c@posting.google.com> Laura Creighton wrote: > (I've always wanted to ask this:) > > The Design Patterns Smalltalk Companion (p 214) discussing Proxy states: > > 'Since the problem lies in Proxy's subclass relation to > object, one way to solve it would be to dissolve this > relationship. How is this possible? Subclass Proxy off nil' > > Do people actually do this. Pardon this phrasing, but isn't it, ah, > 'evil'? I'm way to scared to use it, though of course I had to write > one just to see it. Honestly? I have no idea. I've never done it myself. But then, that doesn't mean much. If it scares you, open up a workspace and play with the objects for a while. Get your hands on them. Get comfortable with them. (You can do this in Python, too, in interactive mode.) And write a bunch of unit tests, while you're at it. It still seems to me like it's pretty deep in the bag of tricks, but I wouldn't be afraid to use it when I needed to. Adam Spitz From prabhu at aero.iitm.ernet.in Tue Nov 6 00:14:48 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 10:44:48 +0530 Subject: Tkinter bind single key In-Reply-To: References: Message-ID: <15335.29128.684790.926174@monster.linux.in> >>>>> "JH" == John Hunter writes: JH> I am reading 'An Introduction to Tkinter' by Fredrik Lundh and JH> my read of Chapter 7 'Events and Bindings' is that this syntax JH> self.__canvas.bind('+', self.zoomin) Try the following instead: self.__canvas.bind('', self.zoomin) or self.__canvas.bind('', self.zoomin) Under Linux you can use the keysymdef.h file to see what the correct names are its usually here: /usr/X11R6/include/X11/keysymdef.h prabhu From daves_spam_dodging_account at yahoo.com Mon Nov 26 14:01:32 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Mon, 26 Nov 2001 11:01:32 -0800 (PST) Subject: WINDOWS USERS???? In-Reply-To: Message-ID: <20011126190133.48988.qmail@web21102.mail.yahoo.com> > -----Original Message----- > From: Power-Tech [mailto:mind.tech at verizon.net] > Subject: Re: WINDOWS USERS???? > > and solutions....let me know how sucessful you have > been at running a > .py > file after you save it....does it open a DOS window? If you want a script to run by double-clicking it in Explorer, and you *don't* want a dos window to open, save the file as .pyw instead of .py. .pyw is for "Python Windows" scripts; they don't open a console window. Welcome! -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From walter at livinglogic.de Thu Nov 15 08:48:24 2001 From: walter at livinglogic.de (Walter =?ISO-8859-1?Q?D=F6rwald?=) Date: Thu, 15 Nov 2001 14:48:24 +0100 Subject: Tidy HTML, was: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> <20011115062102.925$Y5@news.newsreader.com> Message-ID: <3BF3C7A8.50402@livinglogic.de> Hernan M. Foffani wrote: > The fact that with Python is soooo easy to grab and extract data from > remote pages that annoys a lot when such pages aren't valid HTML. > > It's unfair to require that htmllib &co parses invalid HTML though. > This problem can be solved with a simple routine that calls tidy > through a pipe before calling the parser. Better yet, use Marc-Andr? Lemburgs mxTidy (http://www.lemburg.com/files/python/mxTidy.html) Bye, Walter D?rwald From peter at engcorp.com Tue Nov 27 00:40:46 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 27 Nov 2001 00:40:46 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> Message-ID: <3C03275E.2C4D8149@engcorp.com> Huaiyu Zhu wrote: > > On Sat, 24 Nov 2001 21:25:22 -0500, Peter Hansen wrote: [...] > > - That there is no reason to associate tab with any equivalent in spaces. > It should only be used as a distinct character in its own right. > > - That the problems with different tab-sizes are all caused by people > presuming tab can be used as a short hand for spaces. I didn't miss those points. I agree with the latter. The former is also true, provided you are talking strictly about TAB==X spaces, which is *never* something I said. By the way, the phrase "tab size" was outlawed by David a few messages back, I believe. Remember, tabs don't have sizes, or so we were told. See below. > >Yes, the above is what people call a tab. That doesn't say anything > >about the uses to which people (and software) put it. It is *that* > >which is ambiguous and inconsistent. > > There is no problem in using it the right way - as a place-holder of > indentation level. It can be displayed anyway you want, as long as you do > not _assume_ the writer and reader will ever display them the same way in > terms of spaces. This would of course not cause any trouble provided those who used it, used it consistently. That is, they *never* used anything spaces for indentation. Problem is, they don't follow that rule, and don't seem to understand that, with Python having mandated a convention, any mixed use of spaces and tabs set to other than every 8 columns will confuse Python. > If you get around the notion that tab can ever be translated into spaces in > a _universal_ way, you'll find that all the problems dissappear. > > For example, got a problem with mixing tab and space? Well, just don't do > it. They are two different characters. It's the same as mixing w with vv > or mixing m with rn. If this is enforced with the same strictness there > would be no more problem with mixing tab and space than mixing w and vv. Obviously. Isn't this the whole point? Didn't I say that mixing tabs and spaces was going to cause trouble? Thought I did. Anyway, much of this discussion, if not all of it, revolves around the fact that some people *do* mix them. That is apparently inevitable. Therefore, to at least set a convention, if not completely solve the problem, the Python standard is to define TAB as representing indentation to the next multiple of eight spaces. End of story... beginning of some people's problem. Mixing the two without using 8-space TABs confuses Python. Mixing the two even with 8-space TABs confuses everyone, including the programmer, when indentation levels are changed. (And no, I do *not* mean TABs which translate directly into 8 spaces, I mean TABs which advance to the next column multiple of eight. Or however you insist on pronouncing it.) > >Tab, tabstop, whatever. There's no "tab" in the binary world either. > >Just ones and zeros. > > Nonesense. There does exist a tab character, which is _defined_ as a > combination of zeros and ones. What has that to do with tabstop, which is a > horizontal postition? Yadda yadda yadda. Of course there is a TAB character. The fact that I know that was readily apparent. Yes, we all understand binary. That too is apparent. Why don't *you* define an easy way to describe the "size" -- no wait, I mean "tabstop" -- no wait, I can't say that either -- the indescribable characteristic of the TAB character which when represented onscreen as a shift in cursor position can be considered to represent a particular *number* of columns.... I've been told I can't use "tab size" for that, nor "tabstop", nor probably tab width, spacing, or any other term ever used by an editor. If we not only can't agree on a term for it, and you won't even let me define my own term clearly and attempt to use it for rational discussion, I guess we're done... > >Once again, the point you missed is that tabs are sometimes > >treated (by software) in such a way as to advance the cursor > >other than to the next multiple of 8 (which effect I was calling > >the tabstop, so I wouldn't get jumped on by people like you for > >saying tabs represented a fixed 8 spaces). > > Why would it matter to you how other people are displaying a particular > character on screen? They could just as well display it as red circle > inside a blue star followed by a yellow triangle inside a green square. As > long as this character is encoded correctly all the programs they sent you > will display on your screen the way you want to. I care nothing for other people , nor how they display TABs. I am only concerned about them wasting time when they mistakingly think they will be able to type Python code with a mix of TABs and SPACEs when their TABs are not set to 8. > Where is the inconsistency you are complaining about? When they mix it with spaces. Which is where I started about when I mentioned "ambiguity", but we seem to have agreed about the inadvisability of that, so there's no argument. > I think his point is quite clear. The reason you do not see it that way is > because, IMHO, you have not seriously considered the possibility that people > might be arguing for the position that tabs can be used consistently without > a defined equivalence as spaces. If you think I was suggesting TABs should be treated as X spaces, you missed everything I said. By the way, is that phrase you used -- "the position of tabs" -- the permitted way of describing what I inappropriately (so it seems) termed tab "size", and "width", and when my wrist was slapped tried "tabstop" as a temporary substitute? Maybe if we all talk about "position of tabs" we can get somewhere. Problem is, that's the first time in this discussion *that* particular way of describing it has come up Sigh. All that typing, and still you two seem to insist that I was saying things I did not intend, because you seem to believe I don't understand about TAB *characters* just because I used a different term for "width/size/stop/position" than you did. I think I'll quit while I'm way behind on this one. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From infotechsys.wayne at verizon.net Fri Nov 30 16:18:45 2001 From: infotechsys.wayne at verizon.net (infotechsys.wayne at verizon.net) Date: Fri, 30 Nov 2001 16:18:45 -0500 Subject: cgi problem using FieldStorage(). Message-ID: <3C07F7B5.6020205@verizon.net> Hi, I'm learnning cgi and html having a bit of a problem passing values to my cgi script. Here is the first script: ======================================== #!/usr/bin/python theSalesOrder = """Content-type: text/html\n The Test

Customer PO #:

""" print theSalesOrder ========================================= Here is the script that is called my the script above: ------------------------------------------- #!/usr/bin/python import cgi, sys sys.stderr = sys.stdin theSalesOrder = """Content-Type: text/html\n my test

%s

""" form = cgi.FieldStorage() line1 = form['customer'].value print theSalesOrder % (line1) ---------------------------------- I'm running Redhat 7.1 with the lastest release of mozilla, althought I get my error if I use Netscape 4.X, and I'm using Apache 1.3.20. Here the error from apache's error-log: [wayne at localhost online-ledger]$ tail /usr/local/Apache/logs/error_log Traceback (innermost last): File "/usr/local/Apache/cgi-bin/saleOrderAddProc.py", line 13, in ? line1 = form['customer'].value File "/usr/lib/python1.5/cgi.py", line 907, in __getitem__ raise KeyError, key KeyError: customer [Fri Nov 30 15:22:19 2001] [error] [client 127.0.0.1] Premature end of script headers: /usr/local/Apache/cgi-bin/saleOrderAddProc.py [Fri Nov 30 15:24:30 2001] [error] [client 127.0.0.1] Premature end of script headers: /usr/local/Apache/cgi-bin/saleOrderAddProc.py [Fri Nov 30 15:27:19 2001] [error] [client 127.0.0.1] Premature end of script headers: /usr/local/Apache/cgi-bin/saleOrderAddProc.py When I enter data in the first script and submit it, I set the following URL address in my browser; http://localhost/cgi-bin/salesOrderAddProc?customer%3C%2Finput=data entered If I remove the %3C%2Finput and run that it works. WHAT AM I DOING WRONG? Thanks Wayne. From ejohnso9 at earthlink.net Thu Nov 22 13:51:07 2001 From: ejohnso9 at earthlink.net (Erik Johnson) Date: Thu, 22 Nov 2001 18:51:07 GMT Subject: string.join() syntax quirky? Message-ID: <3BFD49D8.F7A4C6CC@earthlink.net> I suppose this question is mostly moot because the language is what it is (though Mr. van Rossum could always change or augment it at his will), but I'll ask anyway... After doing this: s = "string" l = list(s) l.reverse() I have a list of single character strings. A couple of people were kind enough to clue me in to the best way to turn this back to a string: s = "".join(l) This works fine, but it seems syntactically backwards to me: # s = l.join("") makes much more sense to me. The thingy I want to do something to is my list. I am just trying to learn Python, so no doubt there will be some Python things I will just have to get used to, but is there a logical reason why it was implemented as a string method rather than a list method? Does it seem backwards to you or does it make intuitive sense to you? Comments? (other than of the "it's moot" flavor) Thanks! :) -ej From phd at phd.pp.ru Wed Nov 28 03:50:45 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 11:50:45 +0300 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) In-Reply-To: ; from tim@vegeta.ath.cx on Wed, Nov 28, 2001 at 01:18:48AM +0000 References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: <20011128115045.C4239@phd.pp.ru> On Wed, Nov 28, 2001 at 01:18:48AM +0000, Tim Hammerquist wrote: > Ken Seehof graced us by uttering: > [ snip ] > > It has never been in MS's best interest to be compatible with the > > rest of the computing world. > > More precisely, it's never been in Bill's pocketbook's best interest > to be compatible with the rest of the world. > > It's _always_ been in MS's best interest to be compatible. There's > more than enough money in the industry to support Microsoft and any > other vendors. There are other merits, not only money. Corporations want power even more than money. Down with non-free software. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From loewis at informatik.hu-berlin.de Fri Nov 23 10:24:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 23 Nov 2001 16:24:37 +0100 Subject: locale.setlocale not working anymore? python 2.1 References: Message-ID: Syver Enstad writes: > Or is it just my machine? (win2k) Not necessarily your machine, but perhaps your locale setting? What do you get when you do >>> import locale >>> locale.setlocale(locale.LC_ALL) Regards, Martin From adamspitz at bigfoot.com Wed Nov 14 15:17:45 2001 From: adamspitz at bigfoot.com (Adam Spitz) Date: 14 Nov 2001 12:17:45 -0800 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> Message-ID: <87f44f44.0111141217.628f8a1e@posting.google.com> Andrew Dalke wrote: > I've never liked that idea though (which Smalltalk and Ruby both > have). I think adding methods to an existing class is like > playing around with global variables. What's to keep two different > libraries from adding a method with the same name but which > does different things? Faith? :) Seriously? It's almost never a problem. (Python people ought to be familiar with this argument - it's the same one we all use when incredulous C++/Java programmers ask us how we can possibly live without a static type checker. ;) Adam Spitz From phr-n2001d at nightsong.com Sun Nov 4 13:05:40 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 04 Nov 2001 10:05:40 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: <7xy9lmmmx7.fsf@ruckus.brouhaha.com> Marcin 'Qrczak' Kowalczyk writes: > Intel processors and C99 do the first variant. Python does the third > variant. Knuth says the third variant is the true one. In SML and > Haskell the first variant is called quot/rem and the third is called > div/mod. Knuth says to use floor_mod? Where? Every CPU that I know of uses trunc_mod (your 1st variant). Floor_mod makes more sense for a lot of things. I can't help thinking there must be a reason for all the implementations using trunc_mod, but I don't know what it might be. From eppstein at ics.uci.edu Wed Nov 28 18:46:47 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 28 Nov 2001 15:46:47 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C056DF5.F9EE5D13@ccvcorp.com> <3C0575F4.9A23C894@cosc.canterbury.ac.nz> Message-ID: In article <3C0575F4.9A23C894 at cosc.canterbury.ac.nz>, Greg Ewing wrote: > I think the point Mr. Eppstein was making is that > "for i in seq" can be read as "for all values of i > such that i in seq is true". PEP 276 would break > that, because "for i in 5" couldn't sensibly be > read as "for all values of i such that i in 5 > is true", unless "i in 5" on its own were valid and > had a rather unintuitive meaning. Yes, thanks for expressing this more clearly. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From fperez528 at yahoo.com Thu Nov 29 11:46:37 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 30 Nov 2001 16:14:37 +2328 Subject: 2.1 loop with try & continue -> bug? References: Message-ID: <9u93uh$4m$1@peabody.colorado.edu> Marco Beri wrote: > Hi, > look at this simple program: > [snip] Very strange, and I'd say there appears to be a bug. Digging deeper: from the docs we get: ****************** 6.10 The continue statement continue_stmt: "continue" continue may only occur syntactically nested in a for or while loop, but not nested in a function or class definition or try statement within that loop.6.1[1]It continues with the next cycle of the nearest enclosing loop. --------- Footnotes ... loop.6.1[2] It may occur within an except or else clause. The restriction on occurring in the try clause is implementor's laziness and will eventually be lifted. ****************** So we know that technically you shouldn't be putting that continue in your try. However, I found something quite bizarre. I put an extra print in it and here's the code I ran: print "Running..." cont=0 while cont < 5 : print cont cont = cont + 1 try: if cont == 2: continue if cont == 3: print 'Break!' break except: pass Now for the strangeness: if this is run at the interactive interpreter, the results are: >>> print "Running..." Running... >>> cont=0 >>> while cont < 5 : ... print cont ... cont = cont + 1 ... try: ... if cont == 2: ... continue ... if cont == 3: ... print 'Break!' ... break ... except: ... pass ... 0 1 2 Break! 3 4 However, running it at the command line with python: Running... 0 1 2 Break! Running... 0 1 2 Break! .... keeps going on forever, killed it with ctrl-C. So, I suspect that the continue in the try is triggering abnormal behavior in the python interpreter which for some reason isn't triggered at the interactive prompt. It's ok if continue is invalid inside try, but then an error should be raised. Having the *same* code behave so differently between the interpreter and the interactive prompts is a bug in my book. Am I missing something? Cheers, f From wtanksle at dolphin.openprojects.net Fri Nov 9 18:30:25 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 09 Nov 2001 23:30:25 GMT Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Message-ID: On Fri, 9 Nov 2001 16:04:11 GMT, Michael Hudson wrote: >Paul Rubin writes: >> Really the ellipsis should make an iterator: for i in 0...10. >It's probably worth reading the rejected pep on range literals: > http://python.sourceforge.net/peps/pep-0204.html Facinating. The syntax of this proposal makes me think that he's trying to slice an array of nothing (there's no array there), whch seemed to be his downfall. What if slicing/indexing the "int" builtin resulted in a generator with the desired behavior? for x in int[10]: for x in int[1:11]: for x in int[1:11:2]: # now some hard ones for x in int[0:]: # all the natural numbers for x in int[0::2]: # all the even naturals for x in int[:0]: # illegal for x in int[:0:-1]: legal, all negative numbers Wait -- a question. Do slices act on generators? That is, can I slice out every other item of a generator (as I just did above)? If not, could that be added? Once that's added, what's to stop me from annoyingly demanding to be able to slice out every 'n'th item (keeping the rest as part of the generated sequence)? Such a thing would feed my hunger for an interesting prime # sieve... Wait, I'm hearing a voice. It tells me, "WRITE A PEP." Never mind -- I got my answer; I now know what will stop me from demanding those things. Odd, I feel stopped on my current demands as well. :-) >M. > I would hereby duly point you at the website for the current pedal > powered submarine world underwater speed record, except I've lost > the URL. -- Callas, cam.misc Hey, a friend of mine set that record. I wonder if it's still standing... -- -William "Billy" Tanksley From taw_usenet at yahoo.com Thu Nov 8 21:15:45 2001 From: taw_usenet at yahoo.com (ToddW) Date: 8 Nov 2001 18:15:45 -0800 Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> <9se1du$6eg$1@samos.cs.uu.nl> Message-ID: <84a8bdbe.0111081815.7e511982@posting.google.com> geert at cs.uu.nl (Geert-Jan Giezeman) wrote in message news:<9se1du$6eg$1 at samos.cs.uu.nl>... > >"Oleg Broytmann" wrote in message > >news:mailman.1005218719.27461.python-list at python.org... > >> On Thu, Nov 08, 2001 at 11:00:52AM +0000, Geert-Jan Giezeman wrote: > >> > I am trying to create a shelve from a table of 1100 by 1100 floating > >> > point numbers, which I want to store as 1100 lists of length 1100, > >> > indexed by a key. Unfortunately, I get an error when I try to create > >> > this: > >> > bsddb.error; (22, Invalid argument) > >> > >> http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.099.htp > >> > > This FAQ advises to move to a newer version of the Berkeley DB library. > How do I know which version I use? How do I replace it with a newer? > (I installed the standard Python 2.1 distribution for Windows). > > > In "Thomas Weholt" writes: > >I've experienced this problem if I don't close the db-connection after using > >it. Be sure that you call close before ending the script/program. > > > I did that, so that was not the cause of the trouble. I had some difficulties with differing versions of bsddbm due to apache (and therefore mod_python) being linked to a different version than the normal interpreter. I avoided the problem by forcing the use of a different dbm, namely gdbm: # ___db stuff___ import anydbm, gdbm, dbhash #anydbm._defaultmod = dbhash #i.e. bsdbm anydbm._defaultmod = gdbm import shelve Solved the problem. So far, no performance issues. Try it out if all else fails. From peter at engcorp.com Wed Nov 28 09:38:23 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 09:38:23 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> <3C048CCC.6A8C3743@engcorp.com> Message-ID: <3C04F6DF.86368CFD@engcorp.com> David Eppstein wrote: > > Peter Hansen wrote: > > > I agree that sounds like a worthy goal. I disagree that your > > suggestion is any more likely to be understood by anyone, > > other than perhaps a mathematician. [...] > > From context, it seems you mean Ewing's suggestion rather than mine, right? Yes, quite right. Sorry. :) > > Maybe we should look back to BASIC (for i = 1 to 5: next) > > or one of the suggestions for something which looks more > > explicitly like a list of items (for i in [0..5]) or > > (for i in [0, 1, .. 5] ). Especially this latter would > > definitely be understandable to anyone, IMHO. > > Your final option is very close to my suggestion, much earlier in this > thread, which seems to be disliked by many due to its requiring closed > intervals while other Python features use half-open ones. I was skimming the thread by that point, but I can say only that I don't see that there needs to be consistency between these two things. range(5) is a function with a definition which does what it does. It could just as well return true or false, if that's what the docs said it did. [0, 1, ... 5 ] looks like a list and should act like a list. In fact, it should *produce* a list, or in the new world an iterator. That list should "clearly" contain both 0 and 5. Anything else would be surprising. I suppose it's just the consistency argument that detractors dislike, but maybe a second look at it would convince them it's not important. The suggestions of doing [0, 1, ... 5 ) are, however sheer insanity :-). Obscure (to all but mathematicians), error prone, unbalanced braces, rarely needed, etc... If we just wanted to have another way to type range() it would be a waste. If we are trying to improve the readability of the language (especially for newbies) the [0, 1, ... 5] option (or something close) would be a good idea. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From ajs at ix.netcom.com Sat Nov 17 19:21:21 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 17 Nov 2001 19:21:21 -0500 Subject: Teaching python (programming) to children Message-ID: <000501c16fc6$fdd22520$a9e1fea9@carol> >I understand what you mean. With me, the fact is I know little about >Newton's theories. But I do seem to have a consistent distaste for >projects aimed at understanding astronomy which justify themselves as >being based on those theories. Knowing tha the earth is flat was good >enough for our ancestors and by damn, it's good enough for us. Should be admire and accede to the ideas of alchemists who can authentically claim to be carrying forward on the work and ideas of Newton in that subject area. Should we stop at Newton - even where it is provable his was correct only within a limited realm. Can one be the finest of parents and educators, relying on heart and intuition and knowing nothing of Piaget. Your response is particularly obnoxious - because: a) I volunteer that I am uneducated on Piaget - and you take advantage of my candor. I expect I will remain uneducated about him. One needs to set one's priorities. b) My link was to someone who has studied and admires Piaget - but not dogmatically, and he points to studies which contradict some of Piaget's basic findings in areas relevant to my interests and consistent - at least in my interpretation - of my intuition on these matters. Did you look at the link before you shot back with your cheap shot. Is there something in your position beyond intellectual snobbery? Art From loewis at informatik.hu-berlin.de Mon Nov 19 05:38:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Nov 2001 11:38:16 +0100 Subject: Question on default value of __init__ References: <3BF8D3BC.105F0536@pacific.net.hk> Message-ID: Bernie writes: > When I run test.py, an instance of foo is created. Is this the > default behavior in Python for default value? Yes, default values are created when the function is defined. This is the way Python works; it is not just the default. > Are there any way to delay the creation of foo() until bar() is > created. > def __init__( self, param=foo()): > assert isinstance( param, foo), '"in" must be an instance of foo' > pass You should write it like this def __init__(self, param = None): if param is None: param = foo() else: assert isinstance(param, foo), '"in" must be an instance of foo' HTH, Martin From tjreedy at home.com Thu Nov 1 11:27:48 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 01 Nov 2001 16:27:48 GMT Subject: hola nesesito su ayuda (translated - well, kind of) References: <3BE0738C.3080201@movilogic.com> Message-ID: <8KeE7.169394$5A3.63205094@news1.rdc2.pa.home.com> > Here is (I think) what Leandro asked above so that we all can try and help him: > > "I need to implement a registration system for students. I need to > input the student name as well as its address, its registration > number and the courses that he's going to take. Where should I keep > these variables---in a list, a dictionary, or should I put them in a > class?" Fernando - ?puede leer ingles, possiblemente con ayuda desde un amigo o professor? If this is to be a 'serious' program for production use in your school, then you should definitely use a database program or module. (There is relational database module written in Python and available free, but the name currently excapes me.) If this is strictly a class learning exercise, then you could also use any of the three choices you listed. You might think a bit more about the advantages and disadvantages of each. Also, do you keep the collection of student objects in a list or dictionary? What you 'should' do depends on what you can do and what you are supposed to do with the data after it is input. Note: a relational database is a set of tables, each of which is a list of lists, augmented by indexes and numerous functions for accessing and manipulating the data. Buena suerte, Terry J. Reedy From prabhu at aero.iitm.ernet.in Tue Nov 20 03:36:58 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 20 Nov 2001 14:06:58 +0530 Subject: Environment variables in Windows 2000 In-Reply-To: <9tcobh$qql@news.or.intel.com> References: <9tcobh$qql@news.or.intel.com> Message-ID: <15354.5674.87003.661975@monster.linux.in> >>>>> "BG" == Brian Geddes writes: BG> be carried over in environment space automatically by BG> os.putenv(). However, the following which looks like it BG> should work, does not: BG> import os import sys os.system["HELLO"] = "Testing" sys.exit() Umm that should be: >>> import os >>> os.environ['HELLO'] = "testing" >>> os.popen('echo $HELLO').readlines() ['testing\n'] But this will only affect subprocesses as the documentation says: """ putenv (varname, value) Set the environment variable named varname to the string value. Such changes to the environment affect subprocesses started with os.system(), popen() or fork() and execv(). Availability: most flavors of Unix, Windows. ...""" prabhu From dcinege at psychosis.com Wed Nov 21 23:00:35 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Wed, 21 Nov 2001 23:00:35 -0500 Subject: Non-Indented python In-Reply-To: <3BFC0182.7DDF6B4E@ccvcorp.com> References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: On Wednesday 21 November 2001 14:33, you wrote: > Dave Cinege wrote: > > Rule of God: > > The punishment for non-tab based indentation is death. > > This is exactly backwards. Not so. It's completely logical. A single byte, per indented block instead of some variable, arbitary number. (Files are more easily parsable, more easily edited, less error prone, and smaller to boot.) > Tabs are wrong, because different editors will treat them differently. I don't make excuses for poor editors. A programming editor worth anything (IE nedit) will let you define the display of tabs to how many ever spaces you like. > Spaces are right, because a space is a space is a space, everywhere you > go. And as you said a space is a space, and you're stuck with what ever poor choice the author choose, unless go regex happy on the code... If you use a 'single' space, I will pray for your soul and your logical but unreadable code. Otherwise you're going straight to hell. Dave -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From pete at shinners.org Wed Nov 7 01:15:09 2001 From: pete at shinners.org (Pete Shinners) Date: Wed, 07 Nov 2001 06:15:09 GMT Subject: Games Programmed in Python References: <9sahq0$qi1$1@slb6.atl.mindspring.net> Message-ID: <3BEA23A3.8010907@shinners.org> > Could somebody direct me to some examples of games programmed in Python? well, you could start with the game i've written, SolarWolf. it's actually a great example of what can be done pretty easily in python. (unfortunately the server is a bit sketchy) http://shredwheat.zopesite.com/solarwolf this is done with the pygame library, http://www.pygame.org pygame is a wrapper for the SDL libraries. this is a great lowlevel framework for creating your own crossplatform games. there is an active projects page on the pygame site which can point you towards more... http://www.pygame.org/projects/ From sabren at manifestation.com Tue Nov 13 00:10:47 2001 From: sabren at manifestation.com (Michal Wallace) Date: Tue, 13 Nov 2001 00:10:47 -0500 (EST) Subject: Proving optimized function is still correct In-Reply-To: <9sq46c$o93$1@news.carib-link.net> Message-ID: On Mon, 12 Nov 2001 salvasan at yahoo.com wrote: > def count_combos_optimised( m, n ): > numer = 1 > denom = 1 > j = m+n-1 > i = 1 > while i numer = numer * j > denom = denom * i > j = j - 1 > i = i + 1 > return numer/denom > > I've tried a whole bunch of values for m and n and so far both > functions return identical results. > > count_combos( 6, 4 ) and count_combos_optimised( 6, 4 ) both return 126 > > The optimised version operates a lot faster, but how can I be sure > that count_combos_optimised( m, n ) and count_combos( m, n ) will > return the same values for every possible pairing of positive integers > (m,n) ? There could very well be some pair of six digit numbers upon > which they disagree, or maybe no such pair exists, but is there a way > to tell either way? How do you know the first version works? Her code looks a whole lot simpler than the first version, but reading it still makes my head want to explode... The code doesn't really convey what it's trying to accomplish. You're counting combinations of something... Well great... But what does that mean? I'd wager that the reason you have a hard time knowing whether the functions do the same thing is that they don't map well with the way you're thinking about the problem... Or they don't communicate back to you what they're doing. This is the kind of place where comments come in really handy. Go back over each line and think about WHY it's doing what it's doing... And add it as a comment. As far as I know, the only way to validate stuff like this without testing every possible value is to come up with an algebraic description of what you want, prove that it works through logical deduction [remember proofs from geometry class?] and then prove that what you've written matches the algebraic description. It may be that you'd be better off writing this kind of thing in a more functional style. It may or may not speed things up, but it would probably make you a lot more confident that it really does what you think it does. Or, you could ask yourself... Does it really matter if the function fails for m= 928347932874932874 and n=239847923479234872348323? (Maybe it does... That's not for me to say.) Cheers, - Michal ---------------------------------------------------------------------- let me host you! http://www.sabren.com me: http://www.sabren.net ---------------------------------------------------------------------- From gcampanelli at ciudad.com.ar Fri Nov 16 09:21:04 2001 From: gcampanelli at ciudad.com.ar (Gustavo Campanelli) Date: Fri, 16 Nov 2001 11:21:04 -0300 Subject: Databases References: <200111161329.fAGDTiv17156@smtp.wineasy.se> Message-ID: <00df01c16ea9$f1e91fc0$bf992ac8@y4l9i5> This is a really newbie question, I just started with Python 3 days ago, and I?m finding it quite fascinating. I don?t know how this works for you, but I usually learn faster when I?m trying programs, and programs come out easier when I?m actually doing something and not only trying to test a comand. So I?m trying to access a database from python. Where should I look for documentation about using python as interface for MySQL or PostgreSQL? Of course, that is under Linux. Gdc From bedge at troikanetworks.com Tue Nov 20 17:30:43 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 14:30:43 -0800 Subject: Conversion from tuple to argument list? References: Message-ID: <9SAK7.2966$px5.172074@newsfeed.slurp.net> In , Bruce Edge wrote: > Forgive the stupid question, probably a C programmer mindset issue here. > > I have a tuple of data items say (0,1,2) I want to pass to struct.pack, > which takes: > pack (fmt, v1, v2, ...) > > How can I pass my tuple to pack as its arg2,3,4,... > > -TIA, Bruce. Never mind, just found apply. From ballabio at mac.com Wed Nov 14 05:09:02 2001 From: ballabio at mac.com (Luigi Ballabio) Date: Wed, 14 Nov 2001 10:09:02 +0000 Subject: Infinite lists and generators Message-ID: <5.1.0.14.0.20011114100044.00a610d0@n/a> Hi all, I've been reading a few back issues of the Perl Journal, and I came across an article on implementing infinite lists in Perl. Just for fun I went ahead and reimplemented it in Python---I know someone probably did already, but as I said, it was for fun. Also, I've written a test suite which showcases a few tricks such as building the list of all prime numbers, of the Hamming numbers, and the power series of exp, sin and cos. I'm including the file below. My question is: how does one go about pulling such stunts with generators instead? Have fun, Luigi P.S. Here's the file: #------------- Stream.py -------------- """ Infinite lists as explained in Mark-Jason Dominus, "Infinite lists", The Perl Journal Vol.2 No.3 http://www.samag.com/documents/s=1278/sam02030005/ """ class Stream: "infinite linked list with memoization" def __init__(self,head,tail): """head must be an evaluated datum; tail must be either None or a promise to evaluate the rest of the stream, i.e., a function which takes no arguments and returns the rest of the stream or None.""" self.h = head self.t = tail def head(self): "returns the first element of the stream" return self.h def tail(self): "returns the rest of the stream" import types if type(self.t) == types.LambdaType: # evaluate the promise and memoize it self.t = self.t() return self.t def integersFrom(n): "Infinite stream of integers starting from n" return Stream(n,lambda n=n:integersFrom(n+1)) def take(n,s): "returns a list of the first n elements of s" if n == 0: return [] l = [s.head()] while s.tail() and n>1: s = s.tail() l.append(s.head()) n = n-1 return l _old_map = map; def map(f,*sn): """returns the stream of the f(x1,x2...) were the x are the elements of the input streams s1, s2...""" return Stream(f(*_old_map(Stream.head,sn)), lambda f=f,sn=sn: map(f,*_old_map(Stream.tail,sn))) def filter(f,s): """returns the stream of the elements x of the input stream s which satisfy the predicate f""" while s and not f(s.head()): s = s.tail() if not s: return None else: return Stream(s.head(), lambda f=f,s=s: filter(f,s.tail())) def iterate(f,x): "returns the stream of x, f(x), f(f(x)), f(f(f(x))), ..." return Stream(x, lambda f=f,x=x: iterate(f,f(x))) def merge(s1,s2,less = lambda x,y:x 1e-7) self.failIf(math.fabs(sin_x-math.sin(x)) > 1e-7) self.failIf(math.fabs(cos_x-math.cos(x)) > 1e-7) def test(): "Run the module test suite" import sys suite = unittest.TestSuite() suite.addTest(unittest.makeSuite(StreamTest,'test')) if sys.hexversion >= 0x020100f0: unittest.TextTestRunner(verbosity=2).run(suite) else: unittest.TextTestRunner().run(suite) if __name__ == '__main__': test() From fperez528 at yahoo.com Wed Nov 28 12:57:46 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 29 Nov 2001 17:25:46 +2328 Subject: Python evangelists unite! References: Message-ID: <9u6jo8$stl$1@peabody.colorado.edu> brucehapman at hotmail.com wrote: > Okay, I was extolling the benefits of Python to a friend of mine. He > took strong exception to Python's OO model. > [snip] > > So, I need some help. I've checked out c.l.p and some on-line > articles, and I just can't find good practicle examples of a program > that adds members to instances (or classes) at runtime. Anybody got > any? I don't want to have to start avoiding my friend.... > I am currently working on a replacement for the python interpreter which depends *critically* on this. It allows the user to define special commands to control the interpreter and access the underlying shell on the fly, and this requires dynamical generation of method code (via exec with fancy tricks with string formatting) and then binding those methods on the fly to the currently running interpreter. Obviously you can do that in C with a heinous mess of pointer tables, but the point is, having those features available to me is the difference between actually producing the program vs. saying 'Obviously you can do that in C with a heinous mess of pointer tables' and never actually doing it (because it's so ugly and tricky). I'm playing tons of strange tricks with namespaces, code introspection and dynamical changing of running code. I can't even begin to imagine how I would do some of those things in any language other than Python (yes, I don't know Lisp. Shoot me.) Cheers, f. ps. If curious, I think I'll announce the first beta of this around next week. It's almost ready. From volucris at hotmail.com Sun Nov 4 03:16:14 2001 From: volucris at hotmail.com (Greg Krohn) Date: Sun, 4 Nov 2001 02:16:14 -0600 Subject: newbie Tkinter Text widget question References: <1103_1004849705@t4q4p0> Message-ID: <3be4f80b$0$432$6e49188b@news.goldengate.net> "Aaron Sterling" wrote in message news:1103_1004849705 at t4q4p0... > hello exhalted python hackers, > > I understand that the Text widget has a built in tag called 'sel' or SEL. The question is how do I find the start and end > of this (or any other) tags range. The Text class does not seem to define a method to do this. > > humbly awaiting an answer, > aaron > Yes, in fact, it does. It's tag_ranges as in Text.tag_ranges(SEL). It returns a tuple like ('row.col', 'row.col'). Sorry I'm not 'exhalted', but I hope this helps. greg From wzdd at lardcave.net Thu Nov 1 05:00:26 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Thu, 1 Nov 2001 21:00:26 +1100 (EST) Subject: python development practices? In-Reply-To: <200111010841.fA18fR0W005081@ratthing-b246.strakt.com> Message-ID: On 1 Nov, Laura Creighton wrote: > Be careful with the leading underscore thingie. I have more trouble > with python code written by people (who don't work here) who apparantly > as a last step turn _every_ attribute in their class into a _variable. > I come along and want to subclass them, or make a helper class .... What, as punishment? ;-) "You wrote unmaintainable code! It's the subclass for you! -- - Nicholas FitzRoy-Dale http://www.lardcave.net I'm thinking of getting a pet cheese. I already have the cheese food. - http://www.enweirdenment.org/cgi-bin/cube-hof.html From jim at home.com Mon Nov 26 06:44:07 2001 From: jim at home.com (Jim Meier) Date: Mon, 26 Nov 2001 11:44:07 GMT Subject: fork & exec a process? Message-ID: <87667x7o58.fsf@home.com> Hi, I know this has been covered many times before but I can't seem to find it anywhere. I'm trying to fork & exec a process, and be able to read it's output to stderr and stdout. It looks like my changes to the stderr and stdout fds aren't getting seen after the exec (or so I read in a cached article by Guido I managed to find on google). I've also tried a popen trick as mentioned in that file, of opening a pipe and using popen with redirection to it; out_read, out_write = os.pipe() err_read, err_write = os.pipe() ret = os.popen("command >&%d 2>&%d" % (out_write, err_write)) and then reading from out_read and err_read. The problem with this approach is that i can't tell when the process dies - except by calling ret.close(), and blocking until it does close. The purpose of all this is to execute some long-running programs (like ping) and collect their results, while still processing the rest of what needs to be done. There must be a way to do this, what am I missing? -Jim From kragen at canonical.org Mon Nov 26 17:20:29 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 17:20:29 -0500 Subject: calling method on dynamically loaded module References: <3c02bb13$0$11289$39cecf19@nnrp1.twtelecom.net> Message-ID: <83d725rx76.fsf@panacea.canonical.org> "Eric Cifreo" writes: > meth = getattr(mymod, "perform") I think this line reads meth = getattr(mymod, "perform()") in the code that gives you the following error, and that's your problem. > exceptions.AttributeError 'snmp_mod' module has no attribute 'perform()' HTH. From skip at pobox.com Tue Nov 20 06:41:56 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 20 Nov 2001 05:41:56 -0600 Subject: String formatting char In-Reply-To: References: Message-ID: <15354.16772.386158.111601@beluga.mojam.com> Dale> However, the %(x)y syntax isn't appropriate if there are already Dale> '%' characters in the string or if, for some reason, you need to Dale> run the substition twice on two different mapping objects. Dale> You can get around it by substituting '%' for '%%' or translating Dale> to another char and translating back afterwards but what a pain! Dale> Is there some way to alter the format escape character from % to Dale> something else? Not that I'm aware of. I suspect making it changeable would be viewed with slight disfavor. It could lead to a bit of string obfuscation, if nothing else. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From DeepBlue at DeepBlue.org Mon Nov 5 08:25:44 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Mon, 5 Nov 2001 07:25:44 -0600 Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: "Cliff Pruitt" wrote in message news:B80A5A66.125F%mail at cliffpruitt.com... > If i had, say, a > microsoft access Database, is python capable of displaying records and doing > searches on that database? Maybe more importantly is it capable of adding > records The answer is yes. There are ODBC packages to use with Python (mxODBC) http://www.lemburg.com/files/python/mxODBC.html (also check: http://starship.python.net/crew/bwilk/access.html) and you can also use Win32 COM interfaces with Python win32 extensions. DeepBlue From sholden at holdenweb.com Thu Nov 29 07:52:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 29 Nov 2001 07:52:30 -0500 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <3bfe9816.152519843@news.cortland.com> Message-ID: "Oleg Broytmann" wrote in message news:mailman.1007023549.19213.python-list at python.org... > On Wed, Nov 28, 2001 at 11:36:29PM +0000, phil hunt wrote: > > According to Microsoft, open source is un-American. And, also according > > to Microsoft, they are responsible for open source. I guess Microsoft > > must be un-American. > > Certainly :))) > > Oleg. Microsoft is a Russian plot! The cold war isn't over! Quick! Someone tell the PS From jussij at zeusedit.com Wed Nov 28 01:33:37 2001 From: jussij at zeusedit.com (Jussi Jumppanen) Date: Wed, 28 Nov 2001 17:33:37 +1100 Subject: C++ debugger for python/scintilla? References: <3C043024.EA1@zeusedit.com> Message-ID: <3C048541.5B81@zeusedit.com> Neil Hodgson wrote: > Jussi Jumppanen: > > The one problem I found was that for any of the Windows MS-DOS > > based system (ie Win 95,98,Me etc) I had to add this method to > > the pdb.py before any debug output was displayed. > > Did you know about the -u option for running Python in unbuffered > mode? No I did not. I will give it a go and see if that fixes the problem. Thanks. Cheers Jussi. From marcoxa at cs.nyu.edu Mon Nov 12 13:11:19 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 12 Nov 2001 13:11:19 -0500 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> Message-ID: tfb+google at tfeb.org (Tim Bradshaw) writes: ... > `Standardising a library' for a single-implementation language is a > near-trivial task: you write the library and declare it a standard. > > Standardising a library for a multiple-implementation language is > *not* trivial - in fact its very difficult indeed. It costs a lot of > money to do it - the kind of money that is probably just not available > outside the C++/Java/XML camps, where huge amounts of money has been > spent on standardisation. Even this huge amount of money has often > resulted in very poor standards. The CL community has a very *good* > standard, and lacks the kind of huge money needed to generate other > standards, let alone other standards of comparable quality. These are very good points. Let's take an example of what may illustrate the difficulties the CL community faces w.r.t. the "single-implementation/single-standard" language communities. The ANSI standard does not specify a function for "splitting" strings. Maybe an historical oversight, yet that is the way things are. It turns out that it is very easy to write such a function (not only: it is easy to write it in such a way that it operates on every CL `sequence'). The signature may look like: (defun split-sequence (sequence &key (separators (list #\Space)) (start 0) (end nil) (test #'eql) (from-end nil)) ...) Now: to get this into the "standard" is out of the question. To get this to run in every implementation (some commercial, some DFSG compliant, some public domain) is easier. To ensure that upon fring up you CL you can do your-cl-prompt> (split-sequence "I am a string") ("I" "am" "a" "string") your-cl-prompt> (split-sequence (vector 1 2 3 0 5 6 7 0 9) :separators '(0) :test #'= :start 4) (#(1 2 3 0) #(5 6 7) #(9)) is an entirely different community issue. Of course you may judge this state of affairs severely or not. It is just the ways things are. Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From jorgenhansen at hotmail.com Thu Nov 8 07:44:48 2001 From: jorgenhansen at hotmail.com (=?ISO-8859-1?Q?J=F8rgen_Hansen?=) Date: 8 Nov 2001 04:44:48 -0800 Subject: Avoiding resizing of frames in Tkinter References: <117880a1.0111070319.36e66c94@posting.google.com> Message-ID: <117880a1.0111080444.1018acbe@posting.google.com> Hello, I figured it out myself. I used the grid manager instead of the pack manager and that solved my problem like a charm. Cheerio Jorgen From lisowski.tomasz at sssa.NOSPAM.com.pl Fri Nov 9 08:30:49 2001 From: lisowski.tomasz at sssa.NOSPAM.com.pl (Tomasz Lisowski) Date: Fri, 9 Nov 2001 14:30:49 +0100 Subject: Matrix in Python . References: Message-ID: <9sglpt$a3r$1@news.tpi.pl> U?ytkownik "Amit Weisman" napisa? w wiadomo?ci news:mailman.1005303314.15808.python-list at python.org... Hi Is there a module for dealing with Matrix ? TIA Amit For dealing with Matrix you need something more powerful, than Python. You have to realize, that the world does not look as your eyes, and your mind tell you. Otherwise ... Matrix has you! Neo :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From nomad*** at ***freemail.absa.co.za Mon Nov 5 07:01:54 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Mon, 05 Nov 2001 14:01:54 +0200 Subject: Teaching python (programming) to children References: Message-ID: On 05 Nov 2001 10:55:17 +0100, Brian Elmegaard wrote: >However, in order to program you need to be able to write. And out of >the English-speaking world, learning English will be one obstacle >delaying the learning of programming. > >So, any comments are appreciated, especially on: Are there good reasons >for advocating python being a language one could teach children >programming with and are there perspectives in translating python to many >different languages in order to facilitate this, or will children not be >ready for learning programming before they have learnt English after all? IMHO, python would be one of (if not _the_) best language to teach beginning programming - not just children, but as you mention, there is the difficulty with the "englishness" of the language (or almost any other programming language). However, from my viewpoint, and the way I perceive the the world going, children that will have access to PC's are reasonably likely to have already learnt some english, if not quite enough to start out. But the question I have to ask, is what age are we talking about here? IMHO, even if many young children have learnt enough english to program in any language, may not be intellectually mature enough to be able to think in the abstract manner that will be required for all but the most basic algorithms and design patterns. I that case I would greatly prefer a child to learn when it is ready rather than see it taught in lower (pre-high or pre-secondary) schools. just my R0.02 -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From fuessler at informatik.uni-mannheim.de Mon Nov 12 07:18:01 2001 From: fuessler at informatik.uni-mannheim.de (Holger Fuessler) Date: 12 Nov 2001 13:18:01 +0100 Subject: long string constants References: Message-ID: Yes, that was it. Thank you very much. Holger -- Holger Fuessler Praktische Informatik IV Tel: +49 621 181 2605 University of Mannheim Fax: +49 621 181 2601 L15, 16 68131 Mannheim, Germany fuessler at informatik.uni-mannheim.de From warkid at storm.ru Mon Nov 5 07:49:52 2001 From: warkid at storm.ru (Kerim Borchaev) Date: Mon, 5 Nov 2001 15:49:52 +0300 Subject: Non-obvious name bindings Message-ID: <0659.011105@storm.ru> Hello! It seemed that it was my failure of understanding python but the fact that introducing variable in list comprehension binds it to functions scope(as every declaration means to?) is not really obvious. I mean this: >>> [e for e in ['exists']] ['exists'] >>> e 'exists' And I'm still confused - those "temporary" variables declaration looks so "innocent", and in most cases (in every case for list comprehensions I guess?) it's everyones intension not to use this variable somewhere outside the loop. What are your thoughts? Best regards, Kerim mailto:warkid at storm.ru From sholden at holdenweb.com Fri Nov 30 10:08:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 10:08:00 -0500 Subject: using access databases from python References: <3C0672A8.86BD7D43@ecn.purdue.edu> <3C0783DB.BFB3CAC6@ecn.purdue.edu> Message-ID: "Christopher N. Deckard" wrote in message news:3C0783DB.BFB3CAC6 at ecn.purdue.edu... > Steve Holden wrote: > > > > [posted & mailed] > > > > "Christopher N. Deckard" wrote ... > > > Do to M$ Access's inability to correctly export data from its > > > database, I am searching for other ways to dump an access database > > > to tab delimited files. I was wondering if there is an access > > > database python module. Even if it only works on Windows, that's > > > fine. I just need to get data out of Access to put it into a > > > Postgres database. > > > > > You should be able to do considerably better than transfer via tab-delimited > > files. > > Yes. I know. :-) > > > You can access both PostgreSQL and Access through the Python DB API. I > > haven't actually used PostgreSQL in anger yet, but there are at least three > > modules for it. I usually use mxODBC to access Jet databases. It's freeware > > for personal use, though you have to buy a license for commercial > > applications. > > Great. I will look at that. I guess I can read the license, but is > it ok for use by educational institutions? > Look at the license :-) Seriously, I doubt legitimate academic use will violate the freeware terms, but I didn't write the license, and have only scrutinized it to the extent that I know my uses are allowed. > > > If something like that doesn't exist, how else can I do it? > > > > > You'll need to take a look at the DB API documentation, which you'll find > > under the DB SIG's area of www.python .org. It's not that hard to use. > > > > To give you some idea of exactly how simple database transfer is, here's a > > program I used to copy a small Access database into Gadfly so I could test > > an application on that platform. Only one table is involved, but the > > principles would be the same for any number. In this particular program I > > used the odbc module which comes with the Win32 extensions. I was lucky: > > often program will fail if you don't import the dbi module before importing > > odbc. > > Thanks for the example. Does this only work on Windows? My real > end goal is to write an importer product for Zope. User uploads > access database, product does all of the inserts and table creation > if needed. > [Example snipped] Well, generally speaking, it's difficult to access Jet engines from other than Windows platforms. I'm not aware of a remote ODBC Jet driver (though that doesn't mean one doesn't exist). However, there should be nothing to stop you using a PostgreSQL driver that can handle remote connections from a Windows client. So the answer is, you'll need a Windows machine to run the program on, so that you can get at the Access database, but there's probably nothing stopping you from using a PostgreSQL server on some other host on your network. regards Steve -- http://www.holdenweb.com/ From gdemmy at layton-graphics.com Sat Nov 17 12:43:03 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 17 Nov 2001 12:43:03 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: <9t64fv$305$1@nntp9.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > George Demmy: > >identity = lambda x: x # like this in practice (lazy) > > > >def identity(x): # Pythonic -- shows up in profiler, etc > > return x > > > >data = filter(identity, crufty_list) > > Isn't this the same as operator.truth? operator.truth and the identity function are not exactly the same. operator.truth returns 1 if true, 0 if false. identity returns its argument, so: map(operator.truth, (0, 1, "Hi Andrew!")) -> [0, 1, 1] map(lambda x: x, (0, 1, "Hi Andrew!")) -> [0, 1, "Hi Andrew!"] With map, of course, one can imply identity with None, e.g., map(None, (0, 1, "Hi Andrew!")) -> [0, 1, "Hi Andrew!"] For filtering purposes, they have the same effect. G -- George Demmy From jtlispl at poczta.NOSPAM.onet.pl Thu Nov 29 10:44:13 2001 From: jtlispl at poczta.NOSPAM.onet.pl (Tomasz Lisowski) Date: Thu, 29 Nov 2001 16:44:13 +0100 Subject: Strange Tkinter behaviour References: <9u4kf5$ran$1@news.onet.pl> <3C064363.9D3FD2A5@engcorp.com> Message-ID: <9u5l7n$dft$1@news.onet.pl> Uzytkownik "Peter Hansen" napisal w wiadomosci news:3C064363.9D3FD2A5 at engcorp.com... > Tomasz Lisowski wrote: > > > > I am using a CAD system having an embedded Python 2.0 support. The producer > > has created some Python modules giving access to the system internals. Among > > other things there is a module with functions supporting the creation of > > geometrical entities in the drawing. > > Sorry I can't help with the question, but would you mind > telling which CAD system this is that has embedded Python? Tribon M1.4 from Tribon Solutions AB. It is a shipbuilding CAD software. From gh_pythonlist at gmx.de Sun Nov 25 14:39:26 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 25 Nov 2001 20:39:26 +0100 Subject: GUI toolkit In-Reply-To: <6lf20ucrv7ajek3hg2sef4a8s9o1bb4s4p@4ax.com> References: <9tb6ke$1evoq$3@ID-89274.news.dfncis.de> <9td9lv$c8p$1@tyfon.itea.ntnu.no> <9tqsja$qep$1@news1.xs4all.nl> <6lf20ucrv7ajek3hg2sef4a8s9o1bb4s4p@4ax.com> Message-ID: <20011125203924.A5012@lilith.hqd-internal> On Sun, Nov 25, 2001 at 06:59:18PM +0000, Courageous wrote: > > >Perhaps it's worthwhile to understand that you can release your > >application under multiple licenses, yourself. On the other hand, > >you can just release the sourcecode under GPL, and have people > >do what they want on their own platform. > > GPL is Satanic. Use BSD-style licenses. :) Don't upset us Satanists by comparing our Master to the GPL >:-) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From jeff at ccvcorp.com Mon Nov 12 15:35:08 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 12 Nov 2001 12:35:08 -0800 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> <3BEC1A81.6D8766B@ccvcorp.com> Message-ID: <3BF0327C.BCCE2A11@ccvcorp.com> Robert Amesz wrote: > Jeff Shannon wrote: > > > Robert Amesz wrote: > > > >> I wrote: > >> > [something] > >> > >> Ignore previous post: I read 'raw_input' where it actually said > >> 'input'. My mistake. > > > > Though actually, the use of input() is generally not a very good > > idea, and it would be safer to use raw_input() and then convert > > from strings if needed. In this case, it's not needed, and the > > raw_input result would be better off being compared as a string. > > Which is probably why I made that mistake. The use of 'raw_input' is > not that uncommon, but 'input'? I've never seen 'input' being used in > a real program. It's not very useful anyway, as input("Expression: ") > seems to do exactly the same as eval(raw_input("Expression: ")). And > if I'd need a number, I would use float() or int() on whatever > 'raw_input' returns, and probably protect it with a try-except block > to boot. You can't go far wrong by never trusting user input. Agreed completely--the use of input() threw me at first, too. :) Jeff Shannon Technician/Programmer Credit International From root at rainerdeyke.com Thu Nov 8 17:39:08 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 08 Nov 2001 22:39:08 GMT Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: wrote in message news:mailman.1005256814.9657.python-list at python.org... > > Now that the issue of transfinite cardinals has been fully resolved, isn't > it time for yet another unpopular-and-non-pythonic suggestion? I believe > it is. > > What if (in post-2.2) Python the tp_iter slot in the int type was defined > to return an xrange-like iterator such that one could do the following: > > for i in 10: > doSomething(i) I like it. I guess that just goes to show how non-Pythonic I am. Seriously, I don't see how this is worse or less Pythonic than, say, 'for line in file'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From mlh at idi.ntnu.no Tue Nov 13 17:42:00 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Tue, 13 Nov 2001 23:42:00 +0100 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> wrote in message news:mailman.1005687619.18024.python-list at python.org... > All, > > Below is the first draft of PEP 276 "Simple Iterator for ints". > (Available at http://python.sourceforge.net/peps/pep-0276.html) Heh -- cool :) I'd love to drop range() or xrange() from my for loops... (I would like some pseudocode-like literal like 0..n myself, but I see the [0:n] PEP has been rejected, so... :|) The x, = 1 thingy is pretty ugly, though... Let's just hope that iterators don't become indexable... 5[2] is just too weird ;) -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From rune at nesheim.net Sun Nov 25 12:22:11 2001 From: rune at nesheim.net (Rune Nesheim) Date: 25 Nov 2001 09:22:11 -0800 Subject: Clear screen References: <9tqlu7$47pu5$1@ID-110600.news.dfncis.de> Message-ID: <59333ea6.0111250922.79a3e2bd@posting.google.com> "Christian Fuhrmann" wrote in message news:<9tqlu7$47pu5$1 at ID-110600.news.dfncis.de>... > Hi! > How do I Clear the screen in the normal line-commanded window. (In C/C++ I > say cls();) > Chris > (C.Fuhrmann at gmx.de) Import the os module and then you can use the system function you would normaly use to clear the screen in your os. In linux: import os os.system('clear') In dos/windows: import os os.system('cls') From fsdf at d.com Sun Nov 18 02:41:36 2001 From: fsdf at d.com (sads) Date: Sun, 18 Nov 2001 15:41:36 +0800 Subject: Python bindings for Mozilla Message-ID: <3BF76630.2070907@d.com> Hi, Is there any examples out there that demonstratrates how to embed Mozilla in WxPython? Thanks. -Alvin From ajs at ix.netcom.com Wed Nov 28 18:48:48 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Wed, 28 Nov 2001 18:48:48 -0500 Subject: Copy operator (was list.remove for Noivces) Message-ID: <001d01c17867$7b7def60$a9e1fea9@carol> Chris writes - >What I get from this is that someone using Python had better understand >how Python name binding, mutable types, copying, and deep copying work >in order to not get bit eventually. I don't think making it easier tao >make a trivial copy will help that, rather it will hinder it. If there >is something you need to learn, the sooner the better! Yes. I agree. 'But help me understand what I need to understand, the sooner the better.' I had written - > One imports copy, like one imports cgi or tokenize. To a beginner, imports > from outside modules is strictly special purpose stuff. In my case it >was a long time before much beyond math ,os and sys perhaps, were anything > more than absolute exotica. Chris responds - >If anything, this is a good argument for making copy() and deepcopy() a >built-in, rather than part of a module. Yes, I agree. This would accomplish it, probably as well, or better, than my original suggestion of an operator. One learning the language will definitely look into the meaning and use of built-ins before they explore the meaning and use of one of a myriad of modules. My argument, I guess, is that copy is somehow different from the other modules, in that it is as if you are importing a built_in. Is that totally off-base? Truth is I probably would have limited use for copy in my own code. But I am concluding that understanding copy and deepcopy is somehow core Python. You need to understand why you are not using it, as well as why you are using it when you are. That you can get away with [:] is perhaps, in effect, my operator. What is the downside of copy and deepcopy as built_ins. Unnecessary performance hits in the majority of mods which don't need it, I expect. True? >> a) I could be missing something (but I would need convincing) >You make it clear that you are with this statement: That I am missing *a lot* from a technical viewpoint is abundantly clear. Do I seem to being *overstating* my technical understanding. And if Python had no pretense towards being a language suitable for learning, I would be totally out of place in saying much of anything here. But I have in fact put considerable effort into learning programming - to the extent that I have (and I am coming along fine, thank you) - with Python as my first language. Which I think makes me my own kind of 'expert' - on nothing more than learning to program - to the extent that I have - with Python as a first language (and I am coming along fine, thank you) Art From johnny at johnnysfunhouse.com Wed Nov 21 16:50:54 2001 From: johnny at johnnysfunhouse.com (Refrigerator Johnny) Date: Wed, 21 Nov 2001 21:50:54 GMT Subject: importing SWIG extension DLL from VC++ References: <9ZzK7.40081$Ze5.22244774@news1.rdc1.md.home.com> Message-ID: <2lVK7.42123$Ze5.23895651@news1.rdc1.md.home.com> > > This is just a simple test. I have a bigger problem, where importing an > extension DLL causes an assertion? Problems solved. My extension DLL was a release version, and my test application (vc++ with embedded python, which called the extension DLL) was a debug version. I installed the debug extensions from the active python site - not real easy to find. Created the debug version of the extension DLL - make sure you call it mydll_d.dll. from the interpreter python_d.exe (not python.exe), you can then import mydll -john From kragen at canonical.org Wed Nov 21 02:33:49 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 21 Nov 2001 02:33:49 -0500 Subject: deleting directory tree References: Message-ID: <833d38wpb6.fsf@panacea.canonical.org> Tom Harris writes: > Can someone explain what os.removedirs() does? I needed a function to remove > a directory and all its files and subdirectories, and ended up writing one. > It seems that there should be such a function in os, but I drew a blank. I thought the same thing earlier today. I read the manual entry and thought, "Surely this can't mean what it says." But it does. removedirs() is just like makedirs(), but in reverse. Point it at a directory and it will remove it, along with any ancestor directories with no purpose in life other than to contain that directory. I can't imagine why anyone would ever want this. From ritchie at svs.com Tue Nov 6 20:26:06 2001 From: ritchie at svs.com (Dr. David J. Ritchie, Sr.) Date: Tue, 06 Nov 2001 19:26:06 -0600 Subject: Teaching python (programming) to children References: Message-ID: <3BE88DAD.D29B72DD@svs.com> With regard to your question and general topic... Brian Elmegaard wrote: .... > So, any comments are appreciated, especially on: Are there good reasons > for advocating python being a language one could teach children > programming with I would like to mention that I've had good success teaching Middle School students Perl in an after school computer club setting. I have been doing it since 1998. It took me a couple of try's to come up with an approach that worked. First, I took a more text book like approach. That was not very successful. Then, I took a example by example approach. That worked better. I started off from an English language perspective as a way of talking about the syntax and moved more into straight Perl. I tried to key it to the "language arts" curriculum and the push for literacy so the focus was to learn enough Perl to write a "Choose Your Own Adventure" game. In one very successful club season, I ended up with 16 different "adventures" written by kids on their own, ranging from Teletubbies to "Bill Gates vs. Apple Computer". Though they learned other aspects of Perl, the adventure program mainly involved if statements and print statements. For some in the sixth, seventh, and eighth grades, abstract thinking is only just starting to turn on, so the concreteness of the adventure program was an asset. This season I'm going to try to do the Computer Club sessions again but with Python instead of Perl. It should be lots of fun. You can see the Perl handout for the later successful sessions at http://home.mindspring.com/~djrassoc01/PoP/Pop1.html You can see the evaluation of the first attempt and some discussion about the experience at: http://home.mindspring.com/~djrassoc01/previous/VolunteerActivities/Washington/perl.html In a couple of months, I will post to my web site my experiences doing similar things with Python. --David -- Dr. David J. Ritchie djrassoc01 at mindspring.com http://home.mindspring.com/~djrassoc01/ From runyaga at thisbox.com Fri Nov 9 22:42:27 2001 From: runyaga at thisbox.com (alan runyan) Date: Sat, 10 Nov 2001 03:42:27 GMT Subject: Active Directory and ActivePython2.1 Message-ID: I'm trying to use ldap search filters w/ Python against Active Directory and things are jiving. I can get it to work w/ ASP no problem. All help would be *greatly* appreciated. my problemed Python Script adsi = win32com.client.Dispatch('ADsNameSpaces') ldap=adsi.getobject('', 'LDAP:') ldapQuery=';(objectClass=Person);ADsPath,cn;root' myDSObject = ldap.OpenDSObject(ldapQuery,'username','password', 1) I get: Traceback (most recent call last): File "E:\Python21\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "E:\ZOPE\Extensions\adsi.py", line 37, in ? File ">", line 2, in OpenDSObject com_error: (-2147352567, 'Exception occurred.', (0, 'Active Directory', 'Unspecified error\r\n', None, 0, -2147467259), None) in VBScript/ASP Set conn = server.createobject("ADODB.Connection") conn.Provider = "ADSDSOObject" conn.Open "ADs Provider" Set rs = conn.Execute(";(objectClass=Person);ADsPath,objectClass ,cn;subtree") am I doing some glaringly wrong? any comments greatly appreciated ~runyaga From eddie at holyrood.ed.ac.uk Fri Nov 16 13:56:57 2001 From: eddie at holyrood.ed.ac.uk (Eddie Corns) Date: Fri, 16 Nov 2001 18:56:57 +0000 (UTC) Subject: PEP proposal: enhanced string functions References: Message-ID: <9t3nhp$rtf$1@scotsman.ed.ac.uk> >PEP: XXX1 >Title: Optional pad character for string justification functions >Abstract > This PEP proposes a minor enhancement to the ljust(), rjust(), and center() > functions in the standard string module, and their corresponding methods for > string objects. > The proposal is to allow these functions and methods to take one optional > argument in addition to the arguments that they now accept. The argument is > called "pad", and it will default to a single space character. The pad > argument may be over-ridden only by an argument that consists of a single > character. If the pad argument is over-ridden, then the specified pad > character, rather than the default space character, will be used in padding > the string to the desired length. If you were going to improve justification, I suggest the pad should be a string of any length and there should be another optional argument for what direction the string is padded from (ie either from what we have so far to the specified limit or backwards from the limit to where we are). Eg print "Chapter 1".rjust(65," .")+' Page 1' print "Chapter 1.2".rjust(65," .")+' Page 3' which produces: Chapter 1 . . . . . . . . . . . . . . . . . . Page 1 Chapter 1.2 . . . . . . . . . . . . . . . . . . Page 3 OR much better (for this case) print "Chapter 1".rjust(65," .",true)+' Page 1' print "Chapter 1.2".rjust(65," .",true)+' Page 3' which produces: Chapter 1 . . . . . . . . . . . . . . . . . . . Page 1 Chapter 1.2 . . . . . . . . . . . . . . . . . . Page 3 Certainly I was looking for something just like this recently. However I can't help thinking that some more general purpose formatting tools are what's really needed. I was a little bit surprised at the lack of formatting functions in Python. Maybe, I'll write some. Eddie From matt at mondoinfo.com Mon Nov 5 12:43:58 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Mon, 05 Nov 2001 17:43:58 GMT Subject: time.daylight (Daylight Saving Time) References: <3BE68D3B.28AEA20E@cs.utwente.nl> Message-ID: On Mon, 05 Nov 2001 13:59:39 +0100, Richard van de Stadt wrote: >Hi, Hi! >I'm using time.tzname[time.daylight] to display the time zone. This worked >fine as long a Daylight Saving Time (DST) was valid [. . .] >However, now that DST is over, time.daylight keeps on being 1 (on the >5 systems located in different time zones that I've tried). I think you're misinterpreting dime.daylight. At http://www.python.org/doc/current/lib/module-time.html it says: daylight Nonzero if a DST timezone is defined. I think you want something more like: >>> import time >>> timeTuple=time.localtime(time.time()) >>> time.tzname[timeTuple[8]] 'CST' You might want to check that daylight is nonzero first. Regards, Matt From ahamm at programmer.net Thu Nov 29 23:26:20 2001 From: ahamm at programmer.net (Andrew Hamm) Date: Fri, 30 Nov 2001 15:26:20 +1100 Subject: New updates needed for an old computer language humor piece References: <3c0703b3$1_2@news.iprimus.com.au> Message-ID: <3c070a6c_2@news.iprimus.com.au> Andrew Hamm wrote in message <3c0703b3$1_2 at news.iprimus.com.au>... > >set -a COLT $CALIBRE $CALIBRE $CALIBRE $CALIBRE $CALIBRE $CALIBRE > OOOPS! That should be set -A COLT ... From jeff at ccvcorp.com Fri Nov 16 13:53:35 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 16 Nov 2001 10:53:35 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111122102.2058f188@posting.google.com> <7396d2b2.0111131345.22483e62@posting.google.com> <3BF1B946.35E697B1@ccvcorp.com> <7396d2b2.0111151900.6f08b0f0@posting.google.com> Message-ID: <3BF560AF.CEECCD3C@ccvcorp.com> Lemniscate wrote: > Additionally, you mention that I don't have a sheets > parameter in my method calls. That was done on purpose to make the > code a bit easier to read. I modified the methods to have sheets with > a default value of 1. I kind of thought so, since I did the same thing with my excel-manipulating class... ;) I still haven't done anything terribly fancy with excel, just pumping data in and setting format-types, but if you run across any more questions, I'll be happy to help figure things out. :) Jeff Shannon Technician/Programmer Credit International From krussll at cc.umanitoba.ca Fri Nov 23 18:43:55 2001 From: krussll at cc.umanitoba.ca (Kevin Russell) Date: Fri, 23 Nov 2001 17:43:55 -0600 Subject: Microphone input References: Message-ID: <3BFEDF3B.B406D0BE@cc.umanitoba.ca> Jesper Olsen wrote: > > Does python have e.g. a "Multimedia" module, with functions supporting > input from a microphone? > > Java has this, but I have not been able to find something like it for > python. > > Jesper There's no standard module for sound. But check out the "Sound" category at the Vaults of Parnassus. There are a few platform-specific modules that may be able to do what you need. If you need something more cross-platform and can stand the overhead of Tkinter, you can use the Python wrappers for Kare Sjolander's Snack module for TCL. -- Kevin From the1eagle at aol.com Fri Nov 2 00:48:21 2001 From: the1eagle at aol.com (The1Eagle) Date: 02 Nov 2001 05:48:21 GMT Subject: newbie question Message-ID: <20011102004821.02918.00002310@mb-fi.aol.com> Hello All, I am trying to read in a file and place each word in the file into an array or list so that those words can be manipulated (ie alphabetized, counted, deleted, compared, etc). For some reason I can seem to find a way to get split to work in this manner. Any ideas? Here is the code so far, but this may be the wrong approach. Thanks. #function that does all the work def handledata(input): text = input.readlines() #need to parse text. Would be nice to have \n and other punctuation removed. #main routine input = open("\\textfile.txt") handledata(input) From kosh at aesaeion.com Wed Nov 14 23:55:17 2001 From: kosh at aesaeion.com (kosh at aesaeion.com) Date: Wed, 14 Nov 2001 21:55:17 -0700 (MST) Subject: who called a function? Message-ID: How can I find out what object called a function and essentially step back through that? At most I need to step back about 4 to 5 levels but it would be very useful for me to find a particular object back up the list and change behavior based on that. Mostly I just wants the self var as I step back until I find the one I want. Designing the webpages of tomorrow http://webme-eng.com Designing the MMORPGS of tomorrow http://worldforge.org From r.b.rigilink at chello.nl Mon Nov 5 18:53:55 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Mon, 05 Nov 2001 23:53:55 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> Message-ID: <3BE7269A.692326EF@chello.nl> Jive Dadson wrote: > > Chris Barker wrote: > > > > While nothing is actually set in stone, some things are pretty well > > cemented in. > > > > Jive Dadson wrote: > > > Thanks. Before I submit a formal proposal, let me run it by you guys. > > > > That is a good idea, most PEPs start as a discussion here. AN a whle lot > > more start that way and nver make it to a PEP. > > > > > I've looked through all the PEPS and I was surprised that my suggestion > > > is not already there. So, here it is. Please comment. > > > > You can bet that this has been proposed by people new to Python again > > and again and again ... > > What does that tell you? > That people who are new to a language tend to perceive that language in terms of languages they have used previously. The most common requests for language additions by new users tend to fall in the "can't you add this really nice feature from language X to Python" category. > > ... and I can promise you that this is one thing that > > is very well cemented in. If there is one thing that makes Python > > Python, is that it is a highly dynamic language. THat is not going to > > change. > > You must have misunderstood what I wrote. I'm not proposing anything > that would make it "lowly dynamic". > Well, you use the term 'variable declaration' which for most of us carries the connotation of both the definition of a name, and a restriction of the type of values that can be assigned to it. aka static typing. The request for some kind of static typing is quite common. Reasons given are usually 'catching bugs (using the same arguments you give)' or speed. Python, however, happens to be dynamically typed. Most of us feel that the advantages of dynamic typing far outweigh the disadvantages. However, I gather from the rest of your post, that you just want the name definition part of variable declaration, and not the type definition part. Why don't you want static typing. It allows the compiler to catch even more bugs? > > > > > option explicit > > > > > > def initialized = 0 > > > def init_everything(): > > > blah() > > > blah() > > > blah() > > > initialized = 1 > > > > > > The above code would work as anticipated. No pesky "global" qualifier. > > > > Actually, no it wouldn't. The second initialized here is a local > > variable, and it should remain so. Having a variable in a function be > > either local or global depending on something that is outside of the > > funciton is asking for trouble. > > I didn't propose anything like that. The compiler will know that > "initialized" is not local to init_everything because it is not declared > there with a "def". That has absolutely nothing to do with anything > outside the function init_everything. > Yes you did ;) Most local variables shadowing global names, are intended to be local. Therefore, the only reasonable thing for your 'option explicit' to do, would be to raise an Error with "undefined variable initialized in init_everything". Because, assuming that for the simple reason that there is a global with the same name that was defined properly, the undefined local variable is the same as the global one, will usually be _wrong_. Unfortunately the most likely fix someone would apply is to write 'def initialized' at the beginning of the function, which, although usually the right solution, in this case, is an error which will go just as undetected as the missing global. By the way, the only reasonable idiom for this example would be: initialized = 0 def init_everything() # global initialized <- forgotten if not initialized: # and therefore this will be an error blah() blah() blah() initialized = 1 And the compiler catches that just nicely. Also, I just grepped approx 10k lines of Python code and I couldn't find a single 'global' statement in there. > > What we are discussing is not uniquely "Python". Other languages have > had the dubious feature that the first assignment to a variable is its > declaration. Invariably, people discover that it was a lousy idea. The > people who USE it discover that. Yet, there are thousands of people happily using a language (Python) that does have that feature. I'm sure you don't wish to imply that they don't really USE the language ;) > They misspell a variable name and in > doing so they introduce a bug. The bug may not manifest itself until > the code is already shipped. Even if they do notice the bug before it's > too late, it may be very difficult to track down. I've been down that > road a lot of times. > I think it would be reasonable to assume that either - Those of us that USE Python really don't encounter this problem that often, or - Those of us that USE Python have found ways to deal with this problem that work so well that a language change is just a very expensive alternative Have fun, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From DeepBlue at DeepBlue.org Fri Nov 9 11:07:54 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Fri, 9 Nov 2001 10:07:54 -0600 Subject: Trouble with cgi.FieldStorage() on iis/asp References: <3bebd556$0$25387$edfadb0f@dspool01.news.tele.dk> Message-ID: To find the name of the file (if I understand you correctly) check out the following from the cgi file upload script by Tim Middleton: Say you have the following form:
Name of File 1:
Name of File 2:
Name of File 3:
Name of File 4:
Name of File 5:
Name of File 6: (rest of form etc.........) import string etc...... data = cgi.FieldStorage() f = 1 while f: key = "file.%s" % f if data.has_key(key): fn = data[key].filename if not fn: f = f + 1 continue if string.rfind(data[key].filename,"\\") >= 0: fn = fn[string.rfind(data[key].filename,"\\"):] if string.rfind(data[key].filename,"/") >= 0: fn = fn[string.rfind(data[key].filename,"/"):] if string.rfind(data[key].filename,":") >= 0: fn = fn[string.rfind(data[key].filename,":"):] o = open(dirUpload+os.sep+fn,"wb") o.write(data[key].value) o.close() fnList.append(fn) kbList.append(len(data[key].value)) kbCount = kbCount + len(data[key].value) f = f + 1 else: f = 0 This works flawlessly with me, and file is found with no problems. Hope this helps. DeepBlue "Max M" wrote in message news:3bebd556$0$25387$edfadb0f at dspool01.news.tele.dk... > Hi > > I am using Pyhon in asp. And I am trying to download a file. I parse my form > content with the methods in the cgi module. This sort-of works. Actually the > code snippet below works fine. It's just that I cannot find the file name of > the opladed file with this example. > > So I trie to use: > > form = cgi.FieldStorage(fp, pdict) > Instead of: > form = cgi.parse_multipart(fp, pdict) > > And then I tried to get at the data with: > > form['image'].filename > and > form['image'].file > > But apparently my form object is not rigth, as it cannot be indexed. so > form['image'] fails. > > I have tried to read the source of the cgi modul, but I don't see why > "FieldStorage()" should have other input parameters than "parse_multipart()" > to work. > > Does anybody have a clue? > > Regards Max M > > ###################################### > > ## form.asp ############################### > >
>
> > > > ## formAction.asp ########################## > <%@ LANGUAGE="Python"%> > <% > import cgi > from StringIO import StringIO > > def getQuery(): > # Getting the querystring parsed to 'query' dict > qs = str(Request.ServerVariables('QUERY_STRING')) > query = cgi.parse_qs(qs) > return query > > def getForm(): > # Getting the form type & content > content_type = str(Request.ServerVariables('CONTENT_TYPE')) > binaryContent = Request.BinaryRead(Request.TotalBytes) > > # Get the header & create the parameterdict to pass to parse_multipart() > header = cgi.parse_header(content_type) > pdict = header[1] > pdict.update({'content-length':binaryContent[1]}) > > # Parse and get form as dict > fp = StringIO(str(binaryContent[0])) > form = cgi.parse_multipart(fp, pdict) > fp.close() > return form > > form = getForm() > Save the image > f = open('c:/temp/image.jpg','w+b') > f.write(form['image'][0]) > f.close() > > query = getQuery() > %> > > > > From emile at fenx.com Wed Nov 21 21:25:24 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 21 Nov 2001 18:25:24 -0800 Subject: Strange thing: file.close did not show error but work wrong References: Message-ID: <9tho04$2or14$1@ID-11957.news.dfncis.de> "wqhdebian" wrote in message news:db288b61.0111211822.2e903177 at posting.google.com... > f='d:\\d.txt' > fdw='d:\\matlabdata.txt' > import string > fd=open(f,'r') > fdw=open(fdw,'w+') > b=fd.readlines() > num=len(b) > print 'num=' > print num > #print b > print type(b) > #a=string.split(b,' ') > print len(b) > #for i in b[:]: > # print i > fdw.write('i') > fd.close########################### > fdw.close######################### When I use like this ,there is no > warning and > ##############any error message,but the file do not have been > writen.After I change back to fdw.close(),Then it work well. > Yes, this is all as it should be. Python simply recognizes the name without error. In console mode the same line would have responded as though you had typed in print fdw.close which would then respond with something like "method close of file object". HTH, -- Emile van Sebille emile at fenx.com --------- From claird at starbase.neosoft.com Tue Nov 13 18:13:48 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 13 Nov 2001 17:13:48 -0600 Subject: Python implementations (was: Benefits of moving from Python to Common Lisp?) References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> Message-ID: In article <9sp2in$o4e$1 at slb3.atl.mindspring.net>, Andrew Dalke wrote: >Tim Bradshaw: >> Languages such as Perl and (I think) Python are *single instance* >> classes - there is only one implementation, and the language >> is defined implicitly by that implementation. > >As a minor clarification, there are several distinct implementations >of Python (or a Python-like language). The ones I know of are: . . . Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From LLoeffler at home.com Tue Nov 27 15:25:01 2001 From: LLoeffler at home.com (Luke) Date: Tue, 27 Nov 2001 14:25:01 -0600 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> Message-ID: <3C03F69D.1020605@home.com> Greg Ewing wrote: > While trying to think of a range syntax that looks > unambiguously half-open without clashing with list > or tuple constructors, the following blindingly > obvious solution occurred to me: > > for 0 <= i < 5: > ... I'm new to Python (and admit I've only seen this message out of context of the whole thread as my news server is missing the rest--sorry if I'm repeating earlier sentiment), but feel that one of Python's best features is simplicity in syntax... It is so fast to type "for i in range(5):" because the tokens are just words. This is much better than in Java or some other C like syntax where one must type for(int i=0; i < 5; i++)... Where you have more symbols. The former is easier to read because it is natural language and easier to type because your fingers stay where they are more comfortable--over letters. I would rather not introduce a new symbolic looping construct, even if it was only optional... I've yet to find a case where range() or list comprehensions weren't good enough. We all know about the coehesiveness and readibility of code from that other 'P' language that touts many ways to do something. My $.02 L From mikael at isy.liu.se Mon Nov 5 13:08:07 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Mon, 05 Nov 2001 19:08:07 +0100 (MET) Subject: Process intercommunication In-Reply-To: <7x8zdlun4x.fsf@ruckus.brouhaha.com> Message-ID: On 05-Nov-2001 Paul Rubin wrote: > Mikael Olofsson writes: > > I feel that I am in quick sand here. I haven't got the slightest idea > > how to do this. Any help is welcome. > > The simplest way is probably with the SocketServer module. A is a > server that listens on a unix domain socket. B is a client that > connects to the socket and sends the data to A. If you use the > ThreadingMixin or ForkingMixin features, A can talk to multiple > B's simultaneously. Thanks! I'm already there. Greg mentioned sockets, and that led me to try SocketServer. Nice little module, indeed. It seems to be exactly what I need. And I will not need to talk to multiple B's simultaneously. A simple queue is enough. Perhaps I will return with some new questions after a while. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 05-Nov-2001 Time: 18:58:52 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From ajs at ix.netcom.com Sun Nov 25 01:18:28 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 25 Nov 2001 01:18:28 -0500 Subject: A permutation on permutations Message-ID: <001701c17578$ffe975e0$a9e1fea9@carol> What I've come up with is: L is my list of arbitrary length. M= [i for i in range (len(L))] #thanks to Rainer Deyke's post def perms(L): if list == [] : return [[]] return [[list[i] + p for i in range(len(list))\ for p in perms(list[:i] + list[i+1:])] def removedups(t): for p in t: m=copy.copy(p) m.reverse() if m in t: t.remove(m) def drawcurve(t): #t is M or a slice of M perm=perms(t) removedups(perm) for i in range(len(perm)): cp=[L[j] for j in perm[i]] BezierCurve(cp) It seems to work. But I wonder if there is a significantly more efficient solution Art From michael at rcp.co.uk Fri Nov 30 11:29:06 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 30 Nov 2001 16:29:06 +0000 (UTC) Subject: Non-Indented python References: <3C0678DF.2DFE924A@home.net> Message-ID: Marcin 'Qrczak' Kowalczyk wrote in news:slrna0f2eh.uit.qrczak at qrnik.zagroda: > Fri, 30 Nov 2001 12:13:20 +0000 (UTC), Michael Abbott > pisze: > >>> This problem doesn't exist if you use 8 as the tab width because then >>> the apperance is consistent with semantics. >> >> Until you (or, more likely, someone else) run the source through an >> editor which happens to be configured for a different tab size > > That's what I said: the problem doesn't exist if the tab size is always > kept at 8. It doesn't matter how many times indents are converted > between tabs and spaces, and what the tab key inserts, and whether > indents are consistently made of spaces or tabs or they are mixed. > > There is no need to ban tabs, or to ban spaces, or to ban mixing > indents (whether it's mixing tabs with spaces on the same line or > mixing indentation methods on differnent lines belonging to the same > block). Just ban non-standard tab sizes and the problem is solved. > Well, you have to ban something. The problem with banning non-standard tab sizes is that as soon as someone makes a small mistake you can have a real mess to deal with. As I related, the problem with the trashed C file was a real pain, and I don't think the mess was ever cleaned up (I never had occasion to modify the ruined code, so I never took the time to clean up the ruined indentation). Unless you mandate that everyone runs the same editor as you do, tabs are going to trip you up. What is the point of using hard tabs, anyway? I've never understood what purpose they serve in source code. They simply add an invisible source of possible confusion. From mwh at python.net Fri Nov 2 09:21:36 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 2 Nov 2001 14:21:36 GMT Subject: references ??? References: <9rtpsc$13j2@newton.cc.rl.ac.uk> Message-ID: "Thomas Weidner" writes: > Interesting.... > Is this also possible for single values like ints ? > How do i make clear if i want a copy of a or a reference to it ? Have you read this: http://effbot.org/guides/python-objects.htm ? It doesn't answer your question, but it answers the questions you should be asking instead. FWIW, Python handles objects much more like Lisp, scheme and Java than C, C++ or perl, if you know any of these langauges. It can be a bit confusing if you're used to one of the latter learning one of the former, but it's not actually difficult. Cheers, M. -- US elections For those of you fearing that the rest of the world might be making fun of the US because of this: Rest assured, we are. -- http://www.advogato.org/person/jameson/diary.html?start=12 From tim.one at home.com Sat Nov 3 15:23:29 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 15:23:29 -0500 Subject: Feature Wish: "%" Extension In-Reply-To: <7xpu708imm.fsf@ruckus.brouhaha.com> Message-ID: [Tim] > ... 2.2 feature freeze is in effect. [Paul Rubin] > Oh crap. I had some similar patches I meant to get around to. > Even libraries are feature frozen? Yes, even libraries. Feature freeze is in force concurrent with the first beta release. That doesn't mean we won't add new features , but the release manager (Barry Warsaw for 2.2) has to be convinced the risk is too close to zero to measure the difference, the gain too high to be measured at all, and also convinced that he should spend time thinking about that instead of solidifying the beta. In practice, that makes it a pretty solid freeze. Exceptions can be forced by people named Guido, but not by people named, say, Tim. but-iirc-pauls-are-an-unknown-quantity-ly y'rs - tim From java at dejazzd.com Fri Nov 9 13:30:10 2001 From: java at dejazzd.com (Glenn S.) Date: 9 Nov 2001 10:30:10 -0800 Subject: Example for using MySQL References: <9sg7t8$12a85q$1@ID-69142.news.dfncis.de> Message-ID: <31495c21.0111091030.1db66595@posting.google.com> There are examples included with the MySQLdb code. On my development machine, I only need to do this to connect and query the database: import MySQLdb db = MySQLdb.connect(db="test") cursor = db.cursor() cursor.execute('select * from test') results = cursor.fetchall() print results On our web server, where the mysql database is shared, I need to do this to connect: db = MySQLdb.connect(user="myuser", passwd="mypassword", db="mydb", unix_socket="/tmp/mysql.sock") - the unix_socket string is because this file is not in the standard location on this particular web server. There are quite a few options for the connect() method, so get your hands on the docs that come with MySQLdb. Glenn Stauffer "Andreas Penzel" wrote in message news:<9sg7t8$12a85q$1 at ID-69142.news.dfncis.de>... > Hello NG! > > Where can I find an example for using MySQL in Python (specially how to > connect to the DB)? > > Thanks, Andreas From leovd at pacbell.net Wed Nov 7 13:54:10 2001 From: leovd at pacbell.net (Ray Van Dolson) Date: Wed, 07 Nov 2001 18:54:10 GMT Subject: Problem with httplib and POST Message-ID: I'm writing a kind of interface to the Dotster.com website that will allow me to automatically update my DNS entries (controlled via a web interface on their server) when my IP changes by calling a Python script. So far I've made pretty good progress. In case you're interested, the location of my source is currently at: http://www.bludgeon.org/cvs/index.cgi/pydotster/ On to my problem. Once I do all the authentication and stuff, I receive two cookies from the server--a session ID and a cookie setting the domain I am currently working with. Then I can call the editdns form and POST a new IP to it. This is where I am running into problems. Here is an excerpt of the HTML of the form I'm trying to complete:
EDIT RECORD FOR BLUDGEON.ORG
Host NameRecordHost IP Address
ALIAS

Basically I am doing something like this to process this form: h = httplib.HTTPS('www.dotster.com') h.putrequest("POST", "/management/editdns.asp?Update=1&sld_nsrec_id=4444") h.putheader('Accept', 'text/html') h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Host', 'www.dotster.com') h.putheader('Cookie', 'Domain=Name=BLUDGEON%2EORG; path=/ASPSESSIONIDQQQQQWUG=JCNNMKIAEEJABDOPNCCEGFFA; path=/') params = urllib.urlencode({'hostname': HOST_HERE, 'hostip': NEW_IP, 'B1': 'Update DNS Record'}) h.putheader('Content-Length', "%d" % len(params)) h.endheaders() h.send(params) reply, msg, headers = h.getreply() Is there anything glaringly wrong with this that doesn't match up with the FORM above? This executes just fine and I get a redirect from the server (302) however, the new IP is NOT accepted. The old one is still there. I'm scratching my head trying to figure out what I am not sending to the server. Does order of Cookies matter? The whole POST line that I am sending seems a little strange to me since it actually has parameters on it... Could it be perhaps that I am using HTTP/1.0 instead of HTTP/1.1? If so, how can I make httplib use HTTP/1.1? I edited the httplib.py and changed the string from 1.0 to 1.1, but that caused my script to hang. I normally run a sniffer to try and figure out exactly what headers my web browser sends when it does this exacct same thing (successfully), however since this is an SSL-only site, this doesn't exactly work. :) I saved the form do my own server and processed it locally and watched the headers. Of course, the cookies weren't set for my local site (I can't recreate their authentication scheme) but I was able to duplicate the headers exactly in my script. Still no go. Any advice? Ray Van Dolson From rdsteph at earthlink.net Sat Nov 3 16:01:42 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 03 Nov 2001 21:01:42 GMT Subject: Web based AI advice for neophyte??? Message-ID: <3BE45C76.F8737424@earthlink.net> This scriptlet now works sort of interestingly. I am hoping that others might try it out and offer advice on how to improve it. Using a modified version of the multiChoiceGuesser code that Max M posted on this list a few weeks ago, modified to make it slightly more discriminating in it choosing of a possible answer to an English language question by using urllib to query Google with various combinations of the question and possible answers, it is far more fun than and provacative than it was last week. Also I added an algorithm to actually find an answer even if the user does not offer possible choices. This is done by using a (modified and extended NLQ class) posted on the web by "Adam" that simply parses an English sentence and selects keywords. I query Goggle with the question and then use NLQ to make a list of keywords to use as possible answers. Max M's original code worked on a mainloop with a test suite. I have modified it to accept user input from the command line; and now also to prompt the user to offer options or choices form the command line. Future improvements could include using an improved NLQ to select key phrases, not just keywords; using several alternative algorithms to test the likely validity of a given answer, and averaging the results; having Merlin determine the type of query being issued, and modifying his response techniques in accordance (NLQ already has a start on determining types of queries, btu I have not utilized that functionality much yet); and having Merlin ask questions of his own to help clarify the questioners intent when necessary. I could also add prompts to ask the user for various criteria to be used in making decisions, along with "weights' for each criteria, then query the web with each option-criteria pair and calcilate the weighted averages of the Google hits, sor tof liek I do in an earlier hack I called decision analysis. I hope others will come up with even more innovative ideas. I posted a one weekend hack last week of this that was way premature and well nigh worthless. Although this is still a very simple hack, and I am not professional coder, nonetheless this version is infinitely better than last week's, which I should never have posted in such a preliminary stage. I hope you will try this script out even if you found last week's to be vacuous. The script can be found at http://www.awaretek.com/askMerlin.py which might be a better version to use than the pasted-in one below that may not properly preserve whitespace. Also the http://www.awaretek.com/askMerlin site will be kept up to date with later, hopefully improved , versions. Ron Stephens #!/usr/bin/python # AskMerlin is a script I did by putting together two scripts and modfying them both # and adding input/output routines around them. # # First, I ultilized the multiChoiceGuesser script that Max M posted # on the newsgroup comp.lang.python a couple weeks ago. This uses urllib to go out to # the web and judge the appropriateness of a given answer by how many hits it gets on Google # when coupled with the origninal question in a Google search. # My contributions were to enable the program to ask # for both an original question, and then for options to choose from. I also set up a small # routine in order to choose a most appropriate answer, in the case that no options are given. # This is done by using the second program, to create options of its own to choose from # NLQ to pick out Keywords from the page returned by a Google search of the question, by itself. # Then, these keyworsa are used as options or possible answers to the question. # Then, multiChoiceGuesser is applied to the question along with all of the Keywords # generated by NLQ. The result can take a long time, but eventually it gets there, always. (???) # Also, I added to multiChoiceGuesser the requirement to do two google searches, one on # the original question and each option, and one on the option by itlself. Then # we calculate a ratio between each option's Google hit score and its question/option # Google hit score, thus avoiding merely choosing the option that has overwhelmingly high hits # all by itself. # # Surely better algorithms can vastly improve thsi program!!! # # I am hoping some one or some folks come up with improved variatiosn and algorithtms # # Various algoritms could be tried, and then the results from the various algoritms could be # averaged in order to produce more accurate results. # # # Currently, Merlin is may have a low IQ, but he has potential for the future. # Anyway, Merlin can already answer just about any question. # Someday, perhaps he will even answer correctly or at least with wisdom. most or all # of the time. # ;-))))))))))))) # NLQ: # a short program called NLQ, # or natural language query, which can be found online at http://gurno.com/adam/nlq/#download # NLQ is a Class to take an inputted query and output 1. Keywords and 2. also to categorize # the type of question being asked. I am primarily interested in using the Keywords # extracted from a query by NLQ. I shamelesly modified NLQ to add many more # IGNORE_WORDS and otherwise spruce it up. # NLQ.py is still rather dumb, but hey, he has potential ;-))))). import urllib import re import string, sys # stuff __version__ = "0.1" #definine the question types... UNKNOWN = 0 KNOWLEDGE = 1 COMPREHENSION = 2 APPLICATION = 3 ANALYSIS = 4 SYNTHESIS = 5 EVALUATION = 6 KNOWLEDGE_WORDS = ["name", "list", "recall", "define", "tell", "match", "who", "what", "when", "describe", "where"] COMPREHENSION_WORDS = ["retell"] APPLICATION_WORDS = ["why"] ANALYSIS_WORDS = ["how", "classify", "outline", "diagram"] SYNTHESIS_WORDS = [] EVALUATION_WORDS = [] PRONOUNS = ["he", "she", "it", "me", "you", "they", "them", "we", "who", "myself", "yourself", "ourself", "I", "me", "my"] VERBS = ["is", "was", "are", "were", "be", "shall", "am", "isn't", "can't", "won't", "shouldn't", "couldn't", "aren't", "do", "don't", ] OTHER_WORDS = ["if", "to", "too", "there", "will", "the", "a", "let", "I'll", "this", "these", "those", "let", "*.", "+*", ".*", "<*", ">*", "=*", "*=", "*<", "*>", "*.", "*-", "-*", "*:", ":*", ";*", "*;", "*,", ",*", "*.*", "*,*", "*;*", "*:*", "*+*", "*=*", "*-*", "*_*", "*<*", "*>*", "*?*", "*/*", "of", "and", "for", "very", "not", "in", "on", "up", "has", "from", "which", "and", "on", "of", "or", "not", "by", "can", "that", "your", "with", "their", "over", "back", "link", "about", "an", "at", "his", "enter", "into", "so", "was", "a", "as", "but"] IGNORE_WORDS = VERBS + PRONOUNS + OTHER_WORDS + KNOWLEDGE_WORDS + COMPREHENSION_WORDS + APPLICATION_WORDS + ANALYSIS_WORDS def determine_type (word): # for right now this only matches the first word. Soon it will # take the whole string and attempt to match using that. return_type = UNKNOWN if word in KNOWLEDGE_WORDS: return_type = KNOWLEDGE elif word in APPLICATION_WORDS: return_type = APPLICATION elif word in ANALYSIS_WORDS: return_type = ANALYSIS elif word in SYNTHESIS_WORDS: return_type = SYNTHESIS elif word in EVALUATION_WORDS: return_type = EVALUATION elif word in COMPREHENSION_WORDS: return_type = COMPREHENSION return return_type class NLQ: def __init__(self, a_string): self.tuple = string.split(string.lower(a_string)) self.type = determine_type (self.tuple[0]) self.keywords = [] for word in self.tuple[1:]: if "~" in word: continue if "@" in word: continue if "#" in word: continue if "$" in word: continue if "%" in word: continue if "^" in word: continue if "&" in word: continue if "<" in word: continue if ">" in word: continue if ":" in word: continue if ";" in word: continue if "{" in word: continue if "}" in word: continue if "[" in word: continue if "*" in word: continue if "(" in word: continue if ")" in word: continue if "_" in word: continue if "-" in word: continue if "+" in word: continue if "=" in word: continue if "?" in word: continue if "for" == word: continue if word in IGNORE_WORDS: continue if word in OTHER_WORDS: continue if word in VERBS: continue if word in PRONOUNS: continue if "and" == word: continue if word[0] not in string.letters: continue if word[-1] not in string.letters: word = word[:-1] else: self.keywords.append (word) def __repr__(self): return "type: %s\nkeywords: %s" % (self.type, self.keywords) class multiChoiceGuesser: def __init__(self, question='', replys=()): self.question = question self.replys = replys def guessedAnswer(self): hits = [] result = [] for reply in self.replys: x = (self._getGoogleHits(self.question + ' ' + reply)) y = (self._getGoogleHits(reply)) float(x) float(y) if x == 0: x = x + 1 dividend = y / x hits.append(dividend) return hits.index(min(hits)) def _getGoogleHits(self, query): query = urlencode({'q':query}) urlHandle = urlopen('http://www.google.com/search?%s' % query) googlePage = urlHandle.read() try: numberAsString = re.search( 'of about (.*?).', googlePage, re.S ).group(1) hits = re.sub(',', '',numberAsString) urlHandle.close() hits = int(hits) except: hits = 0 return hits def guess(question, choices): mcg = multiChoiceGuesser(question, choices) print 'The question is: ', question print 'The most likely answer is: ', choices[mcg.guessedAnswer()] print '' 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 question = raw_input ("What is your question?") choices = get_list("Enter your options:", "Option %d: ") if choices == []: print "Since you did not give Merlin any options, it may take a while as he thinks. Please be patient; if you do not touch your keyboard or mouse for a few minutes, Merlin will respond ;-)))))" source = _getGooglePage(question) b = NLQ(source) choices = b.keywords u = NLQ(question) bad = u.keywords for thing in bad: choices.remove(thing) del choices[:13] del choices[-13:] guess(question, choices) while 1: question = raw_input ("what is your next question?") choices = get_list("Enter your options:", "Option %d: ") if choices == []: print "Since you did not give Merlin any options, it may take a while as he thinks. Please be patient and if you do not touch your keyboard or mouse for a few minutes, Merlin will respond." source = _getGooglePage(question) b = NLQ(source) choices = b.keywords u = NLQ(question) bad = u.keywords for thing in bad: choices.remove(thing) del choices[:13] del choices[-13:] guess(question, choices) From flynt at gmx.ch Fri Nov 23 12:08:33 2001 From: flynt at gmx.ch (flynt) Date: Fri, 23 Nov 2001 18:08:33 +0100 Subject: Newbie question References: <1puL7.12600$MI2.1847665@typhoon.jacksonville.mediaone.net> Message-ID: <3BFE8291.7C8A79D7@gmx.ch> stephen cox wrote: > > I just started with Python. Have some basic questions. For work, I wanna > develop some data entry screens for our sql server - so I assume there's a > database library out there that gives me functions to connect to a sql > server? Also, for the web, does Python run as a CGI with II5 or is there > some dll that hooks into IIS5? Last question, does Zope need the zserver? I > keep reading that it can run on any server but, I haven't found anything > that tells me how to run it with IIS. Is it just a matter of running Python? > > -- > Stephen Cox > web.net geek for non-profits, political campaigns, and a few socially > conscious businesses. > stephen at stephencox.org > Hello Stephen For the database of course you can use the ODBC adapter, but I am not aware of an adapter MS SQLServer (maybe the Sybase driver would do, as it is basically a Sybase clone ?). Other may know better. I can give you some links to How-To's which deal with IIS and Zope (personally I am working with Apache as IIS is a "non-disclosure" security horror): http://www.zope.org/Members/jephte/HOWTO/IIS_and_Zope_in_REMOTE_USER_mode http://www.zope.org/Members/brianh/iis_howto Zope comes along with its own http server. However you can use Zope also via a cgi which is called *pcgi* or by hiding Zope behind a proxy. Search for the term *pcgi* and for the term *proxy* on http://www.zope.org/ in the search filed in the top bar. In practise very often you will find Zope behind Apache (as a proxy) indeed, instead of running standalone. I know that these are only quite short hints, but maybe it will get you started. HTH --- Flynt From export at sendme.cz Sat Nov 17 03:50:00 2001 From: export at sendme.cz (Lad) Date: 17 Nov 2001 00:50:00 -0800 Subject: Does smtplib lookup MX records? References: <3BF56916.8834B8D7@letterror.com> Message-ID: <52ac9479.0111170050.f56492a@posting.google.com> Just van Rossum wrote in message news:<3BF56916.8834B8D7 at letterror.com>... > Dale Strickland-Clark wrote: > > > I've been trying to send emails with smtplib and had a large number of > > failures. Investigation seems to reveal the the smtplib module does a > > simple connect passing the hostname to socket.connect without trying > > to resolve the MX record. > > > > In some cases this works where the mail server happens to have an > > A-type DNS record anyway but otherwise it fails with a connection > > error. > > > > Is this really the case? > > > > If it is, what do I need to do to lookup the MX record myself? > > > > (This is rather urgent now as this program was hastily written to help > > a client out who's mail server has died.) > > Are you sure you're using smtplib correctly? I *think* it's mostly meant > to talk to a local relay host (eg. smtp.my-isp.com). The smtp server > will take care of the rest. If you insist on delivering yourself, then > yeah, you'd have to look up the mx record for each recipient, but I > wouldn't consider that typical usage of smtplib. Am I missing something? > > Just If you use windows you can use , for MX records lookup, http://www.internext.co.za/stefan/aspmx/aspmx.zip It works well. Ladislav From wurmy at earthlink.net Fri Nov 23 20:14:03 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sat, 24 Nov 2001 01:14:03 GMT Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> Message-ID: <3BFEF45A.79EC5E69@earthlink.net> Power-Tech wrote: > > I am a very newby at phyton, actually I started messing with it two days > ago. I have a > question that may be so dumb that I was afraid of posting in the > mailgroup, could anyone answer me or direct me to someone who can? > The problem is: > I create a small program with the Python IDLE gui, save it as a .py > file, when I double click to open the file, a DOS window opens but > closes immediately, without running the program, or if it is a > calculating program, as soon as I type something, the window closes. Yeah, that's pretty annoying. People already pointed out a few ways to get around this. Here's another: write a batch file that starts a python program, e.g. @echo off c:\python\python.exe %* pause Then edit the associations of the .py file extension, so that this batchfile is started and not python.exe. Double-clicking a .py file should now wait for a keypress after running the program, even when errors occur. HTH, --Hans From sheila at spamcop.net Sat Nov 10 14:00:58 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 10 Nov 2001 19:00:58 GMT Subject: Teaching python (programming) to children References: Message-ID: <9sj1d2.3vv92o3.1@kserver.org> On Sat, 10 Nov 2001 17:33:25 +0100, Laura Creighton wrote in comp.lang.python in article : :Sheila King: :> I don't see why this "circle" would bother any classroom practitioner at :> all. Because teachers really do get to decide what they want to do, to a :> large extent, when they go into their classroom with their students and :> close the door. : :I have a problem. I can't pick the _students_ that come into my :classroom. Same here. Well, when I taught AP courses (Calculus and Computer Science), I did have some say in what student could take the course. But that was an exception. For the other courses I taught, I took all comers. Largely, teachers don't have any option in which students end up in their classroom. : And wherever I have come across a student that learned :calculus from the graphing-calculator school, I have found somebody :who does not understand, really understand, what 'this function is :increasing' _means_. They are incapable of doing their own visualization :of that. Fortunately for me, I don't run into these people that often. :But they are crippled, so much that it shows. It is evident in trying :to have the simplest of conversations with them. They have little or :no mathematical intuition at all. : :So either a) the method is bad, and cripples minds (period) or :b) the method, if not taught according to some vigorous standard and :in conjunction with some other methods, cripples minds (or doesn't :allow them to expand properly). Well, in my opinion, the problem is in the way the previous teachers have assessed the students, allowing them to get by with such a shallow understanding of the topic. Whether or not the graphing calculators is used in the course is really not the issue. The issue is: What type of test questions was the student required to answer. The best scenario, would be having the student take tests, at least half of the time, with no calculator permitted, and having them answer meaty questions on the topic. In other words: I'm not sure that the problem here is either curriculum or method, but assessment. :If the second is the case, then high school teachers must not be :allowed to pick and chose what to do, because with the best intentions :in the world they will produce a program that will produce people are :mathematically naive. Which is my experience. We have people who :never made the leap from arithmetic to mathematics. They are human :calculators, tied to machine calculators, but have no mathematical :intuition whatsoever, and a great difficulty in thinking abstractly. :It is frightening. They do get correct answers, as long as their :calculators have batteries, but they can't understand them. You admit, earlier, that the number of students you've encountered who have this shallow understanding is small, and yet you say that you want to dictate what "high school teachers" should do. In my experience, it doesn't matter what group you are dealing with, whether it is teachers, doctors or plumbers, there will always be a small part of that group that is "bad". And it really isn't reasonable to form the policies for an entire groups based on a few "bad" ones. :One must never design educational policy thinking only how the best :teachers will educate the most exceptional students (exceptionally :good or exceptionally poor.) The policy must instead focus on the :worst third of teachers. This is hard on the gifted teacher, indeed, :but the alternative is hard on _everybody_. Here is what I think: First of all, you will not eliminate the problem of bad teaching by doing this. There will always be some bad teachers. There will always be teachers who have their students do little or nothing and give them passing grades. Fortunately, there are very few of these, but you will always have them. It doesn't matter that you outline the curriculum specifically. Therefore, designing educational policy to "prevent" these teachers from continuing with their bad teaching practices will not work. Furthermore, you acknowledge that it will be hard on the good teachers, and K-12 teaching is already a shi**y job. Believe me. I just left last year after nearly two decades. (Went from high school to college.) The students are great. Being in the classroom is great. The student-interaction part of the job is what it's all about. However, the workload and the policies and all that other stuff make the job very difficult to do. If you take yet one more thing away from the good teachers, they will leave. Then all you will have left is the mediocre and "bad" teachers. This will not help. I believe that in Texas they had (and perhaps still do?) a very lock-step math curriculum. It dictates exactly what topics will be covered, in exactly what method, on what days, etc... The teachers hate it. And I know from at least one source, that it has not solved Texas' math education problems. Also, there are reading programs (Open Court and Success For All), for elementary school with SCRIPTED curriculum. The teachers HATE it and it is questionable that it is an improvement. Some of the teachers I converse with (electronically) feel that it has really lowered the bar on what the students are able to do. (For more input on this things, visit the newsgroups k12.chat.teacher or k12.ed.math and post a question about Open Court Reading or Success For All, or a question about the Texas' regimented math curriculum. Or, go to http:///groups.google.com and search the archives of those groups. I'm sure you will find enough material to show that the programs are not well liked and that the good teachers believe they are actually detrimental to the students.) About the only thing I could envision that would help, is some sort of external exam, not written by the teacher, that the students would have to pass. This way, the student of the poor teacher may not do well on that exam, but at least everyone who passed that exam would have satisfied requirements for that course. And hopefully the poor teacher would be exposed after a short time, and removed from teaching duties. But I can hear all kinds of complaints against this idea, too. Can you imagine the teacher of that course, complaining (similar to your own complaints) that it was the teachers of the previous courses, who crippled the minds of the students he had to deal with, and that he could not get them through the curriculum he was supposed to teach, due to their insufficient background? In any case, here is what I really think: You have a problem. A few students with insufficient understanding of the prerequisite material for your course. Instead of trying to make it someone else's problem (dictate what the high school teachers should do), take ownership of the problem and deal with it yourself. Ultimately, this is what each teacher at each level should do, and it's the only way things are going to work. At the college level: Institute placement exams for the students, to determine their placement as incoming freshman in an appropriate math course. And converse with the department you work in, to put in place reasonable curriculum and policies within your own department, so that once a student has been correctly placed within your system, you can feel confident about their proceeding on to the next course with sufficient knowledge. By having placement exams, you indicate to the high school what you require students to know to come into your program. If large numbers of a particular school's student population are unable to pass your placement exam, notify their administration, their district, etc... so that they can deal with it. Otherwise it all rolls downhill. You complain about the job being done in the high schools. They will complain about the middle school. They will complain about the upper elementary grades. Those will complain about the primary grades. Nothing is accomplished but a lot of finger pointing. Instead: Make it clear the prerequisites for your program, and stick to them. Those students who meet your prereqs but are deficient in a few small areas, deal with it. Remember, too, that the student bears responsibility in all of this as well, especially after they get to about the age of 16 or so. If you have a student in your course who doesn't sufficiently understand the concept of increasing (and I'm sure this was only one small example...such a student must have many other deficiencies as well), that student MUST be aware of his/her own deficiencies. He must be wondering why you are saying things like, "and so we can see that..." and he is sitting there going ??? 'How can she see that???' This should be a CLUE to the student to either ask questions in class or come to office hours. As instructor, you should expect to have a small number of weak students who passed the prereqs, but only just barely, and therefore have a very shaky understanding of the material. Unless these students take ownership of their problem and do something about it, there is nothing that you as instructor can do for them. So, there will be some poor grades. Oh, well. I agree with you completely about the current situation, with students who have a very concrete understanding of math but are unable to make the bridge to abstractness. This has always been one of my battles in the classroom. Currently I'm teaching two sections of College Algebra, and these students have NO abstract thinking ability nor any ability to set up word problems. (OK, that's a sweeping generalization. Maybe I have a few who do have these abilities.) But this course is supposed to introduce some abstraction, and it is like pulling them kicking and screaming. But, I try to take care to ask questions that get at the abstract ideas, or to disallow calculators on some of the exams and quizzes where they might be used as a crutch (i.e. design questions where the calculator is no advantage, or band them from the test if they are one). At least, they will not pass the course I am teaching without some ability to think abstractly. This is the part that is under my control, which I can do something about. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From timr at probo.com Thu Nov 8 00:30:50 2001 From: timr at probo.com (Tim Roberts) Date: Wed, 07 Nov 2001 21:30:50 -0800 Subject: integer to ascii References: <3be90fbc$0$232$edfadb0f@dspool01.news.tele.dk> <3BE9D4AE.A6DF3145@ccvcorp.com> Message-ID: <8v5kuts7kq0l90hh3otenci2uaj8amb7qd@4ax.com> Jeff Shannon wrote: > >Or: > >rows = 2 >columns = 3 >joined = "%d%d" % (rows,columns) > >String formatting is your friend. It is *much* faster than concatenation with >+, too (though this won't show up unless you're doing it in a tight loop...) Yes. This was one of the biggest surprises I had in coming to Python from Perl. I couldn't understand why I kept seeing this = "%s and %s" % ("spam","eggs") instead of this = "spam" + " and " + "eggs" (OK, that's contrived, but you get the idea.) It wasn't until someone pointed out that the former is one operation in C, whereas the second is three interpreted operations, that I finally grokked the idiom. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From Gareth.McCaughan at pobox.com Tue Nov 27 17:15:05 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Tue, 27 Nov 2001 22:15:05 +0000 Subject: Integer Overflow References: <9u0jor$2li$1@peabody.colorado.edu> Message-ID: "Ursus Horibilis" wrote: > unsigned int Lcprng(unsigned int *seed) > { > *seed = 29 * (*seed) + 13; > return (*seed); > } > > How do you do this in Python? def Lcprng(state): """Pass this a list containing just the seed. It will be updated, and the value inside returned.""" state[0] = (29*seed[0]+13) & 0xFFFFFFFFL return state[0] Points to note: - using a 1-element list is about the nearest equivalent we have to passing in a pointer as your C code does. It's not necessarily good style (but then, neither is the pointer-passing thing). - After one iteration, the value in "state" will be a long integer and there will therefore be no danger of overflow. But you should make sure you start it off with a long anyway. By the way, that's not a very good random number generator. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From salvasan at yahoo.com Mon Nov 12 20:41:13 2001 From: salvasan at yahoo.com (salvasan at yahoo.com) Date: Mon, 12 Nov 2001 20:41:13 -0500 Subject: Proving optimized function is still correct Message-ID: <9sq46c$o93$1@news.carib-link.net> A gave a colleague of mine a Python function to optimise: def count_combos( m, n, trial=[] ): #is trial complete? if len(trial) == m: #check if trial is valid total = 0 for x in trial: total = total + x if total == n: #count this valid trial return 1 #otherwise do not count it return 0 else: #RECURSIVE CALL count = 0 for i in range( n+1 ): #extend trial by another test element trial.append(i) #total up valid trials found count = count + count_combos( m, n, trial ) #remove last appended element del( trial[-1] ) return count The preconditions are that arguments m and n are always positive integers. She amazingly reduced the above code to the following: def count_combos_optimised( m, n ): numer = 1 denom = 1 j = m+n-1 i = 1 while i; from taw_usenet@yahoo.com on Mon, Nov 05, 2001 at 03:34:58PM -0800 References: <84a8bdbe.0111051534.501ea62e@posting.google.com> Message-ID: <20011105190720.A2128@node0.opengeometry.ca> On Mon, Nov 05, 2001 at 03:34:58PM -0800, ToddW wrote: > It's simple to get the correct file size for a file. But if it is > gzipped, is there a simple way to snag the file size of the > uncompressed file? gzip -l -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From logiplexsoftware at earthlink.net Sat Nov 24 16:26:00 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Sat, 24 Nov 2001 13:26:00 -0800 Subject: (off-topic humor) While browsing google for python and turtle In-Reply-To: References: Message-ID: <01112413260001.06200@logiplex1.logiplex.net> On Friday 23 November 2001 09:39, Syver Enstad wrote: > With the Python, one can easily drain and refill over 150 gallons in > less than an hour without lugging a bucket or sucking on a hose. Just one more advantage of Python over Java =) -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From philh at comuno.freeserve.co.uk Mon Nov 26 11:18:30 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 26 Nov 2001 16:18:30 +0000 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> Message-ID: On Sun, 25 Nov 2001 23:42:20 GMT, Hans Nowak wrote: >Howdy y'all, > >I'm currently developing a program (in Python, obviously) and plan to >publish it. Before I do so, though, I would like to have some opinions >on the following: > >- should I use a license / copyright notice? Yes >- if so, which one would you recommend? Depends on what you are trying to achieve. >I know of the GPL, Python license, BSD license etc, and opensource.org >has a long list of them, but I absolutely hate legalese, and reading >all of this and pondering the possible consequences of picking one >over the other makes me cringe. Does someone have a pointer to a >page with some concise explanations of these licenses? If you want a copyleft license, choose the GPL. If not, consider the BSDL. >Then there's a second point: I see that many projects use version >control (usually CVS). I tried using DJGPP's cvs, but it >(unsurprisingly) doesn't work well on WinXP. There's such a thing >as WinCVS, but the whole process strikes me as clumsy... checking >in and out and committing every time something changes... what is >the point of this? What happens if you forget a step? Does it have >substantial benefits over versioning your files by hand, aside from >having a repository through which you can undo changes? Depends. If only one person is working on the project, CVS is overkill. If lots of people are working on it, it's a good idea. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From stojek at part-gmbh.de Mon Nov 5 11:51:10 2001 From: stojek at part-gmbh.de (Marcus Stojek) Date: Mon, 05 Nov 2001 16:51:10 GMT Subject: find network drives, win Message-ID: <3be6c267.21367859@news.easynews.net> Hi, under windows I have to find out for a given path whether the drive is local or a network drive (is "mounted" the right word for this?) I tried: ----------------------------------------------- import string import os.path lok=[] net=[] for l in string.uppercase: d=l+":/" if os.path.isdir(d): if os.path.islink(d): #ismount doesn't work either net.append(d) else: lok.append(d) print "local drives", lok print "network drives",net ------------------------------------------------ Could anybody help please? Tanks Marcus From root at [127.0.0.1] Mon Nov 26 01:35:40 2001 From: root at [127.0.0.1] (nobody) Date: Mon, 26 Nov 2001 16:35:40 +1000 Subject: Return value for popen? Message-ID: <3c01e2bc$0$13482$afc38c87@news.optusnet.com.au> Is it possible to get a process' return (errorlevel) value from popen, as it is with os.system()? From nbecker at fred.net Fri Nov 2 15:41:28 2001 From: nbecker at fred.net (N Becker) Date: 2 Nov 2001 12:41:28 -0800 Subject: simple eval question Message-ID: <1f5252d4.0111021241.643efe1e@posting.google.com> What is wrong with this? eval ("print \"hello\"') Traceback (most recent call last): File "", line 1, in ? File "", line 1 print "hello" ^ SyntaxError: invalid syntax I expected that eval takes a string an evaluates it as input to the interpreter, as if it had been typed into the command line. Was I wrong? From greg at cosc.canterbury.ac.nz Thu Nov 1 21:56:46 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 02 Nov 2001 15:56:46 +1300 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> Message-ID: <3BE20B6E.F9275CD0@cosc.canterbury.ac.nz> Stephen Ferg wrote: > > input = "" > for n in xrange(256): # produce numbers 0 through 255 > input = input + chr(n) or, for a faster way of doing that, input = ''.join(range(256)) -- 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 mwh at python.net Mon Nov 26 07:26:11 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 26 Nov 2001 12:26:11 GMT Subject: prep my types for 2.2? References: <3BFEF3DF.5030103@shinners.org> <3BFFD5C4.5080500@shinners.org> Message-ID: Michael Hudson writes: > If you were calling type(int)(1), then you'd have a point. Good grief. Pop quiz: without trying it, what does this print: >>> type(int)("") ? I can see why, but it wasn't really what I expected. Cheers, M. PS: the output of >>> glcr helps explain this. -- I have a cat, so I know that when she digs her very sharp claws into my chest or stomach it's really a sign of affection, but I don't see any reason for programming languages to show affection with pain. -- Erik Naggum, comp.lang.lisp From keyton at weissinger.org Mon Nov 12 23:19:35 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Mon, 12 Nov 2001 23:19:35 -0500 Subject: Request for Validation of Python as Development Language Message-ID: Does anyone have a more recent list of commercial products out there that use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima Online. I'd like more. The information in the books and the python.org site is a bit dated. I'm pretty new to the language and I'd like to use it for more stuff at work. I'm beginning to feel some of the stigma of it being a "scripting language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for those who care) and I'd like to introduce Python into the mix. But I say "scripting language" and people head to the hills yelling "PERL!" which is a bit disconcerting (especially since I like Perl too, though not as much as Python). They need to hear "object oriented application development language" or I need to buck up and realize I'm barking up the wrong tree. Thank you! Keyton From mickey at tm.informatik.uni-frankfurt.de Tue Nov 27 07:15:46 2001 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 27 Nov 2001 14:15:46 +0200 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <3c039202@nntp.server.uni-frankfurt.de> {-- Rot13 - Hateme wrote: > You can demostrate how to realize a MVC model with > python and all the toolkits. It's powerful and useful. > Many applications fit well with MVC. > > Better have the backend seperated from the frontend > from the beginning. Of course. I don't see a problem seperating the model from the view+controller - however, it seems that most or all of the GUI toolkits are built around a combined view and controller aspect. I don't really see how I can seperate them without giving the notion of a kind of artificial seperation ? :M: From mgerrans at ix.netcom.com Sun Nov 11 02:26:43 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Sat, 10 Nov 2001 23:26:43 -0800 Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: <9sl98i$bjs$1@nntp9.atl.mindspring.net> > I have an idea, but considering the fact that I just learned python > yesterday, it probably won't help... That comment made me chuckle. (actually, it is pretty impressive that you learned Python yesterday and are already answering questions -- you must be a quick learner!) As for the original post, my personal opinion is that with this much data, it is time to consider using a database. Or at the very least, you should come up with a scheme to manage and partition in to multiple smaller chunks. Even if it worked with shelve module, wouldn't the performance be pretty awful? The PyWin database modules are pretty handy and the dbm module can be used on Unix platforms. I don't know about other platforms, though. There might be even better database access available... Even if you don't use a database, if all you are storing is a bunch of floats, you don't even need shelve. It is easy enough to write them to (and read from) a file on your own with a loop, isn't it? - Matt From ibl at nospam.com Sun Nov 18 15:39:42 2001 From: ibl at nospam.com (Ingo Blank) Date: Sun, 18 Nov 2001 21:39:42 +0100 Subject: egenix-mx-package error : copy_reg is not intended for use with classes References: Message-ID: <9t96ae$k7c$03$1@news.t-online.com> Hi, I assume that your primary goal is a working PostgreSQL interface for Python. If you are not fixed to pgdb for any reason, you might want to try psycopg instead. It compiles out of the box, though requiring mxDateTime as well, and works without any problems for me. It seems to be pretty stable and fast, at least I had no problems yet. HTH --Ingo ibl at nexgo dot de "Thomas Weholt" schrieb im Newsbeitrag news:BVFJ7.3031$B87.49276 at news1.oke.nextra.no... > Well, it's probably the pgdb module that comes with PostgreSQL 7.1.3 I've > just installed but .... > > Anyway : > > I've installed PostgreSQL 7.1.3 with python enabled. Tried to use pgdb.py > but it needed mxDateTime, so I installed > http://www.lemburg.com/files/python/egenix-mx-base-2.0.2.tar.gz > > Now I get the following error : > > Python 2.1.1 (#1, Aug 30 2001, 17:36:05) > [GCC 2.96 20000731 (Mandrake Linux 8.1 2.96-0.61mdk)] on linux-i386 > Type "copyright", "credits" or "license" for more information. > >>> import pgdb > Traceback (most recent call last): > File "", line 1, in ? > File "/usr/lib/python2.1/site-packages/pgdb.py", line 64, in ? > try: from mx import DateTime > File "mx/DateTime/__init__.py", line 40, in ? > class modinit: > File "mx/DateTime/__init__.py", line 50, in modinit > _DT) > File "/usr/lib/python2.1/copy_reg.py", line 16, in pickle > raise TypeError("copy_reg is not intended for use with classes") > TypeError: copy_reg is not intended for use with classes > >>> > > This is on a Mandrake 8.1-box. > > Any clues ?? > > Thomas > > From slinkp23 at yahoo.com Tue Nov 6 02:16:43 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 06 Nov 2001 07:16:43 GMT Subject: Help Help Help References: <3be77f95@152.65.161.36> Message-ID: On Tue, 06 Nov 2001 06:13:43 GMT, Kojo Duncan wrote: >I'm taking a computer science course and I really need help understanding >python. If you know of any easy to follow tutorials, great emphasis on easy >to follow, please send me a reply on gyekye_7 at yahoo.com . http://www.ibiblio.org/obp/thinkCSpy/ From slinkp23 at yahoo.com Thu Nov 15 13:04:48 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 15 Nov 2001 18:04:48 GMT Subject: How to marshal a function? References: <01111412544105.04702@logiplex1.logiplex.net><0111141538420B.04702@logiplex1.logiplex.net> Message-ID: On Thu, 15 Nov 2001 08:55:14 -0800, John Roth wrote: >Uh, this isn't a mailing list. It's a newsgroup. I fail to >see what 'procmail', 'mailer agent' and other >such things have to do with it. "Ha ha ha ha! You're Both Right! New Shimmer is a floor wax - AND a dessert topping!" --PW From lucio at movilogic.com Fri Nov 23 17:04:52 2001 From: lucio at movilogic.com (Lucio Torre) Date: Fri, 23 Nov 2001 19:04:52 -0300 Subject: Embedding python: Running precompiled code. Message-ID: <3BFEC804.3000304@movilogic.com> Hello, I have embedded python in my aplication and i am running code using: po = PyRun_String("print 'hello'", Py_file_input, d, d); But i want to have the code precompiled so it can run faster. so i would like to do: PyObject* Py_CompileString(char *str, char *filename, int start) Return value: New reference. Parse and compile the Python source code in str, returning the resulting code object. The start token is given by start; this can be used to constrain the code which can be compiled and should be Py_eval_input, Py_file_input, or Py_single_input. The filename specified by filename is used to construct the code object and may appear in tracebacks or SyntaxError exception messages. This returns NULL if the code cannot be parsed or compiled. But how do i run the new python object? any help aprettiated, Lucio From rockvz at yahoo.com Thu Nov 1 07:47:46 2001 From: rockvz at yahoo.com (Rock VZ) Date: Thu, 1 Nov 2001 04:47:46 -0800 (PST) Subject: Component model Message-ID: <20011101124746.5551.qmail@web13503.mail.yahoo.com> Hi, Does Python have support for the component model followed by Bonobo or KPart. I'm currently working with python and wxPython. I will be developing a set of independent applications(each with their own menus, etc) that will later need to be "merged" into one GUI. Is this possible using python? and also the app should run on unix and windows. Thanks Rock ===== __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com From donn at u.washington.edu Fri Nov 16 12:27:06 2001 From: donn at u.washington.edu (Donn Cave) Date: 16 Nov 2001 17:27:06 GMT Subject: Does smtplib lookup MX records? References: Message-ID: <9t3i9a$cuu$1@nntp6.u.washington.edu> Quoth Dale Strickland-Clark : | I've been trying to send emails with smtplib and had a large number of | failures. Investigation seems to reveal the the smtplib module does a | simple connect passing the hostname to socket.connect without trying | to resolve the MX record. | | In some cases this works where the mail server happens to have an | A-type DNS record anyway but otherwise it fails with a connection | error. | | Is this really the case? Yes. | If it is, what do I need to do to lookup the MX record myself? I have never used it for anything, but you can find a Python DNS client implementation in the source directory Demo/dns, if that helps. Note that you have to specify the DNS server, and you'll have to decide who that is somehow according to site & platform. You may find that it will in turn refer you to another authoritative DNS server where you get the answer. A C module that calls res_search() would be another option. Donn Cave, donn at u.washington.edu From Kevin.Smith at themorgue.org Wed Nov 7 18:45:15 2001 From: Kevin.Smith at themorgue.org (Kevin Smith) Date: Wed, 07 Nov 2001 23:45:15 GMT Subject: [ANN] pyLaTeX -LaTeX to HTML, XML, etc. Conversion Framework Message-ID: pyLaTeX 1.0 alpha-1.1 -------------------------------- pyLaTeX is a LaTeX document processing framework written entirely in Python. It comes bundled with HTML and generic XML renderers, and other renderers can be added as well. pyLaTeX differs from other tools like LaTeX2HTML, TeX4ht, TtH, etc. in that the parsing and rendering of the document are completely separated. This separation makes it possible to render the document in multiple output formats. It also allows the parser to create a cleaner document object, so that the rendering process is easier. This is the first public release of pyLaTeX and is not yet feature complete. Most notably, there is no functionality for generating images from graphical LaTeX environments and equations. Full documentation and downloads are available at http://pylatex.sourceforge.net/. Kevin Smith From mail at andreas-penzel.de Tue Nov 13 13:33:17 2001 From: mail at andreas-penzel.de (Andreas Penzel) Date: Tue, 13 Nov 2001 19:33:17 +0100 Subject: input References: <9srncp$15ljf7$1@ID-69142.news.dfncis.de> Message-ID: <9srp2p$1556pr$1@ID-69142.news.dfncis.de> Thanks, that?s it. - Andreas From cliechti at gmx.net Fri Nov 2 22:44:44 2001 From: cliechti at gmx.net (Chris Liechti) Date: 3 Nov 2001 05:44:44 +0200 Subject: Q: Feature Wish: "%" Extension References: <3BE34077.8EA553CB@spam.net> Message-ID: anonymous wrote in news:3BE34077.8EA553CB at spam.net: [...] > For number->string conversion (see it coming yet?), the handy overloaded > "%" operator handles radices 8, 10, and 16 -- with padding, > zero-filling, prefixing (e.g. "0x"). But every time I need to convert a > number to _binary_, I have to call a function of my own to produce the > string, and then intermingle that string with other numbers in the final > "%" format I originally intended. It's awkward and slow. > [...] q = {'0':'0000', '1':'0001', '2':'0010', '3':'0011', '4':'0100', '5':'0101', '6':'0110', '7':'0111', '8':'1000', '9':'1001', 'a':'1010', 'b':'1011', 'c':'1100', 'd':'1101', 'e':'1110', 'f':'1111'} def bin(x): return ''.join(map(q.get,'%x' % x)) print "some text with a number 0b%s in it" % bin(123) the above "bin" is 3x faster than this "foo": def foo(x): r = [] for b in range(len(hex(x))-2): r.append(x&(1< From paustin at eos.ubc.ca Thu Nov 22 12:52:37 2001 From: paustin at eos.ubc.ca (Phil Austin) Date: 22 Nov 2001 09:52:37 -0800 Subject: Using Numeric arrays to store different datatypes References: <9tj9jq$sm4@r02n01.cac.psu.edu> Message-ID: Rajarshi Guha writes: > Hi, > Is it possible to store say a list variable in a Numeric array? > Or even a class in a Numeric arry? > use Numeric.PyObject, but note there's a bug with multidimensional indexing with this type: >>> testArray=Numeric.zeros(16,Numeric.PyObject) >>> testArray[10]=[1,2,3.4] >>> testArray array([0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , [1, 2, 3.3999999999999999] , 0 , 0 , 0 , 0 , 0 ],'O') >>> testArray.shape (16,) >>> testArray.shape=(4,4) >>> testArray array([[0 , 0 , 0 , 0 ], [0 , 0 , 0 , 0 ], [0 , 0 , [1, 2, 3.3999999999999999] , 0 ], [0 , 0 , 0 , 0 ]],'O') >>> testArray[1,1]=[1,2,3] Traceback (most recent call last): File "", line 1, in ? ValueError: array too large for destination >>> testArray.flat[2]=[1,2,3,4] >>> testArray array([[0 , 0 , [1, 2, 3, 4] , 0 ], [0 , 0 , 0 , 0 ], [0 , 0 , [1, 2, 3.3999999999999999] , 0 ], [0 , 0 , 0 , 0 ]],'O') From phr-n2001d at nightsong.com Tue Nov 13 01:43:41 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 12 Nov 2001 22:43:41 -0800 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> <3BF07FA7.10807@yumpee.org> <3BF0BE8C.4010809@yumpee.org> Message-ID: <7x8zdbgogy.fsf@ruckus.brouhaha.com> Manoj Plakal writes: > I'm not trying to reinvent a new network > protocol here. All I'm asking is if there's > some kind of cross-platform ultra-lightweight > COM/CORBA-kind of messaging system, built on top > of some IPC mechanism (UDP or domain sockets or named > pipes or something not too heavy). Did Pyro already come up in this discussion? http://pyro.sourceforge.net. From me at mikerobin.com Thu Nov 1 15:40:55 2001 From: me at mikerobin.com (Michael Robin) Date: 1 Nov 2001 12:40:55 -0800 Subject: Unpacking extension (Re: A small inconsistency in syntax?) References: <6q1yjkvpi6.fsf@abnoba.intevation.de> <52e5ab5f.0110310816.30e9f47f@posting.google.com> <6qhesfsi72.fsf@abnoba.intevation.de> Message-ID: <52e5ab5f.0111011240.2bc402f8@posting.google.com> Bernhard Herzog wrote in message news:<6qhesfsi72.fsf at abnoba.intevation.de>... > me at mikerobin.com (Michael Robin) writes: > > > I'd think there's no reason to disallow it. > > Although in Python the comma operator creates tuples > > rather than the parens, for many it looks as if > > a,b = seq > > is just shorthand for > > (a,b) = seq > > This version would not be removed. You need some kind of grouping to > support nested unpackings. I don't think I ever suggested it would be removed. I was pointing out the asymetry in the list vs. tuple literal building syntax (containment/nesting vs. seperator, respectivily), and how although semantically similar, []'s are required in lists, but ()'s are not required for tuples. (I'm not saying this is good or bad, mind you.) If you like being explict with (a,b), Python should allow [a,b]. If there were a "generic" sequence literal, this would be the place for one, but there is not. > Why, if it doesn't make a difference at all? > a, b = t > (a, b) = t > [a, b] = t > are completely equivalent. They all generate the same bytecode and work > for all kinds of sequences with length 2. As per my previous post, one could view "tuple unpacking" as either (a) A degenerate (though very useful) form of unification or, (b) a seperate language feature totally unto itself, resembling multiple-value binding -- although it is less general than unification and more general than retrieving multiple values from a fn. (Although it is commonly used for the latter.) If your view is (b) then "a, b = foo" would be the preferred and only syntax, but because *the shape of the LHS matters* (as in "a, [b, (c, d)] = foo") some form of nesting is reqired in the LHS; therefore it makes sense to allow [] along with (), especially since it is more self-documenting if, in fact, you are unpacking a list rather than a tuple in a particular portion of the structure to be unpacked (meaning that you can modify it after unpacking it, etc). (And hey, let's give future type-inference systems, human or machine, as much information as they can get.) > > Also, given that lists are mutable and tuples are > > not, the list notation makes some kind of sense, > > even though you're rebinding the names in the LHS > > rather than creating a list, per se. > > In my eyes the mutability of the RHS doesn't enter into it. All that > matters is that it's a sequence of the right length. I belive I said LHS, not RHS, as we were on the topic of the syntax of the name list - but in any case I agree - I never said it mattered. The point was that orinarilly "aList = RHS" is allowed, but "aTuple = RHS" is not; therefore []'s "make some kind of sense", given that the syntax for unpacking is identical to assiging to a literal sequence, and that, in fact, you are causing a side-effect. If unpacking works "for all kinds of sequences with length 2" (your words), why wouldn't the LHS follow suit? (At least for literals - I'm not suggesting you should be able to do: someObjectThatImplements_setitem_() = somethingThatImplements_getitem_or_iter() - but wait... :) (No, seriously - way to dangerous...)) > > Bernhard mike From skip at pobox.com Mon Nov 19 14:10:54 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 19 Nov 2001 13:10:54 -0600 Subject: Cookies In-Reply-To: References: Message-ID: <15353.22846.720200.562431@beluga.mojam.com> David> I want to read the values of a cookie that was placed on my David> computer by a web site. I opened it up and it appears to be David> encoded. Is there anyway to decode the values? Cookies are nothing more than key/value pairs. Subject to certain limitations (length, character set), I believe web sites are welcome to encode the values any way they want, so the short answer is, "no". If you know what steps were taken to encode the value, you may be able to decode it, but that's not always going to be trivial. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From justin at iago.org Fri Nov 30 12:29:15 2001 From: justin at iago.org (Justin Sheehy) Date: Fri, 30 Nov 2001 12:29:15 -0500 Subject: Non-Indented python In-Reply-To: (Nicholas FitzRoy-Dale's message of "Sat, 1 Dec 2001 01:31:23 +1100 (EST)") References: Message-ID: Nicholas FitzRoy-Dale writes: > This isn't directed at Marcin, but I don't understand why people keep > going on about this, because it's not accomplishing anything. Indeed. It's been a dead issue for years. That doesn't stop someone new from bringing it up every few months. > Nobody has presented a convincing argument for tabs-only, spaces-only, > or 8-char tabs only, because there isn't one. Right on the first two, wrong on the third. >From the Python Language Reference, in the section describing how the language treats indentation: First, tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight The Python parser makes the only argument necessary for 8-char tabs only, as anything else will provide a view inconsistent with the behavior of the language. Yes, you can make it work with another view if you absolutely never touch code with spaces used, but it's still asking for trouble to differ from what the language does in this way. You may use whatever view of hard tab characters you wish, but anything other than 8 spaces will provide you with a view inconsistent with the language's behavior. Personally, I consider this and also the convention of the Python Standard Library to be sufficient argument that the right style for me to use is spaces-only, four-space indent levels. Use tabs in your own code all you like, though. I won't argue with you. I'll just untabify it if I ever have to work with it. -Justin From mich_hiker at nowhere.com Sun Nov 25 20:25:29 2001 From: mich_hiker at nowhere.com (Mich Hiker) Date: Sun, 25 Nov 2001 20:25:29 -0500 Subject: Zope database vs. MySQL Message-ID: I'm a new Zope user - developing web-based curriculum materials for a school district. Can anyone tell me the advantages of configuring MySQL to use in tandem with Zope over using Zope's built-in database? I've heard Zope is faster using it's own DB, but others have told me it is limited and I should go with MySQL. Any thoughts? Thanks. From skip at pobox.com Fri Nov 2 10:46:33 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 2 Nov 2001 09:46:33 -0600 Subject: Gadfly and regsub with Python 2.1 In-Reply-To: <3BE2B29B.1E714B89@noaa.gov> References: <3BE2B29B.1E714B89@noaa.gov> Message-ID: <15330.49113.424307.647690@beluga.mojam.com> jim> Are there any pitfalls. an amateur should be aware of, in modifying jim> Gadfly to use the "re" module? It's pretty straightforward. You'll find that in most cases regsub.gsub can simply be replaced with re.sub (modulo any necessary regex syntax changes) and that regsub.sub can be replaced with re.sub after adding a count parameter of 1. I thought there was a regex->re converter script in the source distribution, but I can't seem to locate it at the moment. If you can find it, you may find it useful to convert more complex regular expressions. Ah, wait a minute... Andrew Kuchling wrote a regex-to-re howto, available at http://py-howto.sourceforge.net/regex-to-re/ -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From root at rainerdeyke.com Wed Nov 14 12:27:08 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 14 Nov 2001 17:27:08 GMT Subject: PEP 276 Simple Iterator for ints References: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> <15346.13388.182098.148832@beluga.mojam.com> Message-ID: "Skip Montanaro" wrote in message news:mailman.1005730219.6744.python-list at python.org... > Though after reading the remainder of the thread, I like the Haskell syntax > best. One thing bothers me about the Haskell syntax: using it to generate sequences of less than three elements just looks wrong. [1, 2, ... 3] # This is obviously [1, 2, 3]. [1, 2, ... 2] # What is this? [1, 2]? [1, 2, ... 1] # [1]? [1, 2, ... 0] # []? Another thing that bothers me is that I'm it's not obvious how the elements are evaluated. This is not an issue in Haskell, but it is in Python: def f(n): print n return n for i in [f(0), f(1), ... f(5)]: pass I assume that this prints 0, 1, and 5. That makes sense from one perspective, but doesn't make sense at all from another perspective. Another example: for i in [g() + 0, g() + 1, ... g() + 13]: pass How often is 'g' called? Once? 3 times? 14 times? -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From emile at fenx.com Wed Nov 7 16:38:08 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 7 Nov 2001 13:38:08 -0800 Subject: Capturing screen on MS-Windows References: <3BE988A4.94B8760B@olen.to> Message-ID: <9sc9t0$12al7b$1@ID-11957.news.dfncis.de> "Joonas Paalasmaa" wrote in message news:3BE988A4.94B8760B at olen.to... > Is it possible to somehow capture screen on Windows with Python? Undoubtedly, someone will know of a more direct way, but when I needed this earlier this year I ended up using Hypersnap and mSched dynamically scripted and controlled by python. It worked out well. -- Emile van Sebille emile at fenx.com --------- From eppstein at ics.uci.edu Wed Nov 28 14:44:05 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 28 Nov 2001 11:44:05 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> <3C048CCC.6A8C3743@engcorp.com> Message-ID: In article <3C048CCC.6A8C3743 at engcorp.com>, Peter Hansen wrote: > I agree that sounds like a worthy goal. I disagree that your > suggestion is any more likely to be understood by anyone, > other than perhaps a mathematician. As a very experienced > programmer, I found it quite obscure and am unsure I > would have figured it out were it not for the context of > recent threads on the subject. > > Maybe we should look back to BASIC (for i = 1 to 5: next) > or one of the suggestions for something which looks more > explicitly like a list of items (for i in [0..5]) or > (for i in [0, 1, .. 5] ). Especially this latter would > definitely be understandable to anyone, IMHO. After more thought, I am coming to like Ewing's suggestion of for 0 <= i < 5: much better than the earlier-discussed for i in [0, 1, .. 4]: The latter notation now seems unnecessarily redundant. Think of it by analogy -- which of the following would you most likely use, if 0 <= i < 5: or if i in [0, 1, .. 4]: or if i in range(5): or even (with Perl-like conciseness) if i in 5: ? Another advantage of Ewing's suggestion is that it cleanly avoids the whole closed versus half-open debate. The biggest disadvantage of Ewing's suggestion is the lack of a stepsize (other than -1 which is easily handled by reversing the inequalities). But I think +1 and -1 are by far the most common steps, and anything else can be handled by multiplying the index within the loop, or by using range(). -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From qrczak at knm.org.pl Fri Nov 9 14:06:05 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 9 Nov 2001 19:06:05 +0000 (UTC) Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: Fri, 9 Nov 2001 11:01:25 -0500 (EST), Steven D. Majewski pisze: > Don't you think that the extremely different behaviour of the last of > these compared to the others could be a needless cause of confusion? > > for i in 3,2,1: print i > > for i in 3,2,: print i > > for i in 3,2: print i > > for i in 3,: print i > > for i in 3: print i It's already extremely different (raises an exception instead of printing something). -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From peter at engcorp.com Fri Nov 30 08:23:26 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 30 Nov 2001 08:23:26 -0500 Subject: Python evangelists unite! References: Message-ID: <3C07884E.75E18DF7@engcorp.com> brueckd at tbye.com wrote: > > On Fri, 30 Nov 2001, Peter Milliken wrote: > > > I use Python as a good, quick and dirty hacking language. For real (read > > production) stuff that I expect a customer to run or will require more than > > a single person working for a couple of hours, I look elsewhere :-). Sure > > there are examples of Python being used for "large" jobs - and very > > successful they have been too - but these people are masochists (IMO) :-). > > They could have been more productive with other languages that provide > > better support for generic software engineering principles/standards. > > I am *so* glad that there are people in the world that share your opinion > because you hand me a competitive advantage on a silver platter. I don't > even have to work for it! Keep up the good work; many, many thanks! Dave! :-( Sshhhhh! (Most of the people here are probably not in business themselves. You're not supposed to leak the secret out to our competitors!) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From skip at pobox.com Fri Nov 16 03:10:09 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 09:10:09 +0100 Subject: scope question In-Reply-To: <7xofm4gfqx.fsf@ruckus.brouhaha.com> References: <9t0j1i02oob@enews1.newsguy.com> <7xofm4gfqx.fsf@ruckus.brouhaha.com> Message-ID: <15348.51681.408061.547369@beluga.mojam.com> >> I've never closed a cursor object explicitly. Failing to close it >> doesn't create a memory leak, with or without gc enabled. Paul> I thought failing to close cursors could cause leaks in Oracle. That may well be, but the original question was about MySQLdb and I would think Oracle has a bug if it can't clean up after itself if a client goes away without explicitly closing all the cursors it was using. Skip From greg at cosc.canterbury.ac.nz Wed Nov 28 23:05:42 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 29 Nov 2001 17:05:42 +1300 Subject: Is selecting from multiple list boxes in Tk possible? References: <3C047207.8243CFE7@cosc.canterbury.ac.nz> Message-ID: <3C05B416.4836EED7@cosc.canterbury.ac.nz> Laura Creighton wrote: > > Make your listboxes with exportseletion = 0 That works great. Thanks a lot! -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From qrczak at knm.org.pl Tue Nov 27 13:34:18 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Tue, 27 Nov 2001 18:34:18 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: Tue, 27 Nov 2001 14:30:18 GMT, Terry Reedy pisze: >> if 0: >> print "0" >> print "1" > > Raise SyntaxError. > > Seriously. > > This would be consistent with general philosophy of not guessing in > the face of ambiguity. For me there is no ambiguity because tabs always have size 8. > Once such a directive-by-first-use is made, it is not unreasonable > to require consistency until cancelled by a corresponding dedent.. Let's suppose I'm editing a file written by somebody else. I want to insert a statement so I hit Enter at the end of a line. The editor automatically indents the new line. Later it causes SyntaxError because the file happened to use tabs and I've set my editor to use spaces for indentation. Who is at fault? My poor editor which is unable to guess tab / space convention used in the file and adapt to it automatically? The original author who used tabs at all? Me because I didn't convert the file to spaces before editing? > As I explained in my last post in this thread, > := > is not 'right' but merely an ill-chosen convention of a minority of > computer users, It's not a minority. Almost everybody uses this convention. It's better to use the most common convention consistently than to invent new conventions (like "tab = one indent level"). We could live without tabs if ASCII was designed today, but they are there. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From peterb at cortland.com Wed Nov 14 11:22:36 2001 From: peterb at cortland.com (Peter Bismuti) Date: Wed, 14 Nov 2001 08:22:36 -0800 Subject: sending a function on the fly? Message-ID: <3bf2a06f$1@207.229.64.20> In ECMAscript you can send a function as an argument that is defined on the fly such as: callMyFunction( new Function(){ blah blah }) Something like that. Here the function has not been named and was not defined outside of the call. Can this be done in Python? Thanks From James_Althoff at i2.com Wed Nov 28 20:31:52 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 17:31:52 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: Greq Ewing wrote: >I think the point Mr. Eppstein was making is that >"for i in seq" can be read as "for all values of i >such that i in seq is true". PEP 276 would break >that, because "for i in 5" couldn't sensibly be >read as "for all values of i such that i in 5 >is true", unless "i in 5" on its own were valid and >had a rather unintuitive meaning. But since Python now uses iterator protocol -- not sequence protocol -- in for-loops (presumably in "in" as it were) and such, I would assume that over time for i in spam: would come to be thought of as "for all values of i generated from spam's iterator". I don't think PEP 276 "breaks" that. It, in fact, proposes that types.IntType *implement* that. Obviously there are myriad differences of opinion on this. :-) Jim From ozonehole2k at yahoo.com Thu Nov 29 22:07:42 2001 From: ozonehole2k at yahoo.com (Ozone Hole near South Pole) Date: 29 Nov 2001 19:07:42 -0800 Subject: What's the value of "None" between 2.1.1 and 1.5.2 Message-ID: Hi, I have written a simulation in python 1.5.2.... It used to work fine. When I logged on a new machine which has Python 2.1.1 installed, my simulation has gone wild. Later on, I figured that out one weird thing about the value of "None": In the new machine: Python 2.1.1 (#1, Nov 11 2001, 18:19:24) [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> a=[3,4,5,7,None,0.2,-4] >>> print min(a) None >>> print max(a) 7 Python 1.5.2 (#1, Sep 30 2000, 18:08:36) [GCC 2.95.3 19991030 (prerelease)] on linux-i386 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> a=[3,4,5,7,None,0.2,-4] >>> print min(a) -4 >>> print max(a) None >>> It seems to me that "None" means -Inf in 2.2.1 but means "Inf" in 1.5.2. Why do the Python guys change this assumption? In my calculations, I use "None" to indicate very large estimation error. Is there any formal symbol for this? I don't really want to fix this type of bug again whenever Python upgrades.... TIA From mwh at python.net Wed Nov 21 05:29:54 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 21 Nov 2001 10:29:54 GMT Subject: Conversion from tuple to argument list? References: <3BFAE47F.C014585B@earthlink.net> Message-ID: David Bolen writes: > Thus the preface about "newer python releases". This feature (and > **kwargs for passing keyword arguments) mirrors the use of the similar > syntax in function formal parameters for accepting normal unnamed and > keyword arguments. It was added in Python 2.0. > > It's mentioned briefly in the What's New document for Python 2.0 > (http://www.python.org/2.0/new-python.html). I'm not actually sure > where it may be documented in the primary set of documentation. I'm not sure that it is; I think there's a bug floating around on sf about this. Hopefully it will get fixed before 2.2 gets out. Cheers, M. -- 31. Simplicity does not precede complexity, but follows it. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From tim at vegeta.ath.cx Fri Nov 16 08:01:25 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 16 Nov 2001 13:01:25 GMT Subject: A modest proposal References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <7xg07fwn6l.fsf@ruckus.brouhaha.com> <3BF49DE9.95DC02FA@earthlink.net> Message-ID: Hans Nowak graced us by uttering: > Paul Rubin wrote: >> "Stuart D. Gathman" writes: >> > I have been putting my thoughts toward the elusive goal of making python >> > as fast as some LISP dialects. >> >> The way to do that is with a compiler. Speeding up access to globals >> may help a little, but probably not nearly as much. > > Aight, here's a wild-assed idea, unrelated to the proposal... since > Python and Lisp are both dynamic languages, would it be possible to > write a Python-to-Lisp translator, and then compile the Lisp code > using one of those efficient Lisp compilers? A partial solution, but in keeping with the Unix Philosophy, might be the (quite serious) Parrot project , a non-language-specific backend being developed for Perl 6. There has already been much talk about creating a Python front-end in addition to the normal Perl, leading to speculation about a translating ability, byte-compiling from orig. language and disassembling to another. Would a Lisp front-end to this engine be plausible? Tim Hammerquist -- It has been truly said that hackers have even more words for equipment failures than Yiddish has for obnoxious people. -- Jargon File 4.3.1 From jdadson at ix.netcom.com Fri Nov 2 22:32:40 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 03 Nov 2001 03:32:40 GMT Subject: I found it. [Re: Getting started] References: <3BE34358.8819E585@ix.netcom.com> <9rvhf4$vjrgr$1@ID-11957.news.dfncis.de> <3BE361DE.89B01B1C@ix.netcom.com> Message-ID: <3BE36536.182EA315@ix.netcom.com> I found it. os.chdir() BTW, the system lets me change the variable os.curdir, but that seems to have no effect. If I next do an os.chdir to some other directory, the variable os.curdir does not change. Jive From martin.franklin at westgeo.com Fri Nov 9 09:46:27 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Fri, 9 Nov 2001 14:46:27 +0000 Subject: Matrix in Python . References: <9sglpt$a3r$1@news.tpi.pl> Message-ID: <9sgq6a$qd8$1@mail1.wg.waii.com> Nomad wrote: > On Fri, 9 Nov 2001 14:30:49 +0100, "Tomasz Lisowski" > wrote: > >> For dealing with Matrix you need something more powerful, than Python. = >>You have to realize, that the world does not look as your eyes, and your = >>mind tell you. Otherwise ... Matrix has you! >> >> Neo :-) > > You mean Python is going to take over the world and keep living people > in vats of goo? > > Jeez, and all I was trying to do was turn down the volume of my PC > speakers... How does Guido feel about all of this? > what is the Matrix? From bspears at easystreet.com Wed Nov 7 02:33:23 2001 From: bspears at easystreet.com (Bill Spears) Date: Tue, 06 Nov 2001 23:33:23 -0800 Subject: A-Life or E-life Message-ID: <3BE8E3C3.E8A0ACBE@easystreet.com> Is anybody using Python to do a-life or virtual economics, like sugarscape? From fuessler at demokrit.informatik.uni-mannheim.de Fri Nov 23 02:27:30 2001 From: fuessler at demokrit.informatik.uni-mannheim.de (Holger Fuessler) Date: 23 Nov 2001 08:27:30 +0100 Subject: Storing Data in C++-Object Message-ID: Hi all! How can I store data in a C++-Object and access it from Python? The documentation I found for extending Python in C is only for calling functions with no persistent C-Data. What I need is the instantiation of a C++-Object from Python and then access its methods. Is there any HowTo-Document for doing that? Cheers Holger -- Holger Fuessler Praktische Informatik IV Tel: +49 621 181 2605 University of Mannheim Fax: +49 621 181 2601 L15, 16 68131 Mannheim, Germany fuessler at informatik.uni-mannheim.de From ulbi at ivs.tu-berlin.de Fri Nov 23 04:12:45 2001 From: ulbi at ivs.tu-berlin.de (Andreas Ulbrich) Date: Fri, 23 Nov 2001 10:12:45 +0100 Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: <3BFE130D.30006@ivs.tu-berlin.de> MANUEL FERNANDEZ PEREZ wrote: > Hello, > I'm looking for an editor for Python.I' m interested it works on Windows.Can > anybody help me? > > Thank you > > Manuel Well, that's pretty much a matter of taste. Holy wars have been fought about this issue. Anyhow, I prefer vim (www.vim.org) for all my programming be it Python, C[++], Java or whatever. From seeger at sitewaerts.de Tue Nov 20 11:27:14 2001 From: seeger at sitewaerts.de (Felix Seeger) Date: Tue, 20 Nov 2001 17:27:14 +0100 Subject: problem with a python script Message-ID: <9tdvv4$1ugdj$1@ID-79019.news.dfncis.de> Hi I'm new to python (starting 5 minutes bevor writing this mail ;)) I've got a programm from another person. I like to change the code, so I can use it, but I can't start the orginal code ;( Here is the output: seeger at vauva:~/lin$ python2.1 radminserver.py Traceback (most recent call last): File "radminserver.py", line 1, in ? from internet import * File "internet.py", line 46 def sendmail(self,from,to,msg,mopts="",rcptopts=""): ^ SyntaxError: invalid syntax Here is the part of the code: class Mail: def __init__(self,outserver="localhost"): import smtplib self.outserver=outserver def sendmail(self,from,to,msg,mopts="",rcptopts=""): s=smtplib.SMTP(outserver) s.sendmail(from,to,msg,mopts,recptopts) s.quit() thanks have fun HAL From marcora at colorado.edu Wed Nov 21 14:00:09 2001 From: marcora at colorado.edu (Edoardo ''Dado'' Marcora) Date: Wed, 21 Nov 2001 12:00:09 -0700 Subject: Has anyone ever used Cache' object database with Python Message-ID: <9tgtjc$huf$1@peabody.colorado.edu> I am trying to figure out wether it is possible, and if so how, to call and write Python functions from/for Cache' (www.intersystems.com). I have a Python script that fetches XML formatted bibliographic records from the National Library of Medicine and I would like to be able to use it from Cache'/CSP to insert bibliographic data in my Cache' db. Thank you in advance for your help, Dado -- ======================================== ''Sono diverso perche' sono omozigoto.'' http://ucsu.colorado.edu/~marcora/omozigoto.wav Edoardo "Dado" Marcora 2727 Folsom St. Apt. 318 Boulder, CO 80304 USA Tel: +1-303-492-3450 (W) +1-303-415-0811 (H) Fax: +1-303-492-7744 Email: marcora at colorado.edu ======================================== From peter at engcorp.com Sun Nov 11 11:01:51 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 11 Nov 2001 11:01:51 -0500 Subject: Is this considered black magic? References: Message-ID: <3BEEA0EF.3882B613@engcorp.com> (Reposted... previous one stupidly read object.getattr(name_key), which I *always* type first for some reason. *This* post actually tested. :) Laura Creighton wrote: > > I want to do something which is conceptually very simple. Given a list of > objects, call make everybody call the same method you want to run. Sort > of like apply(), but for methods. [...] > def foreach(name_key, object_list, *args): > print 'foreach: args are ' + `args` > for object in object_list: > try: > object.__class__.__dict__[name_key](object, *args) > except KeyError: > pass How about using getattr() instead? Then the core above would be more like this: method = getattr(object, name_key) # returns bound method if callable(method): try: method(*args) except: print 'Call failed!' Slightly less "black-magical" ? (I personally would pre-qualify the method so that I could wrap the call with a catch-all try/except because otherwise I wouldn't know whether the KeyError, for example, came from the method call or the attempt to find the name in the dictionary.) [...] > foreach ('say', [h, e, s]) > > foreach('speak_up', [e]) > foreach('speak_up', [h, e, s], 'sandwich') > foreach('speak_up', [h, e, s], None) #can i pass None? > > foreach('shout', [h, e, s], 'sandwich') > foreach('shout', [h, e, s], 'sandwich', 'beer') I wouldn't put the list of objects second. Mentally I think it should read "here's a list of thing(s), and for each item in the list, call this method with these arguments." This isn't black magic, this is Python's awesome introspection! :) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From philh at comuno.freeserve.co.uk Wed Nov 28 18:36:29 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Wed, 28 Nov 2001 23:36:29 +0000 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: On Wed, 28 Nov 2001 18:36:27 +0300, Oleg Broytmann wrote: >On Wed, Nov 28, 2001 at 10:23:18AM -0500, Steve Holden wrote: >> > There are other merits, not only money. Corporations want power even >> > more than money. Down with non-free software. >> >> :-) >> >> But seriously, the only advantage of more power is its ability to generate > > Exactly opposite - the advatage of power is power, and the only >advantage of money is... you've guessed it - power. > >> greater revenues. Any other ultimate goal would be un-American. > > Ah, those un-American goals... According to Microsoft, open source is un-American. And, also according to Microsoft, they are responsible for open source. I guess Microsoft must be un-American. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From prabhu at aero.iitm.ernet.in Tue Nov 20 23:48:44 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 21 Nov 2001 10:18:44 +0530 Subject: Tkinter and IDE's In-Reply-To: <9tf4fo$fb5$1@nntp9.atl.mindspring.net> References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> <3bf9f33a.5900599@24.0.228.33> <9tf4fo$fb5$1@nntp9.atl.mindspring.net> Message-ID: <15355.12844.788627.399957@monster.linux.in> >>>>> "DA" == Don Arnold writes: DA> def quit(): print "Hello, I must be going" # import sys # DA> sys.exit() root.quit() DA> root = Tk() widget = Button(root, text="Hello, event world", DA> command = quit) widget.pack() root.mainloop() Well, what happens when you remove the root.mainloop()? Your other errors will occur simply because of the way you have defined quit. Change it like so: >>> from Tkinter import * >>> root = Tk() >>> def quit(): ... print "Hello, I must be going" ... root.destroy() ... >>> widget = Button(root, text="Hello, event world", command = quit) >>> widget.pack() >>> # click on button >>> Hello, I must be going This should definitely work. prabhu From talon at www.tempestnetworks.net Fri Nov 30 11:52:43 2001 From: talon at www.tempestnetworks.net (Stephen Coursen) Date: Fri, 30 Nov 2001 16:52:43 GMT Subject: xmlrpc tutorial? References: <3C063569.8230ADD0@snakefarm.org> <3C07961D.9A7970FA@snakefarm.org> <3C07B7A3.2A6443C9@snakefarm.org> Message-ID: On Fri, 30 Nov 2001 17:45:23 +0100, Carsten Gaebler wrote: >talon at www.tempestnetworks.net wrote: >> >> On Fri, 30 Nov 2001 15:22:21 +0100, Carsten Gaebler wrote: >> >> >However, there seems to be a problem with restarting the server. I >> >have to wait a minute or so to avoid an 'address is already in use' >> >error. >> >> Use the setsockopt function on the socket objet, pass it the value >> SO_REUSEADDR (defined in the socket module). > >Nope, doesn't help. My code is: > >server = SocketServer.TCPServer(('', 8000), TestRequestHandler) >server.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) >server.serve_forever() > >cg. Ah ha, the problem is due to how you're using TCPServer. Try: SocketServer.TCPServer.reuse_address = 1 server = SocketServer.TCPServer( ('', 8000), TestRequestHandler ) server.serve_forever( ) The problem is that the socket is bound (TCPServer.__init__ calls server_bind( )), it logically follows that you have to set this particular socket option before the socket is bound :) HTH, Steve >-- >'In iteger arithetric divsion is no the oposite of multiplication.' > -- scenes from comp.lang.python -- -- Visits always give pleasure: if not on arrival, then on the departure. -- Edouard Le Berquier, "Pensees des Autres" From ol1 at v10a.com Thu Nov 22 11:11:02 2001 From: ol1 at v10a.com (op) Date: Thu, 22 Nov 2001 17:11:02 +0100 Subject: rlcompleter and emacs Message-ID: <200111221611.fAMGB6027821@smtp.wineasy.se> Just found out about the rlcompleter. Any way to get this running under python-mode in emacs. n.b I'm not talking about running a shell in emacs and have rlcompleter work there. I want the autocompletion functionality of pythonwin in emacs python-mode. Amaze me with your twisted python-emacs-lisp-wizardry. op -- You'll be called to a post requiring ability in handling groups of people. From martin at tactilis.co.uk Mon Nov 12 17:11:54 2001 From: martin at tactilis.co.uk (Martin Armstrong) Date: Mon, 12 Nov 2001 22:11:54 +0000 Subject: Signed (and now seen) References: <200111020342.fA23g3x32365@mbuna.arbhome.com.au> Message-ID: In article , J?rgen A. Erhard writes It doesn't matter what you wrote. What matters is: Content-Type: multipart/signed; boundary="pgp-sign-Multipart_Sat_Nov_10_23:43:08_2001-1"; micalg=pgp-sha1; protocol="application/pgp-signature" ^ ^ ^ ^ Colons are no longer broken :) -----------^--^ -- Martin Armstrong From robert_sassmann at hotmail.com Wed Nov 21 13:02:57 2001 From: robert_sassmann at hotmail.com (Robert Sassmann) Date: 21 Nov 2001 10:02:57 -0800 Subject: DBI compliant ADO wrapper? Message-ID: Hi, does anybody know about an existing DBI API compliant ADO/ADOX wrapper for Win32? Thanks --Rob From mrc at CAC.Washington.EDU Wed Nov 7 10:00:54 2001 From: mrc at CAC.Washington.EDU (Mark Crispin) Date: Wed, 7 Nov 2001 07:00:54 -0800 Subject: Q: Fast searching Imap server, IMAP server (in Python) In-Reply-To: References: Message-ID: On 7 Nov 2001, Jan Kybic wrote: > Are you sure Cyrus does it? I did not find anything about it in the > documentation. My first attempt to compile it failed, but I am willing > to try again if it solves my problem. Yes, Cyrus's mailbox format maintains metadata sufficient to answer your "SEARCH SINCE 1-Oct-2001 FROM jan TO jurgen" without having to look at the message files. Once you do one search like this in UW, subsequent searches of a similar nature are instantaneous since UW discovered all the necessary metadata in the first search and now has it cached. Thus, the search would be completely in memory without looking at the disk at all. > I do not think it matters, both are going to get uncomfortably slow > when the number of messages grows. Currently, the search of about 30MB > in about 3000 mail messages takes sometimes several minutes on a Pentium II > computer, which is just too slow for me. That is too slow for most people! I've never had a 30MB/3000 message search take several minutes, not even on a 25MHz 68040 which is much slower than a Pentium II. > I am convinced the only solution is to store the important headers, > possibly with the messages itself, in some database. Yup. Cyrus doesn't store messages in the database, but it does store the metadata there. Exchange uses a database for both (of course, that database is MS proprietary). > I agree that cacheing headers of the mails read in the same session is > a good thing. A server is pretty much forced to cache metadata if its going to have any reasonable performance, especially when multiple sesions are done per search. > However, I do not think the mail client should cache all > the headers of all the mail you ever received, which is what I would > need when searching for some old mail - there are just way too > many. As far as I understood the IMAP philosphy, this should be the > job of the server. Exactly right! The idea of "make the client cache" is based upon the POP3 model and an implicit presumption that users only use a single PC and a PC only has a single user. The soaring popularity of web-based mail should have thoroughly debunked that notion. There will always be a market for web-based mail; for a significant portion of the user community it is the right thing. However, there's also a significant portion of the user community which uses web-based mail as a substitute for a decent GUI that doesn't require the client to cache (Pine has grabbed the user base that doesn't insist upon a GUI). -- Mark -- http://staff.washington.edu/mrc Science does not emerge from voting, party politics, or public debate. From jdavis at empires.org Tue Nov 20 03:56:39 2001 From: jdavis at empires.org (Jeff Davis) Date: Tue, 20 Nov 2001 00:56:39 -0800 Subject: Try block problem References: <9tcnls$42k$1@news1.ucsd.edu> <3bf9eacb$0$79564$6e49188b@news.goldengate.net> Message-ID: <9td60p$g15$1@news1.ucsd.edu> I am not sure you understood my question. I wanted to know why the "finally" could not be used with "try", i.e. why did the developers of python choose to make the language that way. Thanks, Jeff Greg Krohn wrote: > "Jeff Davis" wrote in message > news:9tcnls$42k$1 at news1.ucsd.edu... >> It seems like the following makes sense to me: >> >> try: >> ... >> except: >> ... >> finally: >> ... > > except and finally can't be used together. > >>>> def spam(x): > ... try: > ... print 10 / x > ... finally: > ... print 'Cleanup before exception is raised' > ... >>>> def eggs(x): > ... try: > ... print 10 / x > ... except: > ... print 'Bad x! Bad, bad x!' > ... >>>> spam(1) > 10 > Cleanup before exception is raised >>>> spam(0) > Cleanup before exception is raised > Traceback (most recent call last): > File "", line 1, in ? > File "", line 3, in spam > ZeroDivisionError: integer division or modulo by zero >>>> eggs(1) > 10 >>>> eggs(0) > Bad x! Bad, bad x! > > More info: http://www.python.org/doc/current/ref/try.html > > greg From erno-news at erno.iki.fi Mon Nov 19 13:06:34 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 19 Nov 2001 20:06:34 +0200 Subject: object identity and equivalence References: Message-ID: In article , sandskyfly at hotmail.com (Sandy Norton) writes: | I am a bit confused about when it is correct to use object identity | "is" for comparisons and when I should use the equals '==' operator. as a rule, a is b implies a == b (except for odd things like floating point NaNs that compare inequal to themselves). a == b does not imply a is b. | I haven't personally come across cases where these two operators don't | produce the same results with the same operands. Of course I am not | assuming the semantic equivalence of the operators, as it makes sense | that comparing object identity is the not the same as comparing object | value. But could someone offer me an example that uses the same two | operands with 'is' and '==' and produces 'different' results. for some immutable objects like numbers and strings, python caches some of those according to a few rules for efficiency reasons, so it is unpredictable if a is b given two same-valued objects. mutable objects like user class instances and lists and dictionaries and such can not be cached. | Aside: I'm assuming you can overload the '==' operator but not the | 'is' operator? Is this true? yes. | There! I've announced my ignorance to the world. Feel better already! congratulations :) -- erno From skip at pobox.com Fri Nov 16 12:01:25 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 18:01:25 +0100 Subject: Does smtplib lookup MX records? In-Reply-To: References: Message-ID: <15349.18021.947525.550328@beluga.mojam.com> Dale> If it is, what do I need to do to lookup the MX record myself? There are some DNS bits floating around. You might want to try googling for "DNS ~g comp.lang.python". If you're on a Unix-oid system and you're really in a hurry, why not just use os.popen: import os f = os.popen("host -t mx mojam.com") for line in f: if line.find("mail is handled by") != -1: print "mx:", line.rstrip().split()[-1] this-hack-was-brought-to-you-by-the-letter-X-and-the-number-5-ly, y'rs, Skip From gh_pythonlist at gmx.de Sun Nov 18 21:22:27 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Mon, 19 Nov 2001 03:22:27 +0100 Subject: MySQLdb undefined symbol In-Reply-To: <62e69c0c.0111180314.37cc1486@posting.google.com> References: <62e69c0c.0111180314.37cc1486@posting.google.com> Message-ID: <20011119032227.B910@lilith.hqd-internal> On Sun, Nov 18, 2001 at 03:14:46AM -0800, HW wrote: > Hello, > > I get the following error when I try to import MySQLdb: > > >>> import MySQLdb > Traceback (most recent call last): > File "", line 1, in ? > File "/home/clairvision/local/lib/python2.1/site-packages/MySQLdb/__init__.py", > line 27, in ? > import _mysql > ImportError: /home/clairvision/local/lib/python2.1/site-packages/_mysql.so: > undefined symbol: mysql_field_count > >>> > > Red Hat 6.2, python 2.1.1, MySQLdb 0.9.1 > > Any ideas? Maybe your MySQL is too old. The README says you need MySQL >= 3.22.19. But I'd use the latest 3.23.x anyway. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From chrishbarker at home.net Fri Nov 30 15:36:26 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 30 Nov 2001 12:36:26 -0800 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: <3C07EDCA.4BE0243B@home.net> Lucio Torre wrote: > Seriously, if coherent design is a concern to any of you, please let me > know why a block starting colon is proper, but a block closing elemnt is > not. Coherent design can be a concern, but not neccessarily overriding. Anyway, the colon can be usefull when you want to do a one liner: if istrue: print "it's true" Personally, I'd be happy to live without that, but it is such a small deal that I don't care in the least. Stop flogging the horse, it's DEAD. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From dalke at dalkescientific.com Thu Nov 8 15:08:56 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 8 Nov 2001 13:08:56 -0700 Subject: I just got in! References: Message-ID: <9sep77$eg6$1@slb4.atl.mindspring.net> Kirk Bailey: >I want to learn about python, write some things in it, Welcome. I've found Python very enjoyable and powerful. I hope you find it that way as well. If you want some basics on Python, you may want to look at http://www.python.org/doc/Newbies.html > and show that smug bunch ovver in the perl tree that snakes are way >cooler than camels. One thing about Python people is we are less (outwardly ;) smug then your phrase seems to suggest. Perhaps that derives from the influence of Dutch tolerance in the early days. In any case, you may want to tone down your rhetoric to be less divisive, as the sense of coolness varies too wildly to be a useful distinction. Andrew dalke at dalkescientific.com From claird at starbase.neosoft.com Wed Nov 21 16:40:26 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 21 Nov 2001 15:40:26 -0600 Subject: DDE Client? References: Message-ID: In article , David Brady wrote: >> -----Original Message----- >> From: Patrick Vrijlandt >[mailto:p.vrijlandt at aig.azn.nl] >> >> I'm afraid python dde leaks memory, but I haven't >> checked the source and have no confirmation from >> the author. If your application crashes after a >> few thousand dde-calls, think of this. > >Eww. The spec I'm leaning towards is to be able to >run long-term and stable, with several thousand DDE >calls per day. > >I wonder if it's Python that loses it or DDE itself. >I recall finding a bug WAYYYY back when in the early >DDE implementation. StdDde.c used a linked list of >topics, and IIRC deleting a topic had a bug in it that >would delete the desired node WITHOUT reattaching the >prev node to the next node. This has probably changed >since then; this was in my early coding days working >with MFC 2.x. > >Any thoughts? Who is the author, Mark Hammond? . . . While I feel a bit dirty saying this, you *could* import Tk, then use the Tcl DDE package. Is that worth con- sidering? While the Tcl DDE package is not particularly well known, even among Tcl-ers, my experience with it suggests that it's stable. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From marfadeu at gmx.de Fri Nov 9 16:37:22 2001 From: marfadeu at gmx.de (Markus Faust) Date: Fri, 9 Nov 2001 22:37:22 +0100 Subject: mayavi installation problem on Win NT References: <9sdh9v$hgq$01$1@news.t-online.com> <9sevfv$lrn$06$1@news.t-online.com> <87ofmcoqj2.fsf@optonline.net> Message-ID: <9shibe$g4v$04$1@news.t-online.com> Les, let me comment your question. I actually have difficulties with 2 vtkdll.dll files, the one that I got with the win32 vtk32 installation and yours. Some of the files of the vtk32 installation do not work with your dll. i.e. the vc++ projects test and sample. They link well with the vtk32 vtkdll.dll. Thus you need both dlls and the best at the moment is from my point of view to have the dll near the projects folders and not in the winnt\system32 folder. Markus From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Sun Nov 25 17:11:31 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Sun, 25 Nov 2001 22:11:31 GMT Subject: application scripting References: Message-ID: So... no one has every implemented recordability in a Python-scriptable application? In article , Keith Ray wrote: > Introduction: > > AppleScript is the only ScriptingArchitecture that I know about that > allows recording. An application is recordable when all (or most) > user-interface handling results in the generation of one or more > AppleEvents, which are directly routed to the application itself for > execution. The AppleScript system can record these AppleEvents in a > script, which the user can then edit. This can be a very user-friendly > way for a user to start scripting, but of the relatively few > applications that support AppleScript, even fewer support recordability. > > Mac Applications that are scriptable, but not recordable, have an > architecture something like this: > > [GUI] -> commands -> [Model] <- commands <- [ScriptEngine] > Scripts or AppleEvents --^ > > but recordable applications have an architecture like this: > > [GUI] -> AppleEvents -> [ScriptEngine] -> commands -> [Model] > Scripts or AppleEvents --^ > > Questions: > > Can anyone describe how recordability would be implemented in a C++ > application with (embedded) Python? > > Would a Python-embedded application have to generate Python source code, > to implement the recordability pattern shown above? From peterb at cortland.com Fri Nov 16 11:05:16 2001 From: peterb at cortland.com (Peter Bismuti) Date: Fri, 16 Nov 2001 08:05:16 -0800 Subject: Am I a troll? Split personality? References: <9t1ii2$es0$1@peabody.colorado.edu> <3BF48BA4.D03A627C@engcorp.com> Message-ID: <3bf53f5f@207.229.64.20> I use Outlook express. I was using a news account to post the messages. I have multiple mail accounts, one using my web "handle". When I post to the news account, there is no "from" input box, and I never know from which mail account the post will come from. I can't figure out how to specify from whom the message is being sent. I am new to windows, if anyone knows the answer I'd appreciate help. I've switched to a mailing list so now there shouldn't be any more problems. "Steve Holden" wrote in message news:bH9J7.42958$vQ1.1400215 at atlpnn01.usenetserver.com... > "Peter Hansen" wrote ... > > Fernando P?rez wrote: > > > > > > Peoter Veliki wrote: > > > > > > > I'd like to be able to use a function as an argument without declaring > it > > > > externally. This is what I don't want to do: > > > > > > [snip] > > > > > > Listen, this is the third time you post this question and people > actually > > > *have* answered it already. Could you be bothered to check for replies > first > > > before you repost or is that too much to ask? Do you require > hand-delivery in > > > special stationery or something else we should be aware of? > > > > Funny thing is, he changed names between the second and third posting... > > used to be named Peter Bismuti. I guess while he was out getting the > > name-change papers signed he missed our replies. > > > Perhaps this guy is a troll? Or possibly has multiple personalities... > > regards > Steve > > > -- > http://mail.python.org/mailman/listinfo/python-list > From phr-n2001d at nightsong.com Thu Nov 1 19:10:57 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 01 Nov 2001 16:10:57 -0800 Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> <9rrtud$ff8$1@nntp6.u.washington.edu> <9rsn9s$cvu$3@newshost.accu.uu.nl> Message-ID: <7xy9lquj5a.fsf@ruckus.brouhaha.com> m.faassen at vet.uu.nl (Martijn Faassen) writes: > > Personally, I prefer the effect of double underscore for this case, as > > well. I can easily get to the variables by applying the name mangling > > myself, yet cannot accidentally stomp on the variables in a subclass. > > > To each his/her own. > > That's a good point. I haven't done this because I've never remembered > the name mangling rule. I'm not even sure if it's really part of the > Python standard, but I'd guess it should be. Depending on the name mangling scheme staying the same between python version updates sounds like asking for trouble. From emile at fenx.com Sat Nov 3 11:49:51 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 3 Nov 2001 08:49:51 -0800 Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> Message-ID: <9s17hr$10phqi$1@ID-11957.news.dfncis.de> "Fred" wrote in message news:3BE41CBE.94AED22 at nospamco.com... > I'm dealing with about 100Gb of data that I first just need to > characterize. So, since the slowest part will be simply reading the > data, I'm testing various languages and methods on a 10 line subset, a > 32 Mb subset and a 750 Mb subset. > > The following python program prints out the results in about 30 seconds, > however it doesn't finish for another minute with the 32 Mb set of > data! At first I thought it was stuck and killed it; however I finally > let it run on the smaller data set and all was well. > > Is this a garbage collection issue? Is there a better way to count the > individual values than dictionaries? I put the sys.exit call in while > trying to figure out what was happening but it didn't make a difference. > I'd suspect that python is cleaning house before exiting. Try exiting with os._exit or os.abort. -- Emile van Sebille emile at fenx.com --------- From mwh at python.net Mon Nov 12 07:33:51 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 12 Nov 2001 12:33:51 GMT Subject: cygwin compilation... References: Message-ID: provvisorio100 at yahoo.com (provvisorio) writes: > my cygwin compiler hangs up con win98 after compiling all objects (i > modified THREAD.C n other STUFF...) . Why? > After make bash hangs with the message: > PYTHONPATH= ./python.exe ./setup.py build > > I use a recent release of cygwin n i can compile quite well many > sources.. > What i could check fisrt???? What version of Python? Cygwin comes with Python 2.1.1, and CVS builds out of the box (well, apart from _cursesmodule.c, but we're onto that...) on my nt system. Cheers, M. -- ARTHUR: Why are there three of you? LINTILLAS: Why is there only one of you? ARTHUR: Er... Could I have notice of that question? -- The Hitch-Hikers Guide to the Galaxy, Episode 11 From prabhu at aero.iitm.ernet.in Mon Nov 5 07:59:58 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 5 Nov 2001 18:29:58 +0530 Subject: Python packages - problems, pitfalls. In-Reply-To: References: Message-ID: <15334.36174.555185.864724@monster.linux.in> hi, Thanks for the response atleast I know that I am not the only one who has had this problem. :) >>>>> "CE" == Chuck Esterbrook writes: CE> In my project, Webware, we did ended up with the multiple CE> import problem you described. eg, where a module was imported CE> twice under under "bar" and "foo.bar". This lead to technical CE> problems that were unacceptable. CE> At some level, this was related to the current directory of CE> the process. We solved this by tweaking our app server to make CE> sure it changed the current directory to the highest level of CE> our packaging system (despite its existence in a subpackage) CE> at the very start before any project-specific imports. This CE> solved it. [snip] True, but what if one of your modules did a os.chdir('some_other_dir')? Would this approach still work? prabhu From lrl at ou.edu Fri Nov 23 02:10:44 2001 From: lrl at ou.edu (L) Date: 22 Nov 2001 23:10:44 -0800 Subject: Could someone explain this multidimensional list behaviour? Message-ID: Greetings from a long time java programmer jumping ship, I'm not having trouble getting around this behavior: >>> spam = [[0] * 3] * 3 >>> spam [[0, 0, 0], [0, 0, 0], [0, 0, 0]] >>> spam[0][1] = 1 >>> spam [[0, 1, 0], [0, 1, 0], [0, 1, 0]] I was expecting after making the assignment to get this: [[0, 1, 0], [0, 0, 0], [0, 0, 0]] After flipping through my O'Reilly I know it has to do with the * operator, but don't know how otherwise allocate an n x n "array" type of structure beforehand with each element having a unique pointer, without using some sort of ridiculous two loop setup and appends like the following. >>> spam = [] >>> for y in range(10): inner = [] for x in range(10): inner.append(0) spam.append(inner) del inner >>> spam [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] So what is the easy way to allocate an n x n matrix with unique values? Thanks! From fredNo at nospamco.com Wed Nov 14 12:58:51 2001 From: fredNo at nospamco.com (Fred) Date: Wed, 14 Nov 2001 09:58:51 -0800 Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> Message-ID: <3BF2B0DB.F3AC0BA1@nospamco.com> Thanks, I'll give that a try. With all the talk of windows free() problems discussed above I was trying to figure out what I could do on Digital Unix with 1Gb of memory :-) Alexei Zverovitch wrote: > > Fred wrote in news:3BE41CBE.94AED22 at nospamco.com: > > > Python 2.1.1 (#3, Oct 25 2001, 12:54:40) [C] on osf1V4 > > Since you're running Digital Unix, you might want to > try tweaking the __fast_free_max et al variables used > by the system malloc(). 'man malloc' is your friend > (I believe you'll need to re-link the python executable > if you want to change those variables). > > We've had a similar problem recently when a (C++) > program was taking ages to free() .5 million small > structures. It turned out that most of the time was > spent by free() coalescing memory blocks as they > were being deallocated. Increasing __fast_free_max > solved the problem (IIRC the execution time was > reduced by several orders of magnitude). > > You may be seeing the same (or similar) behaviour. > > Cheers > Alexei > -- > alexei (at) barclays (dot) net From steveb at nebcoinc.com Mon Nov 5 16:50:23 2001 From: steveb at nebcoinc.com (Steve) Date: 5 Nov 2001 13:50:23 -0800 Subject: Converting exponential numbers to strings. Message-ID: <32921e0b.0111051350.41e35f26@posting.google.com> Hi, I'm new to python and I'm trying to write a routine to determine whether or not an object is numeric like so: def isnumeric(s,allow_dec=0,allow_neg=0): decimal_found = 0 negative_found = 0 if s == "": return 0 for x in str(s): if x not in string.digits: if x == "." and allow_dec: if decimal_found: return 0 else: decimal_found = 1 elif x == "-" and allow_neg: if negative_found: return 0 else: negative_found = 1 else: return 0 return 1 Everything works just great, until I pass it a value like: 0.000085 When that happens str(.000085) returns 8.5e-05 I'm open to all suggestions at this point. I've also tried replacing the "for" statement above with: for x in "%20.20f" % s: But that no longer returns the decimal portion of the value. Please CC me in your replies. Thanks in advance, Steve From dcinege at psychosis.com Wed Nov 21 02:57:39 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Wed, 21 Nov 2001 02:57:39 -0500 Subject: os.kill........ In-Reply-To: <9te2g4$sma$1@mail1.wg.waii.com> References: <9te2g4$sma$1@mail1.wg.waii.com> Message-ID: On Tuesday 20 November 2001 12:05, Martin Franklin wrote: > Hi, > > I'm looking for a way of determining if a process is still running (having > spawned it from a python app), I have come up with os.kill(PID, 0) > this will raise an exception if the process does not exist, and do nothing > if the process does exist. The sig of zero does not _seem_ to affect it > (at least not on my linux box) > > My question is..... is this an OK way of doing this? do I have any other > _pure_ python options..... > > > Regards > Martin Probably not very portable, but this may help. It's a function I use to see if a lockfile is stale or not. It's grab info from the process info in /proc. (Yes the function could be cleaner...) def processorisactive(tmpdir): # This is very linux for lf in glob.glob('%s/lockfile.*' % (tmpdir)): pid = string.split(os.path.basename(lf), '.')[1] try: pid_file = '/proc/%s/status' % (pid) f = open(pid_file, 'r') except: continue # Process does not exist name = string.split(f.readline())[1] state = string.split(f.readline())[1] f.close() # FIX ME Check for Sleep state correct? if name[:4] == 'mss_': if state == 'R' or state == 'D' or state == 'S': # It's a running mss_X processor mss.log("\tActive lockfile in '%s'. Skipping." % (tmpdir)) return 1 mss.log("\tRemoving stale lockfile '%s/%s'." % (tmpdir,lf)) os.remove(lf) # Remove stale lockfile return 0 -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From sshark97 at hotmail.com Fri Nov 30 22:47:43 2001 From: sshark97 at hotmail.com (TH Lim) Date: 30 Nov 2001 19:47:43 -0800 Subject: sending ctrl-break signal or ctrl-c Message-ID: hi, i have used os.spawn*(...) to execute a windows application and want to programatically terminate this application using ctrl-C or ctrl-break . how do i that? or is there any windows specific python-API i should condider? thanks. /lim/ From achim.domma at syynx.de Sat Nov 10 14:17:04 2001 From: achim.domma at syynx.de (Achim Domma) Date: Sat, 10 Nov 2001 20:17:04 +0100 Subject: Python in a hospital application please help References: Message-ID: <9sjuab$42c$07$1@news.t-online.com> Hi, depending on the detailed requirements of your application I would stick to a web based solution with Zope. If you use SSL your data is encrypted on the wire. You are free to use Zopes database (ZODB) or to use another one. The problem could be that a browser GUI does not have enough functionality. But in an closed environment you could restrict access to one special browser (for example IE5). In this case you could do a very fine GUI with DHTML. greetings Achim wrote in message news:mailman.1005415299.17379.python-list at python.org... > Hi, > > I want to write an application for the hospital I'm working to. > > I'm newbie in python, and I want to hear some opinios about what are > the options I have.. > > The structure I have in mind is : At Server we will have an > application that handles business rules, connects to databases, and > send objects to the clients . > > At client we will have an wxPython application that will talk to the > server application > > Some things this application must provide > > * Ability to change the database > I think one way tho achieve this is via Object Relational mapper. > Have anyone implemented a library like this in python ? > > * Pool of connections. > In the application I have today all clients have their own > connections to the database. Today I'm using Interbase (free one) but > what if the hospital need a commercial database in the future ? With > a pool of connection we can spent less money, and this is issue in a > hospital in little city of Brazil. > > * The communication between the server and the client must be > encrypted. > Personal information of the patients can't run unencrypted over the > wire. > > > I know that this is difficult application to write, so I want to hear > some design hints, what are the difficulties I'm going to face. What > libraries I can use. > > > Sorry my english and thanks in advance > > Geraldo Lopes de Souza > > From phr-n2001d at nightsong.com Fri Nov 9 09:35:00 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 06:35:00 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> <3BEB602C.EFEA8D82@engcorp.com> <7xofmcy0xd.fsf@ruckus.brouhaha.com> Message-ID: <7xvggk9fmz.fsf@ruckus.brouhaha.com> "Steve Holden" writes: > But of course you'd be happy to trust them to IIS-based, NT-based web > applications, right? No of course not. > My own opinion, for what it's worth (and I am known to bend ears on this > topic): > > Python's delivered software quality is higher > than many commercial language implementations, and > the level of support available is an order of magnitude > better: with Python you end up communicating with > peoiple who actually understand the software. > > I suspect, without any reasonable data to support it, that most such > assertions (but not necessarily yours) boil down to "I'd like to have > someone to sue if things come badly unstuck". Have you READ the typical > commercial language system license agreement? I feel that perl and gcc are both more solid than python right now, and their support is at least as good. Gcc is is used in some military projects where they simply weren't willing to trust anything they didn't have source for. From cliechti at gmx.net Tue Nov 27 15:52:14 2001 From: cliechti at gmx.net (Chris Liechti) Date: 27 Nov 2001 21:52:14 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. References: <02f901c1775e$21c62730$0e0fbb82@corp.es.com> Message-ID: James Oakley wrote in news:mailman.1006878455.5184.python-list at python.org: > On November 27, 2001 12:11 pm, Administrator wrote: >> ScanMail for Microsoft Exchange has detected virus-infected >> attachment(s). > > ...snip... > > As annoying as getting Windows viruses is, getting multiple copies of > this is worse. Imagine if 200 people on the list were running this > stupid Exchange thing... Yikes. maybe this is a challenge for "mailman" or what ever mailing list manager is running. the mailer software should treat these virus warnings as spam and just not relay them.. chris -- Chris From mcfletch at home.com Mon Nov 5 13:36:26 2001 From: mcfletch at home.com (Mike C. Fletcher) Date: Mon, 5 Nov 2001 13:36:26 -0500 Subject: Is Stackless Python DEAD? In-Reply-To: <9s65ko$3eh$1@bob.news.rcn.net> Message-ID: <000b01c16628$c74fb820$0202a8c0@mikeyspace> I'm not sure I understand this argument. The current version is drop-in-compatible with the standard Python 2.0 DLL. You don't re-compile anything in extension modules, they just work the same as with the standard distribution. The patch is (apparently, haven't looked at it) intrusive in it's re-design of the core loop of the interpreter (it is re-writing some pretty basic mechanisms, after all), but for user-land (as distinct from interpreter-implementer-land) code, it's pretty much transparent in my experience. With that said, there are likely to be systems that don't work well under (for instance) micro-threading. Modules that need locks and expect micro-threads to look like real threads will be disappointed (1000s of them can be running in a single OS-level thread, so regular thread locks don't block the micro-threads). However, that's a problem only for those users actually using the Stackless-specific stuff (in essence if there are no micro-threads running, then the thread-assuming extensions work fine). Enjoy, Mike -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of A.M. Kuchling Sent: Monday, November 05, 2001 08:53 To: python-list at python.org Subject: Re: Is Stackless Python DEAD? On Mon, 05 Nov 2001 02:13:00 GMT, Frederic Giacometti wrote: >This words seems to point out that the actual reason is not technical... >This is definitely not a word from the realm of engineering, but more from >someone sense of his core self being disturbed by an outsider. Not at all. Stackless would have ramifications not just for a few files in the core, but also for all the extension modules that come with Python and for all the authors of third-party extension modules. In terms of number of files affected, "intrusive" isn't a bad word to describe the Stackless patches. --amk -- http://mail.python.org/mailman/listinfo/python-list From max at alcyone.com Fri Nov 2 14:11:28 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 02 Nov 2001 11:11:28 -0800 Subject: ANNOUNCE: PySteroids 2.0 References: Message-ID: <3BE2EFE0.9AB59657@alcyone.com> Lucio Torre wrote: > Im happy! this is public release of pysteroids 2.0. my asteroids game > done with pygame. > > Nothing near paradigm shifting in games, but its my baby. > > check it out at: > > http://vampira.dyndns.org/zope/software/ 404. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From arona2 at em8s.com Mon Nov 12 07:48:31 2001 From: arona2 at em8s.com (Arona Ndiaye) Date: Mon, 12 Nov 2001 13:48:31 +0100 Subject: Using browser as interface to python app References: Message-ID: <013701c16b78$590c2420$eb368418@a2000.nl> Greetings to each and everyone. What about... Flash 5 ---> simple GUI Xml ---> data format (flash 5's got Xml support) Flash Kit Tutorial - Flash 5 and XML http://www.flashkit.com/tutorials/3rd_Party/Flash_5_-Chris_Sm-213/index.shtm l Doing a google search will give you gazillions of links. Google results for "Flash 5 Xml tutorial" link follows: http://www.google.com/search?hl=en&q=flash+5+xml+tutorial I'm building a virtual online supermarket with Python and Ming (PHP, C++, Java, Python ( pick you favorite one hehehe ) to SWF ( Macromedia Flash format or whatever it's called format ) on Debian. I like the mix (python + xml + flash) so I guess I'm a little bit biased =) Most kind regards, PS: too lazy to run a spell checker, too lazy to check ( lack of sleep ), so sincere apologies to anyone it might disturbs. ----- Original Message ----- From: "Sandy Norton" Newsgroups: comp.lang.python To: Sent: Sunday, November 11, 2001 4:28 PM Subject: Re: Using browser as interface to python app > wrote in message news:... > > Have you considered a GUI built with Flash 5.0? It's very nice for > > straightforward business apps, and is pretty much agnostic on the browser > > and screen-resolution front. As long as you're just using Windows-type > > widgets, etc., there's really no loading time. You'll probably think it's > > overkill, but it's really no harder than HTML (and a heck of a lot simpler > > than Tkinter, etc.) You're likely to spend an awful lot of time futzing > > with HTML and Javascript in order to serve up those web pages... > > Cool idea.... but I'm clueless as to how this would be done. How would > you get the python interpreter to handle data inputed into the flash > interface and then pipe the output back to the browser? Do you have > examples for doing this? > > Sandy > -- > http://mail.python.org/mailman/listinfo/python-list > From mgerrans at ix.netcom.com Sat Nov 24 01:08:42 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Fri, 23 Nov 2001 22:08:42 -0800 Subject: Keeping Python loaded Message-ID: <9tndpi$qbe$1@slb0.atl.mindspring.net> Is there some existing facility for keeping Python running in memory at all times, ready to execute scripts, rather than having it load each time a script runs? I think I can figure out a way to do this, but I wanted to check first and see if a clever solution (probably better than what I'm brewing) already exists... -- Matt Gerrans Web Page: http://www.CycleThere.com From mikael at isy.liu.se Thu Nov 8 02:34:00 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 08 Nov 2001 08:34:00 +0100 (MET) Subject: Australian Disco (was: And Now for Something Completely Diff In-Reply-To: <9sd21v$nb$1@bugstomper.ihug.com.au> Message-ID: On 08-Nov-2001 Gary Stephenson wrote: > Ahh, yes! The Bee Gee's ;-) - another world treasure which we Ozzies are > proud to claim as our own - despite the dubiousness of said claim. [...] Talking about the BeeGee's, weren't the HeeBeeGeeBee's from Australia? /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 08-Nov-2001 Time: 08:32:15 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From skip at pobox.com Thu Nov 15 09:42:48 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 15 Nov 2001 15:42:48 +0100 Subject: Optimizing sockets to 1000 requests/sec? In-Reply-To: <7xbsi4cg6m.fsf@ruckus.brouhaha.com> References: <9t0du9$f2t$1@pea.uk.research.att.com> <7xbsi4cg6m.fsf@ruckus.brouhaha.com> Message-ID: <15347.54376.368494.142607@beluga.mojam.com> Paul> If it's on the local machine, why mess with TCP at all, instead of Paul> using AF_UNIX? I'm not sure whether the OP intended to run Paul> locally tough. Performance difference isn't that great, and AF_INET obviously lets you migrate the processes to separate machines if you need to. Coincidentally, a few nights ago was doing a little "what if" testing in this area. With two processes on the same machine (my laptop is a 450MHz P-III) communicating via unix sockets and datagrams I was able to push about 5000 24-byte msgs/sec one-way. When I switched to AF_INET and stream connections, the transfer rate only dropped to about 4700 msgs/sec. Last night I was messing around with my Python compilation options and as a result I've changed my build options. I'm now using --with-threads --without-pymalloc OPT=-O3 -minline-all-stringops -fomit-frame-pointer I just measured my TCP/stream rate at about 5200 msgs/sec and unix/datagram rate at about 6400 msgs/sec. Seems like the inline-all-stringops flag really helped (it had a modest effect on pystones, but it doesn't push a lot of strings around - my little message-passing test does). I'm a bit mystified by the different effects on the two versions though. The only difference in the code is in the type of socket connection. The rest of the code is identical. we're-all-slinging-numbers-but-noone's-showing-their-cards-ly, y'rs, -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From loewis at informatik.hu-berlin.de Tue Nov 27 03:40:28 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 27 Nov 2001 09:40:28 +0100 Subject: function operators References: <3C02F6A3.941CCB5E@earthlink.net> Message-ID: "Terry Reedy" writes: > "Hans Nowak" wrote in message > news:3C02F6A3.941CCB5E at earthlink.net... > > # composable_functions.py > > > > from __future__ import nested_scopes > > > > class ComposableFunction: > > > > def __init__(self, f): > > self.f = f > ... > > Does 2.2 allow one to inherit from type 'function'? Yes, but that won't help: 'def foo...' would still create an instance of type function, not of the specialization. Regards, Martin From info at mjais.de Mon Nov 26 18:00:03 2001 From: info at mjais.de (Markus Jais) Date: Tue, 27 Nov 2001 00:00:03 +0100 Subject: [OT] PostgreSQL Book References: Message-ID: <9tuhjg$522oj$1@ID-75083.news.dfncis.de> python at commandprompt.com wrote: > Hello, > > Just letting all you snaker tamers out there that use PostgreSQL that the > book Practical PostgreSQL from OReilly and Command Prompt is now in > production. It will be shipping December 15th. > > You can view the book online at: http://www.postgresql.info/ > > > Sincerely, > > J looks interesting, but there are no chapters about Python ( or Perl, or Ruby) I saw the book already at www.oreilly.com but there was no "table of contents" a chapter on using postgresql with Python (and Ruby) would have been great markus From andreas at mtg.co.at Sun Nov 25 03:41:51 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Sun, 25 Nov 2001 09:41:51 +0100 Subject: GUI toolkit In-Reply-To: <9td9lv$c8p$1@tyfon.itea.ntnu.no> References: <9tb6ke$1evoq$3@ID-89274.news.dfncis.de> <9td9lv$c8p$1@tyfon.itea.ntnu.no> Message-ID: <200111250841.fAP8fum09213@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Dienstag, 20. November 2001 11:01 schrieb Magnus Lie Hetland: > "Bernhard Reiter" wrote in message > news:9tb6ke$1evoq$3 at ID- > > > It is less know that Qt is only Free Software (as in freedom) for X11, > > not for Windows or MacOSX. > > > > (For me that's a big argument. > > Everybody should be aware of it, I've seen this stated wrong many times.) > > At least the Professional edition costs money... But does it prevent > you from building Free software? The FAQ only says that it allows you > (as opposed to the free/Free version) to make non-Free software... Well, yes and no. Some facts ;) I'm from a small software company. I've been considering Qt/PyQt for my actual project (as a side note, a small "one-person" one). One caveat: IANAL ;) I've been considering to put the solution under the GPL. But I'm not sure if I'll be able to do because of local legal consideration. (There are some rules applied here, that forbid opensourcing some part of the certified application. I know, that's 80's-thinking, and that's probably when the legal documents have been drawn up.) Perhaps I'll stick with some Mozilla license. Or perhaps I'll go ahead with a closed source version (even as I consider opensourcing it a quite nice marketing argument :( ) Now to follow the license faq from Trolltech I'd have to fork over 5k$ (for a tripple license, I'm interested in PDA and Win32 versions too ;) ). For an app I'll try to release under GPL? Additionally, there is no possible way to compile GPL'ed Qt software for Windows. Trolltech gives out the the tip to release the software under a "GPL but allowed to link Qt" license. But this just kills the possibility of using third party GPL software. > > And the Free version is very Free (in a very negative sense, IMO) in that > it contaminates software that has been *developed* with the Free version, That's obviously wrong. This kind of contamination isn't even tried by the GPL. Consider following scenario: 1.) Develop your app with a LICENSE file linked to GPL ;) ad 1.) This is legal, because there is a GPL'ed version of Qt/X11 2.) Before starting to distribute (distribution is what the GPL regulates), change the LICENSE file to "property closed-source". Buy a developer licence. ad 2.) This is legal, because one can have multiple licenses for software, and I am the legal owner of that source code. The GPL doesn't try to be an exclusive license. Example Qt/X11: for-pay licensed, QPL licensed and GPL licensed. > even if you ship it with the Professional software... Scary... I'm glad > Emacs doesn't come with a license like that. Well, it is propably not enforcable. But actually, why should I bother with Qt, if it gives me that much (legal) headaches? I rather stick with wxPython. Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8AK7SHJdudm4KnO0RAuKLAKDV4vcDhFWoQHDmGGSLMxOs/phrQwCfVUIF o511EeoY/Fk9Asmo73MmVRI= =HMFi -----END PGP SIGNATURE----- From jtdubs at eos.ncsu.edu Fri Nov 16 10:52:24 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Fri, 16 Nov 2001 10:52:24 -0500 Subject: List Recursion References: Message-ID: <9t3ckc$kq4$1@uni00nw.unity.ncsu.edu> "Daniel Klein" wrote in message news:pr5avt0i0qkhpqml83ijtk66pioc78st9p at 4ax.com... > Now that I've gone thru the exercise to write a whole 6 lines of python code to 'visit' nested list > elements, I'm wondering if there is a builtin utility for this, or if someone has come up with a > better/faster method. Of course, this will eventually be a class method that 'returns' each object > in the list... > > >>> list1 = ['a', 'b'] > >>> list2 = ['1', ['a', 'b'], '2'] > >>> import types > >>> def visitEachListElementOf(alist): > for el in alist: > if isinstance(el, types.ListType): > visitEachListElementOf(el) > else: > print el # do whatever is necessary with the list element > > >>> visitEachElelementOf(list2) > 1 > a > b > 2 > >>> > > Daniel Klein > > "Give a man a computer program and you give him a headache. But teach him to program computers and > you give him the power to create headaches for others the rest of his life!" -- Unknown > > > You may want to check out generators. They are in __future__ right now, but they will make doing things like that a lot prettier. Check out this code: >>> from __future__ import generators >>> import types >>> def leaves(L): ... for node in L: ... if isinstance(node, types.ListType): ... for leaf in leaves(node): ... yield leaf ... else: ... yield node ... >>> list1 = [1, [2, 3], [4, 5, [6, [7]]], 8, 9] >>> for leaf in leaves(list1): print leaf, ... 1 2 3 4 5 6 7 8 9 >>> for leaf in leaves(list1): print (leaf * 2 + 1) ... 3 5 7 9 11 13 15 17 19 >>> [leaf for leaf in leaves(list1)] [1, 2, 3, 4, 5, 6, 7, 8, 9] Anyway, hope that gives you some ideas. As for your actual algorithm though, I couldn't think of a better way offhand. Have fun, Justin Dubs From peter at engcorp.com Mon Nov 12 19:47:36 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 12 Nov 2001 19:47:36 -0500 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> <9sp073$k6d$1@news.lth.se> Message-ID: <3BF06DA8.19F3E284@engcorp.com> David Andreas Alderud wrote: > > > This, of course, represents a value judgment on your part that loose > > typing (and by the way, Python is *strongly* typed, but dynamically so) > > is a bad thing. In any case I would argue that the habits beginners would > > pick up learning Python would serve them well in the future. When they get > > to a statically typed language, or a weakly typed one (Python is neither), > > they will question *its* value and ease of use. > > Depends on the audience I guess, people who are interested in programming > tend to be interested in how the computer works and how to write efficient > programs. I think we were talking about *children*, who are definitely not interested in writing efficient programs... Don't mix first-year students who might want to learn about the guts of a PC with the audience which was targetted by this discussion. > Things like dictionaries are good for non-programmers to get things done, > it's good for a simple solution but can not be transformed in a way that BST > are simply turned into an R\BST when the requirements change. Sorry, no idea what you are talking about. What's a BST? > > No, good teachers who promote consistent coding style, modular > > design, unit testing, and so forth teach students how to write good code. > > The language has very little to do with it, except insofar as some > > languages get in the way of that, while others do not. Python does not. > > Again, depends on what kind of view one has of teaching and learning, my > view is that the students should teach them selves, and that is best done in > Ada. Uh, yeah, so teachers are just there to serve cookies? And would you seriously prefer Ada over Python for teaching *children*? > > Python has proven very effective for hardware programming. Yes, > > via a DLL or driver or something, but then again very little of > > what constitutes "hardware programming" involves access to the > > hardware, and most involves what you *do* with that access. > > We have completely different views on low-level programming, when doing > hardware programming I do not simply mean accessing hardware. Neither do I; that was my point. But likely we are talking apples and oranges... I've been using Python to talk to instruments like oscilloscopes via a GPIB interface, to talk to various devices through serial or parallel ports, and to talk to a 16-bit processor through a dual-port RAM, and to twiddle the bits in a watchdog timer device on an embedded PC104 module. The results have been uniformly superior to those I seen with other languages, thus my claim that Python would be quite effective at teaching "hardware programming" to first-year university students (allowing them to focus on the task at hand, not the language). So what do *you* mean by "hardware programming"? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From fredrik at pythonware.com Thu Nov 15 18:15:25 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Thu, 15 Nov 2001 23:15:25 GMT Subject: Unable to make regular expression match on multiline files References: <3BF43670.E2B6958A@hotmail.com> Message-ID: David Lees wrote: > I am trying to use a simple regular expression to extract some digits > which are tagged with ascii text. Everything works fine on a single > line, but when I use text that has the '\n' character it fails. Here is > a sample. > > >>> p=re.compile('.*Number States: (\d+)',re.MULTILINE) you want DOTALL, not MULTILINE: >>> import re >>> p = re.compile(".*Number States: (\d+)", re.DOTALL) >>> a = " End: -1STATUS\nNumber States: 6\njunk" >>> p.match(a) >>> _.groups() ('6',) > >>> a=' End: -1STATS:\nNumber States: 6\njunk' > >>> m=p.match(a) > >>> m.groups() or better, use re.search instead of re.match: >>> p = re.compile("Number States: (\d+)") >>> p.search(a) >>> _.groups() ('6',) From kybic at ieee.org Wed Nov 7 07:44:44 2001 From: kybic at ieee.org (Jan Kybic) Date: 07 Nov 2001 13:44:44 +0100 Subject: Q: Fast searching Imap server, IMAP server (in Python) References: Message-ID: > >> I put all my mail (now about 30MB) into a local IMAP server, > >> currently Courier-IMAP. I frequently search for old mails with > >> commands such as 'SEARCH SINCE 1-Oct-2001 FROM jan TO jurgen' but they > >> seem to take eternity, I think the server just goes through all the > >> messages one by one. > > > > That's the price you pay for the maildir format used by Courier. > > > >> Would you know about an IMAP server which stores important information > >> about messages (data, from, to, subject) in some sort of a database so > >> that the searches are quicker? > > > > Cyrus. Are you sure Cyrus does it? I did not find anything about it in the documentation. My first attempt to compile it failed, but I am willing to try again if it solves my problem. > > Or use UW, which uses flat files that are much faster to search. > Courier beats UW when searching large mailboxes, on mid-sized hardware: I do not think it matters, both are going to get uncomfortably slow when the number of messages grows. Currently, the search of about 30MB in about 3000 mail messages takes sometimes several minutes on a Pentium II computer, which is just too slow for me. I am convinced the only solution is to store the important headers, possibly with the messages itself, in some database. This has been implemented with Python and MySQL or Postgress. There is (mail2db, ftp://ftp.tummy.com/pub/tummy/Mail2DB/) and think the project is called something like PySQLmail or SQLmail (to check) but there is no IMAP server interface. I am willing to try to do it myself but I would prefer to use an existing solution, if available. > As far as caching mail headers go, again, a real life investigation would > uncover some interesting surprises: such as the fact that the majority of > IMAP mail clients already cache headers. Name them: Outlook/Outlook > Express, Netscape/Mozilla. All of them cache headers. And that takes care I agree that cacheing headers of the mails read in the same session is a good thing. However, I do not think the mail client should cache all the headers of all the mail you ever received, which is what I would need when searching for some old mail - there are just way too many. As far as I understood the IMAP philosphy, this should be the job of the server. I agree that you can (and should) divide your mail into folders. But with the time, you will either have too many folders or too many messages in each of them anyway. Moreover, I sometimes want to search on subject, sometimes on a person, sometimes on a date - this flexibility cannot be offered by folders only. > The only potential savings (as opposed to technically sophisticated > algorithms that were written only to provide material for a dissertation > paper, but serve no useful real-world purpose otherwise) from caching mail > headers can come about if the server has sufficient intelligence to notice > which mail headers the IMAP client usually asks for, and automatically > cache those headers, in advance, on all newly arrived mail, anticipating > that the mail client will request them in the future. I do not require any artificial intelligence. The set of headers to search on can be determined in advance, for example: from, to, cc, bcc, date, subject. I am willing to accept the slow search in the unlikely event of wanting to search on other criteria. Jan -- ------------------------------------------------------------------------- Jan Kybic Robotvis, INRIA, Sophia-Antipolis, France or ,tel. work +33 492 38 7589, fax 7845 http://www-sop.inria.fr/robotvis/personnel/Jan.Kybic/ From icbt at hotmail.com Fri Nov 9 15:44:10 2001 From: icbt at hotmail.com (b t) Date: Fri, 09 Nov 2001 20:44:10 +0000 Subject: newbie Python OO vs Tcl Message-ID: Hi, I am having the argument of whether I should use Python or Tcl for extend a C++ class library. Considering the followings are Python's advantages: Object oriented Class Module Type extension Class exntension by Boost.Python Is there anything similar in Tcl? So far I can only think of its lax syntax... Thanks in advance. Any comments would be appreciated. Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp From greg at cosc.canterbury.ac.nz Thu Nov 29 19:40:34 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 30 Nov 2001 13:40:34 +1300 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C056DF5.F9EE5D13@ccvcorp.com> <3C0575F4.9A23C894@cosc.canterbury.ac.nz> <3C0595BB.F44DB0E7@ccvcorp.com> Message-ID: <3C06D582.74863E17@cosc.canterbury.ac.nz> Jeff Shannon wrote: > > iterators and generators, anyhow. If I have a generator that yields successive > values read from a serial port device, then the phrase "if i in serialinput()" > is meaningless Maybe you should have to say "for i from iterator" instead, when you have something that is already an iterator. -- 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 jeff at ccvcorp.com Mon Nov 12 17:04:14 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 12 Nov 2001 14:04:14 -0800 Subject: Easy(?) newbie question References: <3BEEF8A9.DBF96E74@earthlink.net> <3BEF136E.48601B63@earthlink.net> Message-ID: <3BF0475E.7E64897D@ccvcorp.com> Ron Stephens wrote: > In other words, exec is a statement, but eval and execfile are functions. Since > eval is a function, it doesn't make sense to give it a for loop. Try using exec > instead, I think it will work like you expect. > > > On Sun, Nov 11, 2001 at 10:16:38PM +0000, Erik Johnson wrote: > > > > > > but when I try to put this code into a string and evaluate it, I get a > > > syntax error: > > > > > > >>> s = "for x in range(10): print x," > > > >>> s > > > 'for x in range(10): print x,' > > > >>> eval(s) As another minor bit of advice... exec and eval() should be considered to be dangerous magic--there can be many unexpected results from using these functions, and they should *not* be recommended for newbies, and rarely for experienced coders. They can be essential in a few special circumstances, but for most of the things you may be tempted to use them for, they will be far more of a headeache than a benefit. In other words, try to forget about exec and eval() for a few more months at least. ;) Jeff Shannon Technician/Programmer Credit International From calves at coelce.com.br Tue Nov 27 15:16:11 2001 From: calves at coelce.com.br (Alves, Carlos Alberto - Coelce) Date: Tue, 27 Nov 2001 17:16:11 -0300 Subject: ActivePython Installation problem Message-ID: <29A97D00F387D411AC7900902770E14802B66687@lcoeexc01.coelce.net> > -----Original Message----- > From: Hans Nowak [mailto:wurmy at earthlink.net] > Sent: Tuesday, November 27, 2001 2:35 PM > To: Alves, Carlos Alberto - Coelce > Subject: Re: ActivePython Installation problem > > > > "Alves, Carlos Alberto - Coelce" wrote: > > > > > -----Original Message----- > > > From: Gillou [mailto:nospam at bigfoot.com] > > > Sent: Tuesday, November 27, 2001 11:23 AM > > > To: python-list at python.org > > > Subject: Re: ActivePython Installation problem > > > > > > > > > Did you doanloaded the latest MS installer from Microsoft ? > > > > No, I did'nt. I just downlowded the ActivePython-2_1_1.msi installer > > from ActiveState and try to run it. Do I need that MS installer from > > Microsoft?! > > If the .msi file has an icon that looks like a computer with a CD-ROM > and a box, then you have the installer and something else is wrong > (e.g. error during downloading). If it has a regular icon like other That's exactly what I got. But I can't remember of any trouble during dowload process ( see the error message attached below). Any way, I'll try to download again and see what happen. Thanks at all. > files with extensions unknown to Windows, then you need to download > the installer. > > I think it can be downloaded here: > > http://www.microsoft.com/downloads/release.asp?ReleaseID=17343 > > or do a search on Google or the Micro$oft site to find the most > recent version. > > --Hans > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: ActivePython.jpg Type: image/jpeg Size: 15169 bytes Desc: not available URL: From starx at pacbell.net Mon Nov 26 06:32:31 2001 From: starx at pacbell.net (Philip Swartzleonard) Date: 26 Nov 2001 11:32:31 GMT Subject: A newbie that needs some HELP References: <9ts712$1be$1@slb2.atl.mindspring.net> Message-ID: Don Arnold || Sun 25 Nov 2001 05:49:22p: > >On 25-Nov-2001, "The News" wrote: > > >> Now on to the problem. >> I'm working on lists. Trying to figure them out. So I decide to >> write this little algorithim for user inserted lists. My proto goes >> as follows: >> >> monty = [] >> number = input("How many Monty's are there?") >> for x in range(1,number): >> mln = input("Name a Monty?") >> monty.append(aln) >> print monty >> >> It gets through it but prints out some wierd stuff along with each >> listed monty. Can someone tell me what I'm doing wrong? Also, when I >> try to get it to repeat x at the end of "Name a Monty #", x it gives >> me an error. How could I get around that? >> > >Use 'raw_input()' instead of 'input()'. No one else seems to have noticed, but i think you want 'int( raw_input() )' as the total expression, as you want to use the input to create a range of numbers while raw_input() returns a string... int() parses this for you. :) -- Philip Sw "Starweaver" [rasx] :: www.rubydragon.com - a few thousand lines [*BROKEN] of PHP, HTML, and CSS; but still useless* :) From ws-news at gmx.at Thu Nov 15 08:11:58 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 15 Nov 2001 14:11:58 +0100 Subject: Fork a SocketServer on NT References: Message-ID: <3bf3bfe2$1@brateggebdc5.br-automation.co.at> Hi, I think the threading module provides basic and portable threading. See the class Thread in there. if you have a function to handle the connection something like (untested) def yourHandlerFunction(handlersock, addr): pass import threading threading.Thread(target=yourHandlerFunction, args=(handlersock, addr)).start() should get you started. hth Werner "GT" wrote in message news:e253b770.0111150446.5dc9ef39 at posting.google.com... > Hi, > > I'm trying to fork a SocketServer on NT. But I don't know how to do > this. The os.fork doesn't work on NT. I have this example from the > Echo_server.py in O'Reilly book "Python for Win32". > > serversock = socket(AF_INET, SOCK_STREAM) > serversock.bind((HOST, PORT)) > serversock.listen(5) > print 'socket listening for connections...' > while 1: > handlersock, addr = serversock.accept() > > #now do something with the handler socket > print 'SocketServer connected by', addr > data = handlersock.recv(1024) > > handlersock.send(data) > > handlersock.close() > print 'SocketServer closed ...' > Can anyone show me how to solve this ..... > > thanks for any help, > > GT From tim at zope.com Thu Nov 29 16:24:40 2001 From: tim at zope.com (Tim Peters) Date: Thu, 29 Nov 2001 16:24:40 -0500 Subject: Non-Indented python In-Reply-To: <3C0678DF.2DFE924A@home.net> Message-ID: [Tim] > Nope. The "nanny" in "tabnanny" is there for a reason: > grownups have no problems here. [Chris Barker] > I don't think that's true. You could knock me over with a tab . > I often start working on a file I got from elsewhere with tabs in it, So convert it -- that's what "grownups" do. > get some wierd error, eventually think to check for tabs. Don't you run Python with -tt? > Then I run a script on it, clean it up, and all is well. > This would be a WHOLE LOT easier if I got a "syntax error: mixed tabs > and spaces" the first time I ran it. And what would we lose??? I'd lose a lot of time replying to complaints about the new errors -- as far as Python is concerned, tab characters are 8-space gimmicks, and there's nothing wrong with Python source mixing tabs and spaces under that assumption. While it's anti-social to *distribute* code in that state, Python doesn't care to outlaw private vice. > There are a lot of issue swith backward compatabilty, but this is one > cse where you could run a simple script over any previously valid code > and get valid code back. No problem there. You can already do that. >>> Personally, I would prefer that future versions of Python would allow >>> ONLY tabs or ONLY spaces, but clearly there would be a major >>> disagreement about which to use. >> It would be spaces -- "4-space indents, no hard tab characters >> anywhere" is the coding standard for the Python library. > I imagine Huaiyu, if no one else, would take issue with this. It would be spaces regardless. If you've been reading this thread at all (or any of its 500 isomorphic predecessors), you should have picked up that somebody will take heated issue with any approach whatsoever -- including the status quo. So what? The core developers reached consensus that 4-space etc works best across platforms. We're not going to force anyone else to do that (unless they want to get a module into the core distribution), but the issue is long dead to Guido & company. not-accusing-guido-of-being-a-grownup-ly y'rs - tim From James_Althoff at i2.com Wed Nov 28 16:31:24 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 13:31:24 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Lulu wrote: > >>> if i in 100: print 'even Natural' # I have no idea what this MEANS! Small point, but it would just mean the same as: >>> if i in xrange(100): as in, e.g., >>> i = 2 >>> if i in xrange(100): ... print 'spam' ... spam >>> You just wouldn't have to read or write the xrange thing. :-) Jim From stewart at sig.com Wed Nov 14 10:23:17 2001 From: stewart at sig.com (Stewart, Robert) Date: Wed, 14 Nov 2001 10:23:17 -0500 Subject: Is this considered black magic? Message-ID: > From: Andrew Dalke [mailto:dalke at dalkescientific.com] > > Laura Creighton: > >What is the collective noun for 'attributes that aren't > >methods (you can't call them)'? > > Python calls them "members". > > http://www.python.org/doc/current/lib/specialattrs.html#l2h-113 I did a little checking and found this: http://www.python.org/doc/current/tut/node11.html#SECTION0011330000000000000 000 In that section of the tutorial, "attributes" are distinguished as "methods" and "data attributes." In 7.5.6, of the Python/C API Reference Manual, the type of Descriptor Objects is PyProperty_Type, so that would call into question my recollection of "properties" being an appropriate synonym for "data attributes." So, "data attributes" would seem to be the sanctioned term, though I consider "properties" to be better. Rob Susquehanna International Group, LLP http://www.sig.com IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses. From fredrik at pythonware.com Tue Nov 6 19:02:53 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 00:02:53 GMT Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> Message-ID: David Andreas Alderud wrote: > > And what bad practices would those be? > > Having a non-declarative language as a first choice is bad, teaches them to > write sloppy code. have you teached python to the kind of people you label as "them"? or are you just yet another 3l33t language snob? > Ada is fantastic, with it I write inline Assembly well, duh. nevermind. From owen at astrono.junkwashington.emu Thu Nov 1 11:40:44 2001 From: owen at astrono.junkwashington.emu (Russell E. Owen) Date: Thu, 01 Nov 2001 08:40:44 -0800 Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> Message-ID: <9rrtud$ff8$1@nntp6.u.washington.edu> In article <9rq2v2$fko$1 at newshost.accu.uu.nl>, m.faassen at vet.uu.nl (Martijn Faassen) wrote: >The double underscore is required for name mangling, but I don't really >like the name mangling; it gets in the way. I just want to give the >programmer a hint that some attribute is private, and I use a single >underscore for this, and many Python programmers with me. > >Why does name mangling get in my way? Generally I like to be able to >reach the private variables in subclasses (I suppose this makes them >protected in C++ terms, though my C++ is rusty). I also like being >able to fake things easily in case I need it, for debugging and >testing purposes. In the end I only want to indicate something is private >without all the hassle of name mangling. Personally, I prefer the effect of double underscore for this case, as well. I can easily get to the variables by applying the name mangling myself, yet cannot accidentally stomp on the variables in a subclass. To each his/her own. -- Russell From tjreedy at home.com Thu Nov 22 10:22:43 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 22 Nov 2001 15:22:43 GMT Subject: Non-Indented python References: Message-ID: <7L8L7.244006$5A3.91689632@news1.rdc2.pa.home.com> "David Bolen" wrote in message news:ud72btm0n.fsf at ctwd0143.fitlinxx.com... > But the oldest definitions were just that a TAB character moved the > cursor to the next active tab position. This is how typewriters worked, as well at least some word processing programs. After clearing the default tabs (every whatever - 1/2 inch for WordPerfect), this worked well for tables - tab once to the start of every column, and then adjust tab stops so everything looked nice. To me, a default of 8 spaces is way too much for programming indents - lines rapidly become too short. It is also too much for 1/2inch paragragh indents (5 chars with 10 pitch (chars/inch) fonts, 6 with 12 pitch). Terry J. Reedy From fonnesbeck_chris at yahoo.com Wed Nov 21 18:00:07 2001 From: fonnesbeck_chris at yahoo.com (Chris Fonnesbeck) Date: Wed, 21 Nov 2001 23:00:07 -0000 Subject: string literals in windows dont show up! Message-ID: <9thbln+3do2@eGroups.com> I am trying to append literals (i.e. \n, \r) to the end of lines in a text output file. However, when the file is brought up in the windows notepad, there is no line feed or carriage return. Any idea about how to make windows recognize these literals. Works fine in linux (no big surprise there!) Thanks Chris Fonnesbeck From slhath at home.com Sat Nov 17 22:30:58 2001 From: slhath at home.com (Scott Hathaway) Date: Sun, 18 Nov 2001 03:30:58 GMT Subject: Win32 COM question References: Message-ID: No, python works with all COM servers. Post your exact error and maybe we can help. Thanks, Scott "Michael Kelly" wrote in message news:sn4dvtcfns56ftb2g7imjhgkodjvrt8gnh at 4ax.com... > > Hi all. I've just started trying out python and I have > a question about how it is to use an InProcess > COM server with it. As example I have a COM > dll that does .ini file stuff that has a dual interface > and a type library. In VB I have to make sure > it's selected in References then I can just do > something like: > > Dim IniObj As New ComIniFile > Set IniObj = CreateObject("IniLib.ComIniFile") > IniObj.FileName = App.Path & "\ComIniFileTest.ini" > IniObj.ReadSections MyStrings > > > Following the python quick start tips for COM > I installed the Win32all with PythonWin > and tried this: > > import win32com.client > o = win32com.client.Dispatch("IniLib.ComIniFile") > o.FileName = "C:\Windows\Temp\TryIni.ini" > o.WriteString("StringSection", "Key", "SectionIsPun") > > And I get error messages to the effect that module > types cannot be executed so it leads me to wonder > if this only works for OleAutomation .exe programs > such as MS Word or can you really use COM > .dlls and ActiveX controls?? > > TIA > > > Mike > > -- > > "I don't want to belong to any club that would have me as a member." > -- Groucho Marx From shalehperry at home.com Tue Nov 13 15:49:54 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Tue, 13 Nov 2001 12:49:54 -0800 (PST) Subject: Stopping exception unwinding at exit In-Reply-To: <20011113204200.50877.qmail@web21106.mail.yahoo.com> Message-ID: On a related note, is there a way to tell python to NEVER drop a trace? Even if I have a global exception handler I find I can hit control-C in the time between starting a script and the script executing. This of course leads to a trace and looks quite ugly. From kragen at canonical.org Tue Nov 20 16:24:49 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 20 Nov 2001 16:24:49 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: <9t93vi$6gi$1@slb7.atl.mindspring.net> Message-ID: <83g079m8ym.fsf@panacea.canonical.org> "Andrew Dalke" writes: > Then in the "sort &key (key #'identity)" > line the '&key' says that field is 1) optional and 2) a keyword > argument, and that if not given the identity function is used. > ... > Python only uses one function for this, which means the field > extraction and data comparison must be composed into one function, Well, not really; the advantage of having a separate key function is that it only gets called once for each input item, rather than lg N times, which can be very significant if extracting the key is expensive and the comparison is comparatively fast. You *can* do almost this in Python, using the following code: tmplist = [(x.lower(), x) for x in mylist] tmplist.sort() mylist = [x[1] for x in tmplist] On a 112-item list consisting of eight copies of a short list of words, on my machine, the above method takes about 2.3 ms to sort, while the method relying on an explicit comparison function takes about 9.4 ms to sort, four times slower: list = list[:] list.sort(lambda x, y: cmp(x.lower(), y.lower())) return list (As an aside, what's the recommended way to get timings for things like this? I hacked up a Speed module, but I expect that someone else had done a better one already.) This trick of computing the keys first, once, is what the Perlites call the Schwartzian Transform, but because Perl's references are second-class citizens, you have to provide an explicit comparison function anyway. In both Perl and Python, using the built-in C comparison function is a big win; adding lambda x, y: cmp(x, y) to the 2.3-ms function above made it take 6.7 ms. In Perl, you have to turn your sortable values into strings (the Guttman-Rosler Transform) to sort them with the builtin function; in Python, you can just use a tuple. > The sort function is (was) also defined in terms of C-style > three-way sorting. It's been changed so that only '<' comparison > is needed, but I don't know how that change affects the comparison > function used. In which Python? My 2.1.1 documentation still claims the comparator should return -1, 0, or 1. (Also, is that really a win? You'll have to call the function twice to tell the difference between > and == --- won't that add 50% to your sort times in the common case where the Python comparator is the bottleneck?) From qrczak at knm.org.pl Tue Nov 20 07:42:16 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Tue, 20 Nov 2001 12:42:16 +0000 (UTC) Subject: object identity and equivalence References: <3bf9532b_1@mk-nntp-1.news.uk.worldonline.com> Message-ID: Mon, 19 Nov 2001 18:44:16 -0000, Sandy Norton pisze: >>>> x = 10.0 >>>> y = 10.0 >>>> x is y > 0 The result is different when the first two statements are written in one line: >>> x = 10.0; y = 10.0 >>> x is y 1 So identity of builtin immutable types is indeed very ill-defined. It depends on line breaks. It depende whether statements are entered interactively or they come from a script. And of course it may be different in other versions of the interpreter. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From cliechti at gmx.net Wed Nov 28 14:53:54 2001 From: cliechti at gmx.net (Chris Liechti) Date: 28 Nov 2001 20:53:54 +0100 Subject: Scanning a Subnet with python? References: <9u2d62$5k5$07$1@news.t-online.com> Message-ID: [posted and mailed] "Axel" wrote in news:9u2d62$5k5$07$1 at news.t-online.com: > Hi, > I want to scan a subnet with python, but I don't know how? > What I want to do: > I want to write a chat program in pure python(with a Tkinter gui). It > should include both client and server, so that the first user opens a > server and all other connect to this server. Further, the program > should be OS independent. > > My problem: > I want to give the user possiblity to scan the subnet wheter there is a > server > or not, but how can I perform such a test? you chat programm opens a server on a UDP port. when a new client joins the net it sends a broadcast to this port. all servers will respond to this broadcast and send back a "hello" to the client. the client will get messages from all servers in the same subnet in a few seconds or less. i have some exaple code but on an other machine. drop me a line if your interested. you don't need a dedicated server. each chat programm can be server and client at the same time: server side: - display incomming messages - send "hello" on search broadcasts client side: - send messages to one machine or - send messages as broadcast to all machines you should think up a simple protocol for you packets. differentiate between control messages and text messages. gr?sschen chris > If I get the subnet mask, I will test every IP wheter the computer is > up and wheter there is a runnig server on it, but how can I get the > subnet mask using python? all not needed when you use UDP broadcasts... > Or, does anyone know a better way to scan a subnet with python? > > > Thanx, > Axel > > Python comes with batteries included, > but does it have an otto-motor too? > -- Chris From syt at gemini.logilab.fr Mon Nov 19 08:44:50 2001 From: syt at gemini.logilab.fr (Sylvain Thenault) Date: Mon, 19 Nov 2001 13:44:50 +0000 (UTC) Subject: pygtk Message-ID: this is a little off topic, but does anybody knows how to give the focus to a particular window using pygtk ? (I wish the designed window to take focus and to come to the foreground if another window hided it). TIA -- Sylvain Thenault LOGILAB http://www.logilab.org From wurmy at earthlink.net Tue Nov 27 12:41:38 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 27 Nov 2001 17:41:38 GMT Subject: Integer Overflow References: Message-ID: <3C03D04B.D89F97A2@earthlink.net> Ursus Horibilis wrote: > > Is there a way to force the Python run time system to ignore > integer overflows? I was trying to write a 32-bit Linear > Congruential Pseudo Random Number Generator Say what? > and got clobbered > the first time an integer product or sum went over the 32-bit > limit. Use longs: >>> 2**100 Traceback (most recent call last): File "", line 1, in ? 2**100 OverflowError: integer exponentiation >>> 2L**100 1267650600228229401496703205376L >>> A long integer in Python is simply created by appending an "L" to the number, e.g. 2 (normal integer) vs. 2L (long). HTH, --Hans From calves at coelce.com.br Tue Nov 27 12:07:26 2001 From: calves at coelce.com.br (Alves, Carlos Alberto - Coelce) Date: Tue, 27 Nov 2001 14:07:26 -0300 Subject: ActivePython Installation problem Message-ID: <29A97D00F387D411AC7900902770E14802B39798@lcoeexc01.coelce.net> > -----Original Message----- > From: Gillou [mailto:nospam at bigfoot.com] > Sent: Tuesday, November 27, 2001 11:23 AM > To: python-list at python.org > Subject: Re: ActivePython Installation problem > > > Did you doanloaded the latest MS installer from Microsoft ? No, I did'nt. I just downlowded the ActivePython-2_1_1.msi installer from ActiveState and try to run it. Do I need that MS installer from Microsoft?! > If you're running Win 95, 98 or NT4, you need it ! > The link to this Microsoft installer in dowload page of ActiveState. > It worked for me (Win 98). > > Please post your next questions in plain text. > > HTH > > --Gillou > > "Alves, Carlos Alberto - Coelce" a > ?crit dans le > message news: mailman.1006867365.26491.python-list at python.org... > > Hi all, > > I downloaded and try to install the ActivePython-2_1_1.msi > program, but it > > failed. It seems not be a valid windows package installer. > > Anybody could help resolve it?! > > I'm using Wndows(hit) 95 > > > > Carlos Alberto > > COELCE/DPRON-Departamento de Projetos e Obras Norte > > Fone: 677- 2228 > > e-mail: calves at coelce.com.br > > \|||/ > > (o o) > > --ooo0-(_)-0ooo-- > > > > > > > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From logiplexsoftware at earthlink.net Wed Nov 7 18:37:42 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 7 Nov 2001 15:37:42 -0800 Subject: Teaching python (programming) to children In-Reply-To: <9savp2$5t1$1@news.lth.se> References: <9savp2$5t1$1@news.lth.se> Message-ID: <01110715374201.01343@logiplex1.logiplex.net> On Wednesday 07 November 2001 01:42, David Andreas Alderud wrote: > I see big demand for Ada programmers here in Sweden, not as big as Java and > C++, but indeed much more so than Python :) > Airbus in France use Ada almost exclusivly, if my friend who works there is > correctly informed. Now you've done it. The list has been dead for over an hour. I can only assume everyone is moving to Sweden to learn Ada. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From Gareth.McCaughan at pobox.com Thu Nov 29 19:52:13 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Fri, 30 Nov 2001 00:52:13 +0000 Subject: U=TP References: Message-ID: Andreas Kostyrka wrote: [nothing] And, what's more, P=NP. Or, of course, not. -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From christophertavares at earthlink.net Fri Nov 23 03:47:45 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Fri, 23 Nov 2001 08:47:45 GMT Subject: Non-Indented python References: <3BFD3804.3020502@movilogic.com> Message-ID: "Dave Cinege" wrote in message news:mailman.1006474590.24778.python-list at python.org... > On Thursday 22 November 2001 12:38, you wrote: > > > time to find out. i had unzipped the source with winzip (which uses > > \r\n) and tried to compile it with cygwin. of course, it couldnt do it, > > Commandment #2 > Thou shalt terminate thy line with but one byte. Let he who hath > understanding recognize the number of the byte, 0xA0. Death to thee who > terminates thine with any other byte! > > You use a defective OS built with defective editors. REPENT! > > Dave > It sounds like somebody is overdue for a visit from the cult deprogrammers. Geeze, lighten up. Oh, and it's 0x0a, not 0xa0. Totally different characters. -Chris From core.lists.python at core-sdi.com Fri Nov 23 12:51:31 2001 From: core.lists.python at core-sdi.com (Ricardo Quesada) Date: Fri, 23 Nov 2001 14:51:31 -0300 Subject: RogueLike Games in Python References: <3BFC9160.24AFA11A@alcyone.com> <20011122125424.A13679@cruciatuz.de> <3BFD6670.2080704@movilogic.com> Message-ID: <3BFE8CA2.F5890815@corest.com> Lucio Torre wrote: > i am trying to do one. i did a first attemp in python games with > pysteroids (vampira.dyndns.org), and now im going for an elite > multiplayer kind of game. not exaclty rogue, but multiplayer rpg... Hey, I'm starting a game also in pygame. Lucio, let me know when you have something. riq. --- for a personal reply use: Ricardo Quesada From rbonato at irisa.fr Thu Nov 22 11:17:58 2001 From: rbonato at irisa.fr (Roberto Bonato) Date: Thu, 22 Nov 2001 17:17:58 +0100 Subject: Newbie needs "interface" Message-ID: <3BFD2536.7B4AFFC6@irisa.fr> Hi all I'm writing a function that implements an algorithm and that prints intermediate results all along the (usually very long) computation. Sometimes I want the results to be written on the stdout, sometimes on a Tkinter Text widget, sometimes to a file. I feel the need of something like a Java Interface with a method "write" to wrap all such devices into. Since I'm a newbie at programming and at Python in particular I still cannot find a simple and elegant way to do that. Thanks for any help. -- Roberto Bonato IRISA-INRIA, Campus de Beaulieu - Rennes cedex, France From bbollenbach at home.com Sat Nov 10 19:56:04 2001 From: bbollenbach at home.com (Brad Bollenbach) Date: Sun, 11 Nov 2001 00:56:04 GMT Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> Message-ID: [snip] > In common usage, a data structure is something you make to put your > data in. A class, a list, a dictionary, anything you can put data in. A database is precisely the same thing. You put data in it. > A database is somebody else's data structure(s), possibly already full > of data. You can buy them from people like Oracle, or get free ones > like Postgres, but they all share the property that they are _somebody > else's box of stuff_. If you want to use the data in a database, you No, it's not always somebody else's "box of stuff" by any means. A database can be something as simple as a .dat and its corresponding .idx file. [snip] Simply put (and referring to the most common cases), a database is a relatively large (or, often very large), persistent (as in "written to disk") set of data. It can be something as simple as a set of flat files (that is, your normal .txt's, or the .dat's and .idx's mentioned previously), or as is common is business programming, a "relational database" where data is stored in tables; rows of fixed length data (not /quite/ precise, but accurate enough for purposes of this discussion) with corresponding fields in them. Think of an Excel spread sheet. As it turns out, a .xls file can easily be considered a database. A data structure on the other hand is all the bits and pieces used in your program as variables (or constants) to store data in memory while your program runs. As it turns out, data structures can also be persisted (that is, written to disk), via modules like pickle, but that's hardly a common characteristic among all "data structures". They're the nuts and bolts things like lists, dictionaries, classes, sets, queues, linked lists, et. al. Hope that helps, Brad From mwh at python.net Tue Nov 6 08:39:31 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 6 Nov 2001 13:39:31 GMT Subject: Finding name for a signal number References: <9s8oqk$a38$1@isp-m-srv06.izb.net> Message-ID: Oliver Fromme writes: [schnipp] > The next thing I came up with is extracting the signal > names from the namespace dictionary of the signal module > itself, like this: > > import signal > > def get_signame (n): > "Return the signal name for a signal number." > for sig in dir(signal): > if sig.startswith("SIG"): > value = eval("signal." + sig) > if type(value) is IntType and value == n: > return sig > return "SIG#" + str(n) > > This works. However, the above code seems awkward and > inefficient, in particular the eval() part. Is there a > better way? Did I miss something? Yes: getattr. Also your logic seems a touch backwards - why search through the module every time? I'd do something like this: def getsigdict(): import signal r = {} for name in dir(signal): if name.startswith("SIG"): r[name] = getattr(signal, name) return r sigdict = getsigdict() Cheers, M. -- In many ways, it's a dull language, borrowing solid old concepts from many other languages & styles: boring syntax, unsurprising semantics, few automatic coercions, etc etc. But that's one of the things I like about it. -- Tim Peters, 16 Sep 93 From phd at phd.pp.ru Sun Nov 25 15:32:48 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sun, 25 Nov 2001 23:32:48 +0300 Subject: Free Python Server In-Reply-To: <37aM7.256063$5A3.96426335@news1.rdc2.pa.home.com>; from ssmith619@hotmail.com on Sun, Nov 25, 2001 at 05:45:35PM +0000 References: <15353.40372.784126.72589@beluga.mojam.com> <37aM7.256063$5A3.96426335@news1.rdc2.pa.home.com> Message-ID: <20011125233248.A6942@phd.pp.ru> On Sun, Nov 25, 2001 at 05:45:35PM +0000, Stephen Smith wrote: > I am currently using port5.com, and I don't like the service. What are some > of those Russian ones? 3 sites of Agava.ru: hut.ru, holm.ru, h1.ru. They differ in some minor conditions in rules abd rights. All use ssh2. Servers: FreeBSD. Also they do: unlimited www space, but only for HTML pages, ftp, mail forwrding, statistics, .htaccess, MySQL (for sites that have at least 50 unique hits a day). Perl5 and PHP, there are number of predefined scripts. No Python, but I installed my own on phd.hut.ru. I tried to compile Python myself, but failed - initial disk quota is 30 Megs. So I went to our office server (almost identical FreeBSD), compiled it and uploaded :) If there will be enough requests to install Python system-wide - I beleive they'll install it. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From loewis at informatik.hu-berlin.de Tue Nov 27 03:50:04 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 27 Nov 2001 09:50:04 +0100 Subject: function operators References: Message-ID: "James A. H. Skillen" writes: > but wouldn't: > > f = cos + sin > > be *much* nicer? If a functional notation of operators is acceptable, then this might help as well. import operator class Combiner: def __init__(self,f1,f2): self.f1=f1 self.f2=f2 def __call__(self,*args): return self.combine(self.f1(*args),self.f2(*args)) class Plus(Combiner): combine=operator.add import math sincos = Plus(math.sin,math.cos) print sincos(2) HTH, Martin From modman at altavista.com Wed Nov 14 22:44:48 2001 From: modman at altavista.com (modman) Date: Thu, 15 Nov 2001 03:44:48 GMT Subject: Quick question about private/public methods Message-ID: <3BF338E8.1050308@altavista.com> Why does python not provide for this? it can not possibly hurt any functionality can it? I sort of like the public/private Idea cause it hides the actual methods from the person using the class and the person only needs to know a few little things about what they can pass to the method it also makes the implementation of a class easier to understand when public methods like getEggType() and spamType() are used. just wondering cause I was messing with Python just before I started into C++ at school and I thought that the public/private Idea was pretty cool. Thanks, Jeremy From cliechti at gmx.net Wed Nov 21 20:43:00 2001 From: cliechti at gmx.net (Chris Liechti) Date: 22 Nov 2001 02:43:00 +0100 Subject: rexec r_eval and s_eval (bug?) Message-ID: from what i read in the docs, "r_eval" and "s_eval" should behave like the same, except for the sys.stdxxx variables. the r_* version has no access to sys.stdxxx but the s_* versions have access to a secure sys.stdxxx object exaple 1: >>> r = rexec.RExec() >>> r.s_exec('import sys') >>> r.s_exec('print "stdout" in dir(sys)') 1 >>> r = rexec.RExec() >>> r.r_exec('import sys') >>> r.r_exec('print "stdout" in dir(sys)') 0 >>> stdout (and also stderr, stdin) is only available when the sys module was imported with s_exec. this is what the manual implies. however, strange things happen if i try to modify sys.stdout and even mix r_exec and s_exec statements or even try "sys.stdout = None" and then "print sys.stdout".... and it gets even worse. look at this example: example 2: >>> r = rexec.RExec() >>> r.r_eval('dir()') ['__builtins__', '__doc__', '__name__'] >>> r = rexec.RExec() >>> r.s_eval('dir()') >>> r_eval works as expected and returns a dictionary. however s_eval seems to have a problem as it returns None. (other test strings show the same behaviour e.g. "25" or "'hello'" etc.) both function should actually return the same objects, as long as the expression has nothing to do with sys.stdxxx, but they don't. is this a bug or a feature that i don't understand? chris (Examples from Python 2.1/Win32) -- Chris From gleki at gol.ge Mon Nov 26 13:26:42 2001 From: gleki at gol.ge (Giorgi Lekishvili) Date: Mon, 26 Nov 2001 10:26:42 -0800 Subject: wavelet Message-ID: <3C028962.D467D83D@gol.ge> Dear all! I am sorry to waste your time. Perhaps, here is someone who knows where can I get the python module(s) for wavelet transforms? Thank you. Best wishes, Giorgi From sholden at holdenweb.com Tue Nov 13 17:05:30 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 17:05:30 -0500 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111122102.2058f188@posting.google.com> <7396d2b2.0111131345.22483e62@posting.google.com> Message-ID: "Lemniscate" wrote in message news:7396d2b2.0111131345.22483e62 at posting.google.com... > Actually, here is the code I am working on now. Like I said, I am > tring to learn COM and am, basically, adding methods to the EasyExcel > example given in the Excel chapter of Programming Python on Win32. > Here is what the code I am using now. It uses the same functions and > methods as the previous code, but uses the proper COM methods to > create a Excel file and enter data. The problem I have now, as I > said, is that I cannot insert hyperlinks. I believe I posted my > interactive attempts based on the Excel help files (they should be up > soon so you can see what I mean). Anyways, here is my new code (quick > note: I was working around the problem by creating html files with > the links I wanted and inserting them into an Excel sheet. It > worked/works but is, like you said, not a python thing, plus it makes > things a whole lot messier. I am also in the middle of adding a > Tkinter GUI interface, as well as converting over to > win32com.client.Dispatch methods, so the code is really messy). > Thanks: > I mailed a reply to your hotmail address by accident. I'm guessing that's a write-only mailbox? Here's what I wrote... Lemniscate wrote ... > Okay, my other post should be up soon, but I thought I would throw > this out. First off, I should say I am not a VB person, so I have to > work at converting VB code into win32client compatible commands. > However, the Help File in the MS Excel Help has me stumpted. Here is > the page I am using as a basis and afterwards is just a cut and paste > of my attempts (at an interactive prompt) to insert a hyper link. I have similar problems myself. Prejudicially, I tend to assume this is because VBA was designed by immediately-post-college CS students with little or no feel for programming rightness and no effective supervision. Feel any better? ;-) [ tale of woe snipped ] Does the following help? >>> from win32com.client import Dispatch >>> xlApp = Dispatch("Excel.Application") >>> xlApp.visible = 1 >>> xlApp.Workbooks.Add() >>> sh = xlApp.Workbooks(1).Sheets(1) >>> sh.Range("A1").Select() 1 >>> sh.Hyperlinks.Add(sh.Range("A1"), Address="http://www.holdenweb.com", TextToDisplay="Steve's Web Site") >>> Hope so. you-got-the-web-site-link-above-ly y'rs - steve -- http://www.holdenweb.com/ From peter at engcorp.com Thu Nov 8 22:56:29 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 08 Nov 2001 22:56:29 -0500 Subject: verifying type of socket object? References: <+YrhO+rceV33qbXjWckIp8NUkWP4@4ax.com> Message-ID: <3BEB53ED.45A9671E@engcorp.com> Peter Wang wrote: > > in my code, i'd like to verify that i get passed a socket object. > however, i'm having some trouble figuring out what exactly represents > the "socket type". the main problem is that socket.socket() doesn't > return instances of socket.SocketType: Have you considered the more Pythonic approach of just using the object passed in as though it were a socket, and adding adequate exception handling to deal with it if it is not, or even just allow the exception to propagate up to the caller for it to deal with it? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From ws-news at gmx.at Thu Nov 15 11:59:53 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 15 Nov 2001 17:59:53 +0100 Subject: convert a string to a method call ? References: <25SI7.32$Qh1.10549@newsfeed.slurp.net> Message-ID: <3bf3f54c$1@brateggebdc5.br-automation.co.at> Hi, how about >>> class X: ... def bunch(self): ... print "bunch" ... def of(self): ... print "of" ... def methods(self): ... print "methods" ... >>> xObj = X() >>> meth = "of" >>> tocall = getattr(xObj, meth) >>> tocall() of >>> meth = "bunch" >>> tocall = getattr(xObj, meth) >>> tocall() bunch hth Werner "Bruce Edge" wrote in message news:25SI7.32$Qh1.10549 at newsfeed.slurp.net... > I have an object, say xObj, which has a bunch of methods. > I have the method I want to call in a string, say str. > > How do I call method str on xObj? > > Use eval? If so, the syntax eludes me. > > TIA, Bruce. From tim.one at home.com Mon Nov 12 18:54:17 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 12 Nov 2001 18:54:17 -0500 Subject: Bug in list comprehensions in Pyhton 2.1.1? In-Reply-To: <9slfbl$p9c$1@peabody.colorado.edu> Message-ID: [Fernando P?rez] > Thanks for the info! I'll update to 2.2 when it comes out. In the > meantime there's an easy workaround (as my original post indicated). > > Well, at least it's a nano-ego trip to have found a bug in Python after > having only recently started to use the language :-) That's why it's very important to immerse yourself in Python at the start, at least 24 hours each day: regardless of software product, it's the new users who *always* uncover the bugs that have been there forever. They try things the authors can't even imagine. As a special incentive, at the end of 2100, coinciding with the release of Python 4, we're going to give a Fabulous Prize to whichever Python newcomer found the most bugs in the preceding century. So far, you're the front-runner . From logiplexsoftware at earthlink.net Tue Nov 6 17:26:39 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 6 Nov 2001 14:26:39 -0800 Subject: Beginner in Python In-Reply-To: <3BE85DF9.CDF844D2@gmx.net> References: <3BE85DF9.CDF844D2@gmx.net> Message-ID: <01110614263901.19608@logiplex1.logiplex.net> On Tuesday 06 November 2001 14:02, Christian Schnell wrote: > File "", line 1 > python helloworld.py > ^ > > SyntayError: invalid syntax > You are apparently trying to type this line at the Python prompt. Do not do this. At the MSDOS _command_ prompt ( e.g. c:\> ), type python helloworld.py By the way, when pasting error messages, try to avoid editing them as this obscures the message (since you are new to Python, you might not realize the importance of something you are deleting - in this case you deleted the ">>>" python prompt which would be an obvious indicator to someone reading it that you were doing this in the Python interactive interpreter). -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From sholden at holdenweb.com Mon Nov 5 08:05:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Nov 2001 08:05:09 -0500 Subject: Tiny Personal Firewall vs ZoneAlarm References: Message-ID: "Roger Due" wrote in message news:cdg8uto0sj2g8jm0f0iu15odf145uvsk0u at 4ax.com... > I recently implemented Tiny Personal Firewall 2.0.15 (12 Oct 01) on > our Win2K server that also servers as an application development > workstation, email, & internet access. TPF is easy to setup and > operate and seems to work well. You can get a copy from > www.tinysoftware.com. It understood that I was on a local network and > configured itself properly and set itself up to run as a service. By > default it configures itself for medium security, which means that you > are prompted when one of your applications initiates outside > communication and you can either accept or deny this access and have > the option to tell it to create the appropriate rule for the next > time. > > Before I installed TPF, I had downloaded their 37-page pdf manual and > read it. For someone who is not an expert on firewalls, I found it > easy to understand and much prefer this over help built into the > program. > > By using IE & Eudora & Agent to access the internet, I quickly > configured TPF to allow their traffic. I also used www.grc.com to > refine access further. Then used all the tests found on > http://scan.sygatetech.com to further validate the effectiveness of > TPF. So far it has passed every test. > > Now why did I switch to Tiny Personal Firewall when I had already > purchased ZoneAlarm Pro 2.6 back in June and ZoneAlarm seems to get > all the publicity? The primary reason is that the people at ZoneAlarm > don't have a clue about customer service!!! I tried 5 different times > via email, each time rewording the request, to get an answer as to how > I could get the latest version of ZoneAlarm Pro 2.6 to use with my > license code to install at this time instead of having to install the > older 2.6 version first and then upgrade. Never once did they answer > the question satisfactorily. Of course they don't provide phone > support, but when I managed to get hold of a sales person he was > annoyed and hung up on me without helping. > > So I started doing some additional checking. Some of you have > mentioned WinRoute Pro and I have seen reasonably good reviews of Tiny > Personal Firewall. I placed a call to Tiny and got hold of one of > their sales people. What a switch!!! He was very helpful. I didn't > mention anything about ZoneAlarm at first, but had a lot of questions > about what would be best for our configuration. We decided that TPF > was the way to go. I then called another person who writes reporting > utilities for different firewalls, and he confirmed what I had already > figured out. He also uses TPF and is satisfied. > > Today I called back the salesman at Tiny and thanked him and then > logged onto their web site and paid my $39, since this is being used > in a business environment. For personal use, it is free. > For what it's worth I have been using WinRoute Light, another Tiny product, to multiplex my five-host network out through a single cable IP with Network Address Translation for over three years now. The only time I ever had a problem (two years after buying the product, during a brief period of DSL connection) Tiny got back to me within 24 hours with a sensible and helpful response. A good case for considering cost of ownership rather than cost of purchase: Tiny shoud be encouraged. [obDisclosure: I am a registered Tiny reseller, who has never resold anything]. regards Steve -- http://www.holdenweb.com/ From mikael at isy.liu.se Thu Nov 1 09:57:24 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 01 Nov 2001 15:57:24 +0100 (MET) Subject: Monty Python (was: Freeware Python editor) In-Reply-To: <20011101154852.B675@phd.pp.ru> Message-ID: On 01-Nov-2001 Oleg Broytmann wrote: > On Thu, Nov 01, 2001 at 07:39:31AM -0500, Steve Holden wrote: > > [Makes note to remember that Oleg isn't a Monty Python viewer.] > > Few years ago I tried to view the scetches - there was Russian > translation of them on TV - but found them stupid and boring. Well, I was > in bad mood those days, may be now I'd find it more interesting :) You should really watch them in their original language. And I admit, some of them are not that great (those where legs and arms are cut off and blod everywhere). But then there are the others (for instance the dead parrot sketch), where the humour is in the language. And they are fantastic. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 01-Nov-2001 Time: 15:51:11 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From keyton at weissinger.org Sun Nov 18 23:38:46 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Sun, 18 Nov 2001 23:38:46 -0500 Subject: Anyone Using BlackAdder? In-Reply-To: Message-ID: I asked about Python IDEs yesterday (or so) and many of you responded (thank you). One particularly interesting suggestion was BlackAdder. I'm playing with the Demo copy and am about to drop my real money on it, but wanted to ask the group. Anyone using this? Considerations? I'm not a huge user of debuggers and it seems that BlackAdder == Qt Designer + PyUIC + Debugger. Don't get me wrong. It's very nice and well put together. I just don't want to slap down the coin if I can help it. Looking forward to any insight.... Thank you. Keyton P.S. Pat your selves on the collective backs. This is one of the best news groups I've even jumped into. Lots of good discussion. Lots of feedback and help. Thumbs up. From root at rainerdeyke.com Mon Nov 12 18:24:20 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Mon, 12 Nov 2001 23:24:20 GMT Subject: OT: Mobile Internet Toolkit EULA (was: IsPython really O-O?) References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> Message-ID: "Guido Stepken" wrote in message news:9sph0u$gj7$02$1 at news.t-online.com... > Thanx lots for checking this out ! Hmmm, that means, that it is forbidden > to produce (distribute) code, consisting of (L)GPL Software and Microsoft > OpenSource. One is not allowed to mix code. BSD License + Microsoft Code, > that's OK ! > Any ideas, why ? It makes perfect sense to me. BSD licensed code plays along nicely with closed source. The GPL, on the other hand, is designed to give open source developers a competitive advantage over closed source developers, with the ultimate goal of forcing closed source developers out of business. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From sandysj at juno.com Tue Nov 6 13:01:20 2001 From: sandysj at juno.com (Jeff Sandys) Date: Tue, 6 Nov 2001 18:01:20 GMT Subject: Teaching python (programming) to children References: Message-ID: <3BE82570.D76DCAE9@juno.com> Brian Elmegaard wrote: > > Hi, > > ... Are there good reasons for advocating python > being a language one could teach children programming ... Yes, if you are interested in this you should join the python edu-sig: http://www.python.org/sigs/edu-sig/ I strongly believe in Computer Programming for Everyone (CP4E). Every high school graduate should be able to express themselves with any form of popular expression. They should be able to write or speak an idea, draw a likeness, sing or play music, and create a computer algorithm. They don't need to be a star or make it a vocation, but their expressions should be understood by others and give a feeling of accomplishment to oneself. Computers will become more and more prevalent in society. Microsoft won't be able to provide everyone with the canned expressions that the user wants to express. There needs to be an easy to use programming language that allows a high degree of abstraction. For adults and students Python is that language. Personally though I use Logo for grammar and middle school students. Once I develop an adequate curriculum and syllabus I will use Python in the middle school, because Logo lacks the ability to do object oriented programming. Elica is an advanced version of Logo that has some of Python's features. Perhaps in the future the best features of Logo, simple syntax and error messages, will be combined with Python's best features, object oriented, every platform and large libraries, to make my ideal programming and teaching language. (Python + Elica => Pelican ?) Elica reference: http://www.elica.net Thanks, Jeff Sandys From martin.franklin at westgeo.com Tue Nov 6 16:54:32 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Tue, 6 Nov 2001 21:54:32 +0000 Subject: newbie: selecting text by script in Tkinter fails References: Message-ID: <9s9m4u$2e4s$1@mail1.wg.waii.com> Hi!, Johnny deBris wrote: > Hello!! > > I have a question about selecting text in a Tkinter Text-widget using > the tag_remove and tag_add-methods: there is a small explanation on > how it should be done in 'an Introduction to Tkinter', but I cannot > get the work done the way the author proposes > (http://www.pythonware.com/library/tkinter/introduction/x8369-methods.htm). > Can anybody tell me how I can select a piece of text from script? I'm > working on a texteditor in Python, and this is part of a search-option > I would like to add. For people who think they're suffering from > deja-vu or something: I have posted a question quite similar to this > one a few days ago, but no-one seemed to be able to or want to answer. > (maybe a classical case of RTFM? If so, please tell me where to find > that FM!! :) > > Thanx again, > > Guido Wesdorp > Here are a couple of functions that I user to 'show' my ;found' text def find_text(self): self.parent.textarea.tag_delete("found") pat=self.pattern.get() if not pat: return self.found=self.parent.textarea.search(pat, "insert") if self.found: self.show() def show(self): line, start = map(int, self.found.split('.')) end=start+len(self.pattern.get()) self.parent.textarea.tag_add("found", "%d.%d" %(line, start), "%d.%d" %(line, end)) self.parent.textarea.tag_config("found", background='navy', foreground='white') self.parent.textarea.mark_set("insert", "%d.%d" %(line, end+1)) self.parent.textarea.see("%d.%d" %(line, start)) self.parent.textarea.update() HTH Martin From rgb at panix.com Thu Nov 15 10:59:31 2001 From: rgb at panix.com (Randolph Brown) Date: 15 Nov 2001 15:59:31 GMT Subject: Psyco 0.3.2 References: Message-ID: <9t0op3$ste$1@news.panix.com> In article , Armin Rigo wrote: >Shall I write a technical in-depth overview ? While I'm primarily trying to understand the Self implementation right now, I've been following the Psyco stuff with some interest. A technical summary would be great, and I'm pretty sure others would be interested too. Thanks, -Randy From biz6x6 at net Wed Nov 21 17:08:19 2001 From: biz6x6 at net (Please Read IT Carefully!) Date: 22 Nov 2001 00:08:19 +0200 Subject: ATTENTION! Well-Paid Job in the Internet! Message-ID: -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- (This safeguard is not inserted when using the registered version) -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- (This safeguard is not inserted when using the registered version) -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------------------------------------------------------------------- -------------- next part -------------- An HTML attachment was scrubbed... URL: From david at dataovation.com Fri Nov 16 20:29:41 2001 From: david at dataovation.com (David A McInnis) Date: Fri, 16 Nov 2001 17:29:41 -0800 Subject: Regular Expression Help Needed Message-ID: Ok, I am not very good at regular expressions, so any help is greatly appreciated. Here is the situation. I have a database table that contains a text field. This text field may or may not contain email addresses. I know how to read the content of field to a string. Now what I need is a regular expression that I could use to identify any email addresses in the string. Since the email can be in mixed case, I need a solution that is case insensitive. So, there may be one or more email addresses in the string. When I find one, I need to added it to a list variable and look for other addresses in the string. Thanks, David McInnis From fperez528 at yahoo.com Wed Nov 21 06:49:58 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 22 Nov 2001 11:17:58 +2328 Subject: Colored console on Windows References: <1712.011122@storm.ru> Message-ID: <9tjflj$j08$1@peabody.colorado.edu> Chris Gonnerman wrote: > I wrote a module, WConio, which does exactly what you are wanting. > If you plan to be working at the Windows console very much, you > may also want my Alternative Readline module. You can get both > at: > > http://newcenturycomputers.net/projects Hi Chris, quick question: does your readline module handle multi-line edits? That is, if I have a multi-line statement, does it bring it back as a single editable entity (which would be great) or as the 'real' readline does, as a series of single-line statements (clumsy). Thanks, f. From volucris at hotmail.com Tue Nov 20 00:44:19 2001 From: volucris at hotmail.com (Greg Krohn) Date: Mon, 19 Nov 2001 23:44:19 -0600 Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> Message-ID: <3bf9ec62$0$79563$6e49188b@news.goldengate.net> "Brian Geddes" wrote in message news:9tcobh$qql at news.or.intel.com... > All - > > I've been trying to store/pass information in environment variables in > Windows 2000, but things aren't working the way I expect them to. The docs > state that by making changes to the os.system dictionary, the changes should > be carried over in environment space automatically by os.putenv(). However, > the following which looks like it should work, does not: > > import os > import sys > os.system["HELLO"] = "Testing" > sys.exit() > > # Run Python again > import os > print os.system["HELLO"] Mmm...there's something goofy with that. Are you sure that first one works? Did you assign something to os.system itself? Try type(os.system). It should be a function, not a dictionary. [Python 2.1.1] >>> import os >>> type(os.system) >>> print os.system.__doc__ system(command) -> exit_status Execute the command (a string) in a subshell. From qrczak at knm.org.pl Tue Nov 20 09:05:49 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Tue, 20 Nov 2001 15:05:49 +0100 Subject: Try block problem In-Reply-To: <15354.23921.928826.70642@beluga.mojam.com>; from skip@pobox.com on Tue, Nov 20, 2001 at 07:41:05AM -0600 References: <9tcnls$42k$1@news1.ucsd.edu> <15354.23921.928826.70642@beluga.mojam.com> Message-ID: <20011120150549.A20625@qrnik.zagroda> On Tue, Nov 20, 2001 at 07:41:05AM -0600, Skip Montanaro wrote: > def f(d): > try: > return d.keys() > finally: > d.clear() > > How would that be handled with try/except? Imagine that we have a more generic case where instead of d.keys() and d.clear() there are statements which may throw. Then the above is equivalent to: def f(d): try: result = d.keys() except: d.clear() raise else: d.clear() return result -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From marfadeu at gmx.de Fri Nov 9 16:42:34 2001 From: marfadeu at gmx.de (Markus Faust) Date: Fri, 9 Nov 2001 22:42:34 +0100 Subject: mayavi installation problem on Win NT References: <9sdh9v$hgq$01$1@news.t-online.com> Message-ID: <9shil6$j00$00$2@news.t-online.com> Prabhu, I played a bit around with mayavi. It is one of the greatest programs I saw this year! Astonishing how you can rotate and manipulate 3D views. Very good user interface! I also saw that I'll need more graphics performance ... Markus From mwh at python.net Tue Nov 27 13:18:48 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 27 Nov 2001 18:18:48 GMT Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: "Ursus Horibilis" writes: > Okay. My next project was to do the same thing with 64-bit > numbers. This makes a difference how, exactly? > So how do I disable trapping for integer overflow? You can't, in the way you want anyway. You could always write a class that uses longs and chops off all but the first n bits of the result. This wouldn't do performance any favours, I uspect. Not that in 2.1: >>> 2*sys.maxint Traceback (most recent call last): File "", line 1, in ? OverflowError: integer multiplication but in 2.2: >>> 2*sys.maxint 4294967294L Cheers, M. -- Of course, it obviously is beta hardware so such things are to be expected, but that doesn't mean that you can't point your fingers and generate a nelson style HAHA at a multi billion dollar corporation's expense. -- CmdrTaco on slashdot.org From jeff at ccvcorp.com Wed Nov 28 17:59:08 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 28 Nov 2001 14:59:08 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <3C056C3C.C1F64FEE@ccvcorp.com> James_Althoff at i2.com wrote: > And this might be handy in common situations where you could write, for > example: > > if index not in len(mylist): > print 'index out of range' > > instead of > > if index not in xrange(len(mylist)): > print 'index out of range' Better still, and already valid: if index >= len(mylist): print 'index out of range' The only place where this proposed feature applies, or would even be particularly useful, is in the context of for-loop iteration. Jeff Shannon Technician/Programmer Credit International From emile at fenx.com Wed Nov 14 10:53:22 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 14 Nov 2001 07:53:22 -0800 Subject: Shell commands from within a script References: Message-ID: <9su4bk$1530md$1@ID-11957.news.dfncis.de> "Neil Fryer" wrote in message news:mailman.1005745399.3684.python-list at python.org... > Hi All > > I'm really new to python so if you could please let me know how to execute a > command like say, ftp, from within a script it really would be appreciated. > As I'm only about half way through my first Python tutorial. > >>> import ftplib >>> print ftplib.__doc__ An FTP client class and some helper functions. Based on RFC 959: File Transfer Protocol (FTP), by J. Postel and J. Reynolds Example: >>> from ftplib import FTP >>> ftp = FTP('ftp.python.org') # connect to host, default port >>> ftp.login() # default, i.e.: user anonymous, passwd user at hostname '230 Guest login ok, access restrictions apply.' >>> ftp.retrlines('LIST') # list directory contents total 9 drwxr-xr-x 8 root wheel 1024 Jan 3 1994 . drwxr-xr-x 8 root wheel 1024 Jan 3 1994 .. drwxr-xr-x 2 root wheel 1024 Jan 3 1994 bin drwxr-xr-x 2 root wheel 1024 Jan 3 1994 etc d-wxrwxr-x 2 ftp wheel 1024 Sep 5 13:43 incoming drwxr-xr-x 2 root wheel 1024 Nov 17 1993 lib drwxr-xr-x 6 1094 wheel 1024 Sep 13 19:07 pub drwxr-xr-x 3 root wheel 1024 Jan 3 1994 usr -rw-r--r-- 1 root root 312 Aug 1 1994 welcome.msg '226 Transfer complete.' >>> ftp.quit() '221 Goodbye.' >>> -- Emile van Sebille emile at fenx.com --------- From peter at engcorp.com Mon Nov 19 19:51:10 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 19 Nov 2001 19:51:10 -0500 Subject: (no subject) References: Message-ID: <3BF9A8FE.497A6013@engcorp.com> core.lists.python at core-sdi.com wrote: > > confirm 244847 Sorry, no, it's not a prime. -uncertain-that-was-the-question-ly yr's, Peter Hansen From wurmy at earthlink.net Tue Nov 27 12:35:31 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 27 Nov 2001 17:35:31 GMT Subject: ActivePython Installation problem References: Message-ID: <3C03CED1.CDCC19EE@earthlink.net> > "Alves, Carlos Alberto - Coelce" wrote: > > > -----Original Message----- > > From: Gillou [mailto:nospam at bigfoot.com] > > Sent: Tuesday, November 27, 2001 11:23 AM > > To: python-list at python.org > > Subject: Re: ActivePython Installation problem > > > > > > Did you doanloaded the latest MS installer from Microsoft ? > > No, I did'nt. I just downlowded the ActivePython-2_1_1.msi installer > from ActiveState and try to run it. Do I need that MS installer from > Microsoft?! If the .msi file has an icon that looks like a computer with a CD-ROM and a box, then you have the installer and something else is wrong (e.g. error during downloading). If it has a regular icon like other files with extensions unknown to Windows, then you need to download the installer. I think it can be downloaded here: http://www.microsoft.com/downloads/release.asp?ReleaseID=17343 or do a search on Google or the Micro$oft site to find the most recent version. --Hans From phr-n2001d at nightsong.com Thu Nov 1 19:12:09 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 01 Nov 2001 16:12:09 -0800 Subject: python development practices? References: <9rsmmi$cvu$1@newshost.accu.uu.nl> Message-ID: <7xu1weuj3a.fsf@ruckus.brouhaha.com> m.faassen at vet.uu.nl (Martijn Faassen) writes: > I don't understand the problem; a single leading underscore for attributes > won't give you any such problems. Double underscores are different, but > even then I don't see why 3 classes should live in the same module? If they're related in a natural way, there's no reason to not put them in the same module. I wish Python had something like C++'s "friend" classes, e.g. a way that two classes in the same module can access each other's private instance variables. From vp at cfdrc.com Fri Nov 9 15:54:32 2001 From: vp at cfdrc.com (Vijayan Sarathy) Date: Fri, 09 Nov 2001 14:54:32 -0600 Subject: Using Pipes Between Python & C++ Processes Message-ID: <3BEC4288.EA816D34@cfdrc.com> Hello, I am trying to make a Python script spawn a C++ child process and then have the two of them communicate with each other using pipes.I am trying to have the child process (C++) write something and have the parent (Python) read it. I hand off the file descriptor for the write-end of the pipe to the child process through its argv list. The C++ child process is not able to write to the pipe. When I check on errno, it turns out to be EBADF (invalid file descriptor). This problem occurs ONLY on Windows. It works well on Linux . I am using Python 2.1 Could someone please enlighten me about what I am doing wrong. Thanks. Sincerely Vijayan Sarathy I have included the Python function that does the job of spawning the child using fork and execv. and returns the PID of the child process # Fork a Child Process. # Open a Pipe to the Child and Read what the Child Writes to it def spawnModule (commandString): (r,w)= os.pipe() pid= os.fork() if (pid < 0): print "Error in Forking" sys.exit (-1); elif (pid == 0): # Child Process os.close (r) writeFD= "%d"%w args=[] args.append (commandString) args.append (writeFD) os.execv (args[0],args) else: # Parent Process os.close (w) nbytes= 1024 string= os.read (r,nbytes) print "Received This String -> ", string os.close (r) return pid From montanaro at tttech.com Sat Nov 10 05:43:54 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Sat, 10 Nov 2001 11:43:54 +0100 Subject: iters on ints? (reducing the need for range/xrange) In-Reply-To: <7xzo5v34pt.fsf@ruckus.brouhaha.com> References: <7xzo5v34pt.fsf@ruckus.brouhaha.com> Message-ID: Tim> This isn't even half as disgusting as most people will say it is Tim> . I rather like it! Write a PEP. Paul> The trouble is as someone else noted, "for i in 10" replaces "for Paul> i in range(10)". But how do you handle range(1,10)? "for i in Paul> 1,10" does precisely the wrong thing. Hence the reason for a PEP. ;-) It helps people collect all the pros and cons in one place, lessening the chances that something significant is missed. Writing a PEP doesn't mean it will be accepted, just that the idea merits consideration. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From charles at aspen.sweetshade.local Sun Nov 11 10:31:56 2001 From: charles at aspen.sweetshade.local (Charles Allen) Date: 11 Nov 2001 15:31:56 GMT Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: > "Geert-Jan Giezeman" wrote in message > news:9sdol4$2te$1 at samos.cs.uu.nl... >> >> I am trying to create a shelve from a table of 1100 by 1100 floating >> point numbers, which I want to store as 1100 lists of length 1100, >> indexed by a key. Unfortunately, I get an error when I try to create >>... >> 2)Are there ways to circumvent those problems? Use a different >> database (I like shelves, though), ... Let's take a step back: Is the "1100 lists of length 1100" the way you *want* to access the data internally? Have you looked at Numeric arrays? Those are much cleaner for accessing the data in array format (slicing in any dimension, faster operations, etc). If Numeric arrays suit your purposes, you can try using their toString() method to convert them to a monolithic entity before doing the shelve. You would lose the dimension info unless you stuck the data string inside, e.g., a class that also contained the dimension info. I use this to access externally supplied floating point array data. You should also look at the NetCDF file format interface in the Scientific Python module. This has the advantage of making the data accessible from many different languages and platforms. I've never used it for keyed access on large data sets like you mention, so I don't know what the lookup speed is like. Test it and let us know! -- Charles Allen From phd at phd.pp.ru Fri Nov 9 11:26:00 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 9 Nov 2001 19:26:00 +0300 Subject: Gratuitous post In-Reply-To: ; from sdm7g@Virginia.EDU on Fri, Nov 09, 2001 at 11:10:44AM -0500 References: <9sgrj2$aqq$1@newshost.accu.uu.nl> Message-ID: <20011109192600.G24528@phd.pp.ru> On Fri, Nov 09, 2001 at 11:10:44AM -0500, Steven D. Majewski wrote: > Free Python! Which one? There are so many poor snakes are languishing now in zoo... Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From stepken at little-idiot.de Sun Nov 11 16:02:51 2001 From: stepken at little-idiot.de (Guido Stepken) Date: Sun, 11 Nov 2001 22:02:51 +0100 Subject: IsPython really O-O? - Think different ! References: Message-ID: <9smovs$cbu$02$1@news.t-online.com> My experience, coming from many languages (BASIC, ASSEMBLER, PASCAL, MODULA-2/3, LISP, PROLOG, C, C++, JAVA, now Python is: 1. Python is easy to learn 2. Python is easy to keep in mind 3. Pyton is full OO ! 4. Python Code is reusable 5. Python has simple to unterstand containers, polymorphism 6. Python is powerfull, but easy to understand 7. Python is fun for kids (my experience !) 8. Python is a full OO language with mighty modules and libraries 9. Python can't keep up with smalltalk or haskell in OO features (i am missing makro's, but ist's the best compromise I have ever seen. 10. Python is much more readable than Smalltalk, Eiffel, Haskell, Lisp, C++, JAVA so it's easier for team - programming 11. JAVA is spread all ove the world, but there is JPYTHON !!!!!!!!!! 12. Try Python, an you will see your own ! 13. Python has future - see Microsoft Visual Studio implementation of Python ..... - Even Microsoft likes Python !!!!!!!!!!!!!!!!!!!!!!!! regards, Guido Stepken From mwh at python.net Thu Nov 22 05:52:43 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 22 Nov 2001 10:52:43 GMT Subject: Memory leak in my extention References: <8c39194f.0111212016.33844aa6@posting.google.com> Message-ID: jf.richard at videotron.ca (Jean-Francois Richard) writes: > I am trying to export a c function that build a tuple and return it to > python, everything is working perfectly except that it leak like hell > :( > > It is the first time I write a python extention and I can not seem to > find the method to do it right! > > Here is a code snippet: > > int minx, miny, minz, maxx, maxy, maxz; > Font->BBox(text.c_str(), minx, miny, minz, maxx, maxy, maxz); > > PyObject* result = Py_BuildValue("((iii) (iii))", > minx, miny, minz, > maxx, maxy, maxz); > > return result; > > What have I forgotten?? To include the code that causes the leak? That looks fine to me. Are you sure you're leaking Python objects? Cheers, M. -- > Emacs is a fashion statement. No, Gnus is a fashion statement. Emacs is clothing. Everyone else is running around naked. -- Karl Kleinpaste & Jonadab the Unsightly One, gnu.emacs.gnus From root at rainerdeyke.com Wed Nov 7 09:09:10 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 07 Nov 2001 14:09:10 GMT Subject: A smarter(?) package importer. References: Message-ID: "Prabhu Ramachandran" wrote in message news:mailman.1005121809.21819.python-list at python.org... > Does the performance boost occur mainly because each subsequent > failure would mean that sys.modules would have to scan through all of > its keys and then fail? Hmmm, but if you kept caching failure, you'd > increase the number of keys. If the package nesting is substantial > for every global module this would insert several new item into > sys.modules. Dictionary access is fast. The time needed for dictionary access does not deepend on the size of the dictionary except in degenerate cases. Opening a file is a slow operation, even if it results in failure. > > pkg/ > sub/ > subsub/ > foo.py > > foo.py: > import string > > This would insert all of the following into sys.modules: > subsub.string, sub.string, pkg.string, string Technically, it would add "pkg.sub.subsub.string", "pkg.sub.string", "pkg.string", and "string". > so if each and every package did this we'd have way too many 'string's > that point to None. This means that len(sys.modules) increases quite > significantly. Or can it be proved that caching is better than not > caching at all? It can, and probably has been, but I'm not going to. Test it yourself if you're really interested; I'm going to trust the Python implementation team on this one. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From s713221 at student.gu.edu.au Fri Nov 9 04:21:30 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Fri, 09 Nov 2001 19:21:30 +1000 Subject: Special celebration event for Orlijn? References: Message-ID: <3BEBA01A.2C5B468D@student.gu.edu.au> Hamish Lawson wrote: > > Maybe we should hold a special event in celebration of Guido's new > baby boy, Orlijn Michiel - perhaps a New Orlijn's Jazz Festival? > > OK, I'm sorry :-) > > Hamish Lawson Perhaps we should vote to rename the language in honour? At the very least somebody should name a new module. "I use a cool new programming language called Orlijn!!!"-ly y'rs -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From phr-n2001d at nightsong.com Wed Nov 14 04:29:59 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 14 Nov 2001 01:29:59 -0800 Subject: Infinite lists and generators References: Message-ID: <7xg07hsns8.fsf@ruckus.brouhaha.com> Luigi Ballabio writes: > I've been reading a few back issues of the Perl Journal, and I > came across an article on implementing infinite lists in Perl. Just > for fun I went ahead and reimplemented it in Python---I know someone > probably did already, but as I said, it was for fun. Also, I've > written a test suite which showcases a few tricks such as building the > list of all prime numbers, of the Hamming numbers, and the power > series of exp, sin and cos. I'm including the file below. > > My question is: how does one go about pulling such stunts with > generators instead? You might like to read the book Structure and Interpretation of Computer Programs, by Abelson and Sussman. The entire text is online at: http://mitpress.mit.edu/sicp/sicp.html The programs in the book are in Scheme, but it develops a whole series of programs in the style you're describing. From anisotropy9 at hotmail.com Thu Nov 15 07:40:04 2001 From: anisotropy9 at hotmail.com (Will Deakin) Date: Thu, 15 Nov 2001 12:40:04 +0000 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> Message-ID: <3BF3B7A4.8050602@hotmail.com> Tim wrote: > However a lot of programs spend a lot of time doing stuff where > the typechecking overhead seems to be in the noise. Anything > that's building and manipulating large complex data structures is > probably spending a lot of its time chasing pointers and worrying > much more about cache misses and so on than exact details of > types. I would agree and make the general point that the lack of enforced static-typing, in any project that is a worth doing, is a *boon*. The enforced micro-optimisation and related bugs, security holes and so on of *forcing* type declaration makes wonder about the need for static typing[1]. The Graham quote along the lines of how lisp is two languages: a language for writing programs quickly and quick language for writing programs[2], springs to mind. > ...We might not have found the big problems of course, but really, > it looks like type declarations don't help here much at all... ...if type declarations is not helping at this point then either you live with it, or you need a new algorithm ;) :)w [1] although subject to change at moments whim. [2] since this is c.l.l. I'm sure that somebody will correct me ;) From ws-news at gmx.at Mon Nov 19 05:26:54 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 19 Nov 2001 11:26:54 +0100 Subject: zope base href (newtozope question) References: <9t81ts$nl9$1@uranium.btinternet.com> Message-ID: <3bf8df35@brateggebdc5.br-automation.co.at> Hi, you should still be able to FTP in your testserver and delete the SiteRoot object or SiteAccess rule or whatever causes the URL to be manipulated. An other solution would be to add the domain name to your local hosts file (with the IP of your test server) and than your host will work with your testserver, although using the URL of the live server. (Be sure that your machine does not accidentely publish this domain mapping!). I further recommend you post Zope related questions to Zope's mailing list. See the zope.org site for it. hth Werner "Clancey" wrote in message news:9t81ts$nl9$1 at uranium.btinternet.com... > Have copied a site (via export/import) from live server to test server, in > order to experiment, but have the base ref problem that even the /manage > links from the left hand menu will try to load the manage screens from the > live site.. it would seem that I can do nothing to the site locally, but do > not want to make any changes to the live site at all.. how can i get around > this obstacle? > > any help would be great.. thank you... > > > > From prabhu at aero.iitm.ernet.in Sun Nov 11 02:42:03 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 11 Nov 2001 13:12:03 +0530 Subject: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <037a01c16a6b$993421a0$c300a8c0@ericlaptop> References: <3BED5AD8.24350.78407262@localhost> <037a01c16a6b$993421a0$c300a8c0@ericlaptop> Message-ID: <15342.11211.377711.175571@monster.linux.in> Hi, >>>>> "ej" == "eric" writes: >> Currently, os.py in a package masks the real one from anywhere >> inside the package. This would extend that to anywhere inside >> any nested subpackage. Whether that's a "neat" or a "dirty" >> trick is pretty subjective. The wider the namespace you can >> trample on, the more it tends to be "dirty". ej> Yeah, I guess I come down on the "neat" side in this one. If ej> I have a module or package called 'common' at the top level of ej> a deep hierarchy, I'd like all sub-packages to inherit it. ej> That seems intuitive to me and inline with the concept of a ej> 'package'. Perhaps the hijacking of the Numeric example ej> strikes a nerve, but inheriting the 'common' module shouldn't ej> be so contentious. Also, if someone has the gall to hijack ej> os.py at the top of your package directory structure, it seems ej> very likely you want this new behavior everywhere within your ej> package. I agree on this. Also each package is kind of isolated. Any module like os.py inside a sub package won't affect _every_ other sub package and will only affect packages that are nested inside this particular package. So there is some kind of safety net and its not like sticking everything inside sys.path. :) Also, right now, what prevents someone from sticking an os.py somewhere in sys.path and completely ruining standard behaviour. So, its not asif this new approach to importing package makes things dirty, you can very well do 'bad' things right now. [snip] ej> As for overhead, I thought I'd get a couple more data points ej> from distutils and xml since they are standard packages. The ej> distutils import is pretty much a 0% hit. However, the xml ej> import is *much* slower -- a factor of 3.5. Thats a huge hit ej> and worth complaining about. I don't know if this can be ej> optimized or not. If not, it may be a show stopper, even if ej> the philosophical argument was uncontested. >>>> import my_import import time t1 = time.time();import >>>> xml.sax.saxutils; t2 = time.time();print t2-t1 1.35199999809 >>>> import time t1 = time.time();import xml.sax.saxutils; t2 = >>>> time.time();print t2-t1 0.381000041962 IMHO, this is an unfair/wrong comparison. (0) I suspect that you did not first clean things up by doing a plain import xml.sax.saxutils a few times and then start testing. (1) import itself is implemented in C. my_import is pretty much completely in Python. Here is a fairer comparison (done after a few imports). >>> import time >>> s = time.time (); import xml.sax.saxutils; print time.time()-s 0.0434629917145 >>> import my_import >>> import time >>> s = time.time (); import xml.sax.saxutils; print time.time()-s 0.0503059625626 Which is still not bad at all and nothing close to 350% slowdown. But to see if the presently measured slowdown is not the parent lookup we really need to compare things against the modified (to cache failures) knee.py: >>> import knee >>> import time >>> s = time.time (); import xml.sax.saxutils; print time.time()-s 0.0477709770203 >>> import my_import >>> import time >>> s = time.time (); import xml.sax.saxutils; print time.time()-s 0.0501489639282 Which is really not very bad since its just a 5% slowdown. Here are more tests for scipy: >>> import time >>> s = time.time (); import scipy; print time.time()-s 1.36110007763 >>> import knee, time >>> s = time.time (); import scipy; print time.time()-s 1.48176395893 >>> import my_import, time >>> s = time.time (); import scipy; print time.time()-s 1.5150359869 Which means that doing the parent lookup stuff in this case is really not so bad and the biggest slowdown is mostly thanks to knee being implemented in Python. And there is no question of a 350% slowdown!! :) prabhu From prabhu at aero.iitm.ernet.in Wed Nov 7 00:28:49 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 7 Nov 2001 10:58:49 +0530 Subject: A smarter(?) package importer. Message-ID: <15336.50833.280146.446620@monster.linux.in> hi, I am not sure if its 'correct' to attach a 4KB Python script on this list. Yes, its pretty small but I guess the number of people on the list is large enough that its not the right thing to do? Anyway, I managed to get knee.py to do what I wanted i.e.: (1) Check if module is available in the same directory, if available - use it. (2) If not found walk up to parent dir. Check there, if not there go up until out of package. (3) If not found in (2) look at sys.path for module. I've tested it a bit and it seems to work well. It does not add something like __.foo to refer to a parent package. Also, using this version of knee.py enables one to renest packages without any hassle. I've put up two tiny files for download at a friends machine: http://av.stanford.edu/~prabhu/download/ The relevant files are my_import.py - which is simply an enhanced knee.py (with one bug fix). Note: this was written using Python2.1's knee.py so will work only with 2.x pkg.tar.gz - which is a silly test package that I used for quick and dirty testing, this includes my_import.py and uses it. pkg.tar.gz contains a reasonably deep nesting of packages $ ls -R pkg pkg: __init__.py a.py my_import.py sub/ test.py pkg/sub: __init__.py b.py c.py subsub/ pkg/sub/subsub: __init__.py d.py in d.py I do: import a and import b. So to test it you can do: >>> import pkg.sub.c # sibling a b a.a = a >>> import pkg.sub.b # not so deep nesting. # look ma no prints! >>> import pkg.sub.subusub.d # deep nesting d a.a = a Please do check it out and let me know what you folks think. Now that I have code to do what I meant, could this be made the default behaviour for Python?? Thanks. prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net From gat at jpl.nasa.gov Fri Nov 30 17:06:55 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Fri, 30 Nov 2001 14:06:55 -0800 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: In article , morpheus at here.not.there wrote: > It is not backwards compatible if it solves your problem and if it is it > doesn't solve your problem. As you can see in the second test the first line > does not denote the end of the block because of the semicolon at the end. > This is legal now. Under your proposal it would become illegal breaking > compatibility. No, it would not become "illegal" under my proposal. Please go back and re-read what I wrote, and pay particular attention to the word "optional". E. From loewis at informatik.hu-berlin.de Sun Nov 11 07:47:59 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 11 Nov 2001 13:47:59 +0100 Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: Michael Hudson writes: > generally-in-awe-at-your-thoroughness-ly y'rs, Well, thanks for reading it. After an hour of researching all these pieces, I felt like an idiot doing it just so somebody can report a number to his instructor... I probably could have picked any number, as long as the unit is bytes, not meters... Regards, Martin From mwh at python.net Fri Nov 9 11:00:37 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 9 Nov 2001 16:00:37 GMT Subject: Teaching python (programming) to children References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> Message-ID: Laura Creighton writes: > Paul Rubin writes: > > I think a big goal of the Mindstorms crowd is teaching the concept of > > debugging. Most skills are taught with the idea that you master > > something by learning it well enough to do it perfectly, so if you > > make a mistake at it you haven't learned the skill yet. Teaching > > programming to young kids is supposed to develop the cognitive skill > > of diagnosing and correcting errors. That's more fundamental than > > "applications" like cataloging mp3's or even understanding math > > concepts. > > In the same vein, if any of you out there are writing (or revising) > 'how to program in Python' books or papers, could you please put > the section on exception handling _early_, say, right after 'what > is a loop', rather than in the last chapter? That's what my tech review for one such said over the summer :) This may have been too late, of course. But Laura is right here. Very very right. Cheers, M. -- First time I've gotten a programming job that required a drug test. I was worried they were going to say "you don't have enough LSD in your system to do Unix programming". -- Paul Tomblin -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From sasoft at gmx.de Wed Nov 28 18:03:29 2001 From: sasoft at gmx.de (cruciatuz) Date: Wed, 28 Nov 2001 18:03:29 -0500 Subject: popen and popen2 Message-ID: <20011128180329.A4808@blackscarab> What is the difference between popen and popen2? I compared pydoc popen und pydoc popen2: ### pydoc ### Python Library Documentation: built-in function popen in os popen(...) popen(command [, mode='r' [, bufsize]]) -> pipe Open a pipe to/from a command returning a file object. Python Library Documentation: function popen2 in os popen2(cmd, mode='t', bufsize=-1) ### end pydoc ### The only difference i see is that bufsize is different(?) What does that mean and when do i have to use popen and when do i have to use popen2 ? -- Stefan Antoni ---------------------------- Mit Nov 28 18:00:21 EST 2001 _ ASCII ribbon campaign ( ) - against HTML email X / \ -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From richard at bizarsoftware.com.au Wed Nov 7 19:04:18 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Thu, 8 Nov 2001 11:04:18 +1100 Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) In-Reply-To: <9sbvsa$925$1@newsg2.svr.pol.co.uk> References: <8_dG7.4760$R43.760797@newsb.telia.net> <9sbvsa$925$1@newsg2.svr.pol.co.uk> Message-ID: <200111080002.fA801s344190@bigboy.bizarsoftware.com.au> On Thursday 08 November 2001 05:51, Duncan Smith wrote: > "Fredrik Lundh" wrote in message > news:8_dG7.4760$R43.760797 at newsb.telia.net... > > > Gary Stephenson wrote: > > > Umm, I'm not really sure this is a claim we should be making! Next > > thing > > > > you'll have us claiming responsibility for making disco popular - and > > then > > > > they'll just have to shoot us! ;-) > > > > but Steve Irwin is your fault, right? > > And Rolf Harris. Hang on there, we may have spawned that particular evil, but you poms are the ones encouraging him :) Richard From fperez528 at yahoo.com Sun Nov 18 08:51:31 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 19 Nov 2001 13:19:31 +2328 Subject: conversing with the shell References: Message-ID: <9tbple$g2l$1@peabody.colorado.edu> Michaell Taylor wrote: > Problem is of course the SOMECOMMAND lines. I need to query the shell for > input and then read that input in as a variable. I could use the shell > commands to redirect the output to a file and then read the file with > python, but this seems like a waste. > copied verbatim from my 'tools' module. strip it down to output = commands.getoutput(cmd) if performance is critical. f #---------------------------------------------------------------------------- def bq(cmd,verbose=0,debug=0,head=''): """Dummy substitute for perl's backquotes. Executes a command and returns the output. """ if verbose or debug: print head+cmd if not debug: output = commands.getoutput(cmd) return output From phr-n2001d at nightsong.com Mon Nov 5 01:04:06 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 04 Nov 2001 22:04:06 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE623BF.9F4EA0F2@seebelow.org> Message-ID: <7x4ro94uuh.fsf@ruckus.brouhaha.com> Grant Griffin writes: > Python's system is basically "you must write to a variable before you > can read it". This has the net effect of catching the kind of error you > refer to, in nearly all cases--and I haven't had a significant problem > with the cases that can get missed. > > Therefore, this simple but powerful idea gives you nearly all of the > benefit of variable declarations, yet none of the baggage. Of course it doesn't. If you misspell a symbol in some rarely used path through the code, it's quite possible your testing will miss it. Compile time checking wouldn't. From montanaro at tttech.com Mon Nov 12 01:47:10 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Mon, 12 Nov 2001 07:47:10 +0100 Subject: Is this considered black magic? In-Reply-To: <200111111337.fABDb7eR012232@ratthing-b246.strakt.com> References: <200111111337.fABDb7eR012232@ratthing-b246.strakt.com> Message-ID: Laura> I want to do something which is conceptually very simple. Laura> Given a list of objects, call make everybody call the same Laura> method you want to run. Sort of like apply(), but for Laura> methods. I'm used to thinking of a proxy that forwards attribute lookups to a list of objects as a "collection". That's what LYMB called it: http://www.crd.ge.com/esl/cgsp/fact_sheet/objorien/index.html (that page is probably five years old - convert all verbs to past tense...) and I suspect that's what Smalltalk calls it. In LYMB, the Collection class was used quite heavily. I always wondered why I never needed it in Python. Maybe I did but just didn't know it. ;-) At any rate, here's a simple Collection class for Python that does pretty much what you asked for. It implements get (for retrieving attribute values) and call (for calling attributes) methods. It uses the new 2.2 type/class stuff. You should be able to run it under 2.1 by subclassing from UserList.UserList instead of list. Note that it's not an error to attempt to forward a call to an object that doesn't implement it. The output simply doesn't include any result, so unlike map(), the length of the collection and the output produced by the get and call methods need not be the same. That behavior can easily be changed in a couple different ways, either by lopping off the hasattr check in the get method or providing a default value in the get method to substitute for the missing result. Implementation is left as an exercise for the reader. ;-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ #!/usr/bin/env python class Collection(list): """Collections group objects together and forward attribute lookups. At least this is the Collection I remember from LYMB (an interpreted OO language developed by Bill Lorensen et al at GE CRD), which almost certainly got it from Smalltalk. I don't understand why I've never needed it in Python. It was indispensable in LYMB. (hmmm...) This doesn't look a lot like LYMB's collection class, but then Python doesn't look much like LYMB. It's also a helluva lot easier to write in Python than LYMB because all LYMB's classes were written in C. ;-) """ def get(self, attr): """return a list of attributes from ourselves""" return Collection([getattr(x, attr) for x in self if hasattr(x, attr)]) def call(self, attr, *args, **kwds): """return the result of calling 'attr' for each of our elements""" attrs = self.get(attr) return Collection([x(*args, **kwds) for x in attrs if callable(x)]) import time class Food: def __init__(self): self.t = time.time() time.sleep(0.5) class Ham(Food): def say(self): print "I am Ham, and I don't want any arguments, thank you." return () def speak_up(self, arg): print 'I am Ham, and my arguments are %s' % arg return arg class Eggs(Food): def speak_up(self, arg='bacon'): print 'I am Eggs, and my arguments are %s' % arg return arg class Spam(Food): def shout(self, arg1, arg2='sausage'): print 'I AM SPAM AND MY ARGUMENTS ARE %s AND %s' % (arg1, arg2) return (arg1, arg2) def main(): c = Collection() # kind of boring example... c.extend(range(3)) print c.get("__hash__") print c.call("__hash__") print # slightly more interesting example... c = Collection([Ham(), Eggs(), Spam()]) print "*** when was this food made? ***" times = c.get("t") print map(round, times, [2]*len(times)) print print "*** what kind of food is it? ***" classcol = c.get("__class__") print classcol.get("__name__") print print "*** shouting ***" print c.call("shout", "nickel", "dime") print print "*** speaking up ***" print c.call("speak_up", "juice please") print print "*** saying ***" print c.call("say") print if __name__ == "__main__": main() From mwh at python.net Wed Nov 14 13:35:23 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 18:35:23 GMT Subject: File Permission in Unix References: <00e601c16d2e$5fef0e30$6192003e@rashome> Message-ID: Dave Swegen writes: > On Wed, Nov 14, 2001 at 07:04:07PM +0200, Amit Weisman wrote: > > Hi > > How do one creates a file with specified permissions (e.g. , 777) within > > Python ? > > os.chmod is your friend. Use os.chown to change ownership of a file. Or use os.open with appropriate flags if it's important that the file be created with the appropriate permissions. Then use os.fdopen to get a nice friendly file object. Cheers, M. -- 42. You can measure a programmer's perspective by noting his attitude on the continuing vitality of FORTRAN. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From mwh at python.net Fri Nov 16 07:18:21 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 16 Nov 2001 12:18:21 GMT Subject: What is "marshal data"? References: <859c71be.0111151028.63227109@posting.google.com> <3bf4fd0f$1@brateggebdc5.br-automation.co.at> Message-ID: Michael Hudson writes: > "Werner Schiendl" writes: > > > just a guess, but even if the magic id in the .pyc file is the same, > > does this guarantee that the .pyc file is protable between different > > platforms? > > Yes. This fact is even documented . Woops, shouldn't be so glib. The fact that marshalled data is portable is documented, but it's not obvious that if you're wondering whether pycs are portable between platforms that you should be reading the marshal docs. They are, though. Cheers, M. -- Well, you pretty much need Microsoft stuff to get misbehaviours bad enough to actually tear the time-space continuum. Luckily for you, MS Internet Explorer is available for Solaris. -- Calle Dybedahl, alt.sysadmin.recovery From dalke at dalkescientific.com Sat Nov 10 12:50:17 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sat, 10 Nov 2001 10:50:17 -0700 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> Message-ID: <9sjplc$noj$1@nntp9.atl.mindspring.net> Paul Rubin: >Comparing Python with Perl, generally I find Python better designed >but its implementation more likely to take short cuts. I've reported several core dump bugs in Perl over time. The most recent was a couple months back. I've used Python a lot more than Perl, and I work out of CVS, so it's hard to compare the two, but I feel that they are comparable in implementation solidity. Yes, I've reported Python core dumps as well. I find it impressive you can compare implementation details. When I've found problems or had questions with Perl's C implementation, I haven't been able to figure out heads nor tails of the code. In Python, I've never had that problem except once where there was a 'tstate' bug related to how threads are done. > The security >issue with pickle.loads that we spent a long time discussing is >something I think the perl developers would not have tolerated. I thought most of those pickle bugs have been addressed. I know I sent in fixes for a couple of them. As I recall, it wasn't tolerated, but no one wanted to go fix. As for security, I'm astonished that Perl passes NUL containing strings to system calls, which opens up a Perl script to all sorts of subtle attacks. Perhaps the most famous is http://www.mail-archive.com/modperl at apache.org/msg00396.html Python raises an exception in this case. There are other concerns I have, but the point is I don't see Perl being the best example with which to compare. >There's all kinds of other missing functionality in the runtime system >as well, that doesn't result directly in unrobust programs, but does >make it more difficult to write robustly. A lot of this ng is about >the resulting issues. As I said, I've done Perl coding before, as well as Tcl, C++, and others. I've also hung around those newsgroups. I don't see specifically unusual here indicative of a lack of robustness. It may be because I read c.l.perl from the 4.0.38 -> 5.2 days (so you could say it wasn't as robust then) or c.l.tcl in the 7.x days. Wow! Google says my first post to c.l.py was in Sept. 1995 -- but I was mostly a lurker back then. Could you remind me what sorts of functionality you consider to be missing? Are you talking about things like taintedness and sandboxing? (In which case language like C++ also fit under the category of "more difficult to write robustly", with which I'll agree.) I've written a whole lot of Python code and I can't think of anything in the run-time which needed to be improved to increase robustness. There have been improvements in the language which have improved expressibility and maintainability, but I believe that to be a different though related issue. Andrew dalke at dalkescientific.com From jgardn at alumni.washington.edu Wed Nov 28 21:11:56 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 29 Nov 2001 11:11:56 +0900 Subject: The Editor Poll results are in! In-Reply-To: <01112813100206.00609@linux> References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> <01112813100206.00609@linux> Message-ID: <200111290215.fAT2FST29736@my.knctv.co.kr> The results are in! Emacs: 13 Rude people that use emacs: 1. >:-P (No, RMS did not reply.) *MicroSoft* Visual SlickEdit: 1 brave soul ActiveState Komodo 1.1: 1 lone voice Vim (NOT vi): 7592 Really cool people that use Vim: All of 'em. This poll had a total of 7607 respondents, myself included. Therefore, if you are using emacs and you haven't tried vim yet, you should know that you are in the minority here! HAHAHA! How does it feel to be the underdog now? NYA NYA NYA NYA NYA! This poll is not affected in any way to my aversion to Emacs. Nope, not one bit. I am, after all, a saint, because I use Vim. =) I also remembered to *accidentally* delete the emails so... Jonathan * Disclaimer for the tragically humor-impaired: No, I don't hate emacs. No, I don't hate you. (Well, maybe YOU, but not you.) Yes, I did manipulate the results, and yes, I am a jerk. Yes, it looks like about 75% of the people here use emacs. Can't blame them - python mode is really good. From gherman at darwin.in-berlin.de Thu Nov 29 06:50:23 2001 From: gherman at darwin.in-berlin.de (Dinu Gherman) Date: Thu, 29 Nov 2001 11:50:23 GMT Subject: *args and **opts oddities (?) References: <3C05F634.6EAB5E1@darwin.in-berlin.de> Message-ID: <3c062084.319171093@news.vr.in-berlin.de> On Thu, 29 Nov 2001 10:44:17 GMT, Michael Hudson wrote: >Think about what this does; it calls transform0 with two positional >arguments, the tuple `args', and the dictionary `opts'. These then go >into the `*args' parameter of transform0, and the dictionary `opts' is >empty -- because there weren't any keyword arguments. Argh, stupid me - of course! >Did you want to write > > args, opts = transform0(*args, **opts) I guess I meant to write: apply(transform0, args, opts) Thanks! 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 cliechti at gmx.net Mon Nov 26 13:47:17 2001 From: cliechti at gmx.net (Chris Liechti) Date: 26 Nov 2001 19:47:17 +0100 Subject: resuming execution References: <3C026742.EDBD95FA@math.ufl.edu> Message-ID: [posted and mailed] Nissim Broudo wrote in news:3C026742.EDBD95FA at math.ufl.edu: > Hi, > > I'm running a script on linux by typing > > python -i myscript.py > > and then I hit Ctrl-C and I'm in Python at a prompt >>> > > How can I resume execution ? you cant as you aborted the program. if you want to break into the code and inspect it and then continue, you can use the python debugger. with it you can single step, set breakpoints ans so on. if you use IDLE, pythonwin orr an other ide, you can look for a menu entry for debugging. chris > Thanks ! > > (Please cc: me if you post) > > Nissim Broudo > -- Chris From psycho at tex.ro Wed Nov 14 10:11:30 2001 From: psycho at tex.ro (Ciobanu Vladimir) Date: 14 Nov 2001 07:11:30 -0800 Subject: Threading References: Message-ID: psycho at tex.ro (Ciobanu Vladimir) wrote in message news:... > Consider this: > > class DataBase: > def __init__( self): > self.__dictionary = {} > def __getitem__( self, key): > return self.__dictionary[key] > def __setitem__( self, key, value): > self.__dictionary[key] = value > > This is a very simplified version of the class. It only contains > enough stuff to ask my question. ( I mentioned this so I wouldn't get > answers such as "Why the hell aren't you using a plain dictionary ?") > Now, consider that this DataBase class is to be used in a real > world program, specifically in a threaded world. This would imply I > use locks, which brings me to the actual question. Unfortunately the > Python Library Reference isn't clear enough ( to me, at least) about > this particular detail: > Is it safe to call __getitem__ without placing locks ? > To make it more clear, it is quite obvious that allowing two > threads to simultaneously write ( call __setitem__) isn't desired; but > what about reading ( call __getitem__). Are there any guarantees that > threads don't interfere ( read things that aren't there, resolve in > undefined behaviour in any way) when reading data ? > My first guess would be that I shouldn't be adding locks to > __getitem__, but this depends on the implementation so it's quite > tricky. > > PS: I'd love if Python added a const modifier for methods at least ( > if not for objects too). > > Thanks in advance. I thank Skip Montanaro for his help, but I still didn't get a clear answer. This is my fault since I wasn't clear enough. Skip was kind enough to remind me that if two threads call __getitem__, another thread may get between, call __setitem__ causing the two supposed-to-be identical values got from __getitem__ to be different. I am quite aware of this. Since this DataBase program is going to be quite often updated, I have a better solution. I will add a property to DataBase, namely __readonly. If one user opens it as __readonly, calling function members that change the data in the DataBase ( such as __setitem__) then an exception is raised. I will allow one, and only one user to modify the database at a time. Plus if one is modifyiny, none can read. I had to add this new information in order not to recive the same "someone may change the data" kind of answer. I am trying to be more clear/specific. The point is: If I'm calling only functions such as __getitem__ ( and maybe querry which mainly calls .has_key( key)), is it safe not to add locks to these functions ? I would ask you not to answer if you're not sure about the answer. This is quite important, since it would be a major draw-back if two users couldn't read at the same time. It doesn't make sence, either. Thank you in advance, Vladimir From loewis at informatik.hu-berlin.de Thu Nov 29 11:32:07 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 29 Nov 2001 17:32:07 +0100 Subject: Expat XML Parser References: <9u2t5e$kh4$1@aspen.sucs.soton.ac.uk> Message-ID: "Richard Boardman" writes: > The problem major is that I can't seem to return any of these values at > all - they will all print on the screen, but I can't actually *do* anything > with these values. I don't think it's anything to do with Expat; more my > lack of experience with this language. I can't find any documentation > explaining how Expat works. Expat works in an event-driven manner: For each chunk of the XML document, it invokes a function passing the data it has read. Those functions don't return anything (their return value is ignored); they must do all processing before they return. That processing could be to print the contents out, or it could be to set some global variables to some values, for later inspection. > What I'd like to do is have something that works thus: > > readInXML That is the source of confusion. In event-driven XML processing, there is no separate "read-in"-step. The document is processed while being read; once reading is complete, the processing must be done also. What you want is that reading returns some data structure to inspect. For that, I recommend to use the DOM. To read the document, do document = xml.dom.minidom.parse(url-of-document) > foreach element in XML > if element = "abcdefg" { This is written as for element in document.getElementsByTagName("abcdefg"): > getCharacterData This is more tricky: the content of element may be other elements; or it may be multiple text nodes (e.g. resulting from CDATA sections): chardata = "" for child in element.childNodes: if child.nodeType in [Node.TEXT_NODE, Node.CDATA_SECTION_NODE]: chardata += child.data If you know there ain't any CDATA sections, and no comments, processing instructions etc inside the text, you could also invoke .normalize() first. > doStuff with characterData doStuff(chardata) HTH, Martin From tim at vegeta.ath.cx Thu Nov 1 18:16:21 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Thu, 01 Nov 2001 23:16:21 GMT Subject: Monty Python (was: Freeware Python editor) References: Message-ID: Me parece que Mikael Olofsson dijo: > > On 01-Nov-2001 Oleg Broytmann wrote: > > On Thu, Nov 01, 2001 at 07:39:31AM -0500, Steve Holden wrote: > > > [Makes note to remember that Oleg isn't a Monty Python viewer.] > > > > Few years ago I tried to view the scetches - there was Russian > > translation of them on TV - but found them stupid and boring. Well, I was > > in bad mood those days, may be now I'd find it more interesting :) > > You should really watch them in their original language. [snip] As a native English speaker, I cannot attest to their quality when translated. OTOH, I enjoy Anime much more in the original Japanese, though I do admit that some American voice-actors do incredible jobs attempting to bring the original emotion to the English dub. Tim Hammerquist -- "Even a manager can understand HTML." -- Tim Berners-Lee From aaldv97 at student.remove-this-part.vxu.se Thu Nov 8 11:24:55 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Thu, 8 Nov 2001 17:24:55 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: <9sebn1$28g$1@news.lth.se> > I was an Ada83 programmer (on a non-military project) and I don't think > its a good language for beginners. Ada is too large to be fully understood > within a reasonable time. Type based overloading is very complex to > understand and predict. The task feature was particularly troublesome as it > did not map onto other well established multi-tasking models. Ada95 looks > even more complex with one core language and 10 optional annexes. Where you tought Ada prior to this? Most people with negative image of Ada got off on the wrong foot, which, of cource, is true for everything. Ada83 had only 63 reserved words, Ada95 has only 68. Thougt in all fairness Python only has 28. Task are extremly simple and powerful, they work excelent in multitasking envirionment; tasks are like threading and any user, including the beginners, can use tasks if they can use packages, which they can if they ever printed anything to the screen. > Ada's strict typing goes too far adding much noise to basic operations if > used to define all variables with appropriate constraints. Eventually > programmers give up on this and start using the simple basic types instead. I've found this to be very flexible, maybe you're school with C and that caused problems? > Use appears to have contracted to just military projects here, most > commercial users dropping it for C/C++ to increase productivity. Strange since in every report I've seen on productivity Smalltalk wins and Ada in general is on a strong second place, C++ productivity is generally considered to be 1/6:th or lower of Smalltalk for example. From weismann at netvision.net.il Wed Nov 14 12:04:07 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Wed, 14 Nov 2001 19:04:07 +0200 Subject: File Permission in Unix Message-ID: <00e601c16d2e$5fef0e30$6192003e@rashome> Hi How do one creates a file with specified permissions (e.g. , 777) within Python ? ---------------------------------------------------------------- Weisman Amit 11 Rupin st. Holon 58344 Israel Tel : 050397330 weismana at cs.bgu.ac.il From slinkp23 at yahoo.com Tue Nov 6 00:49:38 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Tue, 06 Nov 2001 05:49:38 GMT Subject: RE Module Question. References: Message-ID: On Mon, 5 Nov 2001 23:50:13 -0500, Adonis Vargas wrote: >test = "this is a test" >if "test" in test: print "found string." > >this is just pseudocode to get the concept im trying to achieve. We just had a thread on this a few days ago... try the archives at groups.google.com. You can do it like so: test = "this is spam" if test.find("spam"): print "found it" Also, look at http://www.vex.net/parnassus/apyllo.py?i=83093702 for a nice alternative to regular expressions. From jgardn at alumni.washington.edu Mon Nov 26 20:55:16 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Tue, 27 Nov 2001 10:55:16 +0900 Subject: function operators In-Reply-To: References: Message-ID: <01112710551605.00606@linux> James A. H. Skillen wrote: > Has anyone ever wished that Python had operators defined on functions? > For example, suppose you want the function f(x) = cos(x) + sin(x). > You could do: > > Does this make sense, or have I been doing too much mathematics? ;-) > Great idea. But Too complicated. It's pretty easy to make them the traditional way. The new syntax would only make python that much harder to read. I think this goes along the lines of why there is no ? : construct. You can just use an if/else, and it reads much easier besides. Jonathan From max at alcyone.com Tue Nov 20 16:00:11 2001 From: max at alcyone.com (Erik Max Francis) Date: Tue, 20 Nov 2001 13:00:11 -0800 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> <3BFAAD1E.9E9AF618@alcyone.com> Message-ID: <3BFAC45B.9D246137@alcyone.com> Bruce Edge wrote: > Additionally, after parsing with re, I still need to convert to > integers, > which is a PITA when you consider the "%x" case. The format string > "knows" > that this is in hex, using re, I get back say a string which I still > need > to dtermine the number base and convert. You can use the int-with-arg form for converting strings to integers other than in base ten. > I'm not arguing :) > It's just that in this one tiny case, scanf would have been the > perfect > tool. It wouldn't be hard to write a simple wrapping script that takes a printf format string, converts it to a regular expression, does a match against a string, then pulls out the arguments and converts them to types as appropriate. But one might just as well be using regular expressions directly in the first place. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From spamhole at mindspring.com Mon Nov 19 00:48:53 2001 From: spamhole at mindspring.com (Derrick) Date: 19 Nov 2001 05:48:53 GMT Subject: Looking for 1.5.2 for an ancient Macintosh - Anyone have it? Message-ID: <9ta6g5$mpp$2@slb7.atl.mindspring.net> I'm trying to find 1.5.2 for a very nice old PowerBook 165 that someone is giving me. Its using MacOS 7.1 to 7.6 - I don't know which one just yet. The Mac's good for word processing because of its portability and great keyboard, but I'm looking for Python (I use 2.1.1 on my PC) in order to have something useful to do on the machine when I'm not writing stories. TIA - dB From joeyahoo at gmx.de Thu Nov 1 06:48:07 2001 From: joeyahoo at gmx.de (Andreas) Date: 1 Nov 2001 03:48:07 -0800 Subject: Zugriff auf Windows Dateieigenschaften Message-ID: Hi, ich bin der totale Pythonanf?nger und muss ein Skript schreiben, um t?glich in einem bestimmten Verzeichnis s?mtliche Dateien zu checken und alle die ?lter als 30 Tage sind zu l?schen. Da bei uns in der Firma vorwiegend mit Python gearbeitet wird, soll ich das nat?rlich auch in Python schreiben. Als Betriebssystem l?uft auf den Rechnern um die es geht Windows NT bzw. Windows2000. In welchen Modulen finde ich denn Funktionen zum Zugriff auf die Dateieigenschaften wie zum Beispiel Erstellungsdatum, ?nderungsdatum etc. Bis jetzt habe ich nur os.path gefunden. Schon mal danke im Voraus. Tsch?? Andreas From fredrik at pythonware.com Wed Nov 7 02:58:49 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 07:58:49 GMT Subject: problems when starting python References: <8ec33ba5.0111062326.1035edf2@posting.google.com> Message-ID: "barabba" wrote: > I just started using python and have the following problem. > when i double-click the pythonw.exe the application does not start !! > Anybody knows why ? pythonw.exe is designed to let you run a python script without an associated console window. to make something appear on the screen, you must 1) pass a script name to pythonw.exe, and 2) make sure that script creates a window (usually by using Tkinter or any other UI toolkit). (you can get around (1) by using the extension ".pyw" instead of ".py", and clicking on the pyw file. the following excerpt from o'reillys "python programming on win32" contains a little more info: http://www.onlamp.com/pub/a/python/excerpts/chpt20/?page=2 ::: if you're just tinkering, use IDLE or fire up a command (MS-DOS) window, and run the interpreter from there: c:\mydir> python myscript.py or c:\mydir> python PythonWare 2.2b1 on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import mymodule From prabhu at aero.iitm.ernet.in Thu Nov 8 10:14:05 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Thu, 8 Nov 2001 20:44:05 +0530 Subject: mayavi installation problem on Win NT In-Reply-To: <9sdh9v$hgq$01$1@news.t-online.com> References: <9sdh9v$hgq$01$1@news.t-online.com> Message-ID: <15338.41277.767494.398557@monster.linux.in> >>>>> "MF" == Markus Faust writes: MF> The module is VTKDLL.DLL with the routines MF> void vtkDataArray::GetData(int,int,int,int,class vtkFloatArray MF> *) void vtkDataArray::CreateDefaultLookupTable(void) void MF> vtkDataArray::SetLookupTable(class vtkLookupTable *) void MF> vtkDataArray::SetName(char const *) char const * MF> vtkDataArray::GetName(void) . . . MF> Has anybody encountered similar problems and knows what to do? MF> Thanks in advance! Its most likely a VTK installation problem. Can you import vtkpython? $ python >>> import vtkpython If this doesn't work then your VTK install is messed up. Also, Les's post should help. prabhu From fperez at pizero.colorado.edu Wed Nov 14 17:03:46 2001 From: fperez at pizero.colorado.edu (=?ISO-8859-1?Q?Fernando_P=E9rez?=) Date: Wed, 14 Nov 2001 15:03:46 -0700 Subject: Non-obvious name bindings In-Reply-To: <3BF2D8CE.7CC12F87@ccvcorp.com> References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> <3BF1BB43.6B4E667B@bgb.cc> <9ssf3h$dfh$1@peabody.colorado.edu> <3BF2D8CE.7CC12F87@ccvcorp.com> Message-ID: On Wed, 14 Nov 2001, Jeff Shannon wrote: > If I'm reading the bug report right, then it *is* expected behavior that list > comp variables are function-local variables, not true "temporary" variables. You are right. The problem is that the list comp. index was propagating *outside* of a function magically. After using a list comprehension your global namespace would grow variables all by itself. Very disconcerting. > > C++ (IIRC) treats loop indices as being limited to the scope of the loop only, > and invalid once the loop ends. Python, however, has a much simpler scoping > scheme, and doesn't use a separate scope for loops (and list comps are just > syntax sugar for a for-loop). > C++ treats variables as *block* local: for(int i=0;i >>> def Example(mystring): > ... spam = [char for char in mystring] > ... print char > ... > >>> Example('spam and eggs') > s > >>> char > Traceback (innermost last): > File "", line 1, in ? > NameError: There is no variable named 'char' > >>> > > This is the expected behavior. There is nothing about list comprehensions that > limits their variables to *only* within the list comp, just as with for-loops. > The bug reported on SF would (I think) have made char a global variable, thus > there would've been no NameError (I'm actually using 2.0 not 2.1 for this, so > can't demonstrate the buggy behavior). The bug appears if you do the above in a file, not at the interpreter. Don't know why the difference. Try my original post which had example code, copy it to a file and run it, you should see the problem (if it exists in 2.0). Cheers, f. From bobhicks at nospam.adelphia.net Sat Nov 3 21:01:22 2001 From: bobhicks at nospam.adelphia.net (Robert Hicks) Date: Sun, 04 Nov 2001 02:01:22 GMT Subject: Gadfly and regsub with Python 2.1 References: <3BE2B29B.1E714B89@noaa.gov> Message-ID: <3BE4A172.1020808@nospam.adelphia.net> jim.vickroy wrote: > Hello, > > I've recently upgraded to Python 2.1 and notice that Gadfly uses the > deprecated "regsub" module. > > Are there any pitfalls. an amateur should be aware of, in modifying > Gadfly to use the "re" module? > > Thanks, > > - jv > > What ever happened to Gadfly? Did it ever get updated? Bob From lfini at arcetri.astro.it Wed Nov 21 04:51:17 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Wed, 21 Nov 2001 10:51:17 +0100 Subject: Still on python GUI toolkit In-Reply-To: References: Message-ID: On Tue, 20 Nov 2001, Tyler Eaves wrote: > Unless you used Tkinter's canvas widget, this wasn't a fair test. Yes, I did. -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From tdelaney at avaya.com Tue Nov 6 18:44:32 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Wed, 7 Nov 2001 10:44:32 +1100 Subject: And Now for Something Completely Different! (was: Monty Pytho n (was: Freeware Python editor)) Message-ID: > From: Fredrik Lundh [mailto:fredrik at pythonware.com] > Gary Stephenson wrote: > > We here downunder have just always claimed him as one of our own > > like ABBA? We've never claimed ABBA. We merely claim to have made them popular and famous ... Tim Delaney From qrczak at knm.org.pl Fri Nov 16 15:33:18 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 16 Nov 2001 20:33:18 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: Fri, 16 Nov 2001 09:35:40 +0100, Skip Montanaro pisze: > > Huaiyu> So my question really is this: Is there any major practical use > Huaiyu> for an object to be unequal to itself? Would it be better to > Huaiyu> just define (a==b) to take a shortcut of (a is b), always? > > The "is" operator is defined to just do pointer comparisons. Here are just > three different ways to generate objects that are equal but not "is": The question was whether (a==b) should check (a is b) first and perform the real value test only when (a is not b), returning 1 otherwise. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From etoffi at bigfoot.com Thu Nov 29 07:17:55 2001 From: etoffi at bigfoot.com (e toffi) Date: 29 Nov 2001 04:17:55 -0800 Subject: pyplets Message-ID: <655abd4a.0111290417.4b28a0f2@posting.google.com> i was thinking (which i dont do often), and came up with an idea (which i *do* do often -- dont ask me how). the idea is pyplets -- the analogue to java applets with a fittingly silly name. anyway the premise is to define an api that lets programmers write small programs that execute in a browser. whatdyathink? From tfb at apocalypse.OCF.Berkeley.EDU Sun Nov 11 17:14:16 2001 From: tfb at apocalypse.OCF.Berkeley.EDU (Thomas F. Burdick) Date: 11 Nov 2001 14:14:16 -0800 Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: "Morten W. Petersen" writes: > Hello, > > I'm currently doing some research, to see if it could be an advantage to > use Common Lisp instead of Python (currently Python and Zope [1] are used > to build web applications). > > While doing this, Google has provided two interesting documents (search > for 'lisp vs python'): > > http://www.strout.net/python/pythonvslisp.html The very top of the page says: The relative merits of the two languages are compared in 11 categories. In an attempt to make a more quantitative comparison, each language is assigned a score from 0 to 10 in each category. These scores are then combined, with appropriate weighting factors, to produce a total score. Each score was assigned as independently as possible, before weighting factors were decided; and weighting factors were chosen without examining the scores. In this way, the final scores are made as objective as possible. >From reading this alone, it is obvious that the author has an agenda, and is about to embark on a completely biased, subjective comparison, who's results he has already decided. Plus, he's wrapping it all up in pseudo-scientific mumbo-jumbo, which is unforgivable. After the first page, I was going to pick the page apart, or at least try to address some its more serious flaws, but there's major, misleading flaws at least one to a paragraph. I don't know if it was meant to be misleading, or just biased, but looking at Marco Antoniotti's reply, I'd guess it's intentionally misleading. I'd try to forget you ever saw it. Not because it favors Python over Lisp, but because it does so dishonestly. On the other hand, I think I'm glad that guy doesn't use Lisp :) > http://www.norvig.com/python-lisp.html I'd read this before, and found it interesting. Not the least because it's by Norvig, whose opinion I respect. It convinced me that if I'm in a situation where I would use CLISP (a bytecode implementation of CL), but can't, that Python is something I should consider. It seems like an underpowered Lisp pretender, but then, there are a lot of worse things to be. -- /|_ .-----------------------. ,' .\ / | No to Imperialist war | ,--' _,' | Wage class war! | / / `-----------------------' ( -. | | ) | (`-. '--.) `. )----' From davebutlerREMOVE at hotmail.com Mon Nov 12 12:38:08 2001 From: davebutlerREMOVE at hotmail.com (Dave Butler) Date: Mon, 12 Nov 2001 17:38:08 GMT Subject: Tkinter Crash under PythonWin Message-ID: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> I recently began exploring Tkinter programming. I built the following program based on similar code in a book: from Tkinter import * top = Tk() quit = Button(top, text='Quit', command=top.quit) quit.pack() mainloop() This simple "app" opens fine and closes when run from a command prompt (under Win2000). However, when run from PythonWin (win32all build 140) the app does not close and a few clicks later PythonWin crashes with a MS Visual C++ runtime error ("abnormal program termination"). Any explanations? Is PythonWin a stable platform for using Tkinter? Thanks, Dave From kfarmer at thuban.org Fri Nov 23 15:03:53 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Fri, 23 Nov 2001 20:03:53 GMT Subject: AppBars in Win32 -- SUCCESS References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> Message-ID: "Thomas Heller" wrote in message news:9tlmkh$3gnos$1 at ID-59885.news.dfncis.de... > Sounds interesting. Will you publish the code? I will, but first I need to clean it up a bit. ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From nomad*** at ***freemail.absa.co.za Mon Nov 5 07:08:54 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Mon, 05 Nov 2001 14:08:54 +0200 Subject: Python GUI for a C program References: Message-ID: <5uvcutgaikb19ig9tbebd426hnhgsd8epm@4ax.com> On Mon, 05 Nov 2001 10:52:55 GMT, "rand0m" wrote: >Hi all, > >could someone point me to some good resources -beside official ones- (code >snippets, tutorials, etc...) that could show me the way to build a Python >GUI (i'm interested in wxPython) for C applications? > >Thank You, >Lorenzo You'd probably be better off just using (to follow your example) wxWindows. If the app is C/C++ based, rather loose the Python overhead for the GUI, and build the GUI straight in C/C++. There are a few tools out there that will enable you to do both though. wxDesigner is a (AFAIK commercial) RAD GUI builder that you can use for either C/C++ or python (via wxWindows / wxPython respectively), or there is also the QT toolkit (non-commercial versions available) which includes the qtDesigner, a C/C++ GUI builder that has python bindings. Both of the above solutions will allow you to prototype GUI's in python, but still (later) compile the GUI as C/C++ to gain the extra speed, and (generally) lower overhead of compiled GUI code. HTH -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From mickey at tm.informatik.uni-frankfurt.de Tue Nov 27 07:24:32 2001 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 27 Nov 2001 14:24:32 +0200 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <9t2ht5$pvi$1@slb3.atl.mindspring.net> Message-ID: <3c03940f@nntp.server.uni-frankfurt.de> Matt Gerrans wrote: > I like the idea of incorporating design patterns (suggested elsewhere in the > thread), where appropriate. > > How about developing a Python GUI IDE (like Delphi, Kylix, C++ Builder, etc.) > that lets you design the UI and choose any of the toolkits as the > implementation? This would perhaps be ambitious, but it would generate a > useful tool and be a self-validating (and self-referential) example of what > you are illustrating. Hmm... a really nice idea, however I think this is really beyond the scope of a medium sized book. Also, isn't AnyGui researching in this direction? At least from a capsulating point of view? :M: From roy at panix.com Sat Nov 3 09:18:39 2001 From: roy at panix.com (Roy Smith) Date: Sat, 03 Nov 2001 09:18:39 -0500 Subject: Q: Feature Wish: "%" Extension References: <3BE34077.8EA553CB@spam.net> Message-ID: Chris Liechti wrote: > def bin(x): return ''.join(map(q.get,'%x' % x)) And people say perl looks like line noise? From andreas at mtg.co.at Wed Nov 28 14:03:41 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Wed, 28 Nov 2001 20:03:41 +0100 Subject: [2.2b2]: class variable and classmethod, subclass In-Reply-To: References: Message-ID: <200111281903.fASJ3oY18210@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Mittwoch, 28. November 2001 15:29 schrieb {-- Rot13 - Hateme: > Thanks for your guys' answers. > > It sucks though. :) At least subclasses should not share > the class variables with their parents. Why does it make > sense? Well, you have to seperate objects that can be modified in place, and constant objects (strings, numbers, tuples, etc.) Consider the following program: class A: a=123 b=[] def x(klass,v): klass.a=v klass.b.append(v) x=classmethod(x) def str(klass,lab): return "%s: a=%3d(%08x) %-7s(%08x)" % (lab, klass.a,id(klass.a), klass.b,id(klass.b),) str=classmethod(str) class B(A): pass print A.str("A"),B.str("B") B.x(100) print A.str("A"),B.str("B") # output: #A: a=123(0812828c) [] (08122cd4) B: a=123(0812828c) [] (08122cd4) #A: a=123(0812828c) [100] (08122cd4) B: a=100(08128298) [100] (08122cd4) When you look at A.x, you can see, that it rebind klass.a to a new object. (Very important: = just labels a reference in python. It's not a classical assignment operator) Because of this, when B.x is called, B.a is bound to a different object then A.a. klass.b OTOH is not rebound, but modified in place. So it A.b and B.b continue to be the same object. Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8BTUTHJdudm4KnO0RAtMhAJ9TiruGtHSaRD1ITYevkAW4Ye4RMQCfSOlL S2AUkgldPvQaZxyfbzhMAt4= =C/Jw -----END PGP SIGNATURE----- From stojek at part-gmbh.de Thu Nov 1 05:27:50 2001 From: stojek at part-gmbh.de (Marcus Stojek) Date: Thu, 01 Nov 2001 10:27:50 GMT Subject: starting externel program (win32) Message-ID: <3be121cb.89811609@news.easynews.net> Hi, from a script I want to start an external program (win32). This should be done in a way that is equivalent to typing the name and options at the dos prompt. The program must not be influenced by exiting the script. Do I have to use system(), spawnv() or spawnve() or something else? Any traps? Tanks Marcus From michele at diee.unica.it Thu Nov 15 12:56:45 2001 From: michele at diee.unica.it (Michele Marchesi) Date: Thu, 15 Nov 2001 18:56:45 +0100 Subject: XP and Agile Methodologies Conference Message-ID: <3BF401DD.701345BD@diee.unica.it> ********* XP2002 - FIRST CALL FOR PAPERS ********* 3rd International Conference on eXtreme Programming and Agile Processes in Software Engineering - XP2002 26-29 May, 2002, Alghero, Sardinia, Italy Home Page: http://www.xp2002.org General Chair: Kent Beck, Three Rivers Institute, USA Program Chair: Michele Marchesi, University of Cagliari, Italy Program Co-chair: Giancarlo Succi, University of Alberta, Canada PRESENTATION OF XP2002 Building on the success of XP2000 and XP2001, the Third International Conference on eXtreme Programming and Agile Processes in Software Engineering will be a forum to discuss theories, practices, experiences, and tools on XP and other agile software processes, like SCRUM, the Adaptive Software Process, Feature Driven Development and the Crystal series. XP2002 will bring together people from industry and academia to share experiences and ideas and to provide an archival source for important papers on agile process-related topics. The conference is also meant to provide information and education to practitioners, identify directions for further research, and to be an ongoing platform for technology transfer. The conference will include technical presentations, panels, poster sessions, activity sessions, workshops, and tutorials. CONFERENCE TOPICS The conference will stress practical applications and implications of XP and other agile processes (AP). Conference topics include, but are not limited to: - Foundations and rationale of XP and AP - Case studies and experiments - Methodology and process - Organizational and management issues and patterns - Scalability issues - Education and training - Introducing AP into an organization - Relation to reuse - Relation to UML and the Unified Process - Relation to the CMM and ISO 9001 - Empirical findings of XP and AP effectiveness - XP Practices: user stories, on-site customer, planning game, short releases, metaphor, simple design, refactoring, pair programming, continuous integration, collective code ownership, no overtime, coding standards - Unit and acceptance testing: practices and experiences - Use of supportive software development tools and environments - Refactoring and continuous integration - Merging of agile processes - Other issues on agile methodologies IMPORTANT DEADLINES: Tutorial proposals: December 15, 2001 Workshops and active sessions proposals: December 31, 2001 Paper submission: December 31, 2001 Acceptance notification: February 15, 2002 Final manuscript submission: April 1, 2002 For more information, including conference topics and instructions to authors, please refer to XP2002 Web site: http://www.xp2002.org or send an e-mail to: michele at diee.unica.it From python at commandprompt.com Mon Nov 26 21:07:49 2001 From: python at commandprompt.com (python at commandprompt.com) Date: Mon, 26 Nov 2001 18:07:49 -0800 (PST) Subject: [OT] PostgreSQL Book In-Reply-To: <9tuhjg$522oj$1@ID-75083.news.dfncis.de> Message-ID: Hello, Well, we didn't want to do what the Addison Wesley book did. The A&W book is about 500 pages and IMHO doesn't cover any topic in depth. Not to mention most of it is regurgitated from the website. We were able to produce 600 pages or original in depth material. The only chapter than could probably use some real beefing up is the JDBC chapter. Basically we want to present a solid book. If we were going to produce a python chapter, I would prefer (and we are talking about it) to have a book that covered say, Python and Perl... for a total of about 500/600 pages. J On Tue, 27 Nov 2001, Markus Jais wrote: > python at commandprompt.com wrote: > > > Hello, > > > > Just letting all you snaker tamers out there that use PostgreSQL that the > > book Practical PostgreSQL from OReilly and Command Prompt is now in > > production. It will be shipping December 15th. > > > > You can view the book online at: http://www.postgresql.info/ > > > > > > Sincerely, > > > > J > > looks interesting, but there are no chapters about > Python ( or Perl, or Ruby) > I saw the book already at www.oreilly.com > but there was no "table of contents" > a chapter on using postgresql with Python (and Ruby) > would have been great > > markus > From fperez528 at yahoo.com Mon Nov 26 06:21:35 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 10:49:35 +2328 Subject: Integer Overflow References: Message-ID: <9u0jor$2li$1@peabody.colorado.edu> Ursus Horibilis wrote: > Is there a way to force the Python run time system to ignore > integer overflows? I was trying to write a 32-bit Linear > Congruential Pseudo Random Number Generator and got clobbered > the first time an integer product or sum went over the 32-bit > limit. well, you can always put the relevant parts in a try:..except block, but I suspect that will kill the speed you need for a rng. If it's just an academic algorithm exercise, do it that way. If you actually need performance, why don't you look at the random module? That may give you some ideas. Out of curiosity, though: I've never written a rng myself. In C, an integer overflow silently goes to 0. Are you relying on this 'feature' in your algorithm? I'm just curious about to whether asking to ignore an overflow without triggering an exception is a design feature or a flaw of the way you are doing things. Cheers, f. From dkuhlman at rexx.com Fri Nov 9 12:49:40 2001 From: dkuhlman at rexx.com (Dave Kuhlman) Date: 9 Nov 2001 11:49:40 -0600 Subject: Two way communication between a python class and a C++ class References: <0r0mut8npqtk8cfp1nato7fmslfkqcv0ki@4ax.com> Message-ID: <1005328872.304796@rexx.com> What you are looking for (if I understand you) is a way to pass an instance of a C++ class to Python so that the Python code can call a method in that class. Stop me if I'm wrong about that ... But, if I'm right, then consider doing the following: Implement a new Python data type. Implement it in C/C++. An instance of this data type will hold (internally) a pointer to the instance of your C++ class, and it will "expose" to Python one or more methods, which will call the methods in (the instance of) your C++ class. Think about the list built-in class in Python. It wraps a C list object, and when you do: mylist = [] mylist.append('hello') It calls an append function (implemented in C) for that object. How to implement it -- Get the Python source distribution. Look in the Objects subdirectory for a file Objects/xxobject.c. Copy and rename that file. Then follow the suggestions in the comments at the top of that file. Also look for help in: http://www.python.org/doc/current/ext/defining-new-types.html I've also written a tool to help generate the source code for simple cases where little more than a wrapper for a C struct is needed. It's called dtGenerator.py and you can find out about it at: http://www.rexx.com/~dkuhlman/ Hope this helps. And, let us know if/when you have more questions. - Dave Firestar wrote: > > Hi, > > I am having a problem obtaining two way communication between a python > class and a c++ class. I can get a python class to communcate with a > c++ class and a c++ class to communicate with a python class, but i > cannot seem to get the communication to go both ways. > > i.e I have a class CTest in c++ and a class PTest in python and when i > create an instance of CTest in c++ it creates an instance of PTest in > python, i then want PTest to be able to call methods in the instance > of CTest that created the instance of PTest. How can i do this? there > seems to be no way to pass the c++ pointer into the python class in > the constructor... > > There must be a way... does anyone know how to do this??? Help much > appreciated!! > > Firestar -- Dave Kuhlman dkuhlman at rexx.com -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- http://www.newsfeeds.com - The #1 Newsgroup Service in the World! -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From ryan.diedrick at lorien.co.uk Fri Nov 9 04:36:08 2001 From: ryan.diedrick at lorien.co.uk (Diedrick, Ryan) Date: Fri, 9 Nov 2001 09:36:08 -0000 Subject: PYTHON DEVELOPER - MANCHESTER-ENGLAND - 3Mth contract Message-ID: > Please let me know if anybody is looking for work as I am looking for > the above. > > Python developer for a 3 month contract to develop Python scripts as > well as support and advise a team of remote users. Networking skills > and Windows 98/NT and knowledge of using Python scripts for > networking. Based in the North West, starting ASAP and interviews will > be from 12/11-16/11 or ASAP. > PLEASE REPY TO MY EMAIL AS I AM NOT A MEMBER OF THE PYTHON LIST. THANKS. > Ryan Diedrick > IT Contracts Specialist > Lorien Resourcing > ' +44(0) 161 888 2521 (Direct Dial) > ' +44(0) 161 877 0415 (Fax) > * email: ryan.diedrick at lorien.co.uk > " Visit our web site : http://www.lorien.co.uk > > Lorien is a founder members of ATSCO > > From prabhu at cyberwaveindia.com Mon Nov 26 13:37:36 2001 From: prabhu at cyberwaveindia.com (Prabhu Ramachandran) Date: 26 Nov 2001 10:37:36 -0800 Subject: Scientific Libraries in Python References: Message-ID: <375ad208.0111261037.5a591853@posting.google.com> Horatio Davis wrote in message news:... [snip] > VTK (Martin et al) - 3D visualization on GTK - personal copyright Well, I guess that is a typo but FWIW I'd like to mention that VTK does not depend on GTK and does not use it at all. There is a pyGTK widget that can embed a VTK render window but that is a different issue. Thanks for the compliments on MayaVi. :) [snip] > Now... licensing. While the top two projects are both less...restrictive, > I reluctantly have to concede that these lists have an awful lot of GPL > code that would be difficult or impossible to do without. The eventual > license, therefore, looks like GPL or (if we're lucky) LGPL. I can even > live with that if it'll get me a coherent scientific library, but others > might have a different viewpoint. What would those viewpoints be? As regards the MayaVi license, MayaVi was developed for the community so I didn't want someone to take the MayaVi codebase, use it for their own purposes and not give back anything in terms of code to the community. That is why I chose the GPL. However, the GPL does force everyone else who links to it to be GPL. I guess LGPL might also work but I really don't know. I'll try to give it some thought. Anyway, I am not sure you want to put all packages into one huge super package. It would be a nightmare to package/distribute! I'd really pity the person who'd have to maintain such a beast. prabhu p.s. Please dont cc me in on replies. My ISP has proved to be incredibly incompetent and has not fixed a stupid DNS problem for the last 5 days!! *Sigh*. From joost_jacob at hotmail.com Fri Nov 30 03:51:39 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 30 Nov 2001 00:51:39 -0800 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> <9u37pb$7dk$1@slb7.atl.mindspring.net> <13285ea2.0111290447.57be5009@posting.google.com> <3C0688CB.B8FB019E@home.net> Message-ID: <13285ea2.0111300051.2a133005@posting.google.com> > By the way, your original code: > > for j in range(self.nh): > sum = 0.0 > for i in range(self.ni): > sum = sum + self.ai[i] * self.wi[i][j] > > Are you sure you want to re-set sum inside the j loop? you are > re-defining it, so unless you store it, you are only going to get the > sum of the last row, which makes it pretty silly to loop through the > whole mess. Of course....i did only show the part of the loop where most time is spend, the sum value is used every iteration. > > Anyway, here is the code for Numeric. You must be using some pretty slow > hardware, or massive arrays to get times as long as you get! um, both hehe. A lot of neural networks are created and all tested. That is why even a 50% speedup could be interesting. If it all takes too long i just change the experiment setup. [snip nice Numeric example] Thank you for the Numeric example. The problem here (univ) is we are not allowed to install anything (except in our personal folder). And not all computers are on the same network so pointing to a Numeric package in my personal folder is no use. Also not all computers have the same OS so you do not even have one single personal folder. We walk around with floppies sometimes :) I really need something totally portable and sticking to whatever is in Python 1.5.2 is the most portable thing i have seen so far. In this respect Python is MUCH better than Java. When they install Python 2.1 on all computers I will be very happy but i believe 2.1 also has no Numeric. I wish Numeric came with Python itself ! I'm thinking of a way to put Numeric on a floppy so i can use it with my program (also on the floppy) on any OS. From frederic.giacometti at arakne.com Wed Nov 7 10:35:43 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Wed, 07 Nov 2001 15:35:43 GMT Subject: C callbacks ? Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: "Gordon McMillan" wrote in message news:Xns91518EE46939Bgmcmhypernetcom at 199.171.54.215... > Frederic Giacometti wrote: > > > > > "Gordon McMillan" wrote in message > > [snip] > > >> But making Python *truly* stackless means getting rid of all recursions, > >> and that is an enormous task. If you don't do that, you've got a > >> language feature that doesn't work in some apparently random set of > >> circumstances. > > > > But how do you process callbacks to Python from C code (extensions or > > embeded python)? > > > > One has to return to C after executing the Python code, and than C has to > > return to Python after executing the remainer of its code... > > All depends on what you mean by "return" . Try thinking of "callbacks" > and the "return" from callbacks as events. > > In Stackless, the Python stack and the C stack are completely separate. > In the case where C code needs to call Python and then do something with > the result (that is, where tail recursion doesn't apply), Christian used > the trick of manufacturing a Python-style frame object that represents the C > code. As far as (Stackless) Python is concerned, it gets dispatched like > any other frame (Stackless' Python "stack" is really a tree). That's a very interesting paradigm :)) Thanks, FG From fredrik at pythonware.com Tue Nov 6 15:49:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 06 Nov 2001 20:49:41 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s43jo$bku$1@news8.svr.pol.co.uk> <9s538j$qo1$1@bugstomper.ihug.com.au> Message-ID: Gary Stephenson wrote: > We here downunder have just always claimed him as one of our own like ABBA? From huaiyu at gauss.almadan.ibm.com Wed Nov 21 13:48:22 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Wed, 21 Nov 2001 18:48:22 +0000 (UTC) Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> <9tdhon$aht52$1@hades.rz.uni-sb.de> Message-ID: On Wed, 21 Nov 2001 19:25:01 -0800, Glenn R Fulford wrote: >On the other hand, most work with matricies has indexing starting from 1. That's just because it does not matter. Since people normally count things from one, that's the convention they use. >Noone uses matrix indices (0,0). Note that MatLab does it's indexing from 1, >and I thought that nupy is thought of as a replacement for matlab? The whole >idea of using software to do mathematics is to have a language which feels >natural to translate the maths into the program. I don't think Numpy was originally intended as a Matlab replacement. It's more like a way to give numerical capability to people already using Python. In contrast, I wrote MatPy for the express purpose of making the interface more like Matlab, as I had used Matlab for years and liked it a lot. But I find matching indexing conventions between two languages of minimal interest - the purpose of these objects is to hide them. On the other hand, if you are ever going to tranform arrays between numerical and non-numerical types within the same language, Python, you really want to match the indexing convention between them. In fact, changing the indexing in MatPy itself is not difficult at all - you can do it within half an hour (the first version of MatPy was done in an afternoon). Look for __getitem__ and friends in the Matrix module. The code is GPLed so you can do almost anything with it. But be warned: the difficulty only comes when you are using such a scheme. If you are really more interested in an outright replacement of Matlab (for licensing issues, for example) instead of having both numerical and Python capabilities in one language, you'd be better off trying Octave. It is excellent and it is GPLed. >> . I initially learned >> programming in Fortran, but when I learned C later it felt much more >> natural. I guess some other people might feel the same way too. > Not me! Glenn. If you have tried to solve differential equations with a difference method in Fortran you'd have felt the pain of indexing from one. More specifically, if you divide an interval into n, the nodes would be most naturally labelled [0, 1, ..., n]. There are many other situations, but I won't repeat them. Huaiyu From loewis at informatik.hu-berlin.de Mon Nov 26 05:09:20 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Nov 2001 11:09:20 +0100 Subject: Sockets, DNS and timeouts References: <9tsqmh$ih1$1@ctb-nnrp1.saix.net> Message-ID: "Grant Beasley" writes: > The problem appears to be that there isn't a timeout in the DNS > module (and sockets in general??). If it uses TCP, there will be a timeout on the TCP connection. If it uses UDP, it apparently doesn't timeout, although it would possible to rewrite it to use a timeout. > Is there an easy way to wrap something in a timeout that'll exit > gracefully without actually having to change the code in the DNS > module? I don't think there is. It may be possible, but it is not easy. Instead, I recommend you try to use the DnsAsyncRequest, passing a "done" handler. It looks like the code hasn't been tested that much, so you may need to dive into the details even if you take this route. HTH, Martin From tim.one at home.com Sun Nov 4 18:57:20 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 18:57:20 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: Message-ID: [Marcin 'Qrczak' Kowalczyk] > Among these types in OCaml: > 1. int: builtin, machine word size, > 2. big_int: unbounded, > 3. num: union of int, big_int and ratio, > all have different meanings of division and modulus! Yet another reason to avoid OCaml . > I wasn't aware that there are more than two variants in use. > > In each case separately division is consistent with modulus. > The following conditions hold in the respective cases: > 1. (-x) div y = -(x div y) > 2. 0 <= x mod y < |y| > 3. x div y = floor (x/y) > > Intel processors and C99 do the first variant. Python does the third > variant. Knuth says the third variant is the true one. In SML and > Haskell the first variant is called quot/rem and the third is called > div/mod. > > I recently needed to express quot/rem and div/mod in terms of the > first and the second variant. I think I haven't seen the second > variant before. Me neither. There's a fourth variant, most useful with floating types, where x%y is defined to be: x - round_to_nearest_or_even_integer(x/y) * y where that expression is mathematical (exact; not using machine fp or integer ops; the infinite-precision *result* is exactly representable as a machine float). The useful property that follows is: |x%y| <= |y|/2 and that's "useful" because floating mod is most often used for some flavor of argument reduction, and you usually want the absolute value of "the leftover part" to be as small as possible (e.g., to speed convergence of a series expansion). Python's choice sucks for floating mod, because x%y in Python cannot always be exact. For example, x = -1e-300, y = 1e300. The exact "floor mod" of x%y is then 1e300-1e-300, and floats are a few thousand bits shy of being able to represent that . So we get this absurdity instead: >>> divmod(-1e-300, 1e300) (-1.0, 1.0000000000000001e+300) >>> Curiously, the C99 "trunc mod" doesn't suffer this problem, basically because the sign of its result is taken from x instead from y (so whenever |x| < |y|, C99 x%y can return x without further ado; else |x| >= |y|, and then exactness is easy (albeit tedious) to achieve). So I'm not at all averse to different mods for different types, and actively wish Python could change its story for float mod. But having different flavors of % for different integer types seems at best mildly nuts. consistency-is-often-a-dumb-idea-ly y'rs - tim From peter at engcorp.com Thu Nov 29 23:00:30 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 29 Nov 2001 23:00:30 -0500 Subject: New updates needed for an old computer language humor piece References: Message-ID: <3C07045E.957F2DD6@engcorp.com> (Will I be the first? Not bloody likely! :-) Ric Werme wrote: > > TASK: Shoot yourself in the foot. [Note: I'm one of Python's biggest fans, but the original was universally disparaging!] Python: You fire the gun, but the bullet travels so slowly towards your foot that you get tired and leave. Python: You insert the bullet into the gun but because there were actually TAB characters in the barrel instead of spaces, the gun jams with an IndentError. Python: You try to load the bullet into the gun, but Guido pulls it away from you and gives you version 2.0. You try to load the bullet into that gun, but he pulls it away again and gives you 2.1 and the gun rejects the bullet. You get another bullet and try again, but he gives you the beta for 2.2 and this time the bullet gets lost inside. Python: You're new to shooting. You start to load the bullet, but then realize the gun does not have a safety on it so you dutifully report your brilliant and original discovery in comp.lang.python and after the thread finally dies out you have forgotten to shoot yourself in the foot. (I note wryly that in no case does Python actually allow you to shoot yourself in the foot! ) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From cs1spw at bath.ac.uk Fri Nov 30 16:37:54 2001 From: cs1spw at bath.ac.uk (Simon Willison) Date: 30 Nov 2001 13:37:54 -0800 Subject: Design tips requested for OOP forum system (using pickle) References: <56zN7.139$Jm.5630@stones> Message-ID: "Graham Ashton" wrote in message news:<56zN7.139$Jm.5630 at stones>... > As you're doing it as a learning exercise, try playing around with > different implementations of your Forum class - don't fix it's internal > design this early. Decide on your initial interface for your Forum class > and then build things that talk to it. Then play around with the inner > workings of the Forum class to see how best to implement it. Thanks for the tip! - I like the idea of a class with a well enough defined interface that I can majorly alter the internals without the outside layer (handling presentation and so forth) knowing that anything has changed. I guess that's where encapsulation becomes important (I'm still getting the hang of important OOP concepts). > I'd start by storing all data about a post > in the Post object and throw the User object concept in the bin for a bit. > Adding it later would be a useful exercise in refactoring if you decide > you really want it. I've decided to store two pieces of information with each post - the name of the user and a flag for registered / unregistered - that way if the "registered" flag is set I know further information can be found about the user who wrote the post by searching for a user account with that unique username (the unregistered flag is there because I don't want to force people to register for some forums e.g "Site Suggestions"). > http://ootips.org/ Great link! - Thanks :) I had a play around in the interactive prompt earlier today and was blown away by how incredibly easy pickle is to use - I've decided to start hacking and see what happens. I'll post again once I've got something to demonstrate, thanks for all the advice. Cheers, Simon From grey at despair.dmiyu.org Wed Nov 21 19:25:38 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Thu, 22 Nov 2001 00:25:38 -0000 Subject: Non-Indented python References: Message-ID: On Thu, 22 Nov 2001 10:19:24 +1100, Delaney, Timothy wrote: > If you use spaces everywhere, you are at the mercy of other code that > doesn't use the *same number* of spaces for indentation. For example, if you > use four spaces for indentation, and you cut and paste code that uses two > spaces per indentation, nothing will work. You will need to reformat one or > the other before copying the code. Or just reformat after copying. You know, something like this: %s/ / /g or %s/ / /g Not perfect, no, but hey, it's just before Thanksgiving and don't want to get more involved. Point is tabs are evil. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From peter at engcorp.com Mon Nov 12 01:09:52 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 12 Nov 2001 01:09:52 -0500 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> Message-ID: <3BEF67B0.31ED5766@engcorp.com> Lemniscate wrote: > > I made a program that takes input from a file (text file with \n > splits). I search a public database and find more links (using the > urllib.urlopen function). I want to plug these links into Excel and > have them as functional links, but all I get is text (a Unicode > translation thing, I assume). You don't say how you are getting the links into Excel? Are you using the win32com package and using the Excel Object Model directly from Python? If that's the case, you need to look up the relevant information in the Excel docs. I found this tidbit: """ Use the Add method to create a hyperlink and add it to the Hyperlinks collection. The following example creates a new hyperlink for cell E5. With Worksheets(1) .Hyperlinks.Add .Range("E5"), "http://www.gohere.com" End With """ > Is there a way to modify the output so > that they will show up as links in Excel? I can send my code to > anybody who wants to see it (it is big and hairy so I don't want to > waste the space here). Big and hairy isn't good, but can't you summarize the relevant portions and post them? It takes a little work, but ensures the quality of the answers is higher... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From matju at sympatico.ca Sun Nov 18 18:22:01 2001 From: matju at sympatico.ca (Mathieu Bouchard) Date: Sun, 18 Nov 2001 18:22:01 -0500 Subject: [ruby-talk:25779] Scripting for both object and non-object (fwd) Message-ID: On Mon, 19 Nov 2001, Ed Ohsone wrote: > I would like to know names of general purpose scripting languages which > are capable of going both object and non-object oriented. > I know tcl is one of that kind. > If you know any others, please let me know URL of their home pages. > The reason I am asking this question is we want to select > a language which best suits our future projects. > One of their requirements is freedom from object-oriented shackles. > Object-oriented design is a great idea but we are going to waters > where it can be impediments. Object-oriented programming is an extension of structured imperative programming. I guess it could be called "more structured". Everything that structured programming is good for can be done as easily in many OO languages. Some other OO languages make it a bit more difficult, but that's usually only two more lines to add. I can say that in both Ruby and Python you can define a plain procedure as easily as you'd do in Perl and Tcl, even though the former two are pure OO languages. In any case, making things more OO is not an excuse for making them more difficult (and actually it should be the opposite: easier) ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju From h.jehadalwan at student.kun.nl Tue Nov 13 07:46:52 2001 From: h.jehadalwan at student.kun.nl (husam) Date: Tue, 13 Nov 2001 13:46:52 +0100 Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> <3BED54C2.1010608@sci.kun.nl> <3BEFD59B.9000709@sci.kun.nl> Message-ID: <3BF1163C.9000502@student.kun.nl> John Roth wrote: > "husam" wrote in message > news:3BEFD59B.9000709 at sci.kun.nl... > >>John Roth wrote: >> >> >>>"husam" wrote in message >>>news:3BED54C2.1010608 at sci.kun.nl... >>> >>> >>> >>>>yes, i understand the general defenition of data bases and of data >>>>structures. i should in fact put the question like this: >>>>is a given dictionary or list of a set of data, a data base? >>>> >>>> >>>> >>>In some respect, it depends on your point of view. All of the >>>data structures quoted in the previous articles in the thread >>>are in fact collections with different access policies. Data bases >>>are also collections with different access policies (SQL being >>>by far the most popular one). >>> >>>I normally think of a data structure as an abstract description >>>of a way to organize a collection, a collection as a concrete >>>example of a data structure with specific data that is in >>>memory, and a data base as something that is managed >>>by an external piece of software, called a 'data base >>>manager.' >>> >>>John Roth >>> >>> >>> >>> >>ok, the thing that i can make up from this discussion is that the >>difference between data base and data structures (list, dicts and >>tuples) lies in the usage policy. i mean data access and data >>manipulation methods differe, but they might resemble each other by >> > the > >>way data is organized. to be more specific, i have builed a small >>application to manage my audio cds. i made two programs in the first >> > one > >>i stored the cds and programs in lists. the length of main_list >>represent cd numbers, and each cd number is a list of the names of the >>audio tracks in that cd. in this program i can manipulate the items in >>any way i desire. in the second program i organized the cds and the >>audio tracks in dictionaries. to go back to the subject and according >> > to > >>what i understood i can now call my application is a data base >> > program, > >>or my cds are organized in a data base! right? >> > > Since there're out there on a permanent file, that's technically > correct. The formal notion of a data base requires that other programs > be able to get at the data with 'relative' ease, which is why most > people don't really regard a flat file as a data base. > > John Roth > >> > > ok, now it's clear. thank you all for your contributions. From sasoft at gmx.de Thu Nov 22 12:54:24 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Thu, 22 Nov 2001 12:54:24 -0500 Subject: RogueLike Games in Python In-Reply-To: <3BFC9160.24AFA11A@alcyone.com>; from max@alcyone.com on Wed, Nov 21, 2001 at 09:47:12PM -0800 References: <3BFC9160.24AFA11A@alcyone.com> Message-ID: <20011122125424.A13679@cruciatuz.de> On Wed, Nov 21, 2001 at 09:47:12PM -0800, Erik Max Francis wrote: > "A. Keyton Weissinger" wrote: > > > Anyone know of any written completely (i.e. not just partially) in > > Python? > > > > Thanks in advance... > > I don't believe there are any, although there are a few in progress. > You can check in rec.games.roguelike.development for more information. > > As a side note about the sad level of understanding of Python in the > world, there was a thread in that newsgroup about how BASIC would be a > superior choice for creating a Roguelike than Python ... I started to implement something like that in python, but i'm not skilled enough to code a robust game engine (threading-problems, server/client problems, KI problems, lack of gameplay etc.). Anybody who's working at this kind of game in pure python? I'm highly interested in this, too. -- Stefan Antoni ---------------------------- Don Nov 22 12:48:40 EST 2001 _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \ From max at alcyone.com Wed Nov 21 17:29:23 2001 From: max at alcyone.com (Erik Max Francis) Date: Wed, 21 Nov 2001 14:29:23 -0800 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <9thaol$opg$1@newstest.laserlink.net> Message-ID: <3BFC2AC3.8EE700B0@alcyone.com> Michael Morgan wrote: > I ran across this link though I have not used it. I'd be inclined to > agree > with the other response that the syntax is just too tough. > http://oomadness.tuxfamily.org/p-genetic.php Note that module is for genetic algorithms, not genetic programming. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From uwe at rocksport.de Sun Nov 18 15:26:06 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 18 Nov 2001 20:26:06 GMT Subject: nice python solution Message-ID: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> Hi, i there a nice python shortcut for: if idx=0: a=val elif idx=1: b=val ??? I tried (a,b)[idx] = val but this does not work, i get an error message. Greetings, Uwe. -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From anthony at interlink.com.au Wed Nov 21 02:22:42 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Wed, 21 Nov 2001 18:22:42 +1100 Subject: DNS, DB server based on Python? In-Reply-To: Message from Brian Lee of "Wed, 14 Nov 2001 16:46:11 +0900." <20011114164611.A18129@jupiter.senux.com> Message-ID: <200111210722.fAL7Mgo09283@mbuna.arbhome.com.au> Adding a DNS server is part of the goal for pydns at some point. Anthony >>> Brian Lee wrote > I'm looking for DNS and DB server based on Python language. > I use bind version 9 and mysql 3.24 on Linux but want to change > other server which is coded by Python language. > > Performance and function of the servers is not important for me. > I want to try to read server code in Python. > > Any comments will be helpful for me. Thank you. > > ps. I don't care the database is rdbms or not. > > -- > Brian Lee - http://www.senux.com/ > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Anthony Baxter It's never too late to have a happy childhood. From shalehperry at home.com Mon Nov 26 17:16:21 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Mon, 26 Nov 2001 14:16:21 -0800 (PST) Subject: calling method on dynamically loaded module In-Reply-To: <3c02bb13$0$11289$39cecf19@nnrp1.twtelecom.net> Message-ID: On 26-Nov-2001 Eric Cifreo wrote: > Hello all, > > I'm trying to dynamically load a set of modules and then call a specific > method on each one. For now there's only one module in the list. > The module seems to be loading correctly, but then the method is not found. > There IS a 'perform' method defined in the loaded module. > evil code I have: d = {} exec $mod in d d['perform'} I could not find the actual code for this on my system, I have it in cvs though so if you want it I can mail it to you. Basically it imports all the symbols into the dictionary, then you can use the symbols as you see fit. From emile at fenx.com Thu Nov 8 14:10:36 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 11:10:36 -0800 Subject: Get file owner in Windows References: <8a27e309.0111081046.5bafb354@posting.google.com> Message-ID: <9selkh$12bvbo$1@ID-11957.news.dfncis.de> "R.Marquez" wrote in message news:8a27e309.0111081046.5bafb354 at posting.google.com... > Does anyone have a handy example of how to get the owner of a file in > windows NT/2000? E:\>python ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import os >>> os.popen("dir /q hack.py").read().split()[-11] 'BUILTIN\\Administrators' There's probably something somewhere in win32 as well... -- Emile van Sebille emile at fenx.com --------- From phd at phd.pp.ru Mon Nov 12 09:53:57 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 12 Nov 2001 17:53:57 +0300 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) In-Reply-To: ; from gward@python.net on Mon, Nov 12, 2001 at 09:33:08AM -0500 References: Message-ID: <20011112175357.F26476@phd.pp.ru> Hi! On Mon, Nov 12, 2001 at 09:33:08AM -0500, Greg Ward wrote: > from optik import OptionParser > [...] > parser = OptionParser() > parser.add_option("-f", "--file", > action="store", type="string", dest="filename", > help="write report to FILE", metavar="FILE") > > (options, args) = parser.parse_args() > > With these few lines of code, users of your script can now do the > "usual thing" on the command-line: > > --file outfile > > (All of these result in > options.filename == "outfile" Can it handle multiple arguments for an option? --file outfile1 outfile2 Or mix options and arguments? --file outfile infile -q Handle multiple args with the same name? --file outfile1 -f outfile2 Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fperez528 at yahoo.com Wed Nov 14 16:18:26 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 15 Nov 2001 20:46:26 +2328 Subject: popen on Win 9x? References: Message-ID: <9t22ac$qg7$1@peabody.colorado.edu> RPM1 wrote: > Goal: Write a python program that can call two other C programs and interact > with the stdin and stdout of the C programs on Win 98. > [snip] >From what I understand, pipes under Win9x aren't exactly what you expect if you come from a 'real' OS background. So there's a good chance your problems are with the underlying OS, not your code. I'm sure you'll get more detailed answers from people who've dealt with win9x pipes in depth soon. This is just a generic heads up. Cheers, f From brueckd at tbye.com Fri Nov 30 21:59:45 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Fri, 30 Nov 2001 18:59:45 -0800 (PST) Subject: A modest indentation proposal In-Reply-To: Message-ID: On Fri, 30 Nov 2001, Erann Gat wrote: > > Sure it is, otherwise you've also just disqualified every other language > > in existence. You said they also like C++. > > Yes, but it's important to understand *why* they like C++. They like C++ > because "everyone uses it." That fact alone can overcome nearly any > technical objection. In which case changing Python doesn't help you much. ;-) > That depends on one's goal. My goal is to convince the Powers that Be > here to let me write flight software in Python instead of C++. If a tiny, > inconsequential change to the language lets me accomplish that then I > think it's an excellent reason to change the language. So should an exception be made for you or for everyone who would like to introduce little tweaks to the language? Do you feel that fixing everyone's pet peeves would keep Python code clean and readable? What if I feel strongly that all class names should have the first letter capitalized? Should that be allowed in? If not, why not, if it'll help me convince others to use Python? But it gets worse than that. What if somehow your request is granted, Python gets changed, and then your Powers That Be still decide not to use Python. Suddenly, we're changing Python for people that don't even *use* it. That's laugh-out-loud funny! > Remember, there's a lot of herd-mentality reasoning > going on here. I could pitch my solution purely internally, but then it > would be "Erann's hack", which makes it bad. (Look at the reaction I'm > getting here.) Yes, people who have used Python for a long time are not exactly lining up to express favor with this idea. Maybe that means that making this change isn't such a good idea. Maybe it means that this theoretical problem doesn't actually occur in practice all that much. > Yes, I see you are beginning to understand. Fortunately, in this case the > list of nit-pick issues seems to be rather short. There's not a whole > laundry list of issues, just this one. Unfortunately, it seems to be a > potential show stopper. Trying to change Python is not the right approach. If nothing else, it's reinforcing your boss' irrational thought process. Anytime I've successfully "gotten permission" to use Python in a professional development environment it has been through showing the benefits, by giving them working code. Frankly, if I were your boss, I'd be frightened of a language where you were able to convince the language creators to change it because I thought of something I didn't like about it. Now *that* would be a decent reason to avoid Python. > > Not that I even have any say in whether or not the suggestion would ever > > be considered, > > Oh, but you *do* have a say because the people who make the decisions here > listen to you. Not directly, of course, they listen to the "buzz", Sometimes, but I'm very thankful for all the times Guido et al choose to ignore the "buzz". He's the BDFL for a reason. For me a lot of Python's "goodness" is rooted in the fact that Guido did not try to make a language that is all things to all people. > No, by their reasoning they should use computers because everyone uses > computers. They should use C++ because everyone uses C++. Should they > use Python? Well, very few people seem to use it (relatively speaking), > but it seems basically OK, kind of like Perl, which everyone uses and that > makes it OK, but it's got that weird indentation thing going on, and that > makes it suspect. Where's the logic in making the clear-thinking people bend over backwards to please the ones with a goofy thought process? Makes no sense to me. > Now from here on how the story goes is up to you. If you simply insist > that the problem doesn't exist you will lose, at least in the short run, > because for the moment "they" *just know* that it's a problem (in much the > same way that they *just know* that C++ *isn't* a problem). If, on the > other hand, you can show that the community recognizes the problem and has > a solution then you win. You are the community. It's up to you. Huh? This is getting silly. I lose because the language doesn't evolve to fix a problem I don't have? I lose because Python maintains its integrity in the face of irrational people who don't even use it? Why don't you go onto Sourceforge and look at some of the open bugs, or look at the list of upcoming features. Every item on that list will provide far more value to far more people. If nothing else, submit your own patch of the fix, or offer someone money to make a custom version of Python for you. You're asking people to use their donated time to "fix" something that nobody else wants, to do work that doesn't actually benefit them because what it would fix doesn't actually cause any pain. Doesn't it make far more sense to work on things that are causing real problems in real programs, rather than problems that might occur in programs that haven't even been written yet by people who might not choose to use Python anyway? -Dave From grante at visi.com Tue Nov 6 22:29:05 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Nov 2001 03:29:05 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: In article , Tim Peters wrote: > [John Roth] >> ... >> See my comment above. I'm not refering to integer division. >> We've been around that circuit too many times to make >> it really appealing to do so again. > > That's why I pointed out in my first reply that this thread had become > *about* integer division. Don't all c.o.l.p threads eventually end up being about integer division? ;) It could be worse, in most other newsgroups all threads end up being about Hitler... -- Grant Edwards grante Yow! Okay... I'm going at home to write the "I HATE visi.com RUBIK's CUBE HANDBOOK FOR DEAD CAT LOVERS"... From tim.one at home.com Sat Nov 3 15:17:29 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 15:17:29 -0500 Subject: MMap "access" keyword, choice of exception class In-Reply-To: <7xu1wbzmg1.fsf@ruckus.brouhaha.com> Message-ID: [Tim] > SystemError is used for things that "can't happen" ... > For example, if the Python Virtual Machine sees an undefined > bytecode; it's akin to an assert. [Paul Rubin] > Note that user code can create undefined bytecode, e.g. by > demarshalling something that looks like a valid code object but isn't. > So I hope SystemError isn't like an assert in the sense that bytecode > validity checking is disabled when the debugging flags are turned off. No, it isn't -- we use "assert" when we want "assert" . From maxx at easynews.com Tue Nov 13 12:30:39 2001 From: maxx at easynews.com (Max) Date: Tue, 13 Nov 2001 17:30:39 GMT Subject: Request for Validation of Python as Development Language References: Message-ID: <6cl2vt4ulnv5ei61cs9i7q2o34co9aem6u@4ax.com> Python is compiled to byte code, and run through a byte code interpreter. Essentially, so is Java, and .NET. I think of "scripting" is simply one of Python's "modes", included alongside of full-scale application development, and prototyping. In reality, Python is _more_ capable than languages like Java, simply because I can choose to develop a complete end-to-end solution, or a simple script to get a simple job done. I would never think to use Java or C# to write database maintenance scripts, but I would not have many reservations about writing a database application in Python. My approach in advocating Python is currently "what gets the job done best ?" For me, best is defined in terms of development speed, ease of maintenance (both now and a year from now when I have lost track of why I wrote the app in the first place), and portability between operating systems AND programmers (I find that understand other's Python code is easier than with most other languages). And in the end, Python plays well with others. Easy interation with Windows COM objects, and Java through Jython means that even if the rest of the camp will not "see the light", Python can still play a role with those who prefer it's advantages. On Mon, 12 Nov 2001 23:19:35 -0500, "A. Keyton Weissinger" wrote: >Does anyone have a more recent list of commercial products out there that >use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima >Online. I'd like more. > >The information in the books and the python.org site is a bit dated. > >I'm pretty new to the language and I'd like to use it for more stuff at >work. I'm beginning to feel some of the stigma of it being a "scripting >language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for >those who care) and I'd like to introduce Python into the mix. But I say >"scripting language" and people head to the hills yelling "PERL!" which is a >bit disconcerting (especially since I like Perl too, though not as much as >Python). They need to hear "object oriented application development >language" or I need to buck up and realize I'm barking up the wrong tree. > >Thank you! > >Keyton > From dale at riverhall.NOTHANKS.co.uk Fri Nov 23 10:31:50 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Fri, 23 Nov 2001 15:31:50 +0000 Subject: What's this: run_pyc_file: nested_scopes: 0? References: <99ksvtsp9uipajsfkqehgbi9hc0f8el4mq@4ax.com> <3bfe5e53$1@brateggebdc5.br-automation.co.at> Message-ID: "Werner Schiendl" wrote: >Hi, > >this message is printed when you specify the flags parameter to a call to > >PyRun_SimpleFileExFlags >PyRun_AnyFileExFlags > >this functions are used, an a flags parameter is passed, in Py_Main, the >function that actually provides the entry for the python executable. > >How do you run your code? > >From a cmd prompt: python module.pyc args... Under Windows 2000 >If the messages bothers you, you should be safe removing the line > > fprintf(stderr, "run_pyc_file: nested_scopes: %d\n", > flags->cf_nested_scopes); > >in line 1079 of the file Python/pythonrun.c. > We have neither the building-Python knowledge or the time to start meddling with the source code - but we really need to get rid of this before we can start shipping this code. Is that my only option? -- Dale Strickland-Clark Riverhall Systems Ltd From liyan at lm365.com Wed Nov 14 14:43:19 2001 From: liyan at lm365.com (liyan at lm365.com) Date: Wed, 14 Nov 2001 14:43:19 -0500 Subject: ±¬Ð¦Ê±ÊÂÂþ»­ 11-14 Message-ID: An HTML attachment was scrubbed... URL: From tim.one at home.com Tue Nov 13 00:22:30 2001 From: tim.one at home.com (Tim Peters) Date: Tue, 13 Nov 2001 00:22:30 -0500 Subject: How much is set in stone? In-Reply-To: <9sq94c$lim$1@slb1.atl.mindspring.net> Message-ID: [Andrew Dalke] > I've been involved with c.l.py for 6 years. I recall reading the > documentation that pickles don't save code objects so should be > safer than marshalls for sending data between intelligent agents. > > I had always assumed it was safe. It wasn't until this thread > came up that I knew there was a problem. (Eg, elsewhere I posted > a pickle that could be used to remove an arbitrary file.) Oddly enough, cPickle rejects that pickle (it only deletes the file when using pickle.py). > So I don't think it's common enough. Now I need to revisit how > I've done some of my quick&dirty network protocols (pickles over > an http session) as I now know it's highly insecure for both > the client and the server. On the bright side of darkness , not all of cPickle got documented. We'll try to repair that for 2.2. In particular, you can set a find_global attribute on a cPickle Unpickler to supply your own function for resolving names, and of special interest is that if you set it to None, the Unpickler won't import modules or unpickle class instances at all. You could, of course, also supply a function that accetps only a set of blessed names (etc). hiding-security-is-our-middle-name-ly y'rs - tim From phr-n2001d at nightsong.com Thu Nov 15 21:13:37 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 18:13:37 -0800 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> Message-ID: <7xu1vvo432.fsf@ruckus.brouhaha.com> I think it's more important to optimize locals and class attribute references (local.x.y.z), than globals. From vb_guy at email.com Sun Nov 25 17:23:50 2001 From: vb_guy at email.com (proudmonkey) Date: 25 Nov 2001 14:23:50 -0800 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> Message-ID: <9c374327.0111251423.2455749b@posting.google.com> Simple question (unless you know as little about this as I do) I have a validated xml document that resembles an outline. As a matter of fact it is outline. What technologies are most appropriate for creating a simple web-interface that would allow users to add/edit this xml document? I once created an asp application that used xml as a "data island" within an html page, and css stylesheets and your standard javascipt to format and present the data. Basically I queried an access db, and formated the recordset as an xml string, and used that string as a 'data island' within the html page...(?,..it was last year). Than any modifications were in the form of insert sql statements....and the sql-->xml-->data island circle continued... My quesiton to anyone willing to listen....What is NOW the most accepted means of editing an XML document through a web-browser?!?!? Any suggestions will help to advance the common-good by contributing to the improvement of the company to which I am presently consulting. From a11w at SoftHome.net Fri Nov 9 13:47:12 2001 From: a11w at SoftHome.net (Jiba) Date: Fri, 9 Nov 2001 13:47:12 -0500 Subject: [website] OOMadness site open ! OO stuff and genetic algo. Message-ID: <3bebd005$0$8744$7a628cd7@news.club-internet.fr> I've just opened by website OOMadness at : http://oomadness.tuxfamily.org/ There's currently 2 interesting Python packages : ----------- PyObjTool 0.1 ----------- WHAT IT IS : Different interesting modules for extreme OO programming ! EventObj : add change-event to any Python object, so you will be notified for all object modification. TreeWidget : (yet another) tree widget for Tkinter; this one is optimized for big number of nodes (10000+). EditObj : edit any Python object in a property list. Support also edition of lists and dicts. (yes, it is what java calls a "bean editor", but for Python !) ----------- Genetic 0.1 ----------- WHAT IT IS: Genetic algorythms in Python. I do not pretend to follow exately nature laws, but rather to try and experiment new Python programming ways ! There's also a module for genetic programming, but result are disappointing... The package includes several Tkinter demos (TSP, ...), enjoy ! --------------------------------- Jiba From mwh at python.net Tue Nov 13 13:16:08 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 13 Nov 2001 18:16:08 GMT Subject: input References: <9srncp$15ljf7$1@ID-69142.news.dfncis.de> Message-ID: "Andreas Penzel" writes: > Hello NG! > > I am new in the world of python. > First I made some Tuturials, but what I could not find: > > How to get an input from the console? raw_input()? Cheers, M. -- The rapid establishment of social ties, even of a fleeting nature, advance not only that goal but its standing in the uberconscious mesh of communal psychic, subjective, and algorithmic interbeing. But I fear I'm restating the obvious. -- Will Ware, comp.lang.python From skip at pobox.com Thu Nov 15 10:14:57 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 15 Nov 2001 16:14:57 +0100 Subject: scope question In-Reply-To: <9t0j1i02oob@enews1.newsguy.com> References: <9t0j1i02oob@enews1.newsguy.com> Message-ID: <15347.56305.701497.94489@beluga.mojam.com> glenn> To close out the cursor and the database connection the cursor is glenn> passed to the close method. How do I get this to work? I find glenn> that I cannot simply do this: glenn> def close(cursor): glenn> cursor.close() glenn> db.close() glenn> This fails with a NameError: global name 'db' is not defined. That stands to reason. Unless the name db is in the module scope of the close function, you won't find it. Why not just pass the db object into the close method and simply delete the cursor object? I normally use many cursors per db connection. It's not obvious that you'd want to delete them at the same time anyway. I've never closed a cursor object explicitly. Failing to close it doesn't create a memory leak, with or without gc enabled. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From kosh at aesaeion.com Wed Nov 28 08:36:15 2001 From: kosh at aesaeion.com (kosh at aesaeion.com) Date: Wed, 28 Nov 2001 06:36:15 -0700 (MST) Subject: windows to linux pickled objects? In-Reply-To: Message-ID: On Wed, 28 Nov 2001, Stephen Boulet wrote: > Thanks to you both for the responses. > > But is writing in binary mode supported under linux? The tutorial says: > > << > On Windows and the Macintosh, 'b' appended to the mode opens the file in > binary mode > >> > > I tried it on linux and the program did run, but the size of the pickled > file only went down from 8183905 bytes to 8180057 bytes, and the file > wasn't binary at all. Maybe the size difference can be explained by the > lack of carriage returns. ;) > > It would be nice if the binary option worked on linux... Actually it makes no difference on the various unix systems. The size shouldn't have actually changed at all AFAIK. On a unix system binary/ascii are the same thing. So you just write to a file and setting it to binary on unix does nothing so yes it is portable since both methods of writing are the same. From neal at metaslash.com Thu Nov 15 11:45:14 2001 From: neal at metaslash.com (Neal Norwitz) Date: Thu, 15 Nov 2001 11:45:14 -0500 Subject: convert a string to a method call ? References: <25SI7.32$Qh1.10549@newsfeed.slurp.net> Message-ID: <3BF3F11A.C7FA3875@metaslash.com> Bruce Edge wrote: > > I have an object, say xObj, which has a bunch of methods. > I have the method I want to call in a string, say str. > > How do I call method str on xObj? method = getattr(xObj, 'str') method() # or apply(method) Neal From emile at fenx.com Mon Nov 5 14:23:29 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 5 Nov 2001 11:23:29 -0800 Subject: Question: Error or misconcept References: <3be65da4$1_3@corp-goliath.newsgroups.com> <9s62qa$11k821$1@ID-11957.news.dfncis.de> <3be69395_1@corp-goliath.newsgroups.com> <9s65ru$10mk5k$1@ID-11957.news.dfncis.de> <3be69dd1_5@corp-goliath.newsgroups.com> Message-ID: <9s6or0$123sot$1@ID-11957.news.dfncis.de> "K?roly Ladv?nszky" wrote in message news:3be69dd1_5 at corp-goliath.newsgroups.com... > Thanks indeed, all clear now. It has really been a misconcept of mine. > Could you perhaps help me with the __dict__ question? To restate the question: > Processing the object's __dict__ special attribute seemed to be a good > choice. > > It works fine for the class: > > class c1: > a1=0 > def f1(self,a): > self.a1=(a) > > c1.__dict__ ==> {'__doc__': None, '__module__': '__main__', 'f1': f1 at 012E0BFC>, 'a1': 0} > > Trying to use it for an object results in an empty dictionary: > > o1=c1() > o1.__dict__ ==> {} > > Referring to an attribute of o1 through the dictionary seems to sortof > refreshing the dictionary: > > o1.__dict__['a1']=2 > o1.__dict__ ==> {'a1': 2} > > Is it a misconcept of mine about __dict__? If it is, what's the right way to > enlist an arbitrary object's attributes, methods? Generally, dir(obj) is a good place to start, as it considers more that just __dict__. But, be careful with introspection. There is a difference between attributes of an object, and what that object can return. Consider the following: >>> class C: pass ... >>> def gg (self,var): ... try: ... return globals()[var] ... except KeyError: ... raise AttributeError, var ... >>> C.__getattr__ = gg >>> >>> c = C() >>> c.i Traceback (innermost last): File "", line 1, in ? File "", line 5, in gg AttributeError: i >>> i = 12 >>> c.i 12 >>> dir(c) [] >>> c.__dict__ {} >>> c.__class__ The same way that c.i returned 12 when i was not found in dir or __dict__ of c or C, __class__ appears as an attribute of c. If you want to seriously get into introspection, learn from the relevant sections of code that attempt it. IIRC, most of the python ide's provide this ability. Remember though, to quote Guido from earlier this summer when asked of the possibility of some form of: > def attrs(x): > return [y for y in all_possible_strings if hasattr(x, y)] Guido replied: In general, this is as impossible as it ever was -- you won't be able to tell *for sure* whether an object has an attribute x, since __getattr__ may be dynamic. > What is 'Bases-search-order-subject-to-python-release-ly y'rs' ? > Look up the section titled _MRO: Method resolution order (the lookup rule)_ in PEP 253 at http://python.sourceforge.net/peps/pep-0253.html for a detailed description of this change. HTH, Emile van Sebille emile at fenx.com From sholden at holdenweb.com Wed Nov 28 22:59:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 22:59:53 -0500 Subject: Non-Indented python References: Message-ID: "Tim Peters" wrote ... > [Chris Barker] > > After reading a whole lot of sometimes ugly bickering, it seems to me > > that most of us Python users do agree on one thing: > > > > Mixing tabs and spaces is a BAD idea. > > Yup. > > > If it is true that there is general consensus about this, is there any > > movement to disallow it altogether in the Python interpreter? > > Nope. The "nanny" in "tabnanny" is there for a reason: grownups have no > problems here. > > > Personally, I would prefer that future versions of Python would allow > > ONLY tabs or ONLY spaces, but clearly there would be a major > > disagreement about which to use. > > It would be spaces -- "4-space indents, no hard tab characters anywhere" is > the coding standard for the Python library. Tools/scripts/reindent.py is > routinely run over the Lib directory to ensure it stays that way, too. > > there-hasn't-been-anything-real-to-argue-about-here-since- > 1993-ly y'rs - tim > Nice to see you raise your head above the parapet, Tim. Hope 2.2 isn't keeping you awake more than 24 hours a day. Can you confirm my suspicion that the asyncore/asynchat libraries (or something I used recently from 2.0) had mixed tabs & spaces? since-this-is-c.l.py-lack-of-controversy-won't-stop-anyone- arguing--ly y'rs - steve -- http://www.holdenweb.com/ From starx at pacbell.net Mon Nov 26 07:04:56 2001 From: starx at pacbell.net (Philip Swartzleonard) Date: 26 Nov 2001 12:04:56 GMT Subject: RogueLike Games in Python References: Message-ID: A. Keyton Weissinger || Wed 21 Nov 2001 08:01:10p: > Anyone know of any written completely (i.e. not just partially) in > Python? > > Thanks in advance... > > Keyton > I've had plans for something along the lines of a 3d roguelike (how's that for a contradiction :) + 1001 other things kinda game (Civilization like world in background, space travel + other vheicles, advanced npcs, text adventure elements, possiblity of shperical-bounding and realtime (paused like in xcom3 or not like in multiplayer) but it would break a possible text display but ... :\, etc etc etc). I've finally come to the conclusion that it's either going to be written in python using pygame and or wxwindows, or be a SDL (or glut even...) framework with an embedded interperter and .pys for all the non-display-crit stuff. (i.e. 98% of my effort, 2% of cpu time) I might be able to make an aplha by 2005-2007 or so :) (Though i should probably work on my mild- and medium-insanity ideas first: a 3d goban of coolnees and a 'bandit kings of ancent china (and every other koei game)' clone :)) end_insane_rambling_and_go_to_bed( 3 hours ago ) -- Philip Sw "Starweaver" [rasx] :: www.rubydragon.com - a few thousand lines [*BROKEN] of PHP, HTML, and CSS; but still useless* :) From phr-n2001d at nightsong.com Thu Nov 15 08:33:05 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 05:33:05 -0800 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <9t0du9$f2t$1@pea.uk.research.att.com> Message-ID: <7xbsi4cg6m.fsf@ruckus.brouhaha.com> Duncan Grisby writes: > This isn't a direct comparison, but I've done some experiments with > CORBA calls using omniORBpy. I did some tests with two 500MHz Pentium > 3 machines running RedHat 6.2 Linux, connected by 100Mbit/s switched > Ethernet. > > With client and server on the same machine, communicating via TCP > loopback, I get: If it's on the local machine, why mess with TCP at all, instead of using AF_UNIX? I'm not sure whether the OP intended to run locally tough. From logiplexsoftware at earthlink.net Fri Nov 9 15:33:48 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 12:33:48 -0800 Subject: Module for reading CSV data In-Reply-To: References: Message-ID: <01110912334801.01414@logiplex1.logiplex.net> On Friday 09 November 2001 11:20, David A McInnis wrote: > Is there a module for reading CSV files into a dictionary? Or is there a > builtin that is used in conjunction with readlines()? > > The first row of my csv file contains field names. Here's another approach using zip() which may be faster (don't really have enough data to benchmark): l = [ ['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], ] d = {} key = 0 for data in apply(zip, l[1:]): d[l[0][key]] = data key += 1 -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From frederic.giacometti at arakne.com Tue Nov 13 10:42:31 2001 From: frederic.giacometti at arakne.com (Frederic Giacometti) Date: Tue, 13 Nov 2001 15:42:31 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> Message-ID: "Michael Hudson" wrote in message news:uu1w0e0vo.fsf at python.net... > "Frederic Giacometti" writes: > > > "Michael Hudson" wrote in message > > news:u4ro58kzx.fsf at python.net... > > > "Frederic Giacometti" writes: > > > > > > [schnipp] > > > > Does this make sense? > > > > > > But isn't the point of many multithreaded apps allowing code to run > > > during blocking IO operations? Your approach would knock that on the > > > head. > > > > In the proposed design, stackless call to another thread never > > blocks the thread; it inserts a frame in one of the thread frame > > schedulers. Just as all C functions external to the Python > > interpreter core, IO functions run outside the interpreter thread. > > I must be missing something. Can you sketch how, say, socket.send() > would be implemented? Would you spawn a new OS thread for every C API > call? I'm afraid I don't understand you to this point... As I mentioned, two thread pools would be maintained. To the extent that send() is reentrant on the underlying OS, it would beexecuted in one of the threads of the reentrant thread pool. This is the 'thread pool' pattern; where threads are kept up (i.e. active) from one call to the next. It's a standard pattern and concurrent programming algorithm. Of course, this requires a non-blocking thread library (i.e. with OS support); not a 'green thread' library (blocking, no OS support). Currently, Python is always build on non-blocking threads when they exist anyway. FG From thomas.heller at ion-tof.com Mon Nov 19 13:07:22 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Mon, 19 Nov 2001 19:07:22 +0100 Subject: context-sensitive help from editor References: <9tbetv$e92$1@netnews.upenn.edu> Message-ID: <9tbhnk$1hes2$1@ID-59885.news.dfncis.de> "Mike Maxwell" wrote in message news:9tbetv$e92$1 at netnews.upenn.edu... > Is there a .HLP or .CHM file out there somewhere? Or is there an easy way > to turn a .HTML file into a .CHM file? (Or a way of passing a keyword to > Adobe Reader or GhostView, so it goes directly to the relevant place in the > doc.) You should search on parnassus (http://www.vex.net/parnassus/) for Python shelf. This will give you not only the docs (and much more) in CHM format, but also the python source code to create them from HTML files. Thomas From wurmy at earthlink.net Thu Nov 29 12:12:24 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Thu, 29 Nov 2001 17:12:24 GMT Subject: doesNotUnderstand ? References: Message-ID: <3C066C72.3D7FE250@earthlink.net> Gerardo Richarte wrote: > > > `__getattr__` is your friend. > > thanks everybody... > > >>> -1/1000000000000000000000000000000000000000000000L > -1L > > add as many zeros as you whis... > > I can undersrtand -1 >> 1000 = -1, but not -1/10000000L ... It's Python's integer division at work... >>> -1/100000L -1L >>> 1/100000L 0L >>> -(1/100000L) 0L Integer division rounds down to the nearest integer. For positive numbers, this is unsurprising: >>> 9/4 2 (2.25 -> 2), but negative numbers may not yield what you expected: >>> -9/4 -3 -2.25 -> -3, because -3 is the first integer *lower* than -2.25. I must admit, it does look strange to see things like -1/10 and get -1 back. --Hans From wurmy at earthlink.net Thu Nov 15 12:21:27 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Thu, 15 Nov 2001 17:21:27 GMT Subject: who called a function? References: Message-ID: <3BF3F982.F26FD164@earthlink.net> kosh at aesaeion.com wrote: > > How can I find out what object called a function and essentially step back > through that? At most I need to step back about 4 to 5 levels but it would > be very useful for me to find a particular object back up the list and > change behavior based on that. Mostly I just wants the self var as I step > back until I find the one I want. This comes from my now-dysfunctional snippet collection... It doesn't step back some levels like you want, but it may be helpful... ------ # 294.py # Author: Michael P. Reilly # Subject: Function which knows who has called it # Packages: miscellaneous.introspection """ : Is if possible in Python to have a function that prints the name : of the function that called it. (I'm thinking of using this in : some debugging code I want to write). The information is captured in the frames in the traceback. """ def you_rang(): import sys try: raise RuntimeError except RuntimeError: exc, val, tb = sys.exc_info() frame = tb.tb_frame.f_back del exc, val, tb try: return frame.f_back.f_code.co_name except AttributeError: # called from the top return None def f(): WhoCalledMe = you_rang() print WhoCalledMe def p(): # p calls f f() p() ------ HTH, --Hans From kseehof at neuralintegrator.com Tue Nov 27 00:04:58 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Mon, 26 Nov 2001 21:04:58 -0800 Subject: C++ debugger for python/scintilla? Message-ID: <000301c17796$09f78260$1d4bb43f@kens> Any know how I might go about implementing a C/C++ debugger in python for debugging python extensions? Is such a project being worked on? The main features that I need are: 1. place a breakpoint in a python extension source code file 2. invoke a python callback when a breakpoint (or exception) is hit 3. step through extension source code 4. access the symbol table Is anyone using PyGDB? Is it what I'm looking for? At first glance, it appears to be inside-out compared to what I want. PyGDB apparently is a python script that uses gdb to debug python code, rather than a python module that debugs extensions (in other words, PyGDB set breakpoints in python code, but I want to set breakpoints in C++ code inside extensions). Perhaps I can use gdb.py directly as a module? It should run on Windoze, Lunux, and popular Unix platforms (anywhere wxPython runs). Once the functionality is in place, I'd want to wrap it into Scintilla to add python extension debugging capabilities to a custom IDE. I'm only likely to do this project if it turns out ot be relatively easy, or someone is willing to share the cost of development, or both, otherwise it might stay on the back burner for a long time. So, does anyone else need this? - Ken Seehof www.neuralintegrator.com kseehof at neuralintegrator.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From graeme at saebex.com Thu Nov 29 07:36:50 2001 From: graeme at saebex.com (Graeme Longman) Date: Thu, 29 Nov 2001 14:36:50 +0200 Subject: M2Crypto, LDAP and python In-Reply-To: Message-ID: Here here, More M2Crypto examples please. -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Stuffed Fried Red Pepper Sent: 29 November 2001 14:30 To: python-list at python.org Subject: M2Crypto, LDAP and python Hi, Could anyone give examples of types of useful applications that they've made using M2Crypto? I'm trying to learn M2Crypto and I'm comparing it with openssl. Is there an LDAP client library for python? -Fiel Cabral -- http://mail.python.org/mailman/listinfo/python-list From emile at fenx.com Wed Nov 7 15:04:59 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 7 Nov 2001 12:04:59 -0800 Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) References: <9sacsk$r82$1@bugstomper.ihug.com.au> <8_dG7.4760$R43.760797@newsb.telia.net> Message-ID: <9sc4ea$12v0ot$1@ID-11957.news.dfncis.de> "Fredrik Lundh" wrote in message news:8_dG7.4760$R43.760797 at newsb.telia.net... > Gary Stephenson wrote: > > Umm, I'm not really sure this is a claim we should be making! Next thing > > you'll have us claiming responsibility for making disco popular - and then > > they'll just have to shoot us! ;-) > > but Steve Irwin is your fault, right? > I don't know about that, but out here San Andreas is our fault. ;-) From ykingma at accessforall.nl Thu Nov 1 14:18:28 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Thu, 01 Nov 2001 20:18:28 +0100 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <3BDF2619.E794EA01@accessforall.nl> Message-ID: <3BE19FFD.1DDE49F7@accessforall.nl> Ype Kingma wrote: > A more python-like way of changing the date format of a string could be: > > new_date = ''.join(old_date[4:5],'/',old_date[6:7],'/',old_date[0:3]) > This might even work: new_date = ''.join((old_date[4:5],'/',old_date[6:7],'/',old_date[0:3])) From export at bmatrading.com Thu Nov 15 16:46:34 2001 From: export at bmatrading.com (A) Date: Thu, 15 Nov 2001 22:46:34 +0100 Subject: Is it a job for Thread or Process? Message-ID: <3BF445CA.3859.12160B8@localhost> Hello, In my Python script I would like to start one function of this script in a different thread or process? That function sends an email. Can you please give me an example how I can start a new thread or process under Win32 systems? Is it better to use a new thread or a new process for this task? Thank you for help. Ladislav From peter at engcorp.com Wed Nov 28 20:39:52 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 20:39:52 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> <3C05758F.DBD8833@engcorp.com> Message-ID: <3C0591E8.730F8C0D@engcorp.com> David Eppstein wrote: > > Peter Hansen wrote: > > > > I don't understand the point. I wouldn't have expected > > anyone to type "i in range(5)" at the prompt, but simply > > "range(5)", resulting in a list, from which the hypothetical > > newbie would likely infer that the for statement was iterating > > over the items in that list. > > I take it you are viewing the syntax of a for-loop as > "for" variable "in" expression: > where "for" and "in" are keywords and expression must be something that > returns a list or iterator. So the "in" of a for-loop has very little > other than spelling to do with "in" operator for list expressions. Yes! > I would rather view a for-loop as > "for" expression: > where (currently) the expression must have as its top level operation the > "in" operation and the lhs must be a variable. The variable is set in all > possible ways that make the expression true. From this point of view, "for > x in 5" looks really ugly, and "for 0 <= x < 5" makes a lot more sense: we > now simply allow one more kind of expression in a for loop, one where the > top level is a three-way comparison and the middle side of the comparison > must be a variable. I'm continually amazed at how easy it is to understand someone else's point of view when after enough discussion all the mistaken assumptions are resolved and shared semantics are established. :-) I suddenly understand the reasoning behind the suggestion, and the claimed elegance. In that light, it's quite nice. My only real objection now is that I believe my understanding of what "in" means with "for" is actually the more appropriate, and this suggestion does not fit with that view. Not to mention how long it took me to get it: it's not self-evident, at least to some people who share my starting point. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From daniell at servicefactory.se Sun Nov 25 08:25:37 2001 From: daniell at servicefactory.se (Daniel Larsson) Date: Sun, 25 Nov 2001 13:25:37 GMT Subject: Does Anybody Know How To Get Tkinter Working?? References: Message-ID: <3C00F1CB.5000107@servicefactory.se> Looks like you need to figure out where your X11 include files are stored, and then run configure with --x-includes=DIR / --x-libraries=DIR Ben Ocean wrote: > Hi; > This is my third request for help and I'm hoping someone will respond > this time :) > > I just configured Tcl--itworks--and I went to configure tk (both latest > stable distros) on my RH71 box and ran into all sorts of errors on > *make*. Both installations are in /usr/lib and I'm in as root. It exits > with Error 1. Here's how the errors start: > > [root at hermes unix]# make > gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall > -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix > -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps > -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 > -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 > -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED > /usr/lib/tk8.4a3/unix/../generic/tk3d.c > In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or > directory > In file included from /usr/lib/tk8.4a3/unix/../generic/tkPort.h:32, > from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:27, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/../unix/tkUnixPort.h:77: X11/Xlib.h: No > such file or directory > etc. etc. etc. etc. etc. etc. etc. etc. etc. > > Any ideas? > TIA, > BenO > > From lukoc at zeus.polsl.gliwice.pl Thu Nov 1 05:31:13 2001 From: lukoc at zeus.polsl.gliwice.pl (lukoc at zeus.polsl.gliwice.pl) Date: Thu, 01 Nov 2001 11:31:13 +0100 Subject: What about background? Message-ID: <200110311032.LAA14785@zeus.polsl.gliwice.pl> Hi! I would like to change background color in my Pythonwin editor (white is to sharp for me), but it's not available from options. Can you help me with this really small problem? From lac at strakt.com Tue Nov 6 08:17:17 2001 From: lac at strakt.com (Laura Creighton) Date: Tue, 06 Nov 2001 14:17:17 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Brian Elmegaard of "06 Nov 2001 08:17:10 +0100." References: <7xvggph61y.fsf@ruckus.brouhaha.com> <9s67gd$874$00$2@news.t-online.com> <7x4ro9un0c.fsf@ruckus.brouhaha.com> Message-ID: <200111061317.fA6DHHua004382@ratthing-b246.strakt.com> When my younger brother was 6 ot 7 years old, he and a friend wrote a BASIC program that was the hit of his school. He interviewed the other children in the neighbourhood and got other language translations for sentences such as ``You smell like a fart.'' and ``You peed in your shoe.'' Then children would queue up for hours in order to be insulted. They could then guess the language they were being insulted in, and if they were wrong they got _more_ insults. They could finally ask for a translation into the language of their choice. Some languages, they found out, don't _have_ a noun for fart, as I recall, only a verb. Many interesting things about languages were learned. As I recall he and his freind laboured mightily for months on this project. I am not sure if his school ever found out about it. It was _the_ _secret_ project. A mathematical ability that was unsure what division was proved to be no barrier. Thinking back on it now, I am struck by how much easier he would have had it if he had a decent exception mechanism. Laura Creighton From bryan at eevolved.com Fri Nov 30 08:40:48 2001 From: bryan at eevolved.com (Bryan) Date: Fri, 30 Nov 2001 08:40:48 -0500 Subject: CryptKit 0.9: cryptsock In-Reply-To: <200111301121.fAUBLwY28204@lap1.mtg.at> References: <200111301121.fAUBLwY28204@lap1.mtg.at> Message-ID: On Friday 30 November 2001 06:21 am, Andreas Kostyrka wrote: > Hi! > > Stupid newbie question: How does cryptsock guard against a > man-in-the-middle attack? > > Andreas Good question. This version doesn't. The next version will implement ECPAK. I am trying to stay away from CA's for now. Any suggestions? -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "The further the spiritual evolution of mankind advances, the more certain it seems to me that the path to genuine religiosity does not lie through the fear of life, and the fear of death, and blind faith, but through striving after rational knowledge."-- Einstein From mwh at python.net Wed Nov 21 13:44:27 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 21 Nov 2001 18:44:27 GMT Subject: dictionary-question References: Message-ID: Bas van Gils writes: > Now, can someone please explain why the > > foo.get("bar",0) += 1 > > won't work Because Python doesn't have a generalised notion of place. The only things you can assign to are * names * attributes * subscripts (including slices) This is fixed in the syntax. Common Lisp does have a more general notion of place, so you *can* do (incf (gethash foo "bar" 0)) (which is basically equivalent to what you want to do above), but it's a fairly complicated facility. > ... and what might be a better sollution then my current > workaround? foo["bar"] = foo.get("bar", 0) + 1 is what foo.get("bar", 0) + 1 would end up doing anyway. Well, without significant additional complexity, anyway. Cheers, M. -- Clue: You've got the appropriate amount of hostility for the Monastery, however you are metaphorically getting out of the safari jeep and kicking the lions. -- coonec -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From simuran at shaw.ca Fri Nov 23 05:29:55 2001 From: simuran at shaw.ca (Alex Rodioukov) Date: Fri, 23 Nov 2001 10:29:55 GMT Subject: PythonWin, PIL, hDIB Message-ID: <873d35n5jv.fsf@bismark.io.sys> Hello, I would like to know if it is possible to create a DIB (device independent bitmap) handle using PIL's ImageWin module and PythonWin. My problem is that I have no clue on how to get from DC (device context) handle to DIB handle. Also, my knowledge of MFC is next to nothing, so the snippet of code doing above mentioned magic would be extremely appreciated :) Also, is there a decent TIFF plug-in for PIL on win32 that will understand G3/G4 TIFFs? TIA, A.R. -- Complex problems have simple, easy to understand wrong answers. From sholden at holdenweb.com Fri Nov 2 13:28:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 13:28:09 -0500 Subject: Underscore data hiding (was python development practices?) References: <7xy9lquj5a.fsf@ruckus.brouhaha.com> Message-ID: "Cliff Wells" wrote ... > On Friday 02 November 2001 04:19, Steve Holden wrote: > > I don't see why. It's a documented part of the language, so a change would > > create backward incompatibility known to be anathema to the development > > team. > > People keep insisting that the Python development team won't introduce > changes that break backward compatability. This may be true for the most > part, but it is definitely not written in stone (or even Python). From the > 2.0 docs for socket.bind(): > > "Bind the socket to address. The socket must not already be bound. (The > format of address depends on the address family -- see above.) Note: This > method has historically accepted a pair of parameters for AF_INET addresses > instead of only a tuple. This was never intentional and is no longer be > available in Python 2.0. " > This particular example was discussed endlessly when 2.0 came out. Guido very clearly stated that the only reason he was introducing that particular "incompatibility" was to enforce what had always been intended and, I believe, documented. The 1.5.2 and prior implementations had been out of spec, and some programmers had taken advantage of that fact. So breakage only occurred when use had been made of a non-documented "buglet". It didn't help that the library used it a few times... > There are a couple of other places (which I don't recall at the moment) where > things were "fixed" in such a way that you would have to change existing > code. Granted this is a rather trivial example. However, I would definitely > be wary of making my code depend upon something like the name-mangling scheme > which is clearly a hack and actually seems a likely place to see a future > change. That's fair enough, and I'm not trying to argue that backwards compatibility is a golden rule that will be enforced forever. Simply stating that, since it *is* a documented feature of the language, there is likely to be considerable thought and discussion before removing it or changing it in ways that will introduce incompatibilities. And I would agree that, since mangled names are explicitly intended to avoid naming clashes, to actually assume that they would take a particular form might be dangerous. regards Steve -- http://www.holdenweb.com/ From sholden at holdenweb.com Fri Nov 9 16:43:28 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Nov 2001 16:43:28 -0500 Subject: WSC in python clears method arguments References: Message-ID: "T Malcolm" wrote ... > "Steve Holden" wrote ... > > "T Malcolm" wrote ... > > > I'm calling a WSC written in Python from a VBS script that is task > > > scheduled. This WSC is a "friendly" interface to the Python ftp > > > library. All is well, except for one quirk. When I call methods on > > > the WSC, it will clear the variable I pass as an argument. > > > [ Steve misunderstands the details ] > > > Well, see, the COM Component isn't a pure Python module. > All of my Python is in a Windows Script Component(WSC)...an xml file > parsed by the ActiveX Scripting engine. Classes are set off with > tags, and the COM interface is also described > using XML tags. Since this isn't a proper python class there's no > "self" first argument on the methods, thus causing half of my > problems. Everything calls, and it works just great, but it eats the > values stored in my argument variables. Blerch. So are you trying to execute Python client-side with this? Let's see some more code! What's the environment? regards Steve -- http://www.holdenweb.com/ From jorjun at mac.com Wed Nov 14 02:16:47 2001 From: jorjun at mac.com (jorjun) Date: Wed, 14 Nov 2001 07:16:47 +0000 Subject: Best language, most productive user interface? Message-ID: <3BF21A5F.8070903@mac.com> Have you tried Aqua under OS X? If so Who thinks Python would make a good client application development language for peer-peer, even office productivity, games? Who thinks Linux is going to take over the mainstream desktop? Who thinks >those< adverts are cool? :|) --unemployed From r.b.rigilink at chello.nl Mon Nov 5 20:58:14 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Tue, 06 Nov 2001 01:58:14 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> <3BE7269A.692326EF@chello.nl> <3BE734BB.51C4488D@ix.netcom.com> Message-ID: <3BE743BD.910259A3@chello.nl> Jive Dadson wrote: > > Roeland Rengelink wrote: > > > > Jive Dadson wrote: > > > You must have misunderstood what I wrote. I'm not proposing anything > > > that would make it "lowly dynamic". > > > > > > > Well, you use the term 'variable declaration' which for most of us > > carries the connotation of both the definition of a name, and a > > restriction of the type of values that can be assigned to it. aka static > > typing. > > If you had read what I wrote, you would know I didn't mean anything like > that. > Since, in the next paragraph, I acknowledged that you didn't mean that, I'm somewhat surprised by that remark. Let me quote myself: > However, I gather from the rest of your post, that you just want the > name definition part of variable declaration, and not the type > definition part. It's somewhat ironic that my honest attempt to understand what you meant by 'variable declaration' --rereading what you wrote several times-- leads to this response, and selective quoting. > > > I didn't propose anything like that. The compiler will know that > > > "initialized" is not local to init_everything because it is not declared > > > there with a "def". That has absolutely nothing to do with anything > > > outside the function init_everything. > > > > > > > Yes you did ;)] > > Did not. (Did too.) Did not. > > > > > Most local variables shadowing global names, are intended to be local. > > Therefore, the only reasonable thing for your 'option explicit' to do, > > would be to raise an Error with "undefined variable initialized in > > init_everything". > > That's right. If you had read my the message you are arguing with, you > would see that I proposed exactly that, even spelling out the syntax of > the exception message. > No, you said that it wouldn't raise an error in that case, because, and I quote: > > > ... The compiler will know that > > > "initialized" is not local to init_everything because it is not declared > > > there with a "def". That has absolutely nothing to do with anything > > > outside the function init_everything. The error you suggested was for an assignment to an undefined variable at global scope. If I understand you correctly, you're proposing that an undefined variable at local scope is assumed to be global scope, and only if there's no global definition it becomes an error. I'm saying that that's a bad idea because the missing definition at local scope would usually be a bug, which would then get hidden because there happens to be an (unrelated) global definition. You're basically replacing hard to detect bugs due to missing global statements with similarly hard to detect bugs due to missing defs. I was also implying that that's a bad trade-off because 'global' is used rarely. Have fun, Roeland -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From jmsun at bioeng.ucsd.edu Fri Nov 16 17:34:46 2001 From: jmsun at bioeng.ucsd.edu (Jeffrey) Date: 16 Nov 2001 14:34:46 -0800 Subject: Tkinter idle? Message-ID: <3daa1aa8.0111161434.775b58fa@posting.google.com> Hi All, This might be an easy question you all. I'm just looking for a way to create a function that is called whenever the Tkinter Tk() is idle. Thanks, Jeff From alanmk at hotmail.com Fri Nov 23 13:38:20 2001 From: alanmk at hotmail.com (Alan Kennedy) Date: 23 Nov 2001 10:38:20 -0800 Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: "MANUEL FERNANDEZ PEREZ" wrote in message news:<3bfd7f87 at news.airtel.net>... > Hello, > I'm looking for an editor for Python.I' m interested it works on Windows.Can > anybody help me? I find UltraEdit, which is just a text editor with some basic IDE-style facilities, to be fast quick and reliable. And it does Python syntax highlighting, with an optional download. http://www.ultraedit.com/ Alan. From sheila at spamcop.net Tue Nov 6 16:21:00 2001 From: sheila at spamcop.net (Sheila King) Date: Tue, 06 Nov 2001 21:21:00 GMT Subject: Teaching python (programming) to children References: <7xsnbs65ke.fsf@ruckus.brouhaha.com> <9s77qb.3vv4gtl.1@kserver.org> <3BE827B7.D5616361@juno.com> <9s8gql.3vv9mlp.1@kserver.org> <9s9g5l$ipf$1@nereid.worldonline.nl> Message-ID: <9s8nto.3vvbcqt.1@kserver.org> On Tue, 6 Nov 2001 21:08:13 +0100, "GerritM" wrote in comp.lang.python in article <9s9g5l$ipf$1 at nereid.worldonline.nl>: :did you have a look at the turtle package in the standard python :distribution? It does all of the "trivial" moves and more. Written by Guido. :I myself have customized it some time ago by making a dutch translation of :the commands. Yes, I've seen it. One of these days (when I get my round tuit), I will play with it a bit more. ;) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From b_lamy at club-internet.fr Sun Nov 11 23:22:34 2001 From: b_lamy at club-internet.fr (Lamy Bertrand) Date: Sun, 11 Nov 2001 23:22:34 -0500 Subject: embedding python in C Message-ID: <3BEF4E8A.E7D3C65B@club-internet.fr> I can't manage to compile my C file that use Python C functions : here is some code : #include int main(int arg, char** argv) { PyObject* p = PyFloat_FromDouble(1.0); PyObject* f = PyTuple_New(5); } I compile that file like this : gcc -g -Wall -Wstrict-prototypes -Xlinker -export-dynamic -I/usr/include/python2.2 -L/usr/lib/python2.2/config -ldl -lutil -lpython2.2 -o./test ./test.c and I have that error : /tmp/ccCbe9OS.o: In function `main': /home/blam/c/./testp.c:54: undefined reference to `PyFloat_FromDouble' /home/blam/c/./testp.c:56: undefined reference to `PyTuple_New' collect2: ld returned 1 exit status I do not understand cause the libpython2.2.a is linked and must normally defines the functions PyFloat_FromDouble and PyTuple_New ?!? - Blam From sholden at holdenweb.com Fri Nov 2 08:42:42 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 08:42:42 -0500 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> Message-ID: <3mxE7.5808$gl5.151284@atlpnn01.usenetserver.com> "Leo Lipelis" wrote ... [...] > This is also nonsense. Sure you can catch all exceptions and examine them. > But in order to code anything intelligent, you again have to know ahead of > time what these exceptions might be. At the very *LEAST* you need a list > of *all possible* exceptions in an entire Python code base, including > Python standard module library! But how much better would it be if you > could narrow the scope to the most likely exceptions. > Presumably all Python written to date is therefore "non-intelligent"? Sounds to me like you've got a project on your hands. Unless you're just bitching about this because you think somebody else will "fix" it if you make enough noise. Unfortunately (for you) the Python community is made up largely of pragmatists. Even if you could convince them that this is a major wart, the response will likely be "Yeah, I suppose it is" followed by a return to coding. The language isn't broken, it's MEANT to be like this. > except: # foo is not bound here... because I am catching ALL exceptions > if (not self.__canHandleException(foo)): # what is foo? > raise foo # and how can you re-raise it here? what is foo? > Technically, "foo" is a euphemism for "fu", meaning "fucked up". But this being Python, you should really be using "spam", "eggs" or "chips". Erm, sorry about the wilful misunderstanding: I think you are groping for raise here. See below ... > ... > > def __canHandleException(foo): > if type(foo) == BlahType: # ahh, but you have to know about BlahType! > return 1 > elif type(foo) == BuzType: # again, you have to know about BuzType! > return 1 > elif type(foo) == OtherType: # and how do you know about OtherType? > return 1 > else: > return 0 > > The above is not very smart and in fact, I don't even know how to reference > the exception object when you use catch-all "except:". Even if it can be > done, it doesn't accomplish anything. > Well I suppose something needs changing if you don't know how to reference the exception object. Probably your understanding :-) ... I agree the above isn't smart, but there is absolutely no need for it. You appear to be complaining, at least in part, about some language which we might call "partial Python". RTFM? > I'd much rather read this: > > except BlahType: > self.__handleBlahError() > except BuzType: > self.__handleBuzError() > except OtherType: > self.__handleOtherError() > > But, no matter how you write it, you *still have to know* what exceptions > you need to handle. You can't magically decide it at run time, nor do you > need to, nor should you. > The Pydiom you are struggling for, already mentioned but not spelled out by another poster, appears to be except BlahType: self.__handleBlahError() except BuzType: self.__handleBuzError() except: raise # can't handle this one, sorry The assumption here is that unknown/unexpected errors will be handled by a higher level. If they aren't, then ... crapola, your program breaks. Shit happens. > The dynamic nature of Python is absolutely not a reason for such a > lucklaster handling of exceptions in Python. Let's get this argument out > of the way, because I don't think it's even worth discussing further, > unless someone can demonstrate that in 99.99% of cases you really can't > possibly know what exceptions you should handle anyway. Again, just > because it's possible to use the language in a twisted way, doesn't mean > that the other 99.99% of exceptions should be penalized by not having a > tool that automatically warns you about unhandled exceptions. > So write the tool. Frankly I don't want to be told about all the unpleasant things I already know the real world can do to me but usually won't. Perhaps this makes me an optimist? > The very uncommon case where someone decides to create and throw random > exceptions, just for fun, should not be protected or used as an excuse to > deny us the very useful service of warning about unhandled exceptions. Nor > should this excuse be used to diminish the importance of such a tool. I > say that without such a tool, exceptions in Python are pointless at worst, > and are very awkward to use at best. Documentation is *not* the answer, > and I already explained why not in my original post. So, basically, you seem to be saying that Python is a fine language, but it won't be usable until someone retrofits an equivalent to Java's "throws" clause. Looks like horseshit, smells like horseshit, this must be ... horseshit! Python is what Python is, and nobody is trying to force it down your throat. To come whingeing to the newsgroup because it isn't enough like Java seems infantile. Ultimately you appear to want no program to ever be able to fail in an ugly way, barfing over the console, and you are prepared to force programmers to work at handling low-probability exceptions to achieve this end. As has already been pointed out, you can always take existing code and wrap it in a catch-all: try: ### "nasty" program except: print "Oh dear, the Universe just exploded" The next thing you know the "exception police" will be stopping us from writing print open("anyoldfile.txt", "r").read() because open can raise several exceptions which this statement fails to handle. Yup, that's horseshit all right. Just as a matter of interest, what would be your "approved" alternative for the above one-liner? Sorry if my response comes off as aggressive, which isn't in the spirit of this newsgroup. I'm actually trying to teach you something here! didn't-realise-i-cared-so-much-ly y'rs - steve -- http://www.holdenweb.com/ From mwh at python.net Fri Nov 30 05:18:46 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 30 Nov 2001 10:18:46 GMT Subject: Strange Tkinter behaviour References: <9u4kf5$ran$1@news.onet.pl> <9u5l8i$dh9$1@news.onet.pl> <9u7j53$lhp$1@news.onet.pl> Message-ID: "Tomasz Lisowski" writes: > Uzytkownik "Michael Hudson" napisal w wiadomosci > news:ulmgpr2i9.fsf at python.net... > > "Tomasz Lisowski" writes: > > > > > I wonder, whether there is a mechanism suspending the Tkinter event > > > loop, so that other event-based applications (not using Tkinter) > > > could get access, and perform their duties. > > > > Unix or Windows? > > Windows Ah. Can't help you then. > > > > Have you looked at createfilehandler? > > ??? What for? This does not seem to concern 'files'. No, but createfilehandler lets you do things when things turn up on file descriptors, which on Unix lets you allow for situations where: > > > other event-based applications (not using Tkinter) could get > > > access, and perform their duties. > > What are you trying to do again? I think I've got a bit confused... > > Please read my original post. Nevertheless ... I did, and was still confused. Sorry. > I am trying to make the text drawing routine (from the native CAD system > producer's module) to show the text immediately, as it used to do, when > Tkinter was not used. > > If I am using Tkinter, and the root window is functionning, the text id > displayed only if the button adding the text is clicked again. Oh. Then I think I got this confused with another thread. Sorry for the confusion. Cheers, M. -- I also feel it essential to note, [...], that Description Logics, non-Monotonic Logics, Default Logics and Circumscription Logics can all collectively go suck a cow. Thank you. -- http://advogato.org/person/Johnath/diary.html?start=4 From pj at sgi.com Wed Nov 28 01:48:49 2001 From: pj at sgi.com (Paul Jackson) Date: 28 Nov 2001 06:48:49 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: <9u21ch$bonls$1@fido.engr.sgi.com> Terry J. Reedy wrote: |> "Marcin 'Qrczak' Kowalczyk" wrote : |> |> > It's not a minority. Almost everybody uses this convention. |> |> |> There are far more people doing word processing, spreadsheet work, and |> database reports than people doing programming and Unix/Linux systems |> work. I believe that almost all of the former would find your dictum |> on tabstops to be weird and useless. Obviously Marcin didn't really mean "almost everyone". I am sure for instance that most Chinese mainland peasants don't use tabs, of any size. He meant almost everyone in some set of users. You've just shown that this set isn't those "doing word processing, spreadsheet work, and database reports" So has it occurred to you that perhaps you have misinterpreted his (admittedly ambiguous) dictum. Rather than suggesting his dictum is weird and useless, how about instead asking yourself for what value of "almost everyone" it is true. Perhaps the set of "people doing text mode editing of Python code" ? -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From katz at Glue.umd.edu Fri Nov 23 18:45:07 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Fri, 23 Nov 2001 18:45:07 -0500 Subject: RogueLike Games in Python In-Reply-To: References: <3BFC9160.24AFA11A@alcyone.com> <20011122125424.A13679@cruciatuz.de> <3BFD6670.2080704@movilogic.com> Message-ID: Hehe, I've been working on this kinda thing for a long time. I've been trying to write a Final Fantasy type clone forever. School limits my free time, however. I think.. there was some sort of project I put up on sourcefourge called FreeFantasy; the sources are there. At the moment, they are just classes for holding player/party information. I'd be happy to help you guys out this winter break. Roey On Fri, 23 Nov 2001, Ricardo Quesada wrote: > > Lucio Torre wrote: > > > i am trying to do one. i did a first attemp in python games with > > pysteroids (vampira.dyndns.org), and now im going for an elite > > multiplayer kind of game. not exaclty rogue, but multiplayer rpg... > > Hey, I'm starting a game also in pygame. > Lucio, let me know when you have something. > > riq. > > > --- for a personal reply use: Ricardo Quesada > > From peter at engcorp.com Fri Nov 9 21:48:23 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 09 Nov 2001 21:48:23 -0500 Subject: Teaching python (programming) to children References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> Message-ID: <3BEC9577.93682746@engcorp.com> John Roth wrote: > "Michael Hudson" wrote: > > Laura Creighton wrote: > > > In the same vein, if any of you out there are writing (or revising) > > > 'how to program in Python' books or papers, could you please put > > > the section on exception handling _early_, say, right after 'what > > > is a loop', rather than in the last chapter? > > > > That's what my tech review for one such said over the summer :) This > > may have been too late, of course. > > > > But Laura is right here. Very very right. > > Then possibly the decision to make exceptions classes was > wrong from a tutorial veiwpoint? Technically, it was the > right decision, but it does shove exception handling rather > late, after classes have been introduced. I wouldn't think one needs to understand classes to be able to use exceptions effectively. They just look like a simple name for a type of problem that could occur in a block of code, and one only needs to learn a little syntax to be able to use them to great effect. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From chrishbarker at home.net Fri Nov 30 13:32:38 2001 From: chrishbarker at home.net (Chris Barker) Date: Fri, 30 Nov 2001 10:32:38 -0800 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: <3C07D0C6.9493C8F3@home.net> Erann Gat wrote: > Yes, this is exactly my point. You can look at the above code and tell > there's something wrong because the braces and indentation provide > redundant information in C. This doesn't make any sense to me. On the one hand, you want to be able to cut & paste code. With delimiters defining blocks, you can do this, and have the editor fix the indentation for you. That's a nice feature, and I do use it a lot, but frankly, you can just as easily screw up the delimiters when you cut&paste (or any edit) as you can screw up the indentation in Python, and when you do so, no editor is going to correct it for you. But what it can do is make the indentation match the delimiters, and then you have a visual clue that something is ammiss: another nice feature. But wait... > No, that's not true. Consider the following two alternative code fragments: > > if x: > foo() > baz() > > if x: > foo() > baz() > > They both look right, but they can't both be right. So you don't think that indentation provides the required visual clue. So you are just plain stuck here, Nothing is going to help you. Consider: if (x){ foo(); baz;} if (x){ foo();} baz(); Both of these are valid C, but if you ask me, it is harder to tell them apart than the Python example. To fix this, you would run your editors indent_for_me function, and get this: if (x){ foo(); baz; } if (x){ foo();} baz(); Ah! now I can see the difference! So, to see the error, you need the indenting to match what the compiler will see. That is exactly what you always get with Python, without having to remember to run the editors indenter. The block delimiters are at best redundant, and at worse error producing. Also, I imagine that your co-workers do accept C, and as Skip points out: C does not require delimiters around blocks of only one line. This is going to cause a whole lot more errors than the Python way. > The reason is that I want to sell > people at JPL on the idea of using Python to write mission-critical > software, and the people I'm trying to sell are raising this objection. I > can counter this objection, but only three-quarters of the way. I can > point out that Python already provides enough redundant information to > reconstruct corrupted indentation at the beginning of blocks, but not at > the end. To reconstruct it at the end of blocks all I can offer is my > "pass/return" hack. You're barking up the wrong tree. No language provides redundant information that lets you re-contruct how what the programmer intended when that is different than the code. In C, if you screw up a }, the code is wrong and no editor is going to fix it. All the editor can do is re-indent and give you a clue that something is amiss. Python already does that by default. People are often adverse to a new thing. What I try to do when evaluating methiod A vs. method B is to find people that have used both, and ask them. Darn few people that have used Python to any degree find the indentation to be a problem. Most of us have used other languages, and tried the other way as well. Many of us found the indentation thing disconcerting at the beginning as well. By the way, if there is any problem with indentation with Python, is that tabs and spaces can be mixed, but you can turn that off by running Python with the -tt switch. (I only just learned that!) > I'd really like to be able to offer a standard > syntactic convention that is endorsed by the Python community. There is one. It's known as indentation ;-) To everyone else: Has a document been created that puts forward a cogent argument about this??? If so it needs to be featured front-and-center ont he web site. If not, I suppose we need to write it, this is the last long email I will write on the subject, and the last long thread I will follow. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From jgardn at alumni.washington.edu Thu Nov 29 21:04:07 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Fri, 30 Nov 2001 11:04:07 +0900 Subject: Python evangelists unite! In-Reply-To: <9u6fnl$b343@news1.gtech.com> References: <9u6fnl$b343@news1.gtech.com> Message-ID: <200111300207.fAU27GT22058@my.knctv.co.kr> On Friday 30 November 2001 08:18 am, Peter Milliken wrote: > I use Python as a good, quick and dirty hacking language. For real (read > production) stuff that I expect a customer to run or will require more than > a single person working for a couple of hours, I look elsewhere :-). Sure > there are examples of Python being used for "large" jobs - and very > successful they have been too - but these people are masochists (IMO) :-). > They could have been more productive with other languages that provide > better support for generic software engineering principles/standards. > Au contraire... I find large projects benefit the most from python. I have a several thousand line program that quickly became unmanageable in C++. In python, everything just blends together seamlessly. When something goes wrong, I don't have to whip out a debugger because it is so easy to read the old code, and I can follow it with my finger better than a debugger could. The parts are extremely interchangeable, modifiable, and reworkable. I can go in and change any class, even the design, and it still pretty much works. When it doesn't, it is easy enough to debug. And the function parameters? THANK HEAVENS that someone has the sense to do what python does when you have like 2 million arguments to a function - NAMED PARAMETERS. And one more word: dir()/__doc__. Every time I wonder what something does, I boot up the command line, import it, and start dir'ing it and __doc__'in it. Without even looking at the code, I have figured out the most important parts, because I have documented it as I wrote it. With C/C++ you have messy defines and stuff you have to manage in addition to the code. And the code is unreadable, even if you are a professional C++ programmer. You have to remember what members there are, whether they are protected, public, or private, and whether the other guy is a friend, child class, or nobody at all. Not to mention you have to watch the memory and freeing it all the time - but not if someone else is still using it! Keep reference counts on pieces of data that are dynamic and used by more than one pointer; then there is the list/array management that has to go on, the off-by-one errors and the every to inevitable type-casting problems... You get the idea. It's a lot to remember as you debug old code. It feels like building a house with tiny pebbles and little sticks and pieces of string. > There, that should bring the 'vangelists out of the woodwork! :-) It's just > too easy, they rise like starving trout - each language has it's strengths > and weaknesses. Python has some very nice features, I use it a good deal. > But it definitely has its place! > I agree with you that there are limitations to Python; I disagree with you that Python was not meant for large projects. > In the meantime, my advice is don't get "emotionally" hooked into the > language. Analyse its strengths and weaknesses, consider other languages > and their strengths and weaknesses and then you can hold an intelligent > conversation with another programmer! :-) > Exactly. Why do *you* use a language? The answer should always be something reasonable. It should never be emotional. Well, unless you are a teenager, then everything is emotional. =) Jonathan From phr-n2001d at nightsong.com Fri Nov 30 23:41:34 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 30 Nov 2001 20:41:34 -0800 Subject: CryptKit 0.9: cryptsock References: <200111301121.fAUBLwY28204@lap1.mtg.at> Message-ID: <7xofljlfgh.fsf@ruckus.brouhaha.com> Bryan writes: > > Stupid newbie question: How does cryptsock guard against a > > man-in-the-middle attack? > > Good question. This version doesn't. The next version will implement > ECPAK. I am trying to stay away from CA's for now. Any suggestions? CA's are for when you're trying to talk to complete strangers. If you're trying to talk to someone you already "know", the obvious non-CA authentication strategy is use a shared secret key. You still want to want DH-like key agreement for the channel encryption, because of the forward secrecy. From deoradh at yahoo.com Mon Nov 12 01:18:33 2001 From: deoradh at yahoo.com (Keith Farmer) Date: 11 Nov 2001 22:18:33 -0800 Subject: C-extension in Python -- returning results References: <3BE9F266.A2794615@ix.netcom.com> Message-ID: Results: Caching the dataset for the original function, I'm able to derive the polynomials at a rate of about 1000 sample points per 0.8 secs (hundreds to thousands of times faster than non-cached). For a 10k sample polynomial derivation, rms and max errors from the original function are on the order of 1e-7 (some 1e-5, but not many). Now to get this derivation automated and demand-driven. *That* can happen entirely in Python. Thanks for the help on the IEEE returns. The hint led me fairly quickly to the error. Keith From thomas.heller at ion-tof.com Tue Nov 20 02:53:33 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Tue, 20 Nov 2001 08:53:33 +0100 Subject: py2exe and its options References: Message-ID: <9td24h$1q16a$1@ID-59885.news.dfncis.de> "TH Lim" wrote in message news:ea8ebdc7.0111192011.72abda0c at posting.google.com... > running bdist [...] > zip -rq D:\workspace\projects\epos\bin\dist\startup-???.win32.zip . > creating 'D:\workspace\projects\epos\bin\dist\startup-???.win32.zip' > and adding > '.' to it > error: D:\workspace\projects\epos\bin\dist\startup-???.win32.zip: > Invalid argume > nt > > What went wrong here? Can anyone please shed some light here? You have been bitten by a distutils bug. Supply a version number in the scetup script and the error should go away: setup(...., version="1.0") Thomas From tundra at tundraware.com Wed Nov 21 19:50:03 2001 From: tundra at tundraware.com (Tim Daneliuk) Date: Thu, 22 Nov 2001 00:50:03 GMT Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> Message-ID: <3BFC4A3E.3790A07C@tundraware.com> Uwe Schmitt wrote: > > Hi, > > i there a nice python shortcut for: > > if idx=0: > a=val > elif idx=1: > b=val > > How about... varlist = ["a", "b"] ... whatever code you need to get idx and val ready ... exec varlist[idx] + "=val" ------------------------------------------------------------------------------ Tim Daneliuk tundra at tundraware.com From ykingma at accessforall.nl Tue Nov 13 14:16:40 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Tue, 13 Nov 2001 20:16:40 +0100 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <97ae44ee.0111121727.2c023382@posting.google.com> Message-ID: <3BF17192.F85D79DF@accessforall.nl> Stephen wrote: > > cimarron+google at taylors.org (Cimarron Taylor) wrote in message news:<29e28c51.0111120234.35d10048 at posting.google.com>... > > shriek at gmx.co.uk (Stephen) wrote in message news:<97ae44ee.0111111912.14006c7f at posting.google.com>... > > > I'm developing a program which sends messages back and forth > > > between two servers using sockets. The message format I've > > > been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" > > > > Why not save yourself a little coding and just use netstrings? > > > > more info: http://itamarst.org/multiplex > > advogato copy: http://www.advogato.org/article/212.html > > python code: http://itamarst.org/downloads/multiplex-0.2.tgz > > description: http://cr.yp.to/proto/netstrings.txt > > Thanks for pointing this out. Is anybody actually > using it though ? Would be a bit concerned with it > being 0.2 release. > It works fine. For efficiency you might need to add buffering especially on the receiving side. > I guess the main reason not to use netstrings is > the ability to interface with other servers that > don't have the netstrings package or the desire to > install it. Sockets seem to be the lowest > common denominator. You would normally use them for messages both ways, with the same python module on both sides. Have fun, Ype -- email at xs4all.nl From mlh at idi.ntnu.no Mon Nov 5 09:05:51 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Mon, 5 Nov 2001 15:05:51 +0100 Subject: Sequenced dictionaries References: Message-ID: <9s66c0$nob$1@tyfon.itea.ntnu.no> "Morten W. Petersen" wrote in message news:Pine.LNX.4.21.0111051436400.21948-100000 at bcryachts.atsat.com... > Hi, > > I'm wondering if there exists any C-based implementations of sequenced > dictionaries, i.e. dictionaries that will remember the order of the > objects 'added' on it. > > I have a pure python implementation [1] but suspect that it will be > too slow.. Alternatively, if anyone could have a look at it and give > some optimization tips, that would be greatly appreciated. Well... You might want to keep around a dictionary (redundantly) for quicker lookups, possibly a separate dictionary for sequence number or something. And you probably ought to use lists (and change them with del, insert, and the like) instead of creating new tuples all the time. I think quite a lot of speedup can be gained by modifying your Python code. > [1] http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/~checkout~/warp-framework/war p_framework/zen.py?rev=1.14&content-type=text/plain > > -Morten -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From horatio at qpsf.edu.au Wed Nov 28 05:23:33 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Wed, 28 Nov 2001 20:23:33 +1000 (EST) Subject: Scientific Libraries in Python In-Reply-To: Message-ID: On Mon, 26 Nov 2001, Travis Oliphant wrote: > SciPy is aiming to be as complete as possible --- but this really means, a > complete set of interfaces and defined user-interactions, with reference > implementations, and tests, and a packaging structure that allows other > packages to be inserted in and potentially maintained by other people. This is the ideal. A single coherent structure, where people can wander up and contribute the things they are interested in, and get the things they want, with much less pain than the current anarchy. > Many of the GSL routines are already in SciPy. Here is a detailed list: [snip snip snip snip SNIP] > So, asided from a few specialized applications, most everything in the > GSL is already included in SciPy. It wouldn't take long to add the extra > functionality if there were a demand for it. The point is well made, and thank you for taking the time to do it so thoroughly. If the things that the GSL is good for are already in SciPy, and already playing nicely with Numeric arrays, then we don't need the GSL. Removing that and PyGSL leaves only Scigraphica and MayaVi with full GPL on the "essential packages" list. (Upon a reread, GNU MP is LGPL'd). This is actually starting to look possible... > Any takers? My, what a lovely deafening silence you induced. (: Like everyone else who's listening, I only really have the time to scratch my own personal itches. These would be things like the missing constants, and the MayaVi/SciPy and Scigraphica/SciPy bridging code. Cheers, AHD From python at commandprompt.com Fri Nov 2 19:15:52 2001 From: python at commandprompt.com (python at commandprompt.com) Date: Fri, 2 Nov 2001 16:15:52 -0800 (PST) Subject: Py/QT Book in final edit In-Reply-To: <20000110035733.A13047@better.net> Message-ID: Hello, The Py/QT book (which covers QT 2 and 3) is now in final edit and will be shipping before the end of the month. For those interested you may view the book online at: http://stage.linuxports.com/projects/pyqt There is a link to preorder on the site as well. J From joonas at olen.to Thu Nov 29 12:48:39 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 29 Nov 2001 19:48:39 +0200 Subject: __setattr__ recursion problem References: <3C066BF8.8D911FCB@olen.to> <9u5rcm$beg$1@thorium.cix.co.uk> Message-ID: <3C0674F7.95B2863A@olen.to> gbreed at cix.compulink.co.uk wrote: > > In article <3C066BF8.8D911FCB at olen.to>, joonas at olen.to (Joonas Paalasmaa) > wrote: > > > The code above causes an infinite loop. How can I set an attribute of > > Class > > without overloading the __setattr__ function? Or does someone have some > > other > > solution to make that script work? > > > > > > > > class Class2: > > eggs = 1 > > spam = 2 > > > > class Class: > > base = Class2() > > def __setattr__(s,attr, value): > > if hasattr(s.base, attr): > > setattr(s.base, attr, value) > > else: > > setattr(s, attr, value) > > > > Class().foo = "eggs" > > Um, well, how about > > class Class(Class2): > pass > > ? > > or change > > setattr(s, attr, value) > > to > > s.__dict__[attr]=value Thanks From d_blade8 at hotmail.com Tue Nov 13 21:53:40 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 13 Nov 2001 18:53:40 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111122102.2058f188@posting.google.com> <3BF16381.A2E07E9A@ccvcorp.com> Message-ID: <7396d2b2.0111131853.738338ef@posting.google.com> I appreciate the help, and I figured out my problem right before your post came up. The problem was that I was trying this: xlApp = win32com.client.Dispatch("Excel.Application") xlApp.Workbooks.Add() xlApp.Worksheets(1).Hyperlinks.Add(Range("A5"), "http://www.thisisatest.com") which give an error because Range is not defined. What works, and what I learned, is that I have to, instead, use: xlApp.Worksheets(1).Hyperlinks.Add(xlApp.Worksheets(1).Range("A5"), "http://www.thisisatest.com") Please notice that I was failing to pass in the whole Range indentifier. Sorry to all, but it seems I was right in my assesment that it was something simple. (Darn it, I hate being right about stuff like that!!!). Thanks for all your help and I hope everyone has a nice day. Jeff Shannon wrote in message news:<3BF16381.A2E07E9A at ccvcorp.com>... > Lemniscate wrote: > > > Okay, my other post should be up soon, but I thought I would throw > > this out. First off, I should say I am not a VB person, so I have to > > work at converting VB code into win32client compatible commands. > > However, the Help File in the MS Excel Help has me stumpted. Here is > > the page I am using as a basis and afterwards is just a cut and paste > > of my attempts (at an interactive prompt) to insert a hyper link. > > Hyperlinks Collection Object > > > > ........ > > Use the Add method to create a hyperlink and add it to the Hyperlinks > > collection. The following example creates a new hyperlink for cell E5. > > > > With Worksheets(1) > > .Hyperlinks.Add .Range("E5"), "http://www.gohere.com" > > End With > > The trick with VB, is that many times function calls don't require parenthesis to group the parameters. This > would translate as something like... > > # xl.sheet is a Worksheet object... > xl.sheet.Hyperlinks.Add( xl.sheet.Range('E5'), "http://www.gohere.com") > > > > > > Okay, here is my interactive attempts. Hopefully, seeing these will > > help you see what I am doing wrong (I am SURE it is something simple, > > but it's ticking me off). Also, as a side note, in PythonWin, I > > cannot run a Commakepy on Excel 9 (I'll add that attempt to the bottom > > of my code so you can all see what I mean). Thanks a bunch. > > You may not have installed the type libraries when you installed Excel. Try installing more Excel > components--anything mentioning VB or macro facilities (or online help, for that matter...) > > > > > >>> from win32com.client import Dispatch > > >>> xlApp = Dispatch("Excel.Application") > > >>> xlApp.Workbooks.Add() > > > >>> OK = xlApp.Workbooks(1).Sheets(1) > > >>> OK.Range("B2:C5").Value = "Range Insert" > > >>> xlApp.Visible = 1 > > >>> xlApp.Hyperlinks.Add.Cells("B5"), 'http://www.gohere.com" > > Traceback ( File "", line 1 > > xlApp.Hyperlinks.Add.Cells("B5"), 'http://www.gohere.com" > > ^ > > SyntaxError: invalid token > > Judging from the help page you quoted above, Hyperlinks is a property of a sheet, not the app, therefore you > should (I think) be doing... > > OK.Hyperlinks.Add(OK.Cells("B5"), "http://www.gohere.com") > > And as I noted previously, Python requires parentheses that VB doesn't. > > Once you get the type library installed (and it *should* be on your Office/Excel cd--I had no problem running > makepy on Excel...) then you can use the COM object browser that's built into PythonWin to examine what functions > are available, and what parameters they expect--some of the information is kind of cryptic, though, and it helps > if you have some idea what you're looking for to begin with. ;) > > I also *strongly* recommend, if you haven't already, reading Python Programming on Win32 (by Mark Hammond & Andy > Robinson). It has fairly extensive examples of driving Excel from within Python. > > Hope this helps. If you have any more questions, feel free to ask. :) > > Jeff Shannon > Technician/Programmer > Credit International From stephen at stephencox.org Thu Nov 22 23:40:47 2001 From: stephen at stephencox.org (stephen cox) Date: Fri, 23 Nov 2001 04:40:47 GMT Subject: Editor for Python References: <3bfd7f87@news.airtel.net> Message-ID: You like it better the Wing? I'm just starting with Python and want a good IDE for Windows. -- Stephen Cox web.net geek for non-profits, political campaigns, and a few socially conscious businesses. stephen at stephencox.org "x" wrote in message news:QcgL7.98469$8a.72600976 at news1.rsm1.occa.home.com... > Look at Kmodo on www.activestate.com > > "MANUEL FERNANDEZ PEREZ" wrote in message > news:3bfd7f87 at news.airtel.net... > > Hello, From h.jehadalwan at student.kun.nl Sun Nov 4 05:35:12 2001 From: h.jehadalwan at student.kun.nl (Husam) Date: Sun, 04 Nov 2001 11:35:12 +0100 Subject: How can i retrieve a key from a dictionary? Message-ID: <3BE519E0.34312B48@student.kun.nl> how can one retrieve or select a key from a dictionary? dict={} dict[1]='one' dict[2]='two' dict.keys() will gets all the keys. but, i need to select explicitly one key for printing along its value. thanks in advance. From core.lists.python at core-sdi.com Wed Nov 28 11:29:32 2001 From: core.lists.python at core-sdi.com (Gerardo Richarte) Date: Wed, 28 Nov 2001 13:29:32 -0300 Subject: Integer Overflow References: <60FB8BB7F0EFC7409B75EEEC13E20192158C50@admin56.narex.com> Message-ID: <3C0510EC.BDACC6DB@corest.com> Bjorn Pettersen wrote: > > From: Hans Nowak [mailto:wurmy at earthlink.net] > > > > Ursus Horibilis wrote: > > > > > > Is there a way to force the Python run time system to ignore integer > > > overflows? I was trying to write a 32-bit Linear > > Use longs: What about performance when using Longs? is it as fast as using standard numbers? I wanted to disable Integer Overflow exceptions last week, and finally started using Longs, with something like (A + B) & 0xffffffff i.e. I had to force the integer overflow condition using Longs (I was implementing a blowfish cipher for a ssh client) and I think it does have a hit on performance. Performer Bye! richie --- for a personal reply use: Gerardo Richarte From mats at laplaza.org Mon Nov 26 17:02:36 2001 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 26 Nov 2001 22:02:36 GMT Subject: Keeping Python loaded References: <9tndpi$qbe$1@slb0.atl.mindspring.net> <83zo5atio1.fsf@panacea.canonical.org> Message-ID: <3c029fb8.261296394@news.laplaza.org> On 25 Nov 2001 20:39:10 -0500, Kragen Sitaker wrote: :> If you merely want to spare disk acceses under Unix, a possible approach :> might be to set the sticky bit on the Python executable. You might need :> to be super-user to do that: :> :> chmod 1755 /usr/bin/python :> :> On the other hand, on Linux at least, the disk cache maintained by :> the system might be helpful to the point of not even having to :> resort to the above trick. :If you're using a version of Unix that runs on hardware that doesn't :support paging, such as a PDP-11, then this might help. But I don't :think Python runs on any such versions of Unix, so the sticky bit on :ordinary files is purely an anachronism. Right. The sticky bit on programs doesn't do anything any longer. The UNIX VM system needs to be left to its own devices most of the time for best performance, /generally/ tricks to bind some pages permanently into memory will make performance worse rather than better. Text (code) pages of programs are shareable so one might think that leaving one copy of Python running, but not doing anything, would have sort of the same effect as the old sticky stuff. But since the VM system knows it can fetch those pages back from the disk if it needs them, if that Python process is inactive it will probably have its' pages thrown out of memory over time anyway. Also, when you launch a larger program, it doesn't all come into memory at once, so any benefits from "sticky"-like behavior are likely to be small. I believe most of the startup time is in work the Python executable does when it launches, not in the system reading some code off the disk. On the other hand, some more mature UNIX VM implementations (I think this does not include Linux, but it's hard to keep track) will hang onto pages previously used by a particular program, and if another copy of that program is started any of those pages that still apply will be reclaimed. Oops, I think I'm starting to wander... If the problem is needing to spawning a large-ish number of Python processes relatively rapidly then some tricks may indeed help, as Martin mentions. I suspect they help most because a copy of an already-set-up process (via fork) doesn't have to go through Python's setup time, but that's only a guess, I've never tried to time anything like this and I bet someone has (and will probably shoot my theories to h*ll). Mats Wichmann From loewis at informatik.hu-berlin.de Sat Nov 10 07:09:16 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 10 Nov 2001 13:09:16 +0100 Subject: GC question References: Message-ID: Kerim Borchaev writes: > Now I get it. But (may be only for me) the code above > didn't look obviously "wrong". Although it's pretty simple. And it isn't "wrong". It just creates cyclic garbage; with a garbage collector in place, this is not a problem. Regards, Martin From cnd at ecn.purdue.edu Thu Nov 29 12:38:48 2001 From: cnd at ecn.purdue.edu (Christopher N. Deckard) Date: Thu, 29 Nov 2001 12:38:48 -0500 Subject: using access databases from python Message-ID: <3C0672A8.86BD7D43@ecn.purdue.edu> Do to M$ Access's inability to correctly export data from its database, I am searching for other ways to dump an access database to tab delimited files. I was wondering if there is an access database python module. Even if it only works on Windows, that's fine. I just need to get data out of Access to put it into a Postgres database. If something like that doesn't exist, how else can I do it? -Chris -- -------------------------------------------------------------------- Christopher N. Deckard | Lead Web Systems Developer cnd at ecn.purdue.edu | Engineering Computer Network http://www.ecn.purdue.edu/ | Purdue University ---- zlib.decompress('x\234K\316Kq((-J)M\325KM)\005\000)"\005w') --- From martin.franklin at westgeo.com Tue Nov 27 08:08:33 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Tue, 27 Nov 2001 13:08:33 +0000 Subject: Determining word wraps in Tkinter text widget References: <371b5d38.0111270218.4b92b810@posting.google.com> Message-ID: <9u037i$u76$1@mail1.wg.waii.com> David Wangerin wrote: > When the text widget is configured for wrapping text on words, is > there an easy and/or elegant method for determining if a specific line > of text has been wrapped? > > I've been developing an app with a text box and some widgets that > float next to each text line, but when a line is too long and gets > wrapped, my floating widgets get out of place. By using > Text.dlineinfo(INSERT) I can get the width in pixels, but this is not > too useful unless I do some conversions based on the font size (which > I'd rather avoid doing). In addition, when my window is resized, the > Text.cget('width') does not update to reflect the new size. > > I could set the wrap to none and add a horizontal scrollbar, but this > really makes the application ugly and is a last resort. > > Anyone have any ideas? > > Thanks, > > David Wangerin... > David, Not really an answer but you could try the Pmw.ScrolledTextbox mega-widget the scroll bars are dynamic (only seen if needed). What do you mean by floating widgets (do you mean window's inside the textbox) or next to the textbox in an adjacent frame? Regards, Martin. From wurmy at earthlink.net Wed Nov 7 08:13:53 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 07 Nov 2001 13:13:53 GMT Subject: Q: Feature Wish: "%" Extension References: <_SZF7.57706$IR4.31105048@news1.denver1.co.home.com> Message-ID: <3BE9338B.70257B81@earthlink.net> Rainer Deyke wrote: > "John Roth" wrote in message > news:tugphsjop81s04 at news.supernews.com... > > Integer division is not an inverse of integer multiplication, therefore > > the proposed counterexample fails. > > What do you mean? '(a * b) / b' equals 'a' for all integers 'a' and 'b' > (assuming 'a * b' evaluates without overflow), except when 'b' equals 0. I think the idea is that (a / b) * b does not equal a in current (non-__future__) Python...? >>> (9 / 4) * 4 8 --Hans Nowak From chrishbarker at home.net Mon Nov 5 13:26:21 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 05 Nov 2001 10:26:21 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> Message-ID: <3BE6D9CD.1D6CF0E1@home.net> While nothing is actually set in stone, some things are pretty well cemented in. Jive Dadson wrote: > Thanks. Before I submit a formal proposal, let me run it by you guys. That is a good idea, most PEPs start as a discussion here. AN a whle lot more start that way and nver make it to a PEP. > I've looked through all the PEPS and I was surprised that my suggestion > is not already there. So, here it is. Please comment. You can bet that this has been proposed by people new to Python again and again and again, and I can promise you that this is one thing that is very well cemented in. If there is one thing that makes Python Python, is that it is a highly dynamic language. THat is not going to change. > option explicit > > def initialized = 0 > def init_everything(): > blah() > blah() > blah() > initialized = 1 > > The above code would work as anticipated. No pesky "global" qualifier. Actually, no it wouldn't. The second initialized here is a local variable, and it should remain so. Having a variable in a function be either local or global depending on something that is outside of the funciton is asking for trouble. If you start changing that too, you really won't have Python anymore!! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From maxx at easynews.com Tue Nov 27 12:11:00 2001 From: maxx at easynews.com (Max) Date: Tue, 27 Nov 2001 17:11:00 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3c029caa.260513688@news.laplaza.org> Message-ID: Why two editors? Will not one or the other do? On Tue, 27 Nov 2001 03:19:06 GMT, Tim Hammerquist wrote: >Mats Wichmann graced us by uttering: >There need not be 50 conflicting opinions. One only needs two editors: > > - Vim > - Emacs > >=) > >Tim Hammerquist From sshark97 at hotmail.com Mon Nov 19 23:11:24 2001 From: sshark97 at hotmail.com (TH Lim) Date: 19 Nov 2001 20:11:24 -0800 Subject: py2exe and its options Message-ID: Hi, I use py2exe to make exe from my python scripts and I want to explore rest of the options other than just "py2exe" alone. Is there any sites have examples available for other options? And, I tried "bdist" but unsuccessful. This is the result i got, running bdist bdist.run: format=zip, command=bdist_dumb, rest=[] running bdist_dumb running build running build_scripts not copying startup.py (up-to-date) installing to build\bdist.win32\dumb running install running install_scripts copying build\scripts\startup.py -> build\bdist.win32\dumb\Python21\Scripts warning: install: modules installed to 'build\bdist.win32\dumb\Python21\', which is not in Python's module search path (sys.path) -- you'll have to change the s earch path yourself changing into 'build\bdist.win32\dumb' zip -rq D:\workspace\projects\epos\bin\dist\startup-???.win32.zip . creating 'D:\workspace\projects\epos\bin\dist\startup-???.win32.zip' and adding '.' to it error: D:\workspace\projects\epos\bin\dist\startup-???.win32.zip: Invalid argume nt What went wrong here? Can anyone please shed some light here? /lim/ From fperez528 at yahoo.com Fri Nov 9 16:48:24 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 10 Nov 2001 21:16:24 +2328 Subject: doc generator References: Message-ID: <9sku4g$egh$1@peabody.colorado.edu> > Itamar Trauring and Jurgen Hermann (sorry Jurgen, no umlaut key) are > working on a "competitor" of HappyDoc's called Teud. It uses XSLT and > lookes much better (IMO) than HappyDoc. > > http://twistedmatrix.com/users/jh.twistd/python/moin.cgi/TeudProject Pardon the ignorance, but in which ways does this add to pydoc's functionality? I went to their website and looked at the example page, and the output is the exact same content I get from running pydoc -g, just with uglier formatting and poor nesting structure. Since pydoc is already part of Python officially, and offers a very powerful object introspection infrastructure (via the inspect module), I'd like to understand what the contribution of this project truly is. I'm honestly not bashing its authors, I'm sure they've put a lot of work into it. I'd just like to clarify in what areas it adds to something that's already built into python, and which does a very good job. Cheers, f From donn at drizzle.com Mon Nov 26 12:33:19 2001 From: donn at drizzle.com (Donn Cave) Date: Mon, 26 Nov 2001 17:33:19 -0000 Subject: fork & exec a process? References: None <87667x7o58.fsf@home.com> Message-ID: <1006795999.280070@yabetcha.sttl.drizzle.com> Quoth Jim Meier : | I'm trying to fork & exec a process, and be able to read it's output | to stderr and stdout. ... | I've also tried a popen trick as mentioned in that file, of opening a | pipe and using popen with redirection to it; | | out_read, out_write = os.pipe() | err_read, err_write = os.pipe() | ret = os.popen("command >&%d 2>&%d" % (out_write, err_write)) That's kind of an awkward way to do it, and I'm kind of surprised it works - I would have guessed popen(3) would close the parent's file descriptors in the fork. Like another poster already, I would suggest something from the popen2 module. | and then reading from out_read and err_read. The problem with this | approach is that i can't tell when the process dies - except by | calling ret.close(), and blocking until it does close. | | The purpose of all this is to execute some long-running programs (like | ping) and collect their results, while still processing the rest of | what needs to be done. If you look at the popen2 module (it's written in Python), you will see it doing a lot of close()s. When every last process closes the write end of a pipe, its readers see end-of-file. That's the simple way to know when the other end dies - if you haven't kept an open write end yourself. Of course end of file yields an empty string. Your other problem is that it might still be alive. If you have read all its output and come back for more, you'll block until it writes more. I would use select() for that, and I would use file descriptors (from_child.fileno()) and os.read with the pipes. Donn Cave, donn at drizzle.com From elmar.hoefner at uibk.ac.at Thu Nov 29 05:58:40 2001 From: elmar.hoefner at uibk.ac.at (Elmar =?ISO-8859-1?Q?H=F6fner?=) Date: Thu, 29 Nov 2001 11:58:40 +0100 Subject: Installing Python > 2.1: make fails in posixmodule.c References: <9u2g7u$5i5al$1@ID-113469.news.dfncis.de> <9u31it$60iuf$1@ID-113469.news.dfncis.de> Message-ID: <9u547c$6bbof$1@ID-113469.news.dfncis.de> Michael Hudson wrote: http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=440522 >> >> Oops, you're right. Although I spent quite a time searching, I oversaw >> it. This link helped me, now it compiles. > > Do you mean to say the patch in the bug summary fixed the problem? > That's very strange, seeing as that patch was applied before 2.1.1 was > released. Well, looking at the sources of 2.2a2 and 2.2b4, it doesn't seem so for me. After I added the following lines mentioned in file http://sourceforge.net/tracker/download.php?group_id=5470&atid=105470&file_id=8323&aid=440522 [which I found on the page above] in Modules/posixmodule.c, it compiles fine: [line 34 in 2.2a4] #ifdef HAVE_GETPRIORITY #ifndef PRIO_PROCESS #include #endif /* !PRIO_PROCESS */ #endif /* HAVE_GETPRIORITY */ [line 40 in 2.2a4] >> I tried at first 2.1.1 [error in line 1102], 2.2a4 [line 1145], 2.0.1 >> [which did compile, but gave me other problems] and at last >> 2.2b2. None of the mentioned [exept 2.0.1] compiled without patching. >> I didn't try CVS, though. Maybe I should have said that this was FYI only. It *does* work after adding the above lines, regardless which version. > I'm really confused now. Can you now do things that make 2.2b2 and > 2.1.1 compile where they didn't beforehand? Can you submit relavent > patches to sf? Well, yes and no. I can't submit this patch to sf, because I got it from there. :) Best regards, Elmar -- | Elmar W. Hoefner | See http://home.pages.at/oeller/pubkey.txt | for my PGP public key. From aaldv97 at student.remove-this-part.vxu.se Wed Nov 7 04:42:49 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Wed, 7 Nov 2001 10:42:49 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> Message-ID: <9savp2$5t1$1@news.lth.se> > Yes and no. Like many others, my first language was BASIC (on an Apple //e). > Later, I took some CS classes where we learned Pascal. I had indeed > developed some bad habits due to language deficiencies in BASIC (everything > global, no argument passing, jumping in and out of routines, etc). However, > it was a good, simple introduction to programming and I like to think I > wasn't permanently crippled by the experience. Later, I took up C, and what > do you know? Pascal gave me "bad" habits (mostly in the area of counting > upon the compiler to warn me about bad things I was about to do). However, I > would never have moved back to Pascal from C because C's flexibility allowed > me to code things that would have been extremely difficult in Pascal. Yes, I > could shoot myself in the foot, but at least I had a gun. I hear you, but it's my experience when teaching at the university that students that start with non-declarative languages write sloppy code. All is relative of cource, but I just speak from my own experience, myself I started with MC68k assembly and went to BASIC and E, and picked up some really bad habits in BASIC that took months to overcome. > That depends upon your perspective on what "good code" is. Code that is easy > to read? Easy to modify? One of Python's strengths is that almost every > line of code is related to solving the programmer's goal rather than telling > the compiler how to compile the code. Not having a lot of extra statements > that have nothing to do with solving the problem results in cleaner, easier > to understand code. The skills you are referring to are difficult to teach > in any language (although, I can't comment on Ada - perhaps it makes > designers out of neophytes in no time ;-) . These come with time and > experience. I love Python, I advocate it a lot, but I believe that Ada95 is the prime language for beginners. Python's biggest strength from my point of view is the fact that it is master tool for fast prototyping, but you can't really take full advantage of that feature in a project until you have a lot of experience with low level languages. > Not really areas of interest for beginners. Depends on the beginner ;-) > It may be. Many excellent languages languish in specialized niches. However > I would hesitate making one of those excellent languages a teaching tool > since people learning it would undoubtedly have to later move to another > language anyway (possibly due to lack of availability on a specific > platform), so most of the features they've come to depend upon would no > longer be available and their reliance upon them would show up as "bad > programming practices" in their new language. The fact that Ada is the only language that truly was designed, people who have used Ada have no problem to pick up other langauges other than fully functional languages such as LISP. > Not knowing Ada makes me reluctant to disagree, but I wonder how a language > so strict that writing sloppy code is difficult can be a very flexible > language. Usually those things are mutually exclusive. Training-wheels on a > bicycle are a common comparison... safety over flexibility. Maybe this is > why you need inline Fortran/C/Assembly in your Ada code - to get around the > restrictions of the language. No, not infelxiblitity, it's just that my first language was assembly so I tend to use inline assembly instead of banging the hardware in Ada. Call it a birth defect, a defect that I would not have if I had started with Ada. > Widespread use? A promising future? Guido himself suggested (in Linux > Journal) that perhaps Dylan was slightly better than Python in some respects, > but I don't see anyone jumping ship just yet (maybe when Visual Dylan hits > the market). I see big demand for Ada programmers here in Sweden, not as big as Java and C++, but indeed much more so than Python :) Airbus in France use Ada almost exclusivly, if my friend who works there is correctly informed. > True, I don't know jack about Ada. I don't know jack because I've never > known anyone (other than yourself) who claims to use it. This doesn't make > it a bad language, just an impractical one. The unfortunate fact is that the > best design doesn't always win (otherwise where would Microsoft be today?). > I think Ada had its chance and failed to claim enough interest to make it > relevant today. Think of Ada as kind of Objective-C of all oo iterative languages, more powerful and better syntax than C++, but not as accepted. I see a growing market for Ada, though I rarely code in Ada anymore (mostly Python), I do this because I prefer the fast prototyping of Python. I believe that Ada is a better choise for the beginner, I'm not claiming to hold the absolute truth. > And please, I'm not trying to offend you, just disagree with you (a little), > so let's not make this another flame war - this list has had too many the > last couple of days. I got nothing to get mad about, I love Python, I just believe that Ada is a better language to begin with. I must say I'm anti-GNU, i.e. anti-GPL/LGPL, but I found this which was an interesting quote from a GPL'ed project: "Using GtkAda and GNAT, we can decrease time to market by a factor of two to four over any other language/compiler." -- http://libre.act-europe.fr/gvd/ From scott_hathaway at riskvision.com Wed Nov 14 14:33:30 2001 From: scott_hathaway at riskvision.com (Scott Hathaway) Date: Wed, 14 Nov 2001 13:33:30 -0600 Subject: reportlab question Message-ID: Hello All, I have a simple script that I am using to create form letters from a text file with reportlab. It works ok until the text is longer than xx characters long. Then the text is just cut off, not word wrapped as I would like. How to I cause reportlab to word wrap the text? Here is the code: import reportlab.pdfgen.canvas from reportlab.lib import colors from reportlab.lib.units import inch import sys c = reportlab.pdfgen.canvas.Canvas(sys.argv[2]) c.setFillColorRGB(0,0,0) allText = open(sys.argv[1],'r').read() pageList = allText.split('#PageBreak#') for page in pageList: c.drawInlineImage('c:/rv_logo.jpg',(.5*inch),(11*inch),100,20) t = c.beginText() t.setTextOrigin(.5*inch, 10.5*inch) t.textLines(page) c.drawText(t) t = None c.showPage() c.save() Thanks in Advance! Scott From philh at comuno.freeserve.co.uk Fri Nov 23 13:52:04 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 23 Nov 2001 18:52:04 +0000 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> Message-ID: On Fri, 23 Nov 2001 20:36:10 +0300, Oleg Broytmann wrote: >On Fri, Nov 23, 2001 at 04:41:55PM +0000, phil hunt wrote: >> PHP is also ugly. As an example, compare: >> >> PHP: $object->$member >> Python: object.member > > Unfortunately, latest versions of Python have its own gotchas. >"; ".join([a.id for a in listIds() if a.b > x]) > looks worse than PHP, it looks almost like perl :( I like Smalltalk syntax here, where you can say things like: a1 := SomeClass listIds select: [ :a | (a at: #b) > x] a2 := a1 collect: [ :a1m | a1m at: #id ] Which AFAIK is an approx translation of the [...] part of the python expression above (it's a long time since i did Smalltalk so I may be wrong). -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From eppstein at ics.uci.edu Wed Nov 28 02:18:46 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 27 Nov 2001 23:18:46 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> <3C048CCC.6A8C3743@engcorp.com> Message-ID: In article <3C048CCC.6A8C3743 at engcorp.com>, Peter Hansen wrote: > > -- but I would be interested in changes that allow > > non-Python-literate programmers to understand my code without having to > > dig through a manual. > > I agree that sounds like a worthy goal. I disagree that your > suggestion is any more likely to be understood by anyone, > other than perhaps a mathematician. As a very experienced > programmer, I found it quite obscure and am unsure I > would have figured it out were it not for the context of > recent threads on the subject. >From context, it seems you mean Ewing's suggestion rather than mine, right? > Maybe we should look back to BASIC (for i = 1 to 5: next) > or one of the suggestions for something which looks more > explicitly like a list of items (for i in [0..5]) or > (for i in [0, 1, .. 5] ). Especially this latter would > definitely be understandable to anyone, IMHO. Your final option is very close to my suggestion, much earlier in this thread, which seems to be disliked by many due to its requiring closed intervals while other Python features use half-open ones. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From shriek at gmx.co.uk Sun Nov 25 19:55:49 2001 From: shriek at gmx.co.uk (Stephen) Date: 25 Nov 2001 16:55:49 -0800 Subject: Returning HTTP POST body from CGI module References: Message-ID: <97ae44ee.0111251655.6f34cf96@posting.google.com> > > I have a Python CGI script receiving XML data via HTTP POST from > > another company. Unfortunately, that company doesn't seem to > > have implemented the HTTP protocol correctly. > > This is completely valid HTTP. They probably ought to have > Content-Type header in there, but it's no big deal. Thank you for putting me straight on this one. Since web browsers seem to send urllib.quote_plus()'ed text, I guess that the web server is urllib.unquote()'ing everything it receives. So, whether you send quoted or unquoted text it will become the same thing. > CGI request content comes in on stdin. The cgi lib just > parses it. The headers tend to show up in the environment, > but I'm not sure any old header you send shows up > there... > > The following program should give you access to the data though: > > #!/usr/bin/python > import sys, os > length = os.environ["CONTENT_LENGTH"] > print sys.stdin.read(length) Excellent, works a treat ~ using sys.stdin.read(int(length)) ~ and thanks for explaining how CGI request content is transfered via stdin. I had been wondering how the data was transfered to Apache. Thanks Michal, Stephen. From phd at phd.pp.ru Tue Nov 20 13:43:28 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 20 Nov 2001 21:43:28 +0300 Subject: os.kill........ In-Reply-To: ; from cliechti@gmx.net on Tue, Nov 20, 2001 at 07:34:53PM +0100 References: <9te2g4$sma$1@mail1.wg.waii.com> Message-ID: <20011120214328.K5035@phd.pp.ru> On Tue, Nov 20, 2001 at 07:34:53PM +0100, Chris Liechti wrote: > a frendly question to quit is sent by signal 9 and an unfrendly, forced > kill of a process can be done with signal 15. Exactly opposite! :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From tatebll at aol.com Thu Nov 8 12:36:57 2001 From: tatebll at aol.com (Bill Tate) Date: 8 Nov 2001 09:36:57 -0800 Subject: Games Programmed in Python References: <9sahq0$qi1$1@slb6.atl.mindspring.net> <3BEA23A3.8010907@shinners.org> Message-ID: Pete Shinners wrote in message news:<3BEA23A3.8010907 at shinners.org>... > > Could somebody direct me to some examples of games programmed in Python? > > well, you could start with the game i've written, SolarWolf. > it's actually a great example of what can be done pretty easily in > python. (unfortunately the server is a bit sketchy) > http://shredwheat.zopesite.com/solarwolf > > this is done with the pygame library, > http://www.pygame.org > > pygame is a wrapper for the SDL libraries. this is a great lowlevel > framework for creating your own crossplatform games. there is an active > projects page on the pygame site which can point you towards more... > http://www.pygame.org/projects/ Pete, This probably goes towards more of something to get excited about in terms of what python is capable of. Check out www.eve-online.com. There FAQ page used to discuss how they are using Python's stackless implementation - I'm presuming they still are using it since it was part of the 'core' - very cool. From weismann at netvision.net.il Fri Nov 9 11:32:44 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Fri, 09 Nov 2001 18:32:44 +0200 Subject: Follow up on the Matrix & Numerical analysis Message-ID: <01f301c1693c$2983eaf0$9792003e@rashome> Is there a way to run M files (MATLAB files) by Python ? If yes - Where can I see an example ? TIA Amit ---------------------------------------------------------------- Weisman Amit 11 Rupin st. Holon 58344 Israel Tel : 050397330 weismana at cs.bgu.ac.il -------------- next part -------------- An HTML attachment was scrubbed... URL: From gh_pythonlist at gmx.de Thu Nov 1 16:45:05 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Thu, 1 Nov 2001 22:45:05 +0100 Subject: List transpose method In-Reply-To: <20011101205127.A4219@ibook.distro.conectiva>; from niemeyer@conectiva.com on Thu, Nov 01, 2001 at 08:51:27PM -0200 References: <20011101205127.A4219@ibook.distro.conectiva> Message-ID: <20011101224504.C7406@lilith.hqd-internal> On Thu, Nov 01, 2001 at 08:51:27PM -0200, Gustavo Niemeyer wrote: > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > > only come up with an ugly multiliner. > > >>> zip((1,2),(3,4),(5,6)) > [(1, 3, 5), (2, 4, 6)] Hmm. How would I apply zip if I have a variable already, like l = ((1,2),(3,4),(5,6)) ? Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From emile at fenx.com Sun Nov 4 07:42:49 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 4 Nov 2001 04:42:49 -0800 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> Message-ID: <9s3dd5$113fdj$1@ID-11957.news.dfncis.de> "Jive Dadson" wrote in message news:3BE4DF39.AE0A8EAA at ix.netcom.com... > I'm a newbie at Python, but I've been up to my ears in it for the last > couple of days. -- Considering using it for a scripting language for a > product at work. I'm very impressed with the system. Of course there > are things I would like to change. :-) So the question is, how much is > set in stone at this point? Is the definition of 2.x now the law of the > land, or can we still make suggestions? > 2.2 is at feature lock, but everything is open after that. Review the existing PEPs to see what has been suggested. http://python.sourceforge.net/peps/ The bottom of http://www.python.org/Help.html has a section titled _Want to Contribute?_ with additional info. -- Emile van Sebille emile at fenx.com --------- From peter at engcorp.com Sun Nov 25 17:12:03 2001 From: peter at engcorp.com (Peter Hansen) Date: Sun, 25 Nov 2001 17:12:03 -0500 Subject: list.remove for Novices References: Message-ID: <3C016CB3.B03B96E6@engcorp.com> Arthur Siegel wrote: > > >>>foo = [1, 2, 3, 4, 5] > >>>for bar in foo: > ... foo.remove(bar) [...] > But damn it to hell. Even when I try to be a normal Python > guy, and just post up "technical" problems, I get into- > or raise - issues/controversary. > > Because I am being asked to accept that the list.remove > behavior is somehow apparent - rather than a true > trap for the novice. I would say that *is* a trap for the novice, but for any *programming* novice, not just a Python novice. That type of thing can happen in almost any environment, and I suspect any defensiveness about it is because it could sound like an unfair attack on Python specifically. That said, if it's not in the Python FAQ it I think it should be. (And a quick search suggests it's not.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From mkelly2002NOSPAM at earthlink.net Sat Nov 17 11:50:00 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Sat, 17 Nov 2001 16:50:00 GMT Subject: Win32 COM question Message-ID: Hi all. I've just started trying out python and I have a question about how it is to use an InProcess COM server with it. As example I have a COM dll that does .ini file stuff that has a dual interface and a type library. In VB I have to make sure it's selected in References then I can just do something like: Dim IniObj As New ComIniFile Set IniObj = CreateObject("IniLib.ComIniFile") IniObj.FileName = App.Path & "\ComIniFileTest.ini" IniObj.ReadSections MyStrings Following the python quick start tips for COM I installed the Win32all with PythonWin and tried this: import win32com.client o = win32com.client.Dispatch("IniLib.ComIniFile") o.FileName = "C:\Windows\Temp\TryIni.ini" o.WriteString("StringSection", "Key", "SectionIsPun") And I get error messages to the effect that module types cannot be executed so it leads me to wonder if this only works for OleAutomation .exe programs such as MS Word or can you really use COM .dlls and ActiveX controls?? TIA Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From fperez528 at yahoo.com Tue Nov 13 18:24:52 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 14 Nov 2001 22:52:52 +2328 Subject: Problem with .pth files under linux References: Message-ID: <9svlac$1d$1@peabody.colorado.edu> Prabhu Ramachandran wrote: > Hmm. This is the reason why Debian as a Linux distro rocks. Debian > modifies site.py so that it also searches in > /usr/local/lib/pythonX.Y/site-packages !! It does this by modifying > site.py slightly like so: > > Original site.py: > > prefixes = [sys.prefix] > if sys.exec_prefix != sys.prefix: > prefixes.append(sys.exec_prefix) > > Debian's version: > > prefixes = [os.path.join(sys.prefix, "local"), sys.prefix] > if sys.exec_prefix != sys.prefix: > prefixes.append(os.path.join(sys.exec_prefix, "local")) > prefixes.append(sys.exec_prefix) > > > Obviously very thoughtful, correct and convenient. :) And furthermore, something that should be part of Python itself!!! Great for Debian users, but this is basically a micro-bug in Python, and it should be fixed at the source. > > Another work around in your case would be to stick your Numeric.pth > alone (with an absolute path) inside /usr/lib/pythonX.Y/site-packages. > > Nnumeric.pth: > /usr/local/lib/pythonX.Y/site-packages/Numeric > Nah. I'd have to do that for a bunch of stuff. My current solution is kludgy but automatic, since I don't need that site-python directory. Anyway, this is more annoying and more work than it should. Cheers, and thanks for all your help. f. From alain.desilets at nrc.ca Tue Nov 20 13:20:34 2001 From: alain.desilets at nrc.ca (Alain =?iso-8859-1?Q?D=E9silets?=) Date: Tue, 20 Nov 2001 13:20:34 -0500 Subject: Please unsubscribe me References: <3BF95C82.A5688F06@nrc.ca> Message-ID: <3BFA9EEF.61CFBC43@nrc.ca> Apologies everyone. I know I'm not supposed to send this on the list, but I sent it to the mail admin yesterday and am still drowning in the volume. And I'm going away for 3 days ;-)! Any admins listening on the list? Thx Alain D?silets wrote: > I tried to unsubscribe, but I can't remember the password I gave. I > tried all my known passwords and none of them worked. Can you > unsubscribe me manually? > > Thanks > > Alain D?silets From qrczak at knm.org.pl Wed Nov 28 12:08:21 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Wed, 28 Nov 2001 17:08:21 +0000 (UTC) Subject: string.join() syntax quirky? References: <3C02AF2D.943951FA@home.net> Message-ID: Mon, 26 Nov 2001 13:07:57 -0800, Chris Barker pisze: > Another way to look at is is that joining and splitting are > inherently string functionailty, and thus belong with the string > object. For me joining and splitting are approximately inverses of each other. join indeed belongs to a string object: the one which is about to be produced! It's like a constructor. It's a coincidence that the separator also happens to be a string. We could have joining without separators. In that case there would be no string object to make this a method of. Not every function makes sense as a method of an existing object. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From ws-news at gmx.at Fri Nov 23 15:55:14 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 23 Nov 2001 21:55:14 +0100 Subject: What's this: run_pyc_file: nested_scopes: 0? References: <99ksvtsp9uipajsfkqehgbi9hc0f8el4mq@4ax.com> <3bfe5e53$1@brateggebdc5.br-automation.co.at> Message-ID: <3bfeb878$1@brateggebdc5.br-automation.co.at> "Dale Strickland-Clark" wrote in message news:ciqsvts0pud08oeo4b3r4i260agt9vpq33 at 4ax.com... .... > > We have neither the building-Python knowledge or the time to start > meddling with the source code - but we really need to get rid of this > before we can start shipping this code. > > Is that my only option? > As I read the code, there is no simple way to turn it completely off w/o changing the source code. It looks a lot like a forgotten debugging aid :-) I never built the Python interpreter myself, but there are project files for Visual Studio available in the PCbuild directory. By opening the working space file (.dsw) and compiling the python library, you should be able to easily rebuilt it. Alternatively, you can just redirect the standard error stream, if this is an option. Something like (untested) python script.pyc 2> nil hth Werner From weismann at netvision.net.il Tue Nov 6 15:29:35 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Tue, 06 Nov 2001 22:29:35 +0200 Subject: Binary heap in Python - Exist ? Message-ID: <00c801c16701$c0fc8f50$1395003e@rashome> Hi . I need a data structure as Binary Heap - Insert (Object , Key ) , and ExtractMax() . What Python module should I use ? TIA Amit ---------------------------------------------------------------- Weisman Amit 11 Rupin st. Holon 58344 Israel Tel : 050397330 weismana at cs.bgu.ac.il -------------- next part -------------- An HTML attachment was scrubbed... URL: From tim at vegeta.ath.cx Mon Nov 12 23:07:25 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 13 Nov 2001 04:07:25 GMT Subject: How much is set in stone? References: Message-ID: Nicholas FitzRoy-Dale graced us by uttering: [ snip ] > Good point! Based on that, here is my Python "Enhancement" proposal: > > Let's make it so that placing "option disturbing" at the start of a > module turns on "C Mode". In this mode, Python's behaviour would be > modified in the following ways: > > * Use of curly braces to delineate syntax blocks, rather than > indentation; > * The C ternary operator would be fully supported, as would > fall-through "switch" statements (as long as the type being > switch()ed is some kind of number, of course); > * Class support would be removed, but everyone knows all you > need is support for struct{} anyway. Structs could only > contain the types "IntType", "FloatType" and "StringType", > but when you get down to it it's all numbers anyway; > * We'd finally get our beloved "goto" statement. > > Fortunately, none of this will affect the "Python-ness" of the language > - without "option disturbing", it will behave exactly as before! What a cruel, cruel joke. Have you no shame?! ;) Tim Hammerquist -- It takes a smart husband to have the last word and not use it. From johnroth at ameritech.net Mon Nov 19 19:54:51 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 19 Nov 2001 16:54:51 -0800 Subject: Tkinter and IDE's References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> Message-ID: "Don Arnold" wrote in message news:9t9qsb$4nd$1 at slb3.atl.mindspring.net... > I'm new to python and am interested in developing apps with Tkinter. > However, every IDE I've come across for the Win32 platform experiences > lockups/aborts when running Tkinter code. So far I've tried IDLE, PythonWin, > and WING with little luck. Does anyone know of an IDE that successfully > executes Tkinter code? > > Thanks, > Don Arnold There's a known problem with Tcl/tk that causes these lockups; at least, I assume it's with tcl/tk since it's been discussed sporadically for quite a while, and the last time, someone said they had seen it in a pure tcl/tk environment. It's reported to only occur on Win 9x (including ME) systems, and not on Win 4.0, 2K, etc systems, and only when using the command line. I suspect that the long term solution is going to be IBM's anygui project. John Roth From gmcm at hypernet.com Fri Nov 30 09:32:06 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 30 Nov 2001 14:32:06 GMT Subject: Python to .dll ? References: <9u63rp$v5g$06$1@news.t-online.com> Message-ID: Dennis Conrad wrote: > Is there a possibility to create a (win32) .dll from a Python-script? I > know there is py2exe, maybe there is something like py2dll...? Installer release 5 can do this. It comes with a dll that allows you to "freeze" an in-process com server. But that dll probably won't do you much good - the C code in the dll is focussed on fooling COM & pythoncom. You should be able to write a dll exposing whatever entry points you need. The code you need to set things up (load Python, set the import hooks, run scripts etc.) has all been factored out into source/common/launch.c (by Alan Green, who was doing exactly this). -- Gordon http://www.mcmillan-inc.com/ From ws-news at gmx.at Thu Nov 15 08:06:10 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 15 Nov 2001 14:06:10 +0100 Subject: Problems compiling python under Win (VS6.0) References: <3bf381b5$1@skynet> Message-ID: <3bf3be86@brateggebdc5.br-automation.co.at> Hi, you need to have the tools you listed to build Python from sources. Alternatively, you can exclude the modules which use them from the build. more details mixed in your post "Serg" wrote in message news:3bf381b5$1 at skynet... > When compiling python under Visual Stdio files missing reported: > python src 2.2b1 > files: tcl.h needs Tcl/Tk installed (maybe source?) > db.h some database API, IIRC > expat.h The Expat XML parsing library. > zlib.h The zlib data compression library. > > Python is taken from python site. > What to do? What is that? > > -- > Keep in touch. Your partner Maltsev. > > hth Werner From uwe at rocksport.de Fri Nov 16 10:53:10 2001 From: uwe at rocksport.de (Uwe Schmitt) Date: 16 Nov 2001 15:53:10 GMT Subject: problem with pickle Message-ID: <9t3cp6$9uk6c$1@hades.rz.uni-sb.de> Hi, I tried to save an object with pickle and load it afterwards. When I try to load my object I get: Traceback (most recent call last): File "rnetgui.py", line 556, in Load obj=pickle.load(fp) File "/usr/local/ActivePython-2.1/lib/python2.1/pickle.py", line 947, in load return Unpickler(file).load() File "/usr/local/ActivePython-2.1/lib/python2.1/pickle.py", line 567, in load dispatch[key](self) File "/usr/local/ActivePython-2.1/lib/python2.1/pickle.py", line 623, in load_float self.append(float(self.readline()[:-1])) ValueError: invalid literal for float(): 150.0 What happened ? Yours, Uwe Schmitt -- Dr. Uwe Schmitt Uwe.Schmitt at num.uni-sb.de Universitaet des Saarlandes Angewandte Mathematik Building 36.1 Room 4.17 PO-Box 151150 D-66041 Saarbruecken Mobile:0177/6806587 Fax:+49(0)681/302-4435 Office:+49(0)681/302-2468 From Randy.L.Kemp at motorola.com Fri Nov 2 13:11:36 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 2 Nov 2001 12:11:36 -0600 Subject: Freeware Python editor Message-ID: <81F59ACE9063D511A5BB0002B328D226511609@il93exm20.css.mot.com> Probably nothing! It's just another one to choose from. Kind of like adding another color to an M & M candy coating. -----Original Message----- From: ullrich at math.okstate.edu [mailto:ullrich at math.okstate.edu] Sent: Friday, November 02, 2001 10:15 AM To: python-list at python.org Subject: Re: Freeware Python editor On Wed, 31 Oct 2001 08:08:22 -0600, Kemp Randy-W18971 wrote: >Check out the free Python editor at www.crimsoneditor.com. Not that it matters to me, but it seems like someone should ask: What does it do that other free(?????????) Python editors don't do? David C. Ullrich From michael.g.abbott at ntlworld.com Sat Nov 3 06:41:34 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Sat, 03 Nov 2001 11:41:34 GMT Subject: Problem formatting Python docs with MikTeX Message-ID: I'm trying to build the Python 2.2 documents using the following command: >python ..\tools\mkhowto --paper=a4 --dvi ..\ref\ref.tex This appears to be the proper way (extracted from the make file; I don't have a suitable make installed), and after some mysterious background work this fires up latex with a suitable TEXINPUTS path, witness the transcript (slightly reformatted for 75 columns): >python ..\tools\mkhowto --paper=a4 --dvi ..\ref\ref.tex +++ TEXINPUTS=C:\Python22\src\Python-2.2b1\Doc\ref;C:\Python22\src\Python- 2.2b1\Doc\paper-a4;C:\Python22\src\Python-2.2b1\Doc\texinputs; +++ latex ref This is TeX, Version 3.14159 (MiKTeX 2.1) (C:\Python22\src\Python-2.2b1\Doc\ref\ref.tex LaTeX2e <2000/06/01> Babel and hyphenation patterns for english, french, german, ngerman, dumylang, nohyphenation, loaded. (C:\texmf\tex\latex\nassflow\manual.cls Document Class: manual 1997/02/05 v2.0 CAWCS manuals (C:\texmf\tex\latex\base\size10.clo)) (C:\Python22\src\Python-2.2b1\Doc\texinputs\boilerplate.tex ! Undefined control sequence. l.3 \authoraddress { ? Unfortunately, the import of manual.cls shows that I have a serious problem: the TEXINPUTS path is evidently being searched (by MixTex) in the wrong order. There is a manual.cls in my Python texinputs directory, but MikTeX is kindly picking up the version in its own distribution. (Note that the TEXINPUTS path clearly *is* being successfully searched later on.) Ouch! Any suggestions on how to proceed? The only hack I can think of is to take all the files in the Python directory, hunt down any aliases in the MikTeX directory and destroy or hide them. Not pretty. Is this a problem with my version of MikTeX, or do I need to change the way in which latex is being invoked? From ws-news at gmx.at Sat Nov 24 17:33:41 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Sat, 24 Nov 2001 23:33:41 +0100 Subject: Windows Scripting Host Python Engine not registered/installed?? References: <1drvvtc91jnbmfoqpn2qdrg37km6ggk9sl@4ax.com> Message-ID: <3c00210b$1@brateggebdc5.br-automation.co.at> Hi, Open the file win32comext\axscript\demos\client\ie\demo.htm with Internet Explorer, it offers a link to the regitration script win32comext\axscript\client\pyscript.py You can just start the script right away, but the above page immediately tells you whether Python Active Scripting works. After that procedure, .pys files should run directly in WSH using Python language (like .vbs runs VB script). hth Werner "Michael Kelly" wrote in message news:1drvvtc91jnbmfoqpn2qdrg37km6ggk9sl at 4ax.com... > Hi. I'm trying out the Windows Scripting Host and even though > PyScript.py runs with no error any python scripting attempt reports > that it cannot find the Python engine. Also in all the demo IE pages > with scripts the Python scripted portions don't work while the VB > script ones do. I think they changed around the subdirectory > structure as some of the docs say win32com folder when the stuff is in > win32comext folder. > > Anyway, WScript.exe seems to work since any text file with > a .vbs extention will invoke it such as a file with .vbs extention > and the single line: > WScript.Echo("Hello World") > pops up a message box. > > Anyone have a tip? I'm a bit bewildered as it seems this > should be an easy one. > > TIA > > > Mike > > -- > > "I don't want to belong to any club that would have me as a member." > -- Groucho Marx From bas_4urs at yahoo.com Mon Nov 19 01:16:36 2001 From: bas_4urs at yahoo.com (alagu shenbagaperumal) Date: Sun, 18 Nov 2001 22:16:36 -0800 (PST) Subject: how to create database oriented ASP pages using python script? In-Reply-To: <1006148018.1275.20607.m12@yahoogroups.com> Message-ID: <20011119061636.68123.qmail@web11904.mail.yahoo.com> hi, how to create Active Server Pages which supports database connectivity using python script. if u explain with sample codes, it will be usefull. with luv, bas __________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com From phd at phd.pp.ru Mon Nov 26 06:47:41 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 26 Nov 2001 14:47:41 +0300 Subject: Free Python Server In-Reply-To: <%vdM7.256960$5A3.96800831@news1.rdc2.pa.home.com>; from ssmith619@hotmail.com on Sun, Nov 25, 2001 at 09:36:59PM +0000 References: <15353.40372.784126.72589@beluga.mojam.com> <37aM7.256063$5A3.96426335@news1.rdc2.pa.home.com> <%vdM7.256960$5A3.96800831@news1.rdc2.pa.home.com> Message-ID: <20011126144741.B13216@phd.pp.ru> On Sun, Nov 25, 2001 at 09:36:59PM +0000, Stephen Smith wrote: > Any sites like those in English? No idea, sorry. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From christophertavares at earthlink.net Mon Nov 19 17:21:36 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Mon, 19 Nov 2001 22:21:36 GMT Subject: Newbie question abt __getitem__ and __iter__ References: Message-ID: "karthik Guru" wrote in message news:mailman.1006174588.23695.python-list at python.org... > hi all, > > what other languages support treating a class as a collection of objects and > allowing indexed access to it's constituents? > > I also liked the iter() concept and the way it works. > I saw C# adopting both these things. > > But which language supported it first? > > thanks, > karthik. > Probably Smalltalk or Lisp - it seems that all of modern computer science is trying desperately to get back to what we already had working just fine in 1970. :-) -Chris From aa at bb.cc Mon Nov 5 09:24:43 2001 From: aa at bb.cc (Károly Ladvánszky) Date: Mon, 5 Nov 2001 15:24:43 +0100 Subject: Question: Error or misconcept References: <3be65da4$1_3@corp-goliath.newsgroups.com> <9s62qa$11k821$1@ID-11957.news.dfncis.de> <3be69395_1@corp-goliath.newsgroups.com> <9s65ru$10mk5k$1@ID-11957.news.dfncis.de> Message-ID: <3be69dd1_5@corp-goliath.newsgroups.com> Thanks indeed, all clear now. It has really been a misconcept of mine. Could you perhaps help me with the __dict__ question? Thanks, K?roly P.S. What is 'Bases-search-order-subject-to-python-release-ly y'rs' ? ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net From dalke at dalkescientific.com Thu Nov 29 12:04:27 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 29 Nov 2001 10:04:27 -0700 Subject: Expat XML Parser References: <9u2t5e$kh4$1@aspen.sucs.soton.ac.uk> Message-ID: <9u5prv$7ps$1@slb7.atl.mindspring.net> Richard Boardman: >I am trying to use the Expat XML parser to extract some data for >processing - sounds simple enough - although I am having great difficulty >finding documentation for Expat and am consequently very stuck. You should be able to use any of the documentation on XML for Python. See http://pyxml.sourceforge.net/topics/ . The interface to use Expat or any of the other parsers is all generic enough that you don't really have to worry about which one you're using. You may also want to ask questions of the XML-SIG -- see http://www.python.org/sigs/xml-sig/ >What I'd like to do is have something that works thus: > >readInXML >foreach element in XML > if element = "abcdefg" { > getCharacterData > doStuff with characterData > } There are two common styles of XML processing, SAX and DOM. What you have here is more DOM like, and can be done like (excuse me since I don't do much DOM programming so some of this is made up, and probably wrong, and probably should be done with XSL ) parser = make_parser() dh = xml.dom.sax_builder.SaxBuilder() parser.setContentHandler(dh) parser.parse(file) for data_set in dh.document.getElementsByTagName("data"): if data_set.get_attrs("set") == "1": print data_set.get_firstChild().get_data() The SAX-style, which I've used a lot, uses callbacks to do everything, and looks like this: parser = make_parser() handler = make_callback_handler() parser.setContentHandler(handler) parser.parse(file) and the 'make_callback_handler' is something like class MyCallbackHandler(handler.ContentHandler): def startDocument(self): self.store_characters = 0 self.text = None self.data_set = [] def startElement(self, tag, attrs): if tag == "data" and attrs["set"] == "1": self.store_characters = 1 self.text = "" def characters(self, text): if self.store_characters: self.text = self.text + text def endElement(self, tag): if self.store_characters: print "I have", self.text self.data_set.append(string.split(self.text)) self.text = None self.store_characters = 0 The SAX style is what you were using in the code included in your post. What you were missing was using an object to store the data. Andrew From fperez528 at yahoo.com Thu Nov 22 12:02:04 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 23 Nov 2001 16:30:04 +2328 Subject: Could someone explain this multidimensional list behaviour? References: Message-ID: <9tmm7a$4e6$1@peabody.colorado.edu> L wrote: > So what is the easy way to allocate an n x n matrix with unique > values? If this is for numerical work, check out Numeric at http://www.pfdubois.com/numpy It will give you *much* faster performance than regular python lists, and what you want to do is simply: In[5]:= x=zeros([2,3],Float) In[6]:= x Out[6]= array([[ 0., 0., 0.], [ 0., 0., 0.]]) Cheers, f From weismann at netvision.net.il Fri Nov 9 05:50:32 2001 From: weismann at netvision.net.il (Amit Weisman) Date: Fri, 09 Nov 2001 12:50:32 +0200 Subject: Matrix in Python . Message-ID: <018001c1690c$5b3af8c0$9792003e@rashome> Hi Is there a module for dealing with Matrix ? TIA Amit ---------------------------------------------------------------- Weisman Amit 11 Rupin st. Holon 58344 Israel Tel : 050397330 weismana at cs.bgu.ac.il -------------- next part -------------- An HTML attachment was scrubbed... URL: From mertz at gnosis.cx Fri Nov 16 04:03:19 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Fri, 16 Nov 2001 04:03:19 -0500 Subject: Recap: PEP 276 Simple Iterator for ints In-Reply-To: References: Message-ID: Hi James, Thanks for the very nice summary of the discussion on the PEP276 threads (including some bits that I chimed in on, like the Haskell examples). I have actually not particularly -argued- for any particular new syntax. I suppose partly because I am too lazy to write a PEP; I've mostly wanted people in the discussion to think about options... and about what new users will find obvious. In terms of your PEP itself, you've probably already seen me mention that I slightly dislike it. I won't cry if it makes it in, and I will probably even use it. But I can see stumbling over the construct in someone elses code. Your example: | for i in table.getRowCount(): | for j in table.getColumnCount(): | print table.getValueAt(i,j) looks pretty clear. The names make it fairly obvious what is intended. But if PEP276 becomes an actual language feature, I think one is going to occassionally see things like: for personRecord in 7: process_record(personRecord) *That* version will probably throw me for a loop. And it will puzzle newbies even more. I readily admit that the names are not well chosen, and the integer literal is awkward--that's why I chose them :-)--but that's the sort of thing that happens. My affection for the Haskell-style syntax is mostly because it is more explicit (I don't care about how many dots and commas go in it). But also because it is more general (arbitrary stepping, obious application to floats). If one is going to do "this sort of thing" eventually, it's better to do it all the way at first. That way you avoid too many slightly different ways of writing the same thing. Yours, David... -- ---[ to our friends at TLAs (spread the word) ]-------------------------- Echelon North Korea Nazi cracking spy smuggle Columbia fissionable Stego White Water strategic Clinton Delta Force militia TEMPEST Libya Mossad ---[ Postmodern Enterprises ]-------------------------- From paulp at ActiveState.com Thu Nov 1 00:16:39 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 31 Oct 2001 21:16:39 -0800 Subject: Python.NET, MONO and Visual Studio etc. References: <3BDC5777.3873D22A@earthlink.net> Message-ID: <3BE0DAB7.2D27EE95@ActiveState.com> Ron Stephens wrote: > >... > > ActiveState also developed a beta version of a Python.NET that would > allow Python to use the CLI and VS. NET compiler. This effort was led by > Mark Hammond. However, the task is difficult and the first beta was slow > and very feature incomplete. I believe the Perl.Net version is further > along? Perl.NET is similarly incomplete. ActiveState has a seperate PerlNET product which is a bridge to .NET from Perl: "allows .NET Framework code to access Perl code running outside Microsoft's .NET framework using the traditional Perl interpreter. PerlNET provides the following functionality: Perl code runs at the same speed within .NET as it does outside All extension modules, including the ones using XS code, are supported PerlNET code is completely compatible with the standard Perl language, including the string form of eval and the runtime use of require" http://aspn.activestate.com/ASPN/Downloads/PerlNET/More PerlNET is like JPE, not like Jython. >... > > Can a MONO.NET be created as easily or, hopefully, even easier , than a > MS Python.NET? Is anyone thinking of creating a Mono.NET? I don't know what Mono.NET would be. Mono is an implementation of .NET already! Python.NET will likely run on Mono and MS.NET equally as long as they both implement the ECMA .NET standard equally. Obviously the Mono guys will try to be as similar to MS.NET as possible. >... The Ruby newsgroup has had a lot > of such discussion about a Ruby.NET (as well as a Java-Ruby version); Talk is cheap. :-) Without any disrespect intended, open source people tend to have big visions and sometimes they shoot past (Linux) and sometimes they don't get to implement as much as they hope for. > and I sense that Perl.Net may be Microsoft's and ActiveStates' first > priorities for scripting languages for .Net. ActiveState got both languages to a point where someone else could take them up and try to optimize them and fill in the holes. There was a sense that we could take what we learned there and make a product for Perl (using a completely new strategy and an unrelated code base). As .NET cranks up, customers may express interest in an equivalent for Python. > By the way, I recall Alex Martelli was involved in the previous > discussion of this topic. He is always one of my favorite posters, I > always learn something when I read his posts, no matter what the topic. > I have missed him lately. Does anyone know if he will be back???? Or am > I just missing his posts? Alex, please come back....:-)))))) Alex is working on a couple of books. In the long run you'll thank him. Paul Prescod From root at rainerdeyke.com Thu Nov 22 01:06:57 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 22 Nov 2001 06:06:57 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: <5C0L7.159189$IR4.55612315@news1.denver1.co.home.com> "Dave Cinege" wrote in message news:mailman.1006401758.28916.python-list at python.org... > I don't make excuses for poor editors. A programming editor worth > anything (IE nedit) will let you define the display of tabs to > how many ever spaces you like. Tabs should not be displayed as spaces at all. I'm inclined to say that any editor that does display them as spaces is broken. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From syt at gemini.logilab.fr Mon Nov 26 10:58:45 2001 From: syt at gemini.logilab.fr (Sylvain Thenault) Date: Mon, 26 Nov 2001 15:58:45 +0000 (UTC) Subject: [newbie] python no module pcre References: <9ttib1$4ir0l$1@ID-6754.news.dfncis.de> Message-ID: On 26 Nov 2001 15:07:29, Wilfried Trabold wrote: > >Trying to install "narval" > >http://www.logilab.org/narval/ > >on suse 7.3 i failed. it says that pcre couldn't be found >but: > >whereis pcre >pcre: /usr/include/pcre.h /usr/share/man/man3/pcre.3.gz > >any hints ? >greetings >bil > >me at mymachine:~> narval --debug [snip traceback] > from Ft.Rdf.Drivers.Memory import DbAdapter > File "/usr/lib/python2.1/site-packages/Ft/Rdf/Drivers/Memory.py", >line 16, in ? > import string, re, pcre >ImportError: No module named pcre I think pcre is part of the standard python distribution. You should have /usr/lib/python2.1/lib-dynload/pcre.so, or I guess you have a problem with your python installation (maybe two installation dir, /usr/lib/python2.1 and /usr/local/python2.1 ?) If you have problem with narval, send questions to narval-en at lists.logilab.org (or narval-fr at lists.logilab.org if you speak french ;) -- Sylvain Thenault LOGILAB http://www.logilab.org From kuran42 at yahoo.com Fri Nov 9 06:25:14 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Fri, 09 Nov 2001 06:25:14 -0500 Subject: Help Help Help References: <3be77f95@152.65.161.36> <3BEA27D7.9050405@yahoo.com> <3BEAE9D6.FB010420@ccvcorp.com> Message-ID: <3BEBBD1A.4050307@yahoo.com> Ahh, your loop is nicer, but I liked the encapsulation of the, err, complex code required to determine if the input was an int... Yea, that's it. The sys.stdin/print inconsistancy would be due to my limited experiencing using python on the command line: I usually get my input from sockets. :) Jeff Shannon wrote: > Jp Calderone wrote: > > >> [snip code] > > Why do the int() conversion twice?? By rewriting your while loop as follows, you > eliminate the need for your isInteger() function.... > > while 1: > x = sys.stdin.readline() > try: > return int(x) > except ValueError: > print "That is not an integer, please try again:", > > I also wonder why you use sys.stdin.readline() in place of raw_input(), but you > still use print and not sys.stdout.write() .... but I suppose that's just a > trivial bit of inconsistency with only aesthetic significance.... :) > > Jeff Shannon > Technician/Programmer > Credit International > > > From tim.one at home.com Fri Nov 30 13:10:37 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 30 Nov 2001 13:10:37 -0500 Subject: What's the value of "None" between 2.1.1 and 1.5.2 In-Reply-To: Message-ID: [Michael Abbott] >>> So why don't comparisons of this type generate an exception? More than half the reason is historical: in its early years, it was technically impossible for Python to "notice" exceptions raised by comparisons (you could raise them, but they were ignored, and the reason cut "deep"). After that, backward compatibility kicked in (e.g., there are many complaints that non-equality comparison of complex numbers now raises an exception, and despite that the result we used to return didn't make much sense). [Steve Holden] >> Because comparisons are used in sorts, for example, and it wasn't >> considered helpful for sorts of lists of arbitrary datatypes to raise >> errors. That's the other half. [Michael Abbott] > Sigh. I understand. > > Of course, if you are sorting a list of arbitrary datatypes using random > datatypes as the key then you're in a state of sin. More like potential sin : many applications for sorting couldn't care less about a total ordering, they merely want to make "equal" elements adjacent, to simplify "the next" step -- and list.sort() is sometimes used to segregate the elements of a huge heterogeneous list by type. If we could do it over again ... From niemeyer at conectiva.com Fri Nov 16 19:37:36 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Fri, 16 Nov 2001 22:37:36 -0200 Subject: Python .elc and /etc/magic In-Reply-To: References: Message-ID: <20011116223736.B1008@ibook.distro.conectiva> > > We should also have something like that for python: > > > > 0 string/b #!\ /bin/bash Bourne-Again shell script text executable > > 0 string/b #!\ /usr/local/bin/bash Bourne-Again shell script text executable > > Why is that necessary? > > porthos loewis 24 ( /tmp ) > cat a.py > #! /usr/bin/python > > print "Hallo, Welt!" > porthos loewis 25 ( /tmp ) > file a.py > a.py: a /usr/bin/python script text Since there are entries for interpreters like perl, awk, gawk, bash and others, I thought python would fit there. Just for curiosity, that's from the default magic file of "file 3.35". [niemeyer at ibook niemeyer]$ grep \/bin /usr/share/misc/magic | wc -l 28 Best regards! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From kfarmer at thuban.org Fri Nov 23 17:33:34 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Fri, 23 Nov 2001 22:33:34 GMT Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> <3BFEC93C.78DB7D98@ccvcorp.com> Message-ID: <29AL7.2768$nK1.269290698@newssvr14.news.prodigy.com> "Jeff Shannon" wrote in message news:3BFEC93C.78DB7D98 at ccvcorp.com... > you're doing repeated runs of the same script, you can run DOSkey and then > you can repeat the command with up-arrow. Actually (at least under Win2k, I think under Win98), DOS already supports up-arrow history. ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From sholden at holdenweb.com Wed Nov 28 11:51:25 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 11:51:25 -0500 Subject: Should I use threads here? References: Message-ID: "Era Akost" wrote in message news:mailman.1006961202.10002.python-list at python.org... > Hi all, > > My problem is the following. I have a program (no > source code) that takes some data from a file and > calculates some models. While executing, the program > outputs continually on the console. > Now, I want to call this program within a Tkinter GUI. > > I call the program (thanks to Steve Holden for the > answer) through popen2() > > i, o = os.popen2('myProgram files') > for line in o.readlines(): > text.insert(END, line) > #text is a widget defined somewhere before. > > But since I want to write the output on a GUI widget, > I saw that this happens only after my program is > executed (I've should have known that). But sometimes > the programs runs for minutes, so in the meantime I > want some results beeing displayed in my GUI. Is that > something can be done with threads? If yes, how? I've > never used them before. Could someone give me an > example? (Python 2.01, Win NT) > Era: readlines() doesn't terminate until it knows (by seeing and end of file on its input stream) that it has read all the input. If you built a loop using readline() you might find you got better results. This will process your lines one at a time: while 1: line = o.readline() if not line: break text.insert(END, line) regards Steve -- http://www.holdenweb.com/ From johnny at johnnysfunhouse.com Tue Nov 20 16:31:49 2001 From: johnny at johnnysfunhouse.com (Refrigerator Johnny) Date: Tue, 20 Nov 2001 21:31:49 GMT Subject: importing SWIG extension DLL from VC++ Message-ID: <9ZzK7.40081$Ze5.22244774@news1.rdc1.md.home.com> >From VC++, I cant seem to import an extension DLL made with SWIG? for example: po = PyImport_ImportModule("import simple"); po = PyRun_String("simple.jbtestfn()",Py_eval_input, pdict, pdict); in the python interpreter I can: import simple simple.jbtestfn() with no problems. This is just a simple test. I have a bigger problem, where importing an extension DLL causes an assertion? any insight/suggestions would be appreciated! -john From kevin at cazabon.com Fri Nov 16 16:59:43 2001 From: kevin at cazabon.com (Kevin Cazabon) Date: 16 Nov 2001 13:59:43 -0800 Subject: Sizing Up Graphics Automatically References: Message-ID: <5a4226f0.0111161359.2e744249@posting.google.com> Actually, it's very easy using Python and PIL (Python Imaging Library, see www.pythonware.com), I do a very similar thing on my website, sizing graphics to the resolution of the user's browser before sending them (to save bandwidth). I use JavaScript on the client side to send me the screen resolution (to a Python cgi script), and process the image from there. See: www.cazabon.com/wedding for the example. If you are interested, I'll gladly provide the source code I use. (it's actually a very nicely automated photo album script, combo Perl/Python. All I do is create a folder, drop images in (any size), and the script does the rest... they're online immediately, in a category named by the folder I created.) Kevin Cazabon. Ben Ocean wrote in message news:... > Hi; > Is it possible to automatically size up a graphic upon upload and > programmatic insertion into a script? I use Zope and want to build a > through-the-Web interface to enable my client to automatically change/add > photos, but I want to set the site up such that all the dimensions of > graphics, font sizes, etc., are resized depending on the visitor's browser > resolution. In order to do that, I *must* somehow capture the dimensions of > the uploaded graphic programmatically? Any ideas how to do this? Anybody > have some code they'd like to share? > TIA, > BenO From kragen at canonical.org Sun Nov 25 20:43:36 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 20:43:36 -0500 Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> <3BFF94BE.512ABA80@verizon.net> Message-ID: <83wv0etign.fsf@panacea.canonical.org> Power-Tech writes: > Yesterday (friday) I got the book "python blible" and I am inmersing myself > in it. This is my first serious atempt to learn a programming language (I > know HTML and some PHP/MySql), but I think Phyton is the way to go for a > fisrt full programming language, right? I don't know --- I haven't not known any programming languages for quite a while, and I haven't taught beginners much. Python seems like it might be a good choice; let us know how it goes! Especially if it doesn't go well. From matt at mondoinfo.com Mon Nov 5 14:16:35 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Mon, 05 Nov 2001 19:16:35 GMT Subject: ping with python References: <3be6cb4a@guardhouse.chbs> Message-ID: On Mon, 05 Nov 2001 17:24:29 GMT, Paul Pfaff wrote: >Hello, Hi! > I'm looking to write a simple Ping tool in Python 2.1.1 to log > response time xx ms. > Python is new for me and I find it really interesting. For the > moment I have buy following good books : > - Programming Python (Mark Lutz, O'Reilly) > - Learning Python (Mark Lutz, David Ascher, O'Reilly) > > But, can you help me please : > 1. I need the reference of a beginner book how explain the basic > functions, or if possible a URL. There are some good introductions and other things linked from: http://www.python.org/doc/Newbies.html Much of that is geared toward folks who aren't programmers. There are other links as well at: http://www.python.org/doc/Intros.html > 2. Can you tell me if an IP library is available ? (commands : ping, > tracert....) There's the socket module which will allow you to write your own programs that use sockets. Jeremy Hylton implemented ping and traceroute: http://www.python.org/~jeremy/python.html and I implemented ping: ftp://ftp.visi.com/users/mdc/ping.py But from the way you spell tracert, I expect that you're using Windows. Those programs are likely to run under NT but not under 95/98/ME. I don't know about 2000. Regards, Matt From arigo at ulb.ac.be Sat Nov 10 14:45:00 2001 From: arigo at ulb.ac.be (Armin Rigo) Date: Sat, 10 Nov 2001 20:45:00 +0100 Subject: Psyco 0.3.1 Message-ID: Hello everybody, Finally, the first usable version of Psyco. It compiles small but realistic code examples. http://homepages.ulb.ac.be/~arigo/psyco/psyco-0.3.1.tgz The included text files can also be read at http://homepages.ulb.ac.be/~arigo/psyco/psyco-0.3.1/README.txt and http://homepages.ulb.ac.be/~arigo/psyco/psyco-0.3.1/ISSUES.txt . Not all Python bytecodes are implemented, but you can already do quite a lot. The missing ones are the ones that cannot be really optimized any more, so they should be easy to implement as a call to a run-time function. I used Python 2.2b1's new typing system to figure out when an attribute is a method. It should still compile with older Python version but you will not get method access optimization. There are a few cases in which Psyco does not exactly follow Python's semantics, mainly with globals/builtins. Builtins are assumed never to change, and we assume that the user will not later add or remove a global variable that will shadow or expose a builtin. This issue and others are discussed in detail in ISSUES.txt. Produced code buffers are never freed. This is a problem for larger examples. See ISSUES.txt. This file will also give you cool examples of Python code which are known tricks to speed up the interpreter but which are no longer needed -- Psyco is able to optimize them correctly. One such nice example is 'range', which is now actually faster than 'xrange', and completely transparent (for x in sequence is equivalent to for i in range(len(sequence)): x = sequence[i]). Inspecting the produced machine code is now possible if you have GDB (the GNU debugger) installed. There is a script that presents the produced cross-calling code buffers as cross-linked HTML pages. And finally... (drums...) some timing results. This is for my notebook Intel PIII 700Mhz with all optimization turned on. Note however that none of these small examples is typical of Python code; they are all small compact algorithms not using complex data structures. f1() is designed specifically for the purpose of showing how fast Psyco is ;-) It works on integers only, and is not at all a real-world algorithm. f2() and f3() are too trivial to be timed. f4() is a function that loads a list of files and counts the number of times each character appears. Ok, this is also a case in which Psyco will clearly win. f5() is like f4() but completely loads the files in memory, whereas f4() loads them line by line. f6() computes the factorial modulo p, using long integers, whose operations are not optimized by Psyco. f7() is the Mandelbrot set. Float/complex not optimized by Psyco. In the latter two examples the gain is only on the stuff around the actual computations. The table is in seconds, as returned by time.clock(), so the numbers don't include delays for loading the (relatively large) code of Psyco itself nor any swapping. Psyco, first call Psyco, next calls Python -OO go1() 0.03 0.02 to 0.03 3.63 go4() 0.35 0.33 3.59 go5() 0.29 0.27 3.47 go6() 0.87 0.85 1.03 to 1.07 go7() 2.16 to 2.18 2.16 to 2.18 2.83 Interesting, isn't it ? A bientot, Armin. From richard at bizarsoftware.com.au Tue Nov 27 17:04:48 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Wed, 28 Nov 2001 09:04:48 +1100 Subject: HOWTO: Programming S/MIME in Python with M2Crypto In-Reply-To: <20011128000245.C1025@madcap.dyndns.org> References: <20011127001748.B783@madcap.dyndns.org> <20011128000245.C1025@madcap.dyndns.org> Message-ID: <200111272204.fARM4h336438@bigboy.bizarsoftware.com.au> On Wednesday 28 November 2001 03:02, Ng Pheng Siong wrote: > On Tue, Nov 27, 2001 at 08:48:44AM +0200, Graeme Longman wrote: > > I know that in the HOWTO you don't actually send the example in 'Sign' > > but have you managed to send and receive this example. If you have > > successfully then maybe it is the 'Outlook' issue. > > The function sendsmime() in sendsmime.py works: I've used this to send to > Netscape Messenger successfully. sendsmime() sends plain, signed, encrypted > or signed-and-encrypted mail. I remember being quite pleased with myself > when I got that done. ;-) The only caveat that we've found is that you can send a multipart e-mail with an encrypted part to Netscape, but not to Outlook. Outlook _only_ handles the entire message, one part, being encrypted. Richard From claird at starbase.neosoft.com Mon Nov 26 15:12:49 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 26 Nov 2001 14:12:49 -0600 Subject: Programming Rayleigh-Ritz method References: <3BFD0E67.9080106@stu.ust.hk> Message-ID: In article , William Park wrote: >On Thu, Nov 22, 2001 at 10:40:39PM +0800, Calvin wrote: >> Greetings, >> Did anyone have the experience of programming the Rayleigh-Ritz method >> using Python. The Rayleigh-Ritz method is a numerical approximation for >> solving energy minimizing problem. If you have program FEM in Python. >> Could you teach me how to write the algorithm? > >Calvin, > - if you have C source code, then it's easy to translate it to Python. > - if you have the algorithm in pseudo-code, then it's even easier. >In other words, write it your self. :-) . . . "... energy minimizing ..." in a general sense, I think it should be noted. Rayleigh-Ritz finds extrema on finite-dimensional subspaces or mani- folds. It's generally presented in terms of variational calculus. Rayleigh-Ritz, as opposed simply to Ritz, typically indicates an interest in eigenvalues, often of physically-germane par- tail differential equations. Python's a worthy vehicle for such work. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From jeff at ccvcorp.com Wed Nov 14 15:06:38 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 14 Nov 2001 12:06:38 -0800 Subject: PEP proposal: enhanced string functions References: Message-ID: <3BF2CECE.35185F36@ccvcorp.com> Stephen Ferg wrote: > PEP: XXX1 > Title: Optional pad character for string justification functions This seems simple and occasionally useful... though to be honest, I don't think I've ever used justification functions, I use length-specified string substitutions instead ( e.g., "%20s %5s" % (name, dept) ...) Your proposal could make the justification functions helpful enough that I might start using them, though. ;) > > =========== > PEP: XXX2 > Title: Optional argument for string strip functions Much of the usage of this, can already be accomplished with mystring.replace(stripchar, '') which eliminates *all* occurences of stripchar, not just leading/trailing ones. Whether this is preferable or not depends upon the context, of course, but I suspect that in most cases (like both of the examples given) this would be equivalent. Jeff Shannon Technician/Programmer Credit International From starx at pacbell.net Wed Nov 28 10:26:30 2001 From: starx at pacbell.net (Philip Swartzleonard) Date: 28 Nov 2001 15:26:30 GMT Subject: lego does Python References: Message-ID: Robin Becker || Wed 28 Nov 2001 07:06:59a: > http://www.lego.com/studios/screening/movie.asp?opt=qtl FWIW this is one of the 'unshot footage' extras on the Holy Grail DVD :) -- Philip Sw "Starweaver" [rasx] :: From paulsid at home.com Wed Nov 14 22:33:38 2001 From: paulsid at home.com (Paul Sidorsky) Date: Wed, 14 Nov 2001 20:33:38 -0700 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> Message-ID: <3BF33792.5E8595F6@home.com> Gernot wrote: > I want to implement the functions myand, myor and mynot. They should have > the same effect as the known boolean operators and, or and not. > > The trick is that I am not allowed to use the boolean operators and, or and > not. > This is what I tried: [snip] > I think, the idea is not that wrong, but anyway, it doesn?t work! It has > something to do with "bool (x)", I think. Maybe this is something like a > module which i have to "activate" first?? Assuming this is for a CS problem, I don't know what the instructor has in mind, of course, but I expect he/she would consider the above approach (if it had worked) as missing the point. It's more likely the instructor wants (or would be more impressed by) a generic solution that would work in any language, especially if this is for a "fundamentals of programming" course. The way I would approach this problem (as I understand it) is to convert each ASCII character of the strings to a number using ord() and then use mathematical and relational operators (+, -, <, >, ==, etc.), assuming they're allowed. (I would think they would have to be.) The conversion is easy with list comprehensions (Python 2.0 and up): xlist = [ord(i) for i in x] ylist = [ord(i) for i in y] This will give you two lists of numbers, the elements of which you can then use the other operators on to mimic the logical operators. Exactly how to do that I won't say because I expect that's what the instructor really wants you to figure out. I hope that's a push in the right direction. But of course I don't know exactly what the goal and specific restrictions are here so I may be way off base. -- ====================================================================== Paul Sidorsky Calgary, Canada paulsid at home.com http://members.home.net/paulsid/ From joseph at arbitrary.org Thu Nov 29 19:29:16 2001 From: joseph at arbitrary.org (Joseph Santaniello) Date: Thu, 29 Nov 2001 16:29:16 -0800 Subject: pygettext examples? Message-ID: Hello everyone, Does anyone have a link or some info on how in practical terms to use the pygettext module? I've looked at the online docs, and they do a good job of explaining in theory how to add multiple languages to an app, but they haven't got me to where I need to be... I need some examples and recipes to be able to figure it out. Thanks, Joseph From neal at metaslash.com Tue Nov 13 08:05:04 2001 From: neal at metaslash.com (Neal Norwitz) Date: Tue, 13 Nov 2001 08:05:04 -0500 Subject: Linux/Alpha memory leaks References: Message-ID: <3BF11A80.AA8A3F9F@metaslash.com> Peter ?strand wrote: > > > > I have some problems with memory leaks in a web application, written in > > > Python. It works good on Sparc/Solaris and Linux/i386 (uses < 10 MB on > > > these platforms), but in Linux/Alpha the application consumes > 50 MB in > > > less than 24 hours. Since the Python application works good on two other > > > Check out this patch which has been applied (9-Nov): > > > > http://sourceforge.net/tracker/index.php?func=detail&aid=478006&group_id=5470&atid=105470 > > > > That may address your problem. Specifically, it closes a leak in 2.2b1+. > > I don't know if it affects 2.1.1. > > Now I have also tried the CVS version, with this patch applied. It still > leaks. > > Maybe I should try with GNU pth threading libraries, instead of > LinuxThreads? I don't know if that would help or not. There are very few leaks in Python when running the regression tests. You can try using a memory leak detector in python to determine the problem. If you can narrow it down to a small test case, it may be possible to determine if the fault is python, glibc, or something else. Neal From adamspitz at bigfoot.com Mon Nov 12 16:06:15 2001 From: adamspitz at bigfoot.com (Adam Spitz) Date: 12 Nov 2001 13:06:15 -0800 Subject: IsPython really O-O? References: Message-ID: <87f44f44.0111121306.426c8e4f@posting.google.com> Tim Hammerquist wrote: > Well, if he didn't think Java was OO, he shouldn't bothered looking at > Python. Besides, no matter how brilliant the programmer, in my > experience, a Smalltalker will never acknowledge anything except > Smalltalk as an OOP. Don't waste your breath. =) For what it's worth, I consider myself a Smalltalker, and I like Python very much. I don't give a hoot about OO purity - I like Smalltalk because I'm really productive in it, and I like Python for the same reason. (Ruby, too. ;) But then, maybe I'm in the minority... Adam Spitz From jgardn at alumni.washington.edu Tue Nov 27 23:10:02 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Wed, 28 Nov 2001 13:10:02 +0900 Subject: Editor for Python: A PLEA In-Reply-To: <3C03CFAC.6A29863@earthlink.net> References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> Message-ID: <01112813100206.00609@linux> > > >There need not be 50 conflicting opinions. One only needs two editors: > > > > > > - Vim > > > - Emacs > > > > Why two editors? Will not one or the other do? > > Yes, but which one that is has been an age-old dispute. :-) I am curious as to what editors are being used to edit python. I get the feeling that most people who post here, especially the gurus, use *ahem* Vim *ahem*. I will do an informal poll. Send an email with a subject of "python editor poll" and I'll do a quick tally and post the results tomorrow. Please don't post your preference to this list, it tends to get exciting. Jonathan * In case you're wondering what editor I use, let me just say that it works really well with the email client that sucks less than all the others. * If you are still wondering, one of my projects at sourceforge is called python-vim. (http://sf.net/projects/python-vim). I haven't uploaded anything because I am waiting for some advice from Bram on licensing. From chrishbarker at home.net Mon Nov 26 16:07:57 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 26 Nov 2001 13:07:57 -0800 Subject: string.join() syntax quirky? References: Message-ID: <3C02AF2D.943951FA@home.net> > > One way to look at it is that the various collection classes do NOT > > inherit from a single base class (which would be a logical place to > > define a join method). Hence to have all kinds of collections > > learn to > > "join" requires a lot of repeat coding. Making join a string method > > solves this problem. > > So instead of doing what's right we're doing what's convenient? Doesn't > sound very Pythonic Another way to look at is is that joining and splitting are inherently string functionailty, and thus belong with the string object. Or the string module, if you take the procedural view of programming. I don't think join() belongs with sequences at all, as sequences can hold anything,not just strings. "".join(list) is a little clunky, but it makes sense to me. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From phd at phd.pp.ru Thu Nov 8 08:44:10 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 8 Nov 2001 16:44:10 +0300 Subject: Shelve problem: why so big? In-Reply-To: <9se1du$6eg$1@samos.cs.uu.nl>; from geert@cs.uu.nl on Thu, Nov 08, 2001 at 01:30:38PM +0000 References: <9sdol4$2te$1@samos.cs.uu.nl> <9se1du$6eg$1@samos.cs.uu.nl> Message-ID: <20011108164410.L6242@phd.pp.ru> On Thu, Nov 08, 2001 at 01:30:38PM +0000, Geert-Jan Giezeman wrote: > >> > bsddb.error; (22, Invalid argument) > >> > >> http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.099.htp > >> > > This FAQ advises to move to a newer version of the Berkeley DB library. > How do I know which version I use? How do I replace it with a newer? Very OS dependent. > (I installed the standard Python 2.1 distribution for Windows). Python 2.1? Probably BSDDB 2.0+. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From fperez528 at yahoo.com Wed Nov 28 11:08:42 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Thu, 29 Nov 2001 15:36:42 +2328 Subject: Whatever happened to String Interpolation? Message-ID: <9u6dbn$nsj$1@peabody.colorado.edu> I'm a big fan of Ka-Ping Yee's Itpl module (which allows strings of the form 'the value of x is $x', but I often find myself not using it so as not to add an extra dependency to a program I want to keep small. There's PEP 215 (http://python.sourceforge.net/peps/pep-0215.html) where he proposed a simple and clean (IMHO) way to build this into the language. I googled for a while and found very few things concerning it. Did this die? If so, why? It seems clean, unobtrusive and fantastically useful. Plus, I think it actually makes Python code much clearer in situations with complex string manipulations. Does anyone know? Cheers, f. From fredrik at pythonware.com Fri Nov 23 14:34:12 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Fri, 23 Nov 2001 19:34:12 GMT Subject: syntax-error? References: Message-ID: Stefan Antoni wrote: > I got the following script and it produces a syntax error which drives > me crazy here's how that function looks in my editor: > def ExtractData(in_string, start_line, end_line): > lstr = in_string.splitlines() > j = 0 # a counter > for i in lstr: the lstr line uses four spaces for indentation, the lines after it uses a single tab. the python interpreter assumes that a tab is 8 spaces. it's a good idea to use the same setting in your editor (or better, to use only spaces or use only tabs). editor configuration tips and tricks can be found here: http://py-howto.sourceforge.net/editor/ From graz at mindless.com Mon Nov 12 11:44:19 2001 From: graz at mindless.com (Graham Ashton) Date: Mon, 12 Nov 2001 16:44:19 GMT Subject: Python in a hospital application please help References: <9sk4hq$2hcg$1@norfair.nerim.net> Message-ID: In article <9sk4hq$2hcg$1 at norfair.nerim.net>, "Gillou" wrote: > You can compile python with SSL support for security but dunno if your > app can connect to the database through SSL (not a pythonic issue). The way forward here may well be to run the database server and the Python server on the same host and disable network connections to the db. It's simple and not very scalable, but with security simplicity is a good thing. > If your application (clients + server) are in a firewalled Intranet, you > don't need more than classical user/password security. What gives you that idea? 90% of security problems are caused by people who are already inside the firewall (i.e. staff). In a hospital you can have all sorts of people wandering around, and you don't want to take chances with people's medical data. With security, don't ever say "that's enough". It's not. Add more if it won't cost you anything. I'd implement a specific firewall on the database server if it was my problem. It's best practice, and you may one day find yourself in the unfortunate situation of needing to demonstrate that you'd taken all reasonable steps to protect the data. > Encryption should not add sensitive security to your data. What do you mean by this? As for the Object-Relational mapper, have a look at PyDO: http://skunkweb.sourceforge.net/PyDO/ -- Graham From tjreedy at home.com Tue Nov 6 06:16:26 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 06 Nov 2001 11:16:26 GMT Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Michael Hudson asks > Did you actually want answers to these questions? It's been sometime > since I looked at it, but think I can remember the answer to some of > them. Take a pinch of salt with most of what follows. The post you answered hasn't arrived here yet, but I have certainly been genuinely curious about some of these questions. > Is this helping? Yes, for me. Thank you. Terry J. Reedy From keiichi at yggdrasil.maisel.enst-bretagne.fr Sat Nov 3 15:37:02 2001 From: keiichi at yggdrasil.maisel.enst-bretagne.fr (Defresne Sylvain) Date: 3 Nov 2001 20:37:02 GMT Subject: [BUG ?] Slicing a 'struct_time' can crash Python interpreter References: Message-ID: Tim Peters wrote: > I'm confused. Python 2.2 has not been released, and won't be until > December -- 2.2b1 is a beta release, and nobody should be shipping a beta > version in a production system (we guarantee that beta releases have nasty > bugs ). So if you're not confused, Debian is. In fact, I'm using the development version of Debian. That explain why an beta version of Python 2.2 is shiped with. But the prefered Python on Debian is still 2.0 . Bye From vincem at en.com Wed Nov 21 06:00:34 2001 From: vincem at en.com (Vincent Marchetti) Date: Wed, 21 Nov 2001 06:00:34 -0500 Subject: How to implement and call C++ class static function References: Message-ID: <3bfb8bcb$0$65159$ac966d11@news.raex.com> In article , "Roman Yakovenko" wrote: > For example > > class CBlaBla > { > static int Foo(){ return 0; } > }; > > > .... > CBlaBla::Foo(); > > Thanks for the help. Roman. I don't know if there's a more Pythonish way, but I do this: def __FooImp__(): return 0 class CBlaBla: ... Foo = __FooImp__ ... From martin.franklin at westgeo.com Mon Nov 26 03:33:52 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Mon, 26 Nov 2001 08:33:52 +0000 Subject: Does Anybody Know How To Get Tkinter Working?? References: Message-ID: <9tsuof$3fja$1@mail1.wg.waii.com> Hi, This is the second time I have responded..... looks like make can't find your X11 headers you may need to install Xfree86 or whatever the RPM is known as. My X11 headers are in /usr/include/X11 so if you don't have these get them....... HTH Martin Ben Ocean wrote: > Hi; > This is my third request for help and I'm hoping someone will respond this > time :) > > I just configured Tcl--itworks--and I went to configure tk (both latest > stable distros) on my RH71 box and ran into all sorts of errors on *make*. > Both installations are in /usr/lib and I'm in as root. It exits with Error > 1. Here's how the errors start: > > [root at hermes unix]# make > gcc -pipe -c -O -D__NO_STRING_INLINES -D__NO_MATH_INLINES -Wall > -Wconversion -Wno-implicit-int -fPIC -I/usr/lib/tk8.4a3/unix > -I/usr/lib/tk8.4a3/unix/../generic -I/usr/lib/tk8.4a3/unix/../bitmaps > -I/usr/lib/tcl8.4a3/generic -DHAVE_UNISTD_H=1 -DHAVE_LIMITS_H=1 > -DSTDC_HEADERS=1 -DHAVE_SYS_TIME_H=1 -DTIME_WITH_SYS_TIME=1 > -DHAVE_PW_GECOS=1 -DTCL_NO_DEPRECATED > /usr/lib/tk8.4a3/unix/../generic/tk3d.c > In file included from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:21, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/tk.h:83: X11/Xlib.h: No such file or > directory In file included from > /usr/lib/tk8.4a3/unix/../generic/tkPort.h:32, > from /usr/lib/tk8.4a3/unix/../generic/tkInt.h:27, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.h:18, > from /usr/lib/tk8.4a3/unix/../generic/tk3d.c:16: > /usr/lib/tk8.4a3/unix/../generic/../unix/tkUnixPort.h:77: X11/Xlib.h: No > such file or directory > etc. etc. etc. etc. etc. etc. etc. etc. etc. > > Any ideas? > TIA, > BenO > > > > From printers at sendme.cz Wed Nov 14 05:51:27 2001 From: printers at sendme.cz (A) Date: Wed, 14 Nov 2001 11:51:27 +0100 Subject: Mimetools and how to use it Message-ID: <3BF25ABF.27201.B52A60@localhost> Hi, >From a web server I receive headers that is an instance of the class MIMETOOLS.MESSAGE. How can decode it to get something like this Date: Wed, 14 Nov 2001 10:02:17 GMT Server: Apache/1.3.6 (Unix) PHP/3.0.14 X-Powered-By: PHP/3.0.14 Set-Cookie: PHPSESSID=000741aaa06ae3645ff0106145f842b5; path=/ Expires: Thu, 19 Nov 1981 08:52:00 GMT Cache-Control: no-store, no-cache, must-revalidate, post-check=0 Pragma: no-cache Set-Cookie: c_id=bla; path=/ Connection: close Content-Type: text/html and how to extract cookies then? Any help would be highly appreciated. Ladislav From bzimmer at ziclix.com Sun Nov 18 10:43:37 2001 From: bzimmer at ziclix.com (brian zimmer) Date: 18 Nov 2001 07:43:37 -0800 Subject: Python servlet with DB References: <3BF7A0EB.C73F67C7@hurst-web.de> Message-ID: Christof Hurst wrote in message news:<3BF7A0EB.C73F67C7 at hurst-web.de>... > i must call a python-servlet out of a java applet. > It's part of a diploma, where python is compared with java. > now i don't know, how to make a connection to ma python, and how to make > the python servlet talk to the DB. > All DB-modules, i'va tried, didn't work. > I want to send an image from the java applet to the python servlet to > write this in a BLOB in my oracle Database. > Who can help me? > Look at zxJDBC (http://www.ziclix.com/zxjdbc) for examples on using a Python DB API module from within Jython/Java. brian From pmullh at yahoo.com Fri Nov 16 10:55:14 2001 From: pmullh at yahoo.com (PM) Date: 16 Nov 2001 07:55:14 -0800 Subject: popen on Win 9x? References: Message-ID: <4be6f063.0111160755.16862086@posting.google.com> "RPM1" wrote in message news:... > Goal: Write a python program that can call two other C programs and interact > with the stdin and stdout of the C programs on Win 98. > > The two C programs are chess programs that I won't have source to. I want > the two programs to play against each other. I have been successful at > using popen2 to act as stdin and stdout for either chess program separately > but when I try to communicate with both I have problems when I close the > second program's pipes. It leaves the process running and leaves a W9xpopen > process going and at least one Winoldap process. > > I open the pipes to each program and then write and read the pipes, (using > fstat and stat to determine how much data is in the pipes coming from the > chess programs so I don't block). My program works on Windows NT but not on > 98. > > Any thoughts? > > Thanks, > Patrick Here's the code: ====================== import string import os import stat import time def get_reply(p): count = 0 while (count == 0): count = os.fstat(p.fileno())[stat.ST_SIZE] data = '' while (count > 0 ): data = data + p.read(1) count = os.fstat(p.fileno())[stat.ST_SIZE] return data to_e1,from_e1 = os.popen2('d:\utils\yace\yace_09956\wb\yace') to_e2,from_e2 = os.popen2('d:\utils\comet\comet_b37 / xboard') to_e1.write('quit\n') time.sleep(3) print get_reply(from_e1) to_e2.write('quit\n') time.sleep(3) print get_reply(from_e2) from_e1.close() to_e1.close() from_e2.close() to_e2.close() ============================= I was able to run each chess program from python separately. I can even run each program separately in separate DOS windows at the same time. Any help would be appreciated, Thanks, Patrick From montanaro at tttech.com Thu Nov 8 10:03:04 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Thu, 08 Nov 2001 16:03:04 +0100 Subject: complex() bug or feature? In-Reply-To: <3BEA9AF2.CCC68665@snakefarm.org> References: <3BEA6446.8D8B4012@snakefarm.org> <3BEA8B0F.E594BE84@snakefarm.org> <3BEA9AF2.CCC68665@snakefarm.org> Message-ID: >> > or should the implementation raise an exception because it violates >> > the docs? I'd prefer the latter. >> >> That what the patch I just submitted to sf does :) Carsten> I was just about to submit my bug report when I read Carsten> this. Seems I'm getting slow. :-) Same here, and I'm in Vienna instead of Chicago for a couple weeks so I had a head start of seven hours over normal! -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From terabaap at yumpee.org Wed Nov 28 19:36:08 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Thu, 29 Nov 2001 00:36:08 GMT Subject: rxvt + python problem: script output buffered and interactive output missing References: <3C04A742.50700@yumpee.org> Message-ID: <3C058311.4030602@yumpee.org> Chris Liechti wrote: > Manoj Plakal wrote in news:3C04A742.50700 at yumpee.org: >>I'm encountering a strange problem when I run >>Python scripts and the Python interpreter in >>an rxvt window (with tcsh) on the latest Cygwin. >>This is with Win98/BeOpen Python 2.0/Cygwin 1.3.5/rxvt-2.7.2. >> >>The scripts print some messages to stdout but >>these gets buffered and appear only when the >>app exits (it runs for a while). If I add >>calls to flush stdout, then the messages appear >>as they are printed. >> >>If I run the Python interpreter itself, I >>get no output at all, the shell just hangs, >>I get the hourglass icon and I can eventually >>break out with Ctrl-C's. >> > > yes i have the same behaviour on my machine... python mistakenly > thinks that it has to thake its input from stdin/pipe instead of running > interactive. python runs if you specify "-i" explicit. > > i guess that it has something to do with the terminal name that rxvt sets, > so that an app doesn't know that its a console window. Cool, thanks, that works. Only problem is that now I can't quit out of the shell using Ctrl-D or Ctrl-Z. And Ctrl-C doesn't seem to produce a KeyboardInterrupt. The stty settings in tcsh seem to be fine, Ctrl-C/D/Z work in the shell. Manoj From mind.tech at verizon.net Sat Nov 24 07:36:03 2001 From: mind.tech at verizon.net (Power-Tech) Date: Sat, 24 Nov 2001 12:36:03 GMT Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> Message-ID: <3BFF94BE.512ABA80@verizon.net> Hey guys, Thank you very much for the answers....I loved this group and I'll definitely stick around to share your expertise! I used the solution mentioned by Jeff: At the very end of your script, add this line: raw_input("Press Enter to Finish") But I also will keep all others in mind. Yesterday (friday) I got the book "python blible" and I am inmersing myself in it. This is my first serious atempt to learn a programming language (I know HTML and some PHP/MySql), but I think Phyton is the way to go for a fisrt full programming language, right? Have a great weekend you all, Willie, NY Power-Tech wrote: > I am a very newby at phyton, actually I started messing with it two days > ago. I have a > question that may be so dumb that I was afraid of posting in the > mailgroup, could anyone answer me or direct me to someone who can? > The problem is: > I create a small program with the Python IDLE gui, save it as a .py > file, when I double click to open the file, a DOS window opens but > closes immediately, without running the program, or if it is a > calculating program, as soon as I type something, the window closes. > I am using Windows 98 OS. > Thanks for your reply... > Willie -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeff at ccvcorp.com Fri Nov 9 19:26:28 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 09 Nov 2001 16:26:28 -0800 Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> <8ZXG7.5723$Yh.305712@atlpnn01.usenetserver.com> Message-ID: <3BEC7434.6A84B5E3@ccvcorp.com> harry wrote: > > He is probably asking you which C library your version of Python was > > compiled with. But you don't need to know that, either. > > > > All Python dictionaries are a standard 2.5 cm by 3.6cm. Integers have no > > width and are all 1.2 cm in length. Strings are all 2 mm times the number > of > > characters, except Unicode strings, which are 4 mm times the number of > > characters. > > could you explain further about the metric standard you're using. this is > the first time a size of data structure is measured using meters instead of > byte/bit. > i need the information for my post-mortem of my assignment to explain why > using python data structure would be efficient. yes, i'm only a studemt who > is still need to learn lots of stuffs. > thanks. Aha! We finally have the reason that you need to know the size. :) Steve's metric measurements were (unless I'm seriously mistaken) a sarcastic attempt to point out that 99.9% of the time, the amount of space taken up by a dict is totally irrelevant. And indeed, in your case, it makes *no* difference to the program, it's only important in justifying it to an outside individual (in this case, your instructor). The point that everyone was trying to make is, there are *very* few instances when it will matter whether a given dict takes up 100 bytes, or 1000 bytes. In a day when computer memory typically measures in the hundreds of millions of bytes (and if that runs out, there's always virtual memory...), a few hundred bytes here and there are insignificant. The real efficiency gain in using a python data structure, is that you've got a very flexible and reliable component that took you all of about 5 minutes to use (compared with how many hours to code a C++ object that'll do the same?). Unless you're working in embedded systems and the like, developer time is *far* more important than memory size or even (in most cases) execution speed. Jeff Shannon Technician/Programmer Credit International From ykingma at accessforall.nl Wed Nov 21 15:21:50 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Wed, 21 Nov 2001 21:21:50 +0100 Subject: getting modules optionally References: <3BFC2647.D9692B49@gol.ge> Message-ID: <3BFC0CCE.B55716AC@accessforall.nl> Steve Holden wrote: > > "Giorgi Lekishvili" wrote in message > news:3BFC2647.D9692B49 at gol.ge... > > Dear all! > > > > I apologize for this nebye-like question. > > > > Suppose, we have a package with one __init__.py file, while the rest are > > other modules (let's call them active modules), which do the essential > > stuff. > > > > Apparently, I need to start like this: > > > > > > from MyPackage import * > > > > I need to import only one active module. This can be done by hardcoding: > > > > from MyPackage.ThisModule import * > > > > What I can not do is to import the module, if I have its name as string. > > > > modname='ThisModule' > > > > Of course, the code below doesn't work: > > > > from MyPackage.modname import * > > > > The question: is there something like eval function, which could > > transfer the string as the real module name? In other words, how have I > > to treat the modname to make this code running? > > > > from MyPackage.modname import * > > > Take a look at the built-in __import__() function. You might also consider avoiding 'from .. import *'. It's ok for interactive use, but it might unexpectedly override some names that are already the module namespace. It is better to specify a new prefix name for the imported names: import MyPackage.modname as Mymodname or from MyPackage import modname or from MyPackage import modname as MyModname Regards, Ype From tim.one at home.com Fri Nov 9 19:39:53 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 9 Nov 2001 19:39:53 -0500 Subject: How much is set in stone? In-Reply-To: <7xofmcy0xd.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > ... > Part of the question "can I write robust applications in Python" is > "how reliable is the interpreter, really?". I've seen Python 2.1.1 > inexplicably crash several times. One thing that another language > might give you besides compiler warnings and false senses of security > is implementations that don't crash. > > Overall Python seems pretty reliable but I think its implementation is > not yet as well shaken out as some other languages' implementations. > I'm happy writing web applications in Python. I could not in good > conscience recommend writing life critical apps (medical implant > firmware, avionics, etc.) in Python in its present form. I invite anyone who cares to study the bug lists for Perl, gcc and Python, and draw an informed conclusion from that. You (Paul) have spread FUD about 2.1.1 before, and I can assure you we didn't pay everyone on c.l.py to refrain from posting "me too!", neither to write about their Python apps running for months at a time. Your experience remains unique, irreproducible (last I heard), and *could* be caused by any number of computer problems, both hardware and software. While *a priori* a crash in a Python program is most likely a bug in Python, the lack of any confirming reports also requires explanation. but-on-your-advice-i'm-going-to-drive-my-pacemaker-with-perl-ly y'rs - tim From Jeremy.Jones at peregrine.com Fri Nov 9 09:56:29 2001 From: Jeremy.Jones at peregrine.com (Jeremy Jones) Date: Fri, 9 Nov 2001 09:56:29 -0500 Subject: Special celebration event for Orlijn? Message-ID: <55720746FFC5D4118A3B00508BF9B80A01290186@atlgaexc3.harbinger.com> Skip> Hmmm... Perl van Rossum. Has a kind of nice ring to it, don't you think? Poor kid. I wouldn't wish that fate on anyone. If Perl van Rossum followed in the path of Perl (the language), people would love him at first, then want nothing to do with him after getting to know him.... Running-away-screaming-at-the-mention-of-Perl-ly y'rs, Jeremy From sholden at holdenweb.com Wed Nov 28 10:21:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 10:21:53 -0500 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: "Andreas Jung" wrote in message news:mailman.1006902434.21898.python-list at python.org... > In Microsoft we trust ! > > On good example of "supporting" standards is WebDAV. When WebDAV came up > some years ago, Microsoft claimed to support this standard. Nowadays > Microsoft support WebDAV in a way where you can talk through WebDAV > from MS clients to MS servers. I have spent a long time debugging problems > between Microsofts WebDAV implementation and other WebDAV servers. They > violate the HTTP 1.1 and WebDAV specs in many ways, making it nearly > impossible > to write compliant server side WebDAV implementations. > And can we say "DNSSEC" or "Kerberos", both non-Microsoft technologies for which MS has provided subtly-castrated versions that do not interoperate with open source implementations? regards Steve -- http://www.holdenweb.com/ From jjl at pobox.com Sat Nov 3 14:39:34 2001 From: jjl at pobox.com (John J. Lee) Date: Sat, 3 Nov 2001 19:39:34 +0000 Subject: Alex Martelli (was: Re: Python.NET, MONO and Visual Studio etc.) In-Reply-To: References: <3BDC5777.3873D22A@earthlink.net> Message-ID: On Wed, 31 Oct 2001, Paul Prescod wrote: [...] > Alex is working on a couple of books. In the long run you'll thank him. [...] Excellent. Python-related? John From tim at vegeta.ath.cx Tue Nov 13 17:26:52 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 13 Nov 2001 22:26:52 GMT Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> Message-ID: Adam Spitz graced us by uttering: > Tim Hammerquist wrote: >> Also, it might have been an unconscious attempt to bring some >> of the less argumentative Smalltalkers out of hiding. > > OK, I'm out of hiding. :) Anything in particular you'd like to > discuss? Yes. Exactly what you here. ;) > I *do* think that Smalltalk's got some advantages over Python, but I > don't think they're in the area of OOness. In terms of OO, Python has > everything I want. My fave part of ST is how it handles the whole object _concept_. As you state, this make small scripts/programs unnecessarily complex/large, but for anything sufficiently large it's amazing! > I'm kinda annoyed about Python's silly type/class distinction. But > then, so are you, and I'm glad to see the efforts at unification > progressing. Agreed. > I'm also kinda annoyed that Python introduced generators, list > comprehensions, and crippled lambdas to deal with an issue that > Smalltalk solves very neatly with its blocks. Having come from Perl (and, BTW, still using/liking it), I found list-comprehensions a welcome addition. Oops! I shouldn't have said that. There may be a PEP to remove them since they resemble a Perl feature! [ snip ] > Oh, and I've been meaning to ask - is there a way for me to add > methods to Dict or List or String? I couldn't figure out how to do it, > and that's where I *really* want it. Dicts, lists, and strings are all "types", the downfalls of which you mentioned earlier. OTOH, someone must've had the some wish, because the latest Python distro comes with the standard modules UserDict, UserList, and UserString which provide inheritable classes (though slightly less efficient) to do with whatever you wish. Add a method, or simply subclass. (As the interface of the above types is fairly standard, adding new methods would technically be a different object exhibiting different behavior, deserving of its own class, right?) I don't currently know of a way to make a custom(ized) String/List/Dict class the default for the ''/[]/{} constructor, though. > But maybe it's useful to hear the perspective of an almost-reasonable > person from outside the community. It has been for me. Thx. Tim Hammerquist -- Anyone who thinks that the act of programming is worth less than $50/hr should leave the industry. -- Randal L. Schwartz (clpm, 27 Jul 2000) From lucio at movilogic.com Fri Nov 30 14:43:40 2001 From: lucio at movilogic.com (Lucio Torre) Date: Fri, 30 Nov 2001 16:43:40 -0300 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: <3C07E16C.2060101@movilogic.com> Erann, Just to let you see how the only important thing is indentation, we are going to remove the colon when opening a block. Seriously, if coherent design is a concern to any of you, please let me know why a block starting colon is proper, but a block closing elemnt is not. Lucio. Erann Gat wrote: >In article <3C0773C2.A12D0BAC at pacific.net.hk>, Bernie > wrote: > >>Erann, I think you find the indentation annoying because you choose 2 spaces >>as your tab size, hence making the block not as apparent as it could >>be. Try four spaces, or use Tools/Scripts/pindent.py if you really cannot >>stand it. >> > >No, that's not it. Let me explain that remark, but first let me say the >following: > > *** I am not suggesting the semicolon rule to replace syntactically > *** significant indentation, but merely to augment it. > >Here's what I find annoying: > >Consider the following code: > >biff() # Line 0 >for x in l: # Line 1 > foo() # Line 2 > baz() # Line 3 >bar() # Line 4 > >When I use python-mode in emacs the editor will automatically indent for >me after line 1. In fact, if I screw up the indentation accidentally, >emacs can automatically restore it in the above example except for line >4. The reason it can do that is because of the colon at the end of line >1. That colon is actually redundant. It tells you unambiguously that the >next line must be indented or you have a syntax error. I consider this >redundancy, and emacs's resulting ability to automatically reconstruct the >indentation to be a feature. > >The reason emacs can't restore the indentation on line 4 is that there is >no such redundant information for emacs to use to determine where a block >ends. People have suggested a convention like: > > >biff() # Line 0 >for x in l: # Line 1 > foo() # Line 2 > baz() # Line 3 ># end for >bar() # Line 4 > >What I am suggesting is no different, except that instead of "# end for" I >want to use ";". The reason is simple: it's less typing, and it's easier >to modify emacs python-mode to detect a trailing semicolon than an >end-block comment. > >There is in fact already a hack for this. I could write: > > >biff() # Line 0 >for x in l: # Line 1 > foo() # Line 2 > baz() # Line 3 > pass >bar() # Line 4 > > >and emacs will re-indent line 4 properly. RETURN also serves to >unambiguously mark the end of a block. But IMO putting in pass statements >all over the place to mark the end of blocks is really ugly. > >I'd also like to respond to a few other comments: > >* Steve Lamb: > >>>It also IMO makes the language unsuitable for mission-critical applications. >>>It's just too easy to screw up indentation (particularly when cutting and >>>pasting large blocks of code) without realizing it. >>> > >> Hogwash, plain and simple. Either you know it because it is visually >>different or you know it when you test the application and it fails >>spectacularly. You /do/ test your mission-critical applications, don't you? >> > >Yes, of course we test our mission critical applications. Please extend >me the courtesy of not immediately assuming I'm an idiot just because I >make a proposal that you don't like. But testing is actually a very >ineffective way of insuring that software works, particularly >mission-critical software. For one thing, it's not possible to test >spacecraft software under field conditions until the spacecraft is >launched, and by then it may be too late. For another, many bugs, >particularly in real-time multithreaded systems, are probabilistic, and so >even if your tests work perfectly that alone does not provide a lot of >confidence that your software is in fact correct. > >* Skip Montaro: > >>As has been demonstrated many a time, you're more likely to screw up a C >>block by omitting braces: >> >> if (cond) >> x = 1; >> y = 1; >> > >Yes, this is exactly my point. You can look at the above code and tell >there's something wrong because the braces and indentation provide >redundant information in C. > >* Skip: > >>In fact, it's such an insidious >>problem in C code that many groups mandate that all blocks use { & }, even >>for one-statement blocks. >> > >Yes, and the situation in Python is that the language mandates an >open-brace (or it's equivalent, the colon) and doesn't provide a >close-brace even as an option. > >>In Python, if it looks right, it is right. >> > >No, that's not true. Consider the following two alternative code fragments: > >if x: > foo() >baz() > >if x: > foo() > baz() > >They both look right, but they can't both be right. > >* Skip: > >> Erann> This convention is 100% backwards-compatible with current >> Erann> practice, that is, code written using this convention runs with >> Erann> no problems in Python as it currently stands. >> >>Not it's not. Semicolons can legitimately be used to end a statement now. >> > >Well, that's actually what I meant by "backwards compatible." I know that >semicolons can be used at the end of statements, but at the moment doing >so is a no-op. (All it does is betray you as still thinking in C/Java.) >I want to take syntax that is currently legal but useless and make it >useful. > >Look, the reason I made this proposal is not that I want to come in and >tell the Python community that syntactically significant indentation is >all screwed up and should be discarded. The reason is that I want to sell >people at JPL on the idea of using Python to write mission-critical >software, and the people I'm trying to sell are raising this objection. I >can counter this objection, but only three-quarters of the way. I can >point out that Python already provides enough redundant information to >reconstruct corrupted indentation at the beginning of blocks, but not at >the end. To reconstruct it at the end of blocks all I can offer is my >"pass/return" hack. I'd really like to be able to offer a standard >syntactic convention that is endorsed by the Python community. That would >make Python a lot easier to sell. > >So lighten up, folks. We're on the same side. > >Erann Gat >gat at jpl.nasa.gov > From laurent.szyster at q-survey.be Tue Nov 13 09:58:09 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Tue, 13 Nov 2001 15:58:09 +0100 Subject: Sockets and messaging services References: <97ae44ee.0111112119.e8f42d2@posting.google.com> Message-ID: <3BF13501.BEFF4899@q-survey.be> Stephen wrote: > > I have a CGI script which takes a HTTP request then sends > a message to a custom server built on top of SocketServer.ThreadingTCPServer. > Not that there is much chance of webserver CGI saturating the latter, > but does Python have a messaging framework, similar to JMS for Java ? > http://developer.java.sun.com/developer/technicalArticles/Networking/messaging/ Not that I'm aware. However, why reinvent the wheel and a new messaging framework? IMHO the SMTP and POP protocols provide the same benefit (and there are Python modules for those protocols). Laurent From toy at rtp.ericsson.se Fri Nov 16 08:49:33 2001 From: toy at rtp.ericsson.se (Raymond Toy) Date: 16 Nov 2001 08:49:33 -0500 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> <7xhervy3v9.fsf@ruckus.brouhaha.com> Message-ID: <4nofm2bzbm.fsf@rtp.ericsson.se> >>>>> "Daniel" == Daniel Lakeland writes: Daniel> In article <7xhervy3v9.fsf at ruckus.brouhaha.com>, "Paul Rubin" Daniel> wrote: >> "Daniel Lakeland" writes: >>> On a similar type of program I worked on in CMUCL it would run plenty >>> fast at home on my 233 MHz PII and then when I took it to work and ran >>> it on a 400 Mhz Sparq or something like that, it would be a dog. >>> >>> Turned out that consing was a big problem, and the x86 had a >>> generational collector, whereas the Sparq had a mark-sweep. >> >> CMUCL uses different GC's on different platforms? Or do you mean you >> were using CMUCL on one box and a different CL on the other? Daniel> Yes CMUCL uses (or used in Feb 2000) different GC's on different Daniel> platforms. That is still true today and for the foreseeable future as well. Ray From dsavitsk at e-coli.net Tue Nov 6 15:21:33 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 06 Nov 2001 20:21:33 GMT Subject: Use a COM-server with python References: <3BE83CFC.7060103@gmx.de> Message-ID: "Marc Gehling" wrote in message news:3BE83CFC.7060103 at gmx.de... > Hello, > > I installed a comserver and i can use it with VB. I would like to use > the server with python. I read some artikels and take a look at "python > programming on win32". > > Can someone translate this vb into python ? > > Dim oRepo As MXLib.MXRepository > Dim oNewFolder As MXFolder > Set oRepo = New MXRepository > oRepo.dbUserName = "rep" > oRepo.dbPassword = "rep" > oRepo.repUserName = "Administrator" > oRepo.repPassword = "Administrator" > oRepo.dbConnectString = "Inf ora8" > oRepo.repositName = "data" > oRepo.connect > oRepo.CreateFolder "testfolder", "folderdescr", 0, "Administrators", > oNewFolder > oRepo.Disconnect > > >>> import win32com.client >>> oRepo = win32com.client.Dispatch("MXLib.MXRepository") >>> oRepo.dbUserName() = "rep" >>> oRepo.dbPassword() = "rep" >>> oRepo.repUserName() = "Administrator" >>> oRepo.repPassword() = "Administrator" # probably not the most secure choice >>> oRepo.dbConnectString() = "Inf ora8" >>> oRepo.repositName() = "data" >>> oRepo.connect() >>> oRepo.CreateFolder("testfolder", "folderdescr", 0, "Administrators") >>> # oNewFolder # not sure what this i as it was never set in the vb example >>> oRepo.Disconnect() i have found that for com components written in vb sometimes () are unnecessary when passing args. i don't know why that is, though. also, it is likely that since "Disconnect" starts with "D" and not "d" "connect" will be the same. python is not forgiving in the same way as vb. -d From harold at 1st-spot.net Thu Nov 22 11:31:06 2001 From: harold at 1st-spot.net (Harold Shore) Date: Thu, 22 Nov 2001 16:31:06 GMT Subject: Web hosts and Python 2.1 Message-ID: <20011122.082840.1253263156.7318@localhost.localdomain> As I progress with using Python naturally I've wanted to convert my web sites from Perl CGI's to Python. However, my current ISP and most of the others who have attractive packages for my kind of website , while they do have Python installed, only have the 1.52 version. with probably got installed with their latest OS upgrade. Asking them to install a 2.1 version of Python hasn't been fruitful so far. So my question is: does anyone on this group know of a North American web host who offers an up-to-date python package? Cheers. Harold From nhodgson at bigpond.net.au Thu Nov 29 15:02:34 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 29 Nov 2001 20:02:34 GMT Subject: pyplets References: <655abd4a.0111290417.4b28a0f2@posting.google.com> Message-ID: Oleg Broytmann: > Do you suppose to alter ALL major browsers to support Python? (You can > alter Mozilla, but not Netscape, and certainly not M$IE). IE, having an open interface to scripting languages has supported Python for years. Neil From tjreedy at home.com Tue Nov 27 09:30:18 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 27 Nov 2001 14:30:18 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> Message-ID: <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrna071tg.isc.qrczak at qrnik.zagroda... > Tue, 27 Nov 2001 01:27:15 +0000 (UTC), Huaiyu Zhu pisze: > > > - That there is no reason to associate tab with any equivalent in spaces. > > It should only be used as a distinct character in its own right. > > What should a Python interpreter do with this? > > if 0: > print "0" > print "1" Raise SyntaxError. Seriously. This would be consistent with general philosophy of not guessing in the face of ambiguity. Each indent is effectively a temporary directive #pragma = # or some number of spaces. Once such a directive-by-first-use is made, it is not unreasonable to require consistency until cancelled by a corresponding dedent.. ... > Mixing tabs and spaces is not recommended because some people use tabs > in a wrong way (with a size different than 8), but I would not forbid it. As I explained in my last post in this thread, := is not 'right' but merely an ill-chosen convention of a minority of computer users, which seldom gives one the visual layout one wants and which is therefore arguably 'wrong'. Terry J. Reedy From fperez528 at yahoo.com Mon Nov 12 09:57:50 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 13 Nov 2001 14:25:50 +2328 Subject: PEP proposal: enhanced string functions References: Message-ID: <9ss36g$4a4$1@peabody.colorado.edu> Stephen Ferg wrote: > I have been thinking about two proposals for PEPs, and I would like to see > what other folks think of them. They aren't anything major, just small > enhancements that I think would be easy to do and useful. > [snip] FWIW, it sounds like a good idea to me. Clean, small, unobtrusive, but potentially very useful in many common situations. Cheers, f. From ungrzr2 at ubatxbat.pbz Tue Nov 27 00:44:24 2001 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 27 Nov 2001 05:44:24 GMT Subject: [2.2b2]: class variable and classmethod, subclass Message-ID: In 2.2B2 Inside a class,I did a change to a class variable inside the class' classmethod. If the variable has not been changed in the subclass before, the class variable in the subclass of the class is also changed. Is this behavior intentional or a bug? There is no such behavior if the change is done in a normal member method. The code: ===== class A: _test = 'start' def change(cls, str="changed"): cls._test = str print cls, "change:", cls._test change = classmethod(change) def val(self): print self.__class__, "val:", self._test class B(A): def val(self): print self.__class__, "val:", self._test A().val() B().val() A().change("Changed by A 1") B().val() A().change("Changed by A 2") B().val() B().change("Changed by B") B().val() A().change("Changed by A 1") B().val() ===> output: __main__.A val: start __main__.B val: start __main__.A change: Changed by A 1 __main__.B val: Changed by A 1 __main__.A change: Changed by A 2 __main__.B val: Changed by A 2 __main__.B change: Changed by B __main__.B val: Changed by B __main__.A change: Changed by A 1 __main__.B val: Changed by B From marfadeu at gmx.de Thu Nov 8 17:03:14 2001 From: marfadeu at gmx.de (Markus Faust) Date: Thu, 8 Nov 2001 23:03:14 +0100 Subject: mayavi installation problem on Win NT References: <9sdh9v$hgq$01$1@news.t-online.com> Message-ID: <9sevfv$lrn$06$1@news.t-online.com> Thanks Les and Prabhu, there was indeed another vtkdll.dll in the path (..winnt\system32) from the vtk installation I assume. After having removed it from the path I could start mayavi. Thanks again! Markus From emile at fenx.com Fri Nov 9 18:15:44 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 9 Nov 2001 15:15:44 -0800 Subject: count in 'for ... in ...' References: Message-ID: <9shoca$13b8h7$1@ID-11957.news.dfncis.de> wrote in message news:mailman.1005345613.25757.python-list at python.org... > > Try this. > > for s in my_list: > print my_list.index(s), ".", s > > This way you don't need a counter variable. > While this will work for some lists, it won't for [1,2,3,2,1] or other lists with duplicate values. Also, IIUC, consider that my_list.index(val) does the equivalent of: for i in range(len(my_list)): if my_list[i] == val: print i break else: raise ValueError In long lists this can be _very_ expensive/slow. You're really better with: for i in range(len(my_list)): print i, my_list[i] At least then each entry is only visited once. -- Emile van Sebille emile at fenx.com --------- From wolfson at uchicago.edu Thu Nov 29 01:00:46 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Thu, 29 Nov 2001 00:00:46 -0600 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C046EB4.55B36D9D@cosc.canterbury.ac.nz> <3C0502B0.1F73497C@sympatico.ca> <3C05744D.D52CBBF0@cosc.canterbury.ac.nz> Message-ID: Here is the really killer proposal everyone's been waiting for. What we need is a for-loop with the following syntax: for lower < (func) < upper named "name": <= would also be permissible; the parentheses around func are to aid in disambiguation (for instance, in a lambda expression, it would otherwise be impossible to determine where it ended). What this would do is simple. func would be a function of one argument accepting an integer and returning an integer-like result. It would be called starting with 0 and then with successively incremented values until the value returned is no longer in the specified range. Otherwise, that value would be stored in the local scope with the name specified by the "named" part. "named" would be a pseudo-keyword like "as". This would allow all sorts of wacky loop indexing. For example, if you wanted an infinite loop with an index that alternated between 0 and 1, nothing could be simpler: for 0 <= (lambda x: int(math.sin(math.pi * x/2.))**2) <= 1 named "i": #body of loop And the indexing variable could be a class instance, a tuple, anything you like, as long as it supports < or <=! Imagine the largely useless possibilities! I think the issue is settled. -- BTR Why does this Wolfson person see fit to clutter up Usenet with such absurd nonsense? -- Bob Cunningham in From gmcm at hypernet.com Sat Nov 10 16:59:20 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 10 Nov 2001 21:59:20 GMT Subject: type(__builtins__) strangeness References: Message-ID: Michael Hudson wrote: > tavis at calrudd.com (Tavis Rudd) writes: >> why does type(__builtins__) return when called in the >> __main__ scope and when called inside an imported >> module? > Beause it's specially designed to confuse people who are too > inquisitive :) > > Seriously, I don't know, but I know that I don't need to know. > Obscure implementation detail. Ignore it. Not that far off! When you exec or eval code, you're allowed to pass in a globals dictionary. If you want to override the exec'd / eval'd code's access to potentially dangerous builtins, you can override what it sees as __builtins__ by creating a dict named "__builtins__". If no "__builtins__" is found in the dict you hand to exec / eval, then one is created. If you really need it, use "import __builtin__" to get the module. - Gordon From chris.gonnerman at newcenturycomputers.net Fri Nov 2 09:00:33 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Fri, 2 Nov 2001 08:00:33 -0600 Subject: references ??? References: <9rtpsc$13j2@newton.cc.rl.ac.uk> Message-ID: <005e01c163a6$c525e300$0101010a@local> ----- Original Message ----- From: "Thomas Weidner" > In <9rtpsc$13j2 at newton.cc.rl.ac.uk>, Richard Brodie wrote: > > Implicitly. Consider the following: > > > >>>> a = [1,2,3] > >>>> b = a > >>>> b[1] = 20 > >>>> print a > > [1, 20, 3] > > Interesting.... > Is this also possible for single values like ints ? Not exactly. Consider: >>> a = 1 # a is reference to scalar integer 1 >>> b = a # b is reference to same scalar integer 1 >>> b = 2 # b is rebound to scalar integer 2 >>> print a # a is still bound where it was before 1 In effect, all Python variables are references (pointers in other words) to objects; even the simple number 1 is stored internally as an object. The assignment statement, assigning to a simple name, rebinds the name to a different object. What you want, therefore, is the same as a reference to a reference to a scalar object. Python doesn't do that; generally, it's not needed. You will see, from time to time, mentions on this list about thinking Pythonically. When you master that you won't miss painful complexities like nested references. From db3l at fitlinxx.com Tue Nov 13 14:57:02 2001 From: db3l at fitlinxx.com (David Bolen) Date: 13 Nov 2001 14:57:02 -0500 Subject: Somebody just wanted to run wxPython asynchronously References: Message-ID: Laura Creighton writes: > and I just went and deleted that piece of mail because I am an idiot, > so I can't put this in the correct thread. > > And I have no idea who it was, etc. > > but use this: > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 > > > change the Tkinter references to your equivalent wxPython ones. > > There is nothing in this that requires Tkinter. Or as an alternative, I'd probably suggest posting an event to the main GUI thread when something was available (either that the queue has an element or to eliminate the use of the queue entirely) rather than making the main thread poll 10x/s to see if there is something available. Less overhead that way. Some other examples of methods of having a long running background task interacting with a primary GUI thread in wxPython can also be found at http://wiki.wxpython.org/index.cgi/LongRunningTasks -- -- 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 chris.gonnerman at newcenturycomputers.net Thu Nov 8 08:45:14 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 8 Nov 2001 07:45:14 -0600 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111080405.77c024a2@posting.google.com> Message-ID: <004e01c1685b$99818740$0101010a@local> Maybe I've missed something, but isn't this a problem for the server administrators? Have you talked/emailed him/her/them about this problem? Otherwise, a C wrapper is the only choice. You can't make it work any other way without the assistance of someone with administrative privileges. ----- Original Message ----- From: "pawn" > My CGI scripts save information submitted by users in files, and later > display this information inside HTML templates. > > It seems to me that either I find a way to let these scripts run with > my UID, or, in order to let them read / write files in the data > directory, I have to make it world-writable which means malicious > users on the same system can delete files, as well as create files > which were not processed by the CGI's policies. > > Is there something I'm missing here? *Can* I get by without setuid? From ptaylor at hellmann.net Sat Nov 3 23:43:45 2001 From: ptaylor at hellmann.net (Peta Ylorhovik) Date: Sun, 04 Nov 2001 04:43:45 GMT Subject: Jews or Muslims? Who's a better hacker? Or phreaker? Message-ID: <5I3F7.9918$ND1.818724@brie.direct.ca> Jews or Muslims? Who's a better hacker? Or phreaker? From emile at fenx.com Thu Nov 15 11:36:12 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 15 Nov 2001 08:36:12 -0800 Subject: convert a string to a method call ? References: <25SI7.32$Qh1.10549@newsfeed.slurp.net> Message-ID: <9t0r83$15fg5f$1@ID-11957.news.dfncis.de> "Bruce Edge" wrote in message news:25SI7.32$Qh1.10549 at newsfeed.slurp.net... > I have an object, say xObj, which has a bunch of methods. > I have the method I want to call in a string, say str. > > How do I call method str on xObj? > > Use eval? If so, the syntax eludes me. > Here's one way: >>> class Test: ... def meth1(self, *args): ... return "meth1: %s" % repr(args) ... def meth2(self, *args): ... return "meth2: %s" % repr(args) ... >>> t = Test() >>> apply(getattr(t, 'meth1'), (1,2,3)) 'meth1: (1, 2, 3)' >>> apply(getattr(t, 'meth2'), ('a','b','c')) "meth2: ('a', 'b', 'c')" >>> -- Emile van Sebille emile at fenx.com From mertz at gnosis.cx Wed Nov 28 15:58:23 2001 From: mertz at gnosis.cx (Lulu of the Lotus-Eaters) Date: Wed, 28 Nov 2001 15:58:23 -0500 Subject: PEP 276 Simple Iterator for ints Message-ID: David Eppstein wrote: |The latter notation now seems unnecessarily redundant. Think of it by |analogy -- which of the following would you most likely use, | if 0 <= i < 5: |or | if i in [0, 1, .. 4]: |or | if i in range(5): |or even (with Perl-like conciseness) | if i in 5: I think this is wrong--the "redundant" part, that is. These forms, at first brush, have very different meanings from each other. In a hypothetical Python++ that had all the variations implemented, they would have a different range of application: >>> i = 2; j = 3 # want an even Natural number less than 100... >>> if 0 < i < 100: print 'even Natural' ... even Natural >>> if 0 < j < 100: print 'even Natural' # gives wrong answer ... even Natural >>> if i in [2,4 .. 98]: print 'even Natural' ... even Natural >>> if j in [2,4 .. 98]: print 'even Natural' # gives correct answer ... >>> if i in 100: print 'even Natural' # I have no idea what this MEANS! ... ????? Those are step-size issues. But even with step-sizes of one, a similar problem comes up: >>> x = 3.5 >>> if 0 <= x < 5: print 'in range [0 .. 5)' ... in range [0 .. 5) >>> if x in [0,1 .. 4]: print 'in range [0 .. 5)' ... >>> if x in 5: print 'in range [0 .. 5)' # No idea what this MEANS! ... ????? Given the BDFL's goal of Int/Float/Rational unification in some far-future, the integer-only 'min <= x < max' syntax looks particularly bad. Yours, Lulu... From kragen at pobox.com Tue Nov 27 17:14:12 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 17:14:12 -0500 Subject: newbie question - object from a string? References: Message-ID: <83g06z6evf.fsf@panacea.canonical.org> Gordon Scott writes: > I have a file named MyHandlers.py in which I have the class MyHandler. > > when I use > > __import__('MyHandlers', globals(), locals(), ['MyHandler']) or > . > . > . > eval('MyHandler()', globals(), locals()) or eval('MyHandlers.MyHandler()', > globals(), locals()) > > I get a NameError: name 'MyHandler' is not defined. __import__ doesn't import anything into your namespace; it just loads and returns the module. You can say: MyHandler = __import__('MyHandlers').MyHandler and then you can call MyHandler. HTH. From murat.demir at icn.siemens.de Fri Nov 9 04:05:04 2001 From: murat.demir at icn.siemens.de (Murat Demir) Date: 9 Nov 2001 09:05:04 GMT Subject: CORBA client & server with Python Message-ID: <01c168fd$978fe8d0$06d1178b@mvn40020> did someone try to write CORBA client and server applications with Python? Can you offer me a "hello world" application about it? thanks murat From mwh at python.net Mon Nov 5 08:30:49 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 5 Nov 2001 13:30:49 GMT Subject: Question: Error or misconcept References: <3be65da4$1_3@corp-goliath.newsgroups.com> <9s62qa$11k821$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" writes: > "K?roly Ladv?nszky" wrote in message > news:3be65da4$1_3 at corp-goliath.newsgroups.com... > > I have run into the following problems. > > > > 1.) > > > > class c1: > > a1=[] > > > You've just created a class level shared object a1. Remove this and add the > following if you want instance level: > > def __init__(self): > a1 = [] ^ self. Cheers, M. -- "The future" has arrived but they forgot to update the docs. -- R. David Murray, 9 May 2000 From stuart at bmsi.com Thu Nov 15 21:41:18 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Thu, 15 Nov 2001 21:41:18 -0500 Subject: A modest proposal (continued) References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <9t1sc0$40c$1@nntp1-cm.news.eni.net> <7xu1vvo432.fsf@ruckus.brouhaha.com> Message-ID: <9t1uce$5d8$1@nntp1-cm.news.eni.net> In article <7xu1vvo432.fsf at ruckus.brouhaha.com>, "Paul Rubin" wrote: > I think it's more important to optimize locals and class attribute > references (local.x.y.z), than globals. The SymbolTable/array separation optimizes class attributes. You missed that section in my first post, so I'll repeat it in different words here. The SymbolTable is stored with the class - initialized to all class attributes mentioned in the code defined within the class. The attribute array is stored with each instance. Dynamically adding attributes to a class is handled by a) growing the class SYmbolTable and expanding instance attribute arrays as needed. This could result in lots of unused instance slots when lots of random identifiers are added dynamically. b) keeping an auxilliary dictionary for attributes not mentioned in the initial class definition. I guess the big problem is accounting for a class possibly overriding attribute fetching. However, if we simply *always* call __getattr__, and the default definition simply follows the same strategy as the load global and is coded inline, then a class attribute lookup is essentially equivalent to two optimized globals. E.g. load class idxOf__getattr__ # cached like global access if not defined: load class idxOfName # cached like global access else: call __getattr__ -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - background song for a Microsoft sponsored "Where do you want to go from here?" commercial. From mvonehr at web.de Wed Nov 28 11:51:51 2001 From: mvonehr at web.de (Markus) Date: 28 Nov 2001 08:51:51 -0800 Subject: sourcecode scrambler Message-ID: <55881dd4.0111280851.682ac024@posting.google.com> Hallo, does anyone know how to scramble my python source-code? I want to assign random names to all variables and modules, thanks for any answer, Markus From ajs at ix.netcom.com Sat Nov 10 00:42:57 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 10 Nov 2001 00:42:57 -0500 Subject: Teaching python (programming) to children Message-ID: <000001c169aa$e18c2720$a9e1fea9@carol> Paul writes - > Normally nobody thinks of kids that young as needing >"programming instruction" or training in software development. Then remind me again how it came up in the context of this thread? >Here's an article from Papert's website about it called "Tomorrow's >Classrooms", that gives a sense of what he wanted to accomplish: > http://www.papert.org/articles/TomorrowsClassrooms.html Reminds me very, very much of an article I read in the Linux Journal a while back, that wasn't about Python, but was in a supplement devoted to it. >Basically he was trying to follow up the ideas of Jean Piaget, the >child development researcher. That's great for the folks who don't happen to think Piaget is at some level horseshit. Happily, a programming language need not take a position - unless it for some reason chooses to. My deepest objection - and why I'm consistently nasty when getting near this subject - is that it always seems to be the tool in play < LOGO/MindStorm/Alice, etc and etc> and its creators/advocates that are hogging center stage. And off in the corner somewhere is the happy student, and somewhere backstage, a subject matter. God, I'm tired of going around in this circle. Art From joost_jacob at hotmail.com Thu Nov 29 07:47:24 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 29 Nov 2001 04:47:24 -0800 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> <9u37pb$7dk$1@slb7.atl.mindspring.net> Message-ID: <13285ea2.0111290447.57be5009@posting.google.com> Thank you (and the other posters) for the replies ! Using Numeric would be great but has to wait until it is included in a python distribution and they install that new version here. All these computers have Python 1.5.2 and some have no network connection so i cannot link to numeric at my computer or something like that. Maybe i should supply Numeric with the program but i try to avoid that. Coding part in C is no option since the platform is unknown, they have winNT, linux and solaris. But, i managed to get a nice speedup ! And a surprising result. Here is my optimization story: The original code: version_0 for j in range(self.nh): sum = 0.0 for i in range(self.ni): sum = sum + self.ai[i] * self.wi[i][j] This version takes 101 seconds in my test program. Doing your Andrew's tips about avoiding lookups i got: version_1 range_ni = range(self.ni) range_nh = range(self.nh) ai = self.ai wi = self.wi for j in range_nh: sum = 0.0 for i in range_ni: sum = sum + ai[i] * wi[i][j] This took 76 seconds for the test, a big improvement ! Next thing to try was to transpose the "wi" indexes and keep all my other code working. Transposing the indices in the code was difficult (complex neural network update function) since some other code had to be changed too. The original was bpnn.py i found on internet, by Neil Schemenauer (thank you if you read this!). But pffff, finally i had it done (and did testing) and now i could translate the original code to: version_2 for j in range_nh: sum = 0.0 for i in range_ni: sum = sum + ai[i] * wi[j][i] This also takes 76 seconds doing the test. But now we can do the reduce()/map() stuff! C-loops! FAST!! hurray! version_3 for j in range_nh: sum = reduce(operator.add, map(operator.mul, ai, wi[j])) This version takes 94 seconds. :(((( I can do better: version_4 for j in range_nh: wij = wi[j] sum = reduce(operator.add, map(operator.mul, ai, wij)) This version takes 90.4 seconds. Argh ! Oh well at least they produce the same output in my testprogram as the other versions so i am pretty sure the code is semantically correct. And the winner is: version_5 for j in range_nh: wij = wi[j] sum = 0.0 for i in range_ni: sum = sum + ai[i] * wij[i] Taking 68.7 seconds. This is like version_2 but with using "wij" to avoid some indexing. Ok i have a faster version now, but i did not like the reduce/map adventure at all hehehe. I read in another post that Guido does not like to reduce() either and this could be just another example of.... I sure hope i do not have a nasty bug hidden somewhere but that seems unlikely since all the versions produce the same result when using the neural network. ---------------------------------------------------------------- "I have a problem: my Python for-loop is too slow. Oh wait i can use reduce() and map() and aww that will be cool!" From qrczak at knm.org.pl Sat Nov 10 06:12:58 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Sat, 10 Nov 2001 11:12:58 +0000 (UTC) Subject: iters on ints? (reducing the need for range/xrange) References: <52e5ab5f.0111090851.2d4e023d@posting.google.com> <52e5ab5f.0111092003.56966343@posting.google.com> Message-ID: 9 Nov 2001 20:03:28 -0800, Michael Robin pisze: > I was just saying that I think in most other languages that specify > numeric targets of "for" without extra syntax or an explicit test > expression the endcases are inclusive. Indeed, but Python already uses exclusive end in its current spelling of 'for i = 0 to 10', i.e. 'for i in range(11):'. It would be no more confusing that it's currently. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From mark at laptop.local Wed Nov 21 11:37:11 2001 From: mark at laptop.local (mark at laptop.local) Date: 21 Nov 2001 11:37:11 -0500 Subject: How do you get persistent database connections with Python? References: <9sshgb$eh4$1@laptop.local> Message-ID: <9tgl7n$12h$1@laptop.local> In article , Gerhard =?iso-8859-1?Q?H=E4ring?= wrote: >On Tue, Nov 13, 2001 at 08:30:51PM -0500, mark at laptop.local wrote: >> How do you create persistent database connections with Apache, Python, >> and PostgreSQL? Any generic methods of creating persistent database connections >> would be helpful. >> >> I have been trying like crazy to find information on the topic, but I can't >> find any useful information. >> >> I am using mod_python and also PyGreSQL modules. I can switch to others >> if need be. > >The db module doesn't matter. What you probably need to check out is the >Python documenation (wrt. importing modules). Your mod_python handler >lives as long as the Apache process lives. > >So, you just have to instantiate a db connection in the handler's module >and store the connection object it in the module. That's all there is to >it. > I have been thinking about this. I am just using the normal cgi handler for mod_python. The docs frown on using the cgi handler, but that is the easiest thing for me to do. I don't need complicated webpages or any fancy stuff. Most of my programming has nothing to do with html code, so I don't want anything fancy. So, I guess why question really is, how do I get it to work with the cgi handler? Mark From me at mikerobin.com Thu Nov 1 20:46:26 2001 From: me at mikerobin.com (Michael Robin) Date: 1 Nov 2001 17:46:26 -0800 Subject: starting externel program (win32) References: Message-ID: <52e5ab5f.0111011746.4272a123@posting.google.com> or try win32api.ShellExecute, as in: win32api.ShellExecute(0, None, "cmd", "/c dir /s", "c:\\", 1) mike ---------- win32api.ShellExecute int = ShellExecute(hwnd, op , file , params , dir , bShow ) Opens or prints a file. Parameters hwnd : int The handle of the parent window, or 0 for no parent. This window receives any message boxes an application produces (for example, for error reporting). op : string The operation to perform. May be "open", "print", or None, which defaults to "open". file : string The name of the file to open. params : string The parameters to pass, if the file name contains an executable. Should be None for a document file. dir : string The initial directory for the application. bShow : int Specifies whether the application is shown when it is opened. If the lpszFile parameter specifies a document file, this parameter is zero. Win32 API References ShellExecute Return Value The instance handle of the application that was run. (This handle could also be the handle of a dynamic data exchange [DDE] server application.) If there is an error, the method raises an exception. m "Alves, Carlos Alberto - Coelce" wrote in message news:... > I don't know the details,but I think COM objects could resolve this problem. > > Carlos Alberto > COELCE/DPRON-Departamento de Projetos e Obras Norte > Fone: 677- 2228 > e-mail: calves at coelce.com.br > \|||/ > (o o) > --ooo0-( )-0ooo-- > > > > -----Original Message----- > From: stojek at part-gmbh.de [mailto:stojek at part-gmbh.de] > Sent: Thursday, November 01, 2001 7:28 AM > To: python-list at python.org > Subject: starting externel program (win32) > > > Hi, > > from a script I want to start an external program (win32). This should > be done in a way that is equivalent to typing the name and options at > the dos prompt. The program must not be influenced by exiting the > script. > > Do I have to use system(), spawnv() or spawnve() or something else? > Any traps? > > Tanks > Marcus From kosh at aesaeion.com Thu Nov 15 02:57:28 2001 From: kosh at aesaeion.com (kosh at aesaeion.com) Date: Thu, 15 Nov 2001 00:57:28 -0700 (MST) Subject: who called a function? In-Reply-To: <7xeln0wncz.fsf@ruckus.brouhaha.com> Message-ID: On 14 Nov 2001, Paul Rubin wrote: > writes: > > How can I find out what object called a function and essentially step back > > through that? At most I need to step back about 4 to 5 levels but it would > > be very useful for me to find a particular object back up the list and > > change behavior based on that. Mostly I just wants the self var as I step > > back until I find the one I want. > > Raise and catch an exception and examine the stack trace object. > -- How do I step back through the trace stack object? Basically a few points would be nice or better yet a web page that shows some examples. Designing the webpages of tomorrow http://webme-eng.com Designing the MMORPGS of tomorrow http://worldforge.org From jdadson at ix.netcom.com Sun Nov 4 21:34:05 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 02:34:05 GMT Subject: Q: Feature Wish: "%" Extension References: <7xsnbu9qc4.fsf@ruckus.brouhaha.com> Message-ID: <3BE5FA77.F72C9902@ix.netcom.com> Paul Rubin wrote: > > "Tim Peters" writes: > > > Knuth says to use floor_mod? Where? > > > > Knuth *defines* x mod y as being x - y * floor(x/y), way back in volume 1. > > It simply has the nicest properties when x and y are ints and y > 0. > > Yes, x mod y is usually defined that way. However, "x remainder y" > doesn't necessarily mean the same thing. The question then is whether > % in a programming language should denote "mod" or "remainder". I could argue that the common understanding of "remainder" is the same as the mathematical definition of "mod". If something "remains", it is positive. Suppose you have a small business funded by two venture capitalists. Scenario one: You have a good month. After paying creditors, you show a surplus ("remainder") of seven dollars. You want to divy up the money between the investors, who insist on getting paid in round amounts. 7//2 = 3 rem 1. You pay each investor 3 dollars, and you have a remainder of one dollar. Scenario two: You have a bad month. You are seven bucks in the hole. To pay your creditors, you must extract a second round of funding from the investors. (-7)//2 = -4 rem 1. You hit up each investor for four bucks, and after paying your debts, you have one dollar ("remainder") left over. Jive From prabhu at aero.iitm.ernet.in Tue Nov 13 00:08:34 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 13 Nov 2001 10:38:34 +0530 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <15344.5763.557118.787529@walden.zope.com> References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> Message-ID: <15344.43730.821724.769885@monster.linux.in> >>>>> "JH" == Jeremy Hylton writes: >>>>> "PR" == Prabhu Ramachandran writes: JH> I haven't followed this thread closely. Is there some reason JH> that explicit names in imports is not sufficient? PR> Yes indeed there is. I've already explained my reasons twice. PR> Eric also explained why this was important for Scipy. [snip] JH> I have had a hard time trying to figure out precisely what the JH> problems are. I think you got it mostly right. Let me try to elaborate on it. (1) Re-nesting a package is a pain. What I mean by re-nesting is that say I have a package, A, that is separate (and that has its own sub packages) and now I want it as part of another package, B. Lets further suppose that the module which re-nests the package, B, tracks the development of A and keeps their copy updated. In this case A is developed as a standalone package and B adds something to it that A cannot/refuses to use. With the current approach B would be forced to modify A every time A changes in some significant way simply because A was re-nested. Yes, this is contrived but such situations do occur. To make things clearer. My main objection is that the name of a package when one imports it depends on its parent packages name. This is IMHO absurd. foo/ sub/ sub1/ From sub1 if you had to import anything from sub you'd have to do import foo.sub.module. So if foo is now part of something else - you have to change all references to foo. (2) If you have a complex package with more than 2-3 nested sub directories it becomes a huge pain to use clean import statements and not have to type long lines just to get to different modules. (3) If you argue that import must always do only absolute imports then why are sibling packages allowed? i.e. if there are two modules in the same directory Python currently allows one to import them with a relative name rather than an absolute foo.sub.pkg kind of name. If this is valid, then its natural to expect that searching also be done in the local package structure. (4) Yes, its possible re-factoring code but sometimes this can be a pain if you have a CVS tree and you want to re-organize your package structure. Bernhard Herzog posted a solution for my specific problem, so that really is not the issue. In my case the current cvsroot for my sources is this: cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mayavi/mayavi/ and Bernhard's solution would create a directory structure like so: cvs.sourceforge.net/cgi-bin/viewcvs.cgi/mayavi/mayavi/mayavi/ Which is pretty crazy if you ask me, its bad enough as it is. :) this will solve my particular problem but is dirty. JH> What does "re-nesting" mean? It get the impression you mean JH> putting one package inside another after it was developed and JH> pacakged for use as a top-level package. If so, it doesn't JH> seem like a problem that occurs that often, right? I'd be JH> hesitant to add features to the import mechanism to cater to JH> an infrequent case. I've had about 4 others mailing me about their related problems. So I wouldn't classify this as a rare problem that can be safely ignored. JH> I'd rather see the imports be explicit "import root.a.b.c" JH> than "import b.c". Then re-nesting requires all the import JH> statements to be edited. It's more typing and might even JH> require a simple script to do search-and-replace, but it JH> doesn't sound like a prohibitive burden. It all depends. I think Eric explained his position pretty clearly. I'm convinced that Python's import structure needs improvement. JH> I expect there is more to the issue than just wanting to avoid JH> some extra typing. A short PEP that describes the specific JH> problems being solved and discussing alternatives would help. Well, its all about convenience anyway - if not we'd all be talking to computers in binary! Why do we need 'high-level' programming languages? Yes, I'm digressing into te philosophy of computing but I dont think syntactic sugar is something to be ignored because its silly. PR> from pkg import subpkg is also not the best way to do PR> imports. I personally prefer import pkg.subpkg and I believe PR> this is the recommended way of doing imports. JH> Why do you think this is the recommended way of doing imports? JH> I use both in my code and haven't been able to come up with a JH> clear rationale for doing one or the other. The from JH> ... import form seems useful when the name of the JH> package/module is long or when it's only one or two names I'm JH> using. Well, the Python howto explains it much better than I could hope to: http://py-howto.sourceforge.net/doanddont/node8.html Since re-loading packages is important for me, I prefer using plain imports. prabhu From mickey at tm.informatik.uni-frankfurt.de Tue Nov 27 07:20:43 2001 From: mickey at tm.informatik.uni-frankfurt.de (Michael 'Mickey' Lauer) Date: 27 Nov 2001 14:20:43 +0200 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <3c03932b@nntp.server.uni-frankfurt.de> Kevin Altis wrote: > Some other suggestions which you may already be covering: > 2. Whether the toolkit uses native widgets (wxPython does, tkinter does > not). AFAIK Tkinter uses native widgets for menus, common dialogs, etc. since v8? > 3. Widget and classes list and notable widgets. For example, the tkinter > canvas widget. Yes. I will spend nearly a whole chapter on the topic of how to make nice custom controls with the canvas widget. > 5. Strategies for handling long running tasks with the toolkit. Does the > toolkit support separate threads outside of the GUI event loop, yield, or > other mechanisms? Good suggestion. I will have to handle this. > 7. Costs associated with using the toolkit on different platforms. Which costs do you mean? License fee, for instance when developing commercial qt-apps on windows? > 10. Is the toolkit still being actively updated? A very strong point. Thanks for your list! Cheers, :M: From sholden at holdenweb.com Mon Nov 19 13:39:21 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Nov 2001 13:39:21 -0500 Subject: list to list of pairs References: <3BF94B42.346E96EF@uniserve.com> Message-ID: <8icK7.56961$vQ1.2279341@atlpnn01.usenetserver.com> wrote ... > > I've sure I've seen this somewhere...but I can't today... > > I need to convert a list like [1,2,3,4,5,6] to a list of pairs [[1,2], > [3,4], [5,6]]. Isn't there a way to do this with map() or zip()??? > >>> def pairs(l): ... return [[l[i], l[i+1]] for i in range(0, len(l), 2)] ... >>> pairs([1,2,3,4,5,6]) [[1, 2], [3, 4], [5, 6]] >>> regards Steve --- http://www.holdenweb.com/ From garys at ihug.com.au Sun Nov 4 23:18:28 2001 From: garys at ihug.com.au (Gary Stephenson) Date: Mon, 5 Nov 2001 15:18:28 +1100 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s43jo$bku$1@news8.svr.pol.co.uk> Message-ID: <9s538j$qo1$1@bugstomper.ihug.com.au> > > The patriot (scoundrel??) in me wishes to point out that Spike was / is an > > Australian - though I imagine many Brits would be somewhat upset to learn > > this . > > Yet he was born in India and (now) holds an Irish passport (as a result of > having an Irish father (English mother? not sure)). Has he ever held an > Australian passport? Umm, errr, you've got me there! I'd forgotten that he was born in India. We here downunder have just always claimed him as one of our own - and will continue to do so, you festering putrid pile of maggot infested batsh*t, I blow my nose at you, I fart in your general direction ... and if you want to argue any further about it I suggest you need the room down the hall! This is abuse! ) gary From nospam at bigfoot.com Mon Nov 19 15:21:51 2001 From: nospam at bigfoot.com (Gillou) Date: Mon, 19 Nov 2001 21:21:51 +0100 Subject: Help with my first CGI program??? References: <3BF95D73.2886D584@earthlink.net> Message-ID: <9tbpoj$omi$1@norfair.nerim.net> cgi.FielStorage() is empty object when called from a command line ! That's why you got your error. You can check if you're in a CGI and make some command line tests with this somewhere in your script : ... class cgiItemJoker: def __init__(self, anyvalue) self.value = anyvalue ... if os.environ.has_key('GATEWAY_INTERFACE'): # Called from web server using GCI formdata = cgi.FielStorage() else: # Called from command line or other (not web form) # Provide some test data... formdata = {'akey', cgiItemJoker('avalue'), 'anotherkey': cgiItemJoker('anothervalue'), ...} # run the body of the CGI script ... HTH --Gillou "Ron Stephens" a ?crit dans le message news: 3BF95D73.2886D584 at earthlink.net... > Any help would be appreciated. I am getting a KEYERROR when I run my CGI > program as a standalone python program. Maybe its just because the ... From pinard at iro.umontreal.ca Wed Nov 14 21:00:46 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 14 Nov 2001 21:00:46 -0500 Subject: How to marshal a function? In-Reply-To: <0111141538420B.04702@logiplex1.logiplex.net> References: <01111412544105.04702@logiplex1.logiplex.net> <0111141538420B.04702@logiplex1.logiplex.net> Message-ID: [Cliff Wells] > BTW, are you aware that you are double-posting? Oh, I merely reply to all like I usually do, as there is no `Reply-To:' to invite my mailer agent (Gnus) to do otherwise. So you receive two copies, one as the author of the original, the other as a list member. Both messages you received from me should be identical even up to the Message-ID, and many user agents automatically hide duplicates nowadays, or at least, have provisions for doing so. Otherwise, a simple `procmail' filter should easily take care of recent duplicates -- I can dig it for you in the documentation if you do not quickly find it. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From loewis at informatik.hu-berlin.de Fri Nov 30 07:44:21 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 30 Nov 2001 13:44:21 +0100 Subject: Accessing a Python Class from a C program References: Message-ID: Paul Weimer writes: > PyObject *pval = PyDict_GetItemString(m_pDict, "result"); [...] > This works fine if 'result' is a type like ant int or string but if > it's a class (in this case I want to use FixedPoint - it does > exactly what I need) I don't know how to get the results back > accurately. It works the very same way: pval will be a class the class instance object that result was assigned to. I don't know what you want to do with that result, just tell us how you would process the result in Python, and we tell you how to write that in C. E.g. if you were doing print result.counter then in C, this would read PyObject *counter = PyObject_GetAttrString(pval, "counter"); HTH, Martin From kalipygian at hotmail.com Thu Nov 22 21:09:12 2001 From: kalipygian at hotmail.com (Kali Kim) Date: 22 Nov 2001 18:09:12 -0800 Subject: How to reorganize shelve/dbhash/bsddb? Message-ID: <64a28082.0111221809.b914a7c@posting.google.com> Gdbm has reorganize functionality which will clean up deleted records. but dbhash doesn't seem to have it. The file just gets larger and larger even without anything in it. Any help will be greatly appreciated. From dcinege at psychosis.com Tue Nov 27 15:15:41 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Tue, 27 Nov 2001 15:15:41 -0500 Subject: Non-Indented python In-Reply-To: <3C03DC9D.1E57D73@astro.cornell.edu> References: <9sbd8i$680$1@wanadoo.fr> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> <3C03DC9D.1E57D73@astro.cornell.edu> Message-ID: On Tuesday 27 November 2001 13:34, you wrote: > > > What should a Python interpreter do with this? > > > > > > if 0: > > > print "0" > > > print "1" > > > > Raise SyntaxError. > > AMEN!! PEP!! Yes, it would break existing code, but that code > *should* be broken (in some sense it already is). Required 'me too'. What's that? Oh ok. God says he's in on this one too. -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From gat at jpl.nasa.gov Fri Nov 30 11:19:02 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Fri, 30 Nov 2001 08:19:02 -0800 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: In article <3C0773C2.A12D0BAC at pacific.net.hk>, Bernie wrote: > Erann, I think you find the indentation annoying because you choose 2 spaces > as your tab size, hence making the block not as apparent as it could > be. Try four spaces, or use Tools/Scripts/pindent.py if you really cannot > stand it. No, that's not it. Let me explain that remark, but first let me say the following: *** I am not suggesting the semicolon rule to replace syntactically *** significant indentation, but merely to augment it. Here's what I find annoying: Consider the following code: biff() # Line 0 for x in l: # Line 1 foo() # Line 2 baz() # Line 3 bar() # Line 4 When I use python-mode in emacs the editor will automatically indent for me after line 1. In fact, if I screw up the indentation accidentally, emacs can automatically restore it in the above example except for line 4. The reason it can do that is because of the colon at the end of line 1. That colon is actually redundant. It tells you unambiguously that the next line must be indented or you have a syntax error. I consider this redundancy, and emacs's resulting ability to automatically reconstruct the indentation to be a feature. The reason emacs can't restore the indentation on line 4 is that there is no such redundant information for emacs to use to determine where a block ends. People have suggested a convention like: biff() # Line 0 for x in l: # Line 1 foo() # Line 2 baz() # Line 3 # end for bar() # Line 4 What I am suggesting is no different, except that instead of "# end for" I want to use ";". The reason is simple: it's less typing, and it's easier to modify emacs python-mode to detect a trailing semicolon than an end-block comment. There is in fact already a hack for this. I could write: biff() # Line 0 for x in l: # Line 1 foo() # Line 2 baz() # Line 3 pass bar() # Line 4 and emacs will re-indent line 4 properly. RETURN also serves to unambiguously mark the end of a block. But IMO putting in pass statements all over the place to mark the end of blocks is really ugly. I'd also like to respond to a few other comments: * Steve Lamb: > > It also IMO makes the language unsuitable for mission-critical applications. > > It's just too easy to screw up indentation (particularly when cutting and > > pasting large blocks of code) without realizing it. > Hogwash, plain and simple. Either you know it because it is visually > different or you know it when you test the application and it fails > spectacularly. You /do/ test your mission-critical applications, don't you? Yes, of course we test our mission critical applications. Please extend me the courtesy of not immediately assuming I'm an idiot just because I make a proposal that you don't like. But testing is actually a very ineffective way of insuring that software works, particularly mission-critical software. For one thing, it's not possible to test spacecraft software under field conditions until the spacecraft is launched, and by then it may be too late. For another, many bugs, particularly in real-time multithreaded systems, are probabilistic, and so even if your tests work perfectly that alone does not provide a lot of confidence that your software is in fact correct. * Skip Montaro: > As has been demonstrated many a time, you're more likely to screw up a C > block by omitting braces: > > if (cond) > x = 1; > y = 1; Yes, this is exactly my point. You can look at the above code and tell there's something wrong because the braces and indentation provide redundant information in C. * Skip: > In fact, it's such an insidious > problem in C code that many groups mandate that all blocks use { & }, even > for one-statement blocks. Yes, and the situation in Python is that the language mandates an open-brace (or it's equivalent, the colon) and doesn't provide a close-brace even as an option. > In Python, if it looks right, it is right. No, that's not true. Consider the following two alternative code fragments: if x: foo() baz() if x: foo() baz() They both look right, but they can't both be right. * Skip: > Erann> This convention is 100% backwards-compatible with current > Erann> practice, that is, code written using this convention runs with > Erann> no problems in Python as it currently stands. > >Not it's not. Semicolons can legitimately be used to end a statement now. Well, that's actually what I meant by "backwards compatible." I know that semicolons can be used at the end of statements, but at the moment doing so is a no-op. (All it does is betray you as still thinking in C/Java.) I want to take syntax that is currently legal but useless and make it useful. Look, the reason I made this proposal is not that I want to come in and tell the Python community that syntactically significant indentation is all screwed up and should be discarded. The reason is that I want to sell people at JPL on the idea of using Python to write mission-critical software, and the people I'm trying to sell are raising this objection. I can counter this objection, but only three-quarters of the way. I can point out that Python already provides enough redundant information to reconstruct corrupted indentation at the beginning of blocks, but not at the end. To reconstruct it at the end of blocks all I can offer is my "pass/return" hack. I'd really like to be able to offer a standard syntactic convention that is endorsed by the Python community. That would make Python a lot easier to sell. So lighten up, folks. We're on the same side. Erann Gat gat at jpl.nasa.gov From James_Althoff at i2.com Fri Nov 9 13:40:38 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Fri, 9 Nov 2001 10:40:38 -0800 Subject: iters on ints? (reducing the need for range/xrange) Message-ID: Steven D. Majewski wrote: >I wouldn't be against 'iter(10)' returning an iterator but having 10 BE >an iterator is too much of a surprise. Actually, that ("iter(10) returns an iterator") *is* the proposal (well, at least that's what I *thought* was the suggestion :-): i.e., iter(10) would return an iterator that iterates across the integers 0,1,2,3,4,5,6,7,8,9 (consistent with the standard sequence-indexing convention). 10 would not *be* an iterator itself, but would return one in the context of a for-loop just like lists and tuples do. Jim From maxm at normik.dk Thu Nov 15 05:08:50 2001 From: maxm at normik.dk (Max M) Date: Thu, 15 Nov 2001 11:08:50 +0100 Subject: sending a function on the fly? References: <3bf2a06f$1@207.229.64.20> Message-ID: <3bf3942f$0$256$edfadb0f@dspool01.news.tele.dk> "Peter Bismuti" wrote in message news:3bf2a06f$1 at 207.229.64.20... > In ECMAscript you can send a function as an argument that is defined on the > fly such as: > > callMyFunction( new Function(){ blah blah }) > > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? Maybe the exec function can be used instead? functionText = """ def hello(): print 'Hello World' """ exec(functionText) hello() >>> Hello World Regards Max M From johnroth at ameritech.net Thu Nov 22 12:04:03 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 22 Nov 2001 09:04:03 -0800 Subject: Indenting with tabs vs spaces References: Message-ID: "Peoter Veili" wrote in message news:mailman.1006387828.11756.python-list at python.org... > Indenting with tabs can be done such that it will look the same on every > editor that uses fixed-width fonts, meaning everything will line up > correctly, it least in the sense that really matters. Here's an example of > what I mean: > > > > function helloThere("hello", > "there"){ > } > > > The proper way to do this is the second line needs to be typed with one tab > followed by enough spaces to line up the "hello" and "there". This way the > "hello" and "there" will line up correctly on any editor. If the person was > lazy and tabbed all the way out to right before "there" and then filled in > with a > few spaces, it may not line up depending on what your tabwidth is set to. > > Besides this I know of no problems with using tabs. The trouble with this is that all of your tools need to agree on where the tab stops are set. In the example above, you probably used four character tabs, and the tool you used formatted it as 8 character tabs. (At least, it looks that way to me.) If you disagree with the interpreter, you've lost it. In particular, if you try using four character tabs, and the Python interpreter thinks you are using 8 character tabs, you're going to have lots of indentation errors that your editor won't show. > I find them cleaner and > more efficient. I'd rather tab 10 times than hit the space bar 40 times. I > never have to go through a whole file and manually line things up because at > one place in the file I accidentally didn't indent with the right amount of > spaces and half the file needs fixing. Auto-indent helps, but still.... A good syntax aware editor does all of this for you. If you're arguing with your editor, you can: 1. get a new editor you agree with 2. find another job where you can use the editor of your choice, 3. get over it. 4. suffer. John Roth > > > > > From seeger at sitewaerts.de Thu Nov 22 03:37:45 2001 From: seeger at sitewaerts.de (Felix Seeger) Date: Thu, 22 Nov 2001 09:37:45 +0100 Subject: writnig my first programm References: <9tfrf5$27hfr$1@ID-79019.news.dfncis.de> <83zo5fvpk8.fsf@panacea.canonical.org> Message-ID: <9tid61$2ptdl$1@ID-79019.news.dfncis.de> Kragen Sitaker wrote: > Felix Seeger writes: >> A "adminclient <--> server <--> server-client" programm (all scripts are >> stored in the server and they will be given to the server-client if >> someone runs a command from the adminclient. >> The adminclient could be a GUI or a WebInterface. >> It's nice because the Server has always an uptodate version of the >> scripts. >> >> What do you think, is this possible ? > > As far as I understand, you want to keep your scripts in one place so > you can update them, and you want to be able to run them, either on a > particular server or on all the servers at once, in response to a GUI > or web interface. That's very possible, and probably pretty easy; you > could do it with a shell script from a web interface. Ok, but my Problem is: How can I transfer the commands from the Webinterface to the Server? About ssh or with my own server <--> client. I don't know, can I talk about ssh without entering a passwort and saving it in my python scripts ? I could scp a script to the server, and then ssh to run is, delete it. thanks have fun HAL From emile at fenx.com Mon Nov 5 08:13:26 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 5 Nov 2001 05:13:26 -0800 Subject: Non-obvious name bindings References: Message-ID: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> ----- Original Message ----- From: "Kerim Borchaev" Newsgroups: comp.lang.python Sent: Monday, November 05, 2001 4:49 AM Subject: Non-obvious name bindings > Hello! > > It seemed that it was my failure of understanding python but the > fact that introducing variable in list comprehension binds it to > functions scope(as every declaration means to?) is not really > obvious. > > I mean this: > > >>> [e for e in ['exists']] > ['exists'] > >>> e > 'exists' > > And I'm still confused - those "temporary" variables declaration > looks so "innocent", and in most cases (in every case for list > comprehensions I guess?) it's everyones intension not to use this > variable somewhere outside the loop. > > What are your thoughts? If you look at the structure as shorthand for a for loop and list.append it may make more sense: >>> [e for e in 'exists'] ['e', 'x', 'i', 's', 't', 's'] >>> e 's' >>> for e in 'exists': print e, e x i s t s >>> e 's' HTH, Emile van Sebille emile at fenx.com --------- From ulbi at ivs.tu-berlin.de Tue Nov 20 09:22:56 2001 From: ulbi at ivs.tu-berlin.de (Andreas Ulbrich) Date: Tue, 20 Nov 2001 15:22:56 +0100 Subject: Python to compile to Java-bytecode References: <61f6bfa8.0111200558.2f52ad44@posting.google.com> Message-ID: <3BFA6740.8070706@ivs.tu-berlin.de> Toni Gaya wrote: > There is any project that allows compile a Python program to Java > bytecode, as py2exe does compiling a python program to a .exe? I know > that there is Jython.. but.. It is a python interpreter writen in > Java, not a compiler of python source to Java bytecode (Althought it > implies compile source itself and support libraries, I think it is the > interesting thing). > > Does not someone more think about compile a python program to Java > byte code, and the possibility of merge python and java using soap? I > think it is a important thing to compete against .NET > Or it is obvious to use a python interpreter in any platform, a java > interpreter in same platform, and comunicate them using Soap?! I think Jython is exactly what we need. Of course it includes a runtime system (interpreter) but this is necessary because Python's object model is somewhat different from Java's (dynamic typing, inheritance). jythonc allows you to compile a Python source to Java bytecode that you can plug into any other java application. I think a real compiler with no runtime system necessary will only be possible with a statically typed Python, which is subject to the future. From huaiyu at gauss.almadan.ibm.com Tue Nov 13 13:42:08 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Tue, 13 Nov 2001 18:42:08 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> Message-ID: On 12 Nov 2001 23:45:51 -0500, David Bolen wrote: >On the non-empirical front, I peeked at the listobject.c source for >its list_richcompare function and no, there doesn't appear to be any >shortcut check for having both lists refer to the same object (at >least in the latest CVS source). It does do the length check (for == >and !=), but otherwise it's the full recursion with the generic >comparison applied to each element. > >It would be an easy optimization to add, although I'm wondering how >much benefit typical real-life code would see. > class A: def __cmp__(a,b): return -1 a = [A()]*3 a == a # returns 0 a is a # returns 1 Is this intended? I would think that mandating a is b implies a == b would make programs easier to read. Huaiyu From jgardn at alumni.washington.edu Sat Nov 10 08:51:59 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Sat, 10 Nov 2001 22:51:59 +0900 Subject: Python Vim Module Message-ID: <01111022515900.00639@linux> I am announcing my intentions to work on a python vim module. The first version will be just enough to send messages to a Vim session. I am aiming for it to work on the Linux platform first. If anyone out there is working on something similar or have already done something like this, let me know. Jonathan From jdadson at ix.netcom.com Sun Nov 4 21:02:20 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 02:02:20 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> Message-ID: <3BE5F306.446480AD@ix.netcom.com> Thanks. Before I submit a formal proposal, let me run it by you guys. I've looked through all the PEPS and I was surprised that my suggestion is not already there. So, here it is. Please comment. Other languages have started life with the feature that the first occurrence of an identifier defines it. The first time a programmer spends an afternoon chasing a bug introduced by misspelling an identifier, he begins to doubt the wisdom of that feature. Suppose you are called on to modify a long and complex module written by someone else. At some point you forget that the original programmer did not comply with your company's variable naming conventions. He named a variable "keepRecord" when it should have been "keep_record". After you've made your changes, the code usually works fine, but occasionally it deletes a record it is supposed to keep. You stare at the code for hours and you can see absolutely nothing wrong with it. Here's another one. A programmer who is new to Python code might write the following: initialized = 0 def init_everything(): blah() blah() blah() initialized = 1 # Oh noooooo! I would have complete sympathy for this hypothetical unfortunate fellow. Visual Basic (and perhaps other Basics, so far as I know) implement a way to have your cake and yet not spoil the old cake. It will correctly process code that is written to the old standard, but it allows you to require a defining occurrence of an identifier. If you want it the new way, you put a line at the top of your module that says, option explicit Of course you must know to put that in your source code, but most books on Visual Basic tell you up front always to do it. It gets to be a habit. Here's how it might work in Python. Again the module would have something at the top, like "option explicit" ("import explicit"? or what?) telling the interpreter that within that module, variables must be declared before use. Then the defining occurrence of a variable could look similar to the declaration of a function: option explicit def initialized = 0 def init_everything(): blah() blah() blah() initialized = 1 The above code would work as anticipated. No pesky "global" qualifier. The following would generate an error message, just like trying to call an undefined function does: >>>option explicit >>>initialized = 0 Traceback (most recent call last): File "", line 1, in ? NameError: initialized is not defined. After due warning (a year or two), "option explicit" could become the default. Old code might need "option implicit" or something added at the top to keep it working. From fperez528 at yahoo.com Tue Nov 27 16:04:00 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 28 Nov 2001 20:32:00 +2328 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> Message-ID: <9u4a9a$2k9$1@peabody.colorado.edu> J.Jacob wrote: > List comprehension in the later Python versions is fun but i need to > get this piece of code to run as quickly as possible on Python > version 1.5.2 and no NumPy available (not allowed to install extra > things on the computers here alas). > > This is the code as it is now, it works allright but the profiler > says we spend a lot of time here: > for j in range(self.nh): > sum = 0.0 > for i in range(self.ni): > sum = sum + self.ai[i] * self.wi[i][j] > > the .nh and .ni values are correct > I have been trying things like > > import operator > reduce(operator.add, map( operator.mul, ... )) > > but i am not at all used to optimization wizardry so i have no idea > if i can find a good solution. > Any expert wants to help ? Sorry to be blunt, but if you really do need speed (and you seem quite adamant about it), you *need* NumPy. This thing executing as a python loop will take ages for large matrices, while in NumPy it runs as a C loop without tpyechecking at every step. There's simply no comparison. I understand you may have sysadmin limitations, but you must have at least a personal directory somewhere (if not, are you editing in memory only? :). Just put numpy there, and add the path to sys.path. It won't be available system wide but you'll be able to work. And I'd double check the order of your indices just to be safe: you are doing sum_elements(wi_transpose*ai), where wi is a matrix and ai a vector. Are you sure you need the transpose? If you do, it will cost you even in Numpy to do it. The only fast way out is to write it in C where you can write the indices any way you want. Cheers, f From chrishbarker at home.net Thu Nov 29 19:56:19 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 16:56:19 -0800 Subject: Copy operator (was list.remove for Noivces) References: <3C054C58.9961A62@home.net> <3C0694D6.2F143D59@home.net> Message-ID: <3C06D933.67ABC273@home.net> Mark Fardal wrote: > > b = a.copy() > > Not available in Python 1.5.2, as you feared. Does it behave differently > than b = copy.copy(a) ? Probably not. > > In the 7th paragraph of "Array Basics" in my copy of the docs, it says: > > "functions which return arrays which are simply differnt views of the > > same data will in fact share their data" This applies to slices, but I > > agree that that is not made clear AT ALL in that section of the docs. > > Hm, the quoted criterion seems more than slightly circular to me. > How does it tell you that copy.copy(a) makes a copy of the data, but > a[:] does not? It doesn't. All it tells you is that you need to be careful about when Numeric is making a copy, and when it's not. As I said, this needs more documentation. By the way, Numeric2 has been introduced in an early form, and I don't know if any of this is changing, but maybe we can make an effort to make it clear in the new docs. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From fernstrom at geocities.com Fri Nov 30 18:12:56 2001 From: fernstrom at geocities.com (Christer Fernstrom) Date: 30 Nov 2001 15:12:56 -0800 Subject: Pic programmer in Python? Message-ID: Does anybody know of a PIC programmer in Python that works over a COM port (JDM type programmer) in Windows? -- christer From gustafl at algonet.se Sat Nov 3 11:56:32 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: Sat, 3 Nov 2001 16:56:32 +0000 (UTC) Subject: String argument -> name of list? Message-ID: I'm making a program for training musical scales. It should for example be able to ask things like: "What is the name of the sixth chord in the F# Phrygian scale?". I have a list of scale names that looks like this: # Scale names scales = [ 'ionian', 'dorian', 'phrygian', 'lydian', 'mixolydian', 'aeolian', 'locrian' ] There's also a list for each of these scales, so that the program can calculate how a scale looks, based on the chromatic scale and a root key. # Modal scale structures ionian = [0, 2, 2, 1, 2, 2, 2] dorian = [0, 2, 1, 2, 2, 2, 1] phrygian = [0, 1, 2, 2, 2, 1, 2] lydian = [0, 2, 2, 2, 1, 2, 2] mixolydian = [0, 2, 2, 1, 2, 2, 1] aeolian = [0, 2, 1, 2, 2, 1, 2] locrian = [0, 1, 2, 2, 1, 2, 2] The program chooses one of the scales randomly, so I may get for example the string 'dorian' in one session and the string 'locrian' in the next. Finally, there's a function that should take any of the lists of scale structures as an argument. Or perhaps it's better if it takes a string value, but it's currently taking the list. Anyway I choose, the problem is to make the conversion from a string ('ionian') to the list name (ionian) to get the scale structure. I wonder if it is any simple syntax for converting a string to the name of a list? Or should I use another structure instead, like a dictionary with strings + lists, or a list with strings + lists? Gustaf From ngreco at softhome.net Sun Nov 11 11:00:37 2001 From: ngreco at softhome.net (Nahuel Greco) Date: Sun, 11 Nov 2001 13:00:37 -0300 Subject: Fw: Re: IsPython really O-O? Message-ID: <20011111130037.22f56383.ngreco@softhome.net> On Sat, 10 Nov 2001 20:13:47 -0500 wrote: > A Smalltalk guru in our organization looked at Python last weekend (after I > had made a big scene saying that it may be a solution to some of our > cross-platform issues) and came away saying that it was no more > object-oriented than Java. I sputtered around a bit but could hardly make a > decent argument, as I'm a mere designer. We do very large-scale industrial > work here, all O-O, with object databases (I thought the ZODB business > looked great). Is my friend right? Is Python not "really" appropriate for > true O-O applications, in the sense that Viz-Age Smalltalk and Eifel and so > on are??? IMHO: Python is Object Oriented, and is more close to ST than Java, because python has dynamic resolution of method calling, like smalltalk, etc. But, Smalltalk is not Object Oriented, is **Object Based!** sometime ago, in a smalltalk workshop, a line was drawed: C++ --> Java --> Python --> Ruby ------(light years)---> Smalltalk Smalltalk isnt a language, is a box where objects lives, and are manipulated by default with a language unfortunately called also Smalltalk (but you can add other languages to your box, like Lisp or Prolog, or Python). In smalltalk, you dont edit source files, you manipulate objects (that, again, are live). If you want to add a class, you create a new class object, and then, when you want to create objects, you send a message to the class to create instances of them. All the objects created (in your "box", the ST) are "persistent" by default, when you close the ambient/box, the next time that you open it, are there. There isnt a distinction between "Create the program" and "Use it", you always play with live objects. In smalltalk, you dont use the classic cycle: 1- Design 2- Edit 3- Compile (or not, in the case of python) 4- Run / find errors 5- Debug / goto 2 You do something called "Evolutionary Programming", that means, you dont put your ideas in paper, and then code, instead, you use ST as the paper, and you play with the objects until the design is enough close to the reality. Then, as a by-product, you have the program or the framework created :) All the design / edit / debug are done in the same step. Im not an ST expert, but im very impressed with ST coming from a C++/Python background. C++ taught me,.. ehhrm, OO as a method of organize the code, Python get me into instropection and classes as first class objects and dynamic things, but ST is the whole coherent thing. Think Zope/ZODB as a poor-man smalltalk :) Try Squeak, i think that Object Based is the future (not only for languages, also for "Operating Systems" or computing in general), maybe with more use of asynchronuly message passing. As a funny side note, somebody asked the ST guru to do a "hello world", then the ST guy go inside the ambient, and typed "hello world". The "hello world" object was created, that show you that is another paradigm to be assimilated :) In the python language comparision page, you note that Guido really dont know ST "the paradigm", only smalltalk "the language/syntax". Sorry my poor english and my flame :) - Nahuel Greco Web Development - Open Source - - http://www.codelarvs.com.ar Game Programming - Research - - Freelance coding / sysadmin Networking. The answer is 42. - From kragen at pobox.com Tue Nov 27 19:18:43 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 19:18:43 -0500 Subject: Sockets and messaging services References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> Message-ID: <834rnf693w.fsf@panacea.canonical.org> shriek at gmx.co.uk (Stephen) writes: > Using a mailserver as a messaging platform for middleware ? > Now that's lateral thinking. It also screams of "huge hack" Not really, in my mind. I spent much of the last two years implementing publish-and-subscribe messaging middleware. I ended up wishing we'd just used a mail server for most of it. > and I can't imagine it would be as flexible or scalable as a > proper message queue server. There are people who have worked hard on making mailservers very scalable; I haven't used their results, but it isn't evident to me why mailservers have to be slower than JMS servers. Can you explain? From paul at boddie.net Mon Nov 12 10:24:27 2001 From: paul at boddie.net (Paul Boddie) Date: 12 Nov 2001 07:24:27 -0800 Subject: Post HTML checkboxes? References: <9soc2i$ch$1@green.tninet.se> Message-ID: <23891c90.0111120724.81ea577@posting.google.com> "Gustaf Liljegren" wrote in message news:<9soc2i$ch$1 at green.tninet.se>... > For some reason, my the values of my (X)HTML checkboxes won't show up in the > CGI dictionary of name + values. I have a form with these two checkboxes: > > > I think you ought to try using the "name" attribute rather than the "id" attribute. That will result in the field values being passed to your CGI program under the names you attempted to specify above. Paul From DTSRV10-SA at dutchtone.nl Tue Nov 27 11:04:51 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Tue, 27 Nov 2001 17:04:51 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C717BC@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = _printers at sendme.cz Recipient(s) = python-list at python.org Subject = Scanning Time = 11/27/2001 17:04:50 Action on virus found: The attachment news_doc.DOC.scr exists WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From tom.hines at usa.net Wed Nov 7 15:16:42 2001 From: tom.hines at usa.net (Tom Hines) Date: 7 Nov 2001 12:16:42 -0800 Subject: odbc: how to call a stored function in Oracle Message-ID: <25c120d1.0111071216.1947ca09@posting.google.com> Hi. I'm using ActivePython 2.1.212 and MS ODBC driver for Oracle. I am able to call a stored procedure that returns a cursor, but I haven't been able to figure out how to call a stored function or a procedure that has an output parameter. # this works schools = "" ret = cur.execute( "{Call MYPKG.MYPROC (?, {resultset 50, outSchools})}", ('myparam', schools)) # this doesn't work retparam = 0 ret = cur.execute("{? = Call MYPKG.MYFUNC (?)}", (retparam, 5341562)) I've tried a million combinations trying to get it to work, but I either get dbi.internal-error: [Microsoft][ODBC driver for Oracle]Invalid parameter type in EXEC or dbi.program-error: [Microsoft][ODBC driver for Oracle][Oracle]ORA-06550: line 1, column 7: PLS-00306: wrong number or types of arguments in call to 'MYFUNC' ORA-06550: line 1, column 7: PL/SQL: Statement ignored in EXEC Anybody know how to do this? -- Tom Hines From sigma at safepassage.ca Sun Nov 18 02:37:52 2001 From: sigma at safepassage.ca (Reid Nichol) Date: Sun, 18 Nov 2001 01:37:52 -0600 Subject: ssl error References: <9t7edj$pqd$1@violet.singnet.com.sg> Message-ID: <9yJJ7.1849$7b2.60534@news1.mts.net> Ng Pheng Siong wrote: > According to Reid Nichol : >> sslerror: SSL_connect error >> >> The error in my logs on my server if I try to connect to port 22: >> Bad protocol version identification '\M^@\M^@\^A\^C\^A' from 192.168.0.2 > > Port 22 is where SSH normally lives. It looks like you're trying to talk > the SSL protocol to an SSH server. SSH != SSL. > > There is a module to control OpenSSH binaries; look around on Parnassus. > > Silly me, that would expain that. thanks ----- If you truly love the memory, you must set it free()! From s713221 at student.gu.edu.au Mon Nov 5 04:48:29 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Mon, 05 Nov 2001 19:48:29 +1000 Subject: passing parameters to generators ? References: <9s3gh1$vh2fi$1@ID-11957.news.dfncis.de> Message-ID: <3BE6606D.167514DB@student.gu.edu.au> Emile van Sebille wrote: > This came up earlier this week. Here's my response to the earlier question: > > You can share mutable objects to pass in information: > > def gf(args): > while 1: > yield args[0]*args[1] > > a = [2,3] > g = gf(a) > print g.next() > a[1]=4 > print g.next() > > Is this what you're looking for? Yow! Emile, how on earth did you discover this, or should I read the PEP a little more thoroughly? -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From stuffedfriedred at yahoo.com Thu Nov 29 07:30:17 2001 From: stuffedfriedred at yahoo.com (Stuffed Fried Red Pepper) Date: Thu, 29 Nov 2001 07:30:17 -0500 Subject: M2Crypto, LDAP and python Message-ID: Hi, Could anyone give examples of types of useful applications that they've made using M2Crypto? I'm trying to learn M2Crypto and I'm comparing it with openssl. Is there an LDAP client library for python? -Fiel Cabral From paul at prescod.net Fri Nov 2 13:08:46 2001 From: paul at prescod.net (Paul Prescod) Date: Fri, 02 Nov 2001 10:08:46 -0800 Subject: Python.NET, MONO and Visual Studio etc. References: <3BDC5777.3873D22A@earthlink.net> Message-ID: <3BE2E12E.47CD6277@prescod.net> Max wrote: > > On Wed, 31 Oct 2001 21:16:39 -0800, Paul Prescod wrote: > > >As .NET cranks up, customers may express interest in an equivalent for > >Python. > > Would not the product be sucessful with an opposite strategy? If I understant > the CLR concept in .NET correctly, then a component "compiled" to run under the > CLR becomes "language invisible", i.e. the target cannot determine (and does not > care) what the source language is, correct? This is true also of the bridge strategy. You compile bridge objects that look to other .NET objects as if they were implemented in .NET. The tradeoffs to compiling everything into .NET runtimes are familiar from Jython: lowered runtime performance, no access to extensions like NumPy, PIL, PyOpenGL and subtle compatibility problems with the main Python interpreter. Neither approach is clearly better, but I think that ActiveState values complete backwards compatibility very highly because our corporate customers do. Paul Prescod From cliechti at gmx.net Sat Nov 10 13:26:22 2001 From: cliechti at gmx.net (Chris Liechti) Date: 10 Nov 2001 20:26:22 +0200 Subject: string manipulation question References: Message-ID: [posted and mailed] "AT&T News" wrote in news:iUcH7.106616$WW.6280952 at bgtnsc05-news.ops.worldnet.att.net: > Greetings, > I am looking for a more resaonable way to do the following, instead of > ugly > "if", "elif" constructs. Here goes: > > I have a string (line) that might contain, for example *any* *one* of > the patterns or words "whale" , "cat". > How do I elegantly set a variable say "animal" depending upon what word > is there. I.e I want > animal = "MAMMAL" if line contains the word "whale" > or > animal = "FELINE" if line contains the word "cat". > > is there a elegant way to code the above construct, I have 10 of these > patterns/keywords that can be found in a line. I thought of using a > dictionary for the keyword patterns, but the pattern/keyword does not > have any known context in the line. > > TIA > MO > > don't know if i get what you want, but here's my solution.. >>> animals = {'whale':'MAMAL', 'cat':'FELINE'} >>> def ident(s): ... for word in s.split(): ... for ani, group in animals.items(): ... if word == ani: ... return group ... >>> ident('there is more than one whale out there in the sea') 'MAMAL' >>> ident('a cat sits on the veranda') 'FELINE' >>> print ident('no animal here') None -- Chris From lars at larsshack.org Mon Nov 5 11:50:58 2001 From: lars at larsshack.org (Lars Kellogg-Stedman) Date: Mon, 05 Nov 2001 16:50:58 GMT Subject: Where is xml.dom.core? Message-ID: I'd like to start using python for some XML generation. I've got python 2.1.1 and PyXML 0.6.6, but all of the tutorials and examples I've come across start out with: from xml.dom import core Which on my system results in: >>> from xml.dom import core Traceback (most recent call last): File "", line 1, in ? ImportError: cannot import name core I'm going to be *generating* xml, so my impression is that I want the Builder module (xml.dom.builder). But it's not here either... So what am I missing? Thanks! -- Lar -- Lars Kellogg-Stedman --> http://www.larsshack.org/ From lac at strakt.com Sun Nov 11 08:37:07 2001 From: lac at strakt.com (Laura Creighton) Date: Sun, 11 Nov 2001 14:37:07 +0100 Subject: Is this considered black magic? Message-ID: <200111111337.fABDb7eR012232@ratthing-b246.strakt.com> I want to do something which is conceptually very simple. Given a list of objects, call make everybody call the same method you want to run. Sort of like apply(), but for methods. This is what I came up with: class Ham: def say(self): print "I am Ham, and I don't want any arguments, thank you." def speak_up(self, arg): print 'I am Ham, and my arguments are %s' % arg class Eggs: def speak_up(self, arg='bacon'): print 'I am Eggs, and my arguments are %s' % arg class Spam: def shout(self, arg1, arg2='sausage'): print 'I AM SPAM AND MY ARGUMENTS ARE %s AND %s' % (arg1, arg2) def foreach(name_key, object_list, *args): print 'foreach: args are ' + `args` for object in object_list: try: object.__class__.__dict__[name_key](object, *args) except KeyError: pass ########################## if __name__ == '__main__': h=Ham() e=Eggs() s=Spam() foreach ('say', [h, e, s]) foreach('speak_up', [e]) foreach('speak_up', [h, e, s], 'sandwich') foreach('speak_up', [h, e, s], None) #can i pass None? foreach('shout', [h, e, s], 'sandwich') foreach('shout', [h, e, s], 'sandwich', 'beer') -------------- This works: foreach: args are () I am Ham, and I don't want any arguments, thank you. foreach: args are () I am Eggs, and my arguments are bacon foreach: args are ('sandwich',) I am Ham, and my arguments are sandwich I am Eggs, and my arguments are sandwich foreach: args are (None,) I am Ham, and my arguments are None I am Eggs, and my arguments are None foreach: args are ('sandwich',) I AM SPAM AND MY ARGUMENTS ARE sandwich AND sausage foreach: args are ('sandwich', 'beer') I AM SPAM AND MY ARGUMENTS ARE sandwich AND beer ---------------- But is it white, grey, or black magic? Is there a better way I should have done? Suggestions on what to name the function gratefully welcomed. Laura Creighton From andreas at mtg.co.at Wed Nov 28 01:13:25 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Wed, 28 Nov 2001 07:13:25 +0100 Subject: [2.2b2]: class variable and classmethod, subclass In-Reply-To: <83u1vf6gua.fsf@panacea.canonical.org> References: <83u1vf6gua.fsf@panacea.canonical.org> Message-ID: <200111280613.fAS6DZY14468@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 "{-- Rot13 - Hateme" writes: > In 2.2B2 > Inside a class,I did a change to a class variable inside the class' > classmethod. If the variable has not been changed in the subclass before, > the class variable in the subclass of the class is also changed. Is this > behavior intentional or a bug? Well, it is the Pythonish way. Actually class variables in Python never had anywhere the semantics one might be used from other languages. (*grin* Never forget, Python is THE Lisp of Hashtables, instead of Cons cells ;) ) Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8BICLHJdudm4KnO0RAgR8AJ4q/uMP08wx5dMHA2gcjJ+L5xY7ZQCfWDmH YBaXdW3ZnkVz68rbRPsoFps= =LBY0 -----END PGP SIGNATURE----- From wtanksle at dolphin.openprojects.net Thu Nov 15 18:32:47 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Thu, 15 Nov 2001 23:32:47 GMT Subject: PEP 276 Simple Iterator for ints References: Message-ID: On Thu, 15 Nov 2001 13:20:41 -0800, Ken Seehof wrote: >The `end' argument issue goes away if the slice returns an iterator, so >int[:] returns the sequence of natural numbers [0, 1, 2, ...], which would >be a useful idiom as an infinite for loop: >. for i in int[:]: >. print i >. do_something(i) >. if done(): break I agree, but I don't think it should be legal to fail to give a starting point. So the above should be int[0:], not int[:]. >True, but having both would seem to be redundant, since you would not need >both solutions which would be redundant. Hence I am suggesting int >slicing as an alternative to PEP 276 (did I say that already? :-) I agree. I, however, am also starting to wonder about this... Aside from infinite for loops, which DO seem very useful and not possible under the old system, I've lost track of why we're arguing about this. Why should we make any change here? What are we fixing? >BTW, as a reminder, __getslice__ is depricated, so we are really talking >about __getitem__(slice), which amounts to the same thing. Sorry, I didn't know about that. >- Ken -- -William "Billy" Tanksley From tim.one at home.com Sun Nov 4 22:20:14 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 22:20:14 -0500 Subject: Program very slow to finish In-Reply-To: Message-ID: [Andrew MacIntyre] > IIUC, len(nacc.keys()) is a very expensive way to get the same value as > len(nacc). YUC. nwegwtsf-ly y'rs - tim From kragen at pobox.com Tue Nov 27 16:31:41 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 16:31:41 -0500 Subject: [2.2b2]: class variable and classmethod, subclass References: Message-ID: <83u1vf6gua.fsf@panacea.canonical.org> "{-- Rot13 - Hateme" writes: > In 2.2B2 > Inside a class,I did a change to a class variable inside the class' > classmethod. If the variable has not been changed in the subclass before, > the class variable in the subclass of the class is also changed. Is this > behavior intentional or a bug? It is intentional, I think, although I didn't write it and so I don't know; derived classes (subclasses) inherit all attributes from their base class (superclass) unless they override them (define them themselves). > There is no such behavior if the change is done in a normal member > method. I assume you mean if you say self.foo = 3 in a normal member method, dervied classes' foos don't change? That's because you're setting the attribute on the instance, not the class. From gh_pythonlist at gmx.de Fri Nov 30 17:47:16 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Fri, 30 Nov 2001 23:47:16 +0100 Subject: 2.1 loop with try & continue -> bug? In-Reply-To: References: Message-ID: <20011130234715.A3097@lilith.hqd-internal> On Fri, Nov 30, 2001 at 10:33:45PM +0000, Marco Beri wrote: > Hi, > look at this simple program: > > print "Running..." > cont=0 > while -1 : > print cont > cont = cont + 1 > try: > if cont == 2: > continue > if cont == 3: > break > except: > pass > > If I run it with python 2.1, this is the output: > Running... > 0 > 1 > 2 > Running... > 0 > 1 > 2 > . > . > . > > And so on, so it's clear that the "break" statement is never reached. > It seems that the "continue" included into the "try" statemente break > to an understood "while". It's a known and fixed problem: http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=462937 Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From dpetrac at yahoo.com Fri Nov 9 05:42:05 2001 From: dpetrac at yahoo.com (Danijel) Date: Fri, 9 Nov 2001 11:42:05 +0100 Subject: Focus problem References: <9sb4bj$smv$1@sunce.iskon.hr> <3BE9D760.ADCB0041@ccvcorp.com> Message-ID: <9sgbok$ura$1@sunce.iskon.hr> I was used EVT_KILL_FOCUS() succesfully, but now I got a new problem. :( When I select target entry field, and then select something else, and then came back on that target entry, I lose cursor. On all other fields exsists, except on this one. Sorce code I was used: txtEnry1.Connect(txtEntry1.GetId(),-1,wxEVT_KILL_FOCUS,self.OnKill) "Jeff Shannon" wrote in message news:3BE9D760.ADCB0041 at ccvcorp.com... > > Danijel wrote: > > > Hi! > > Is there a way to track focus change on window/control? I can't find that. > > I believe that the EVT_KILL_FOCUS() will do what you need--check into the docs > on that. > > Also, since this *is* a wxPython-specific question, you may get a more > thorough response if you ask it on the wxPython-users mailing list instead of > the main Python list. (You can find the wxPython list through > www.wxPython.org) > > > Jeff Shannon > Technician/Programmer > Credit International > > From brian at rk-speed-rugby.dk Tue Nov 6 02:17:10 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 06 Nov 2001 08:17:10 +0100 Subject: Teaching python (programming) to children References: <7xvggph61y.fsf@ruckus.brouhaha.com> <9s67gd$874$00$2@news.t-online.com> <7x4ro9un0c.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin writes: > Guido Stepken writes: > > > the Logo language. See the book Mindstorms, by Seymour Papert. He > > > > I have had great success in making children (12-15) having fun programming > > python .... before the were only interested in playing gameboy...with > Yes, Python is probably a good choice at ages 12-15. By "children" I > thought of the kids aged maybe 6-8. Python wouldn't make any sense > at that age, but Logo apparently worked ok. And I thought about the ages inbetween, I guess. At 8 they don't have the reading and writing skills to program, at 10 I believe they do. I will look at pygame. -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From phd at phd.pp.ru Tue Nov 20 03:34:51 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 20 Nov 2001 11:34:51 +0300 Subject: Free Python Server In-Reply-To: <15353.40372.784126.72589@beluga.mojam.com>; from skip@pobox.com on Mon, Nov 19, 2001 at 06:03:00PM -0600 References: <15353.40372.784126.72589@beluga.mojam.com> Message-ID: <20011120113451.A1343@phd.pp.ru> On Mon, Nov 19, 2001 at 06:03:00PM -0600, Skip Montanaro wrote: > Stephen> Hey, does anyone know of any free web hosting solutions that > Stephen> offer Python, and no banners or pop-up ads? > > I hate to play the devil's advocate here, but if they don't charge for their > web hosting and don't put up ads, how are they supposed to make the money > necessary to keep offering their services to you? Oh, right, they take your > personal info and sell it to direct marketing folks. http://www.port5.com/ does this - 15 megs, no banner, ftp access, email forwarding, statistics - all for free. But no Python. There are few Russian free webservers providers that have no Python, but have shell access, so I just installed Python myself. I am pretty sure there other, not Russian providers. Of course, there are banners and all that. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From calves at coelce.com.br Tue Nov 27 09:22:56 2001 From: calves at coelce.com.br (Alves, Carlos Alberto - Coelce) Date: Tue, 27 Nov 2001 11:22:56 -0300 Subject: ActivePython Installation problem Message-ID: <29A97D00F387D411AC7900902770E14802B3919C@lcoeexc01.coelce.net> Hi all, I downloaded and try to install the ActivePython-2_1_1.msi program, but it failed. It seems not be a valid windows package installer. Anybody could help resolve it?! I'm using Wndows(hit) 95 Carlos Alberto COELCE/DPRON-Departamento de Projetos e Obras Norte Fone: 677- 2228 e-mail: calves at coelce.com.br \|||/ (o o) --ooo0-(_)-0ooo-- -------------- next part -------------- An HTML attachment was scrubbed... URL: From chris.gonnerman at newcenturycomputers.net Thu Nov 22 19:03:03 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 22 Nov 2001 18:03:03 -0600 Subject: Alternative Readline (was Re: Colored console on Windows) References: <1712.011122@storm.ru> <9tjflj$j08$1@peabody.colorado.edu> Message-ID: <004701c173b2$4f3f3580$0101010a@local> ----- Original Message ----- From: "Fernando P?rez" > Hi Chris, > > quick question: does your readline module handle multi-line edits? That is, > if I have a multi-line statement, does it bring it back as a single editable > entity (which would be great) or as the 'real' readline does, as a series of > single-line statements (clumsy). It's not directly my problem. Python provides a hook for readline, for the purpose of reading single lines. My Alternative Readline package consists of a module _rlsetup which allows Python (vs. C) code to be linked to the hook, and a Python module providing line editing. The Python interpreter core handles collecting multiline commands, and AFAIK I can't change the behavior. From pzw1 at cor-no-spam-nell.edu Thu Nov 1 09:41:09 2001 From: pzw1 at cor-no-spam-nell.edu (Peter Wang) Date: Thu, 01 Nov 2001 09:41:09 -0500 Subject: python development practices? References: Message-ID: thanks for the warning. we're adopting the convention of all data is default private (unless in a rare, commented exception case), using get/set functions, and the rule of "if it ain't in the unit test, don't use it." -peter On Thu, 01 Nov 2001 09:41:27 +0100, Laura Creighton wrote: >Be careful with the leading underscore thingie. I have more trouble >with python code written by people (who don't work here) who apparantly >as a last step turn _every_ attribute in their class into a _variable. >I come along and want to subclass them, or make a helper class .... >I'm also tired of finding 3 classes which absolutely, positively, >_must_ live in the same file; especially since this is so rarely documented. > >Laura Creighton From djc at object-craft.com.au Wed Nov 21 05:41:21 2001 From: djc at object-craft.com.au (Dave Cole) Date: 21 Nov 2001 21:41:21 +1100 Subject: Microphone input References: Message-ID: >>>>> "Jesper" == Jesper Olsen writes: Jesper> Does python have e.g. a "Multimedia" module, with functions Jesper> supporting input from a microphone? Jesper> Java has this, but I have not been able to find something like Jesper> it for python. Are you the same Jesper Olsen who used to work at International Data Post? - Dave From ej at ee.duke.edu Sun Nov 11 00:40:54 2001 From: ej at ee.duke.edu (eric) Date: Sun, 11 Nov 2001 00:40:54 -0500 Subject: Proposal for a modified import mechanism. References: <3BED6E5B.8E142057@arakne.com> <033301c16a1a$59c1c690$c300a8c0@ericlaptop> <3BED9F9A.30F77DB3@arakne.com> Message-ID: <038301c16a73$70c5f790$c300a8c0@ericlaptop> Hey Frederic, > But then, this is not an import problem. > If you use Numeric, you call Numeric. If you call something other than Numeric, > just give a different name, and all the confusion will go away. This is certainly an option, but not a good one in my opinion. The main issue is we want to force a specific version of Numeric for SciPy while allowing people to keep their old standard version of Numeric available for their production code. Single level packages provide a handy way of doing this. Multi-level packages (like SciPy) do not. I guess I just don't see why making a package multi-level should inherently make it harder to do things. > If you're worried that you've already encoded the Numeric name 50 times into > 300 files; run a python script over these 300 files; this will do the renaming > of the 15.000 occurences of the Numeric name. Sure, but this is inconvenient, and something I think should be handled by the packaging facility, not by running a renaming script. > > > That makes SciPy > > self-contained and allows people to try it out without worrying that it > > might break their current installation. There are other solutions to this > > problem, but Prabhu's fix is by far the easiest and most robust. > > And then, in maintenance/integration phase, sometimes 'Numeric' will call > Numeric, some other times it will your package ? In the integration phase, users would need to change the "from Numeric import *" to "from scipy import *" (or search and replace Numeric with scipy) in their code as Numeric is completely subsumed into scipy. So, when not using SciPy, their legacy code can continue using an old version of Numeric. When switching to SciPy, the make the replacement. As I said, its mainly a version issue (with a few minor changes). > > What if somebody, for some reason I know nothing of (e.g. probably some > integration) wants to call Numeric and your Numeric package in the same module ? > Wish them tough luck to sort out this poisoned gift.... > > > Prabhu's import also has some other nice benefits. Some of the sub-packages > > in SciPy are useful outside of SciPy. Also sometimes it is easier to > > develop a packages outside of the SciPy framework. It would be nice to be > > able to develop a module or package 'foo' outside of SciPy and then move it > > into SciPy at a later date. However, every SciPy sub-package that referred > > to foo prior to its inclusion in SciPy now has to be updated from 'import > > foo' to 'import scipy.foo'. These kind of issues make it very painful and > > time consuming to rearrange package structures or move modules and > > sub-packages in and out of the package. > > There are basic python scripts which do this painlessly. If you're really > working on a large project, there's a project architect which normally would > take care of such things, and for whom this should not be a too much of a > problem. Hmmm. I guess the "project architect" in this case is jointly held by Travis Oliphant and yours truely. Neither of us are packaging guru's, but do have a fair amount of experience with Python. We worked quite a while on (and are still working on) packaging issues. Incidently, I have know idea what Travis O.'s opinion is on this specific topic. > > > > Simplifying this will improves > > package development. > > > > > I'm personnally against anything that enlarges the search path uselessly; > > > > Hopefully I've explained why it is useful for complex packages. > > Python helps in many areas, but expecting it to palliate for the package design > and architecture flaws that inexorably surface anytimes something non-trivial is > developped, might be somehow at the edge. Python has not yet replaced the need > for relevant software architects. Them thars fightin' words. ; ) I'm biased, but don't thinking scipy's architecture is flawed. It is simply a *very* large package of integrated sub-packages that also relies heavily on a 3rd evolving group of modules (Numeric). As such, it reveals the difficult issues that arise when trying to build large packages of integrated sub-packages that rely on a 3rd evolving group of modules... > > > > > > because the obvious reason of increased name space collision, increased > > > run-time overhead etc... > > > > I'm missing something here because I don't understand why this increases > > name space collision. If the objection is to the fact that SciPy can have a > > version of Numeric in it that masks a Numeric installed in site-packages, I > > guess I consider this a feature, not a bug. > > Actually, it is normally worse than a bug: it is a source of bug tomorrow in > your application - of all the bugs you'll have when your programmer will be > confusing the two Numeric packages, as well as all the mainteance and > integration problems you'll have down the line -. I disagree and don't think that is true in this (and many other) situations. People who want to use SciPy will migrate completely to it since it includes Numeric. What the sub-package option offers is a way to test SciPy and optionally use it while keeping their standard Numeric around for their production code. > > But by then, hopefully for you, you'll be somewhere else... The sad reality of > most projects :(( > > > Afterall, this is already the > > behavior for single level packages, extending it to multi-level packages > > seems natural. If this isn't your objection, please explain. > > > > The current runtime overhead isn't so bad. Prabhu sent me a few numbers on > > the SciPy import (which contains maybe 10-15 nested packages). I attached > > them below -- the overhead is less than 10%. It should be negligible for > > standard modules as only packages are really affected (right Prabhu?). > > And that's how, when you cumulate of the overheads for all new features, you get > potenially +100-200% overhead on the new releases. > Albeit all the efforts of the Python team, Python 2.0 is up to 70% slower than > python 1.5.2; Python 2.1.1 is up to 30% slower than python 2.0, and so on... > So, +10% on only such a minor features is anything but negligible :((( The computational cost of additional functionality is always a question of what portion of a program is impacted. If we were talking about 10% hit on looping structures or dictionary lookups or local variable lookups, then yes it needs extreme scrutiny. Adding 10% to a rare event is not worthy of note. I expect (and see) 0% overhead for importing standard modules (by far the most common case). Adding 10% overhead to importing a very large package with 10-15 nested sub-packages is just not a big deal. The 350% cost I saw (noted in a response to Gordon) is a *huge* deal and would need to be solved (moving to C would help) before this became standard. eric ----- Original Message ----- From: "Frederic Giacometti" To: "eric" Cc: ; ; ; Sent: Saturday, November 10, 2001 4:43 PM Subject: Re: Proposal for a modified import mechanism. > > > eric wrote: > > > I have to agree with Prabhu on this one. The current behavior of import, > > while fine for standard modules and even simple packages with a single > > level, is sub-optimal for packages that contain sub-packages. The proposed > > behavior solves the problem. > > > > Handling the packaging issues in SciPy was difficult, and even resulted in a > > (not always popular) decision to build and overwrite the Numeric package on > > machines that install SciPy. Prabhu's import doesn't resolve all the issues > > (I think packages may just be difficult...), but it would have solved this > > one. The proposed import allows us to put our own version of Numeric in the > > top SciPy directory. Then all SciPy sub-packages would grab this one > > instead of an existing site-packages/Numeric. > > But then, this is not an import problem. > If you use Numeric, you call Numeric. If you call something other than Numeric, > just give a different name, and all the confusion will go away. > If you're worried that you've already encoded the Numeric name 50 times into > 300 files; run a python script over these 300 files; this will do the renaming > of the 15.000 occurences of the Numeric name. > > > That makes SciPy > > self-contained and allows people to try it out without worrying that it > > might break their current installation. There are other solutions to this > > problem, but Prabhu's fix is by far the easiest and most robust. > > And then, in maintenance/integration phase, sometimes 'Numeric' will call > Numeric, some other times it will your package ? > > What if somebody, for some reason I know nothing of (e.g. probably some > integration) wants to call Numeric and your Numeric package in the same module ? > Wish them tough luck to sort out this poisoned gift.... > > > Prabhu's import also has some other nice benefits. Some of the sub-packages > > in SciPy are useful outside of SciPy. Also sometimes it is easier to > > develop a packages outside of the SciPy framework. It would be nice to be > > able to develop a module or package 'foo' outside of SciPy and then move it > > into SciPy at a later date. However, every SciPy sub-package that referred > > to foo prior to its inclusion in SciPy now has to be updated from 'import > > foo' to 'import scipy.foo'. These kind of issues make it very painful and > > time consuming to rearrange package structures or move modules and > > sub-packages in and out of the package. > > There are basic python scripts which do this painlessly. If you're really > working on a large project, there's a project architect which normally would > take care of such things, and for whom this should not be a too much of a > problem. > > > > Simplifying this will improves > > package development. > > > > > I'm personnally against anything that enlarges the search path uselessly; > > > > Hopefully I've explained why it is useful for complex packages. > > Python helps in many areas, but expecting it to palliate for the package design > and architecture flaws that inexorably surface anytimes something non-trivial is > developped, might be somehow at the edge. Python has not yet replaced the need > for relevant software architects. > > > > > > because the obvious reason of increased name space collision, increased > > > run-time overhead etc... > > > > I'm missing something here because I don't understand why this increases > > name space collision. If the objection is to the fact that SciPy can have a > > version of Numeric in it that masks a Numeric installed in site-packages, I > > guess I consider this a feature, not a bug. > > Actually, it is normally worse than a bug: it is a source of bug tomorrow in > your application - of all the bugs you'll have when your programmer will be > confusing the two Numeric packages, as well as all the mainteance and > integration problems you'll have down the line -. > > But by then, hopefully for you, you'll be somewhere else... The sad reality of > most projects :(( > > > Afterall, this is already the > > behavior for single level packages, extending it to multi-level packages > > seems natural. If this isn't your objection, please explain. > > > > The current runtime overhead isn't so bad. Prabhu sent me a few numbers on > > the SciPy import (which contains maybe 10-15 nested packages). I attached > > them below -- the overhead is less than 10%. It should be negligible for > > standard modules as only packages are really affected (right Prabhu?). > > And that's how, when you cumulate of the overheads for all new features, you get > potenially +100-200% overhead on the new releases. > Albeit all the efforts of the Python team, Python 2.0 is up to 70% slower than > python 1.5.2; Python 2.1.1 is up to 30% slower than python 2.0, and so on... > So, +10% on only such a minor features is anything but negligible :((( > > FG From gh_pythonlist at gmx.de Sun Nov 11 16:33:51 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 11 Nov 2001 22:33:51 +0100 Subject: IsPython really O-O? - Think different ! In-Reply-To: <9smovs$cbu$02$1@news.t-online.com> References: <9smovs$cbu$02$1@news.t-online.com> Message-ID: <20011111223350.A1119@lilith.hqd-internal> On Sun, Nov 11, 2001 at 10:02:51PM +0100, Guido Stepken wrote: > My experience, coming from many languages (BASIC, ASSEMBLER, PASCAL, > MODULA-2/3, LISP, PROLOG, C, C++, JAVA, now Python is: > > 1. Python is easy to learn > 2. Python is easy to keep in mind > 3. Python is full OO! Modules and functions (and others) are first-class objects, which is something rarely found in other languages. There are no ugly primitive types like in Java. So it's at least more OO than any language I know. But then, I don't know Smalltalk. Hey, if you want to annoy a Smalltalk zealot, why don't you tell him that his language is far less functional than Haskell, Ocaml or even Python! And far less type-safe than Ada, Eiffel or Java (this is just my guess, but it might be true). > 4. Python Code is reusable > 5. Python has simple to unterstand containers, polymorphism > 6. Python is powerfull, but easy to understand > 7. Python is fun for kids (my experience !) > 8. Python is a full OO language with mighty modules and libraries > 9. Python can't keep up with smalltalk or haskell in OO features (i am > missing makro's, but ist's the best compromise I have ever seen. Well, I think Python can keap up very well with Haskell's OO features ;-) Not with functional features, though. But I've heard the list comprehensions were inspired by Haskell. Never could wrap my head around Haskell's IO, myself. > 10. Python is much more readable than Smalltalk, Eiffel, Haskell, Lisp, > C++, JAVA so it's easier for team - programming > 11. JAVA is spread all over the world, but there is JPYTHON !!!!!!!!!! > 12. Try Python, an you will see your own ! > 13. Python has future - see Microsoft Visual Studio implementation of > Python ..... - Even Microsoft likes Python !!!!!!!!!!!!!!!!!!!!!!!! A minor correction: VisualPython is an ActiveState product. Microsoft has AFAIK nothin to do with it except that they provide VisualStudio 7 with a plug-in API for other languages, debuggers, etc. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From joonas at olen.to Thu Nov 29 16:46:55 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 29 Nov 2001 23:46:55 +0200 Subject: Please help -- looking for copy of Python2C References: <3d799735.0111290631.17db9392@posting.google.com> Message-ID: <3C06ACCF.9847961F@olen.to> Graham Fawcett wrote: > > I'm looking for a copy of Python2C. Unfortunately the home site of the > project, http://www.mudlib.org/~rassilon/p2c/ , appears to be offline > and has been for some time. > > Does someone have a copy available for download, or could they e-mail > me a copy and I will publish it for others? (If you have a tarball of > the old p2c site, that would be even better than just the app!) I have the py2c files extracted but not the original archive. From ws-news at gmx.at Sat Nov 24 17:21:40 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Sat, 24 Nov 2001 23:21:40 +0100 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> <3bfecd77@brateggebdc5.br-automation.co.at> <97ae44ee.0111232129.550244cd@posting.google.com> Message-ID: <3c001e3a$1@brateggebdc5.br-automation.co.at> Hi, "Martin von Loewis" wrote in message news:j43d34pgp2.fsf at informatik.hu-berlin.de... ... > > > Just to clear up my own understanding, is it fair to say that > > a "built-in" module can be defined as one that is included in > > the core Python distributed, and is written in C as oppopsed > > to Python, but which still needs to be imported before use ? > > Almost correct. There is a slight overloading of names > here. Traditionally "builtin" modules are the ones listed in > sys.builtin_module_names, which in turn are the ones statically linked > with the compiler. These days, most installations build the modules > shipped with Python as shared libraries, so they are strictly speaking > "extension modules". However, to distinguish them from third-party > extension modules, they are often called "builtin" even if not linked > with the interpreter. But this does not mean, that one cannot just take one's own C extension and link it statically with the interpreter. This can be very convenient if you embed Python into an other Application or work on a platform that has limited/bad support for dynamic loading. Personally, I think the term 'built-in' tells more about whether it is 'in' the interpreter (python) binary or a seperate file (no matter if Python or C). I'd call the modules coming with Python 'The Python Standard Library' - but this if of course personal taste. Best regards Werner From kragen at pobox.com Tue Nov 27 17:40:50 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 17:40:50 -0500 Subject: Evaluate a python expression from C? References: Message-ID: <83adx76dn1.fsf@panacea.canonical.org> David Brady writes: > Could the problem be the NULL args I pass in? For > simple evaluation, what should I populate them with > instead? There were several problems; that was one of them. Here's an apparently-working program, in C: #include #include void PyEval(char *data) { char *buf; PyObject *globals, *locals, *pObj; Py_Initialize(); globals = PyDict_New(); if (!globals) return; locals = PyDict_New(); if (!locals) { Py_DECREF(globals); return; } // The following line doesn't access violate. pObj = PyRun_String(data, Py_eval_input, globals, locals); PyArg_ParseTuple(pObj, "s", &buf); printf("%s", buf); Py_DECREF(pObj); Py_DECREF(globals); Py_DECREF(locals); } int main(int argc, char **argv) { PyEval(argv[1]); } I compiled it with cc -g pyeval.c -Wall -I/usr/local/include/python2.1 -lpython2.1 -L/usr/local/lib/python2.1/config -o pyeval -ldl -lpthread -lm -lutil which is somewhat system-dependent, and run it with ./pyeval '("hi\n",)' (because, after all, PyArg_ParseTuple is expecting a tuple containing a string) From grante at visi.com Wed Nov 7 10:01:16 2001 From: grante at visi.com (Grant Edwards) Date: Wed, 07 Nov 2001 15:01:16 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: In article , Tim Peters wrote: >> It could be worse, in most other newsgroups all threads end up >> being about Hitler... > > No threads on c.l.py end up being about Hitler. Not even this one! Indeed, > I expect this one to veer into transfinite cardinals before I finish this > sentence. Are they the ones with a fanatacal devotion to the pope whose three main weapons are... -- Grant Edwards grante Yow! Life is selling at REVOLUTIONARY HAIR visi.com PRODUCTS! From hamish_lawson at yahoo.co.uk Thu Nov 15 10:05:10 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: 15 Nov 2001 07:05:10 -0800 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <915a998f.0111150705.7d9677ef@posting.google.com> > Abstract > > Python 2.1 added new functionality to support iterators[1]. Shouldn't that be Python 2.2? Hamish Lawson From senux at senux.com Wed Nov 14 02:46:11 2001 From: senux at senux.com (Brian Lee) Date: Wed, 14 Nov 2001 16:46:11 +0900 Subject: DNS, DB server based on Python? Message-ID: <20011114164611.A18129@jupiter.senux.com> I'm looking for DNS and DB server based on Python language. I use bind version 9 and mysql 3.24 on Linux but want to change other server which is coded by Python language. Performance and function of the servers is not important for me. I want to try to read server code in Python. Any comments will be helpful for me. Thank you. ps. I don't care the database is rdbms or not. -- Brian Lee - http://www.senux.com/ From dalke at dalkescientific.com Mon Nov 12 22:10:41 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Mon, 12 Nov 2001 20:10:41 -0700 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> <9sp073$k6d$1@news.lth.se> Message-ID: <9sq30e$4hp$1@slb1.atl.mindspring.net> David Andreas Alderud: >Depends on the audience I guess, people who are interested in >programming tend to be interested in how the computer works and >how to write efficient programs. When I started programming I didn't know how the hardware worked. Nearly 20 years later, I still don't know. Frankly, I know just enough to say things like "dopants", "Fermi surface" and "binary logic gate" then handwave up to the C view of the system. I tried learning the peek/pokes people used for performance and gave up because it didn't make sense to me. I've written perhaps 500 lines of assembly in my life. >Things like dictionaries are good for non-programmers to get things done, >it's good for a simple solution but can not be transformed in a way that BST >are simply turned into an R\BST when the requirements change. I still use dictionaries, heavily. For commentary, see http://aspn.activestate.com/ASPN/Mail/Message/python-Tutor/538598 >Again, depends on what kind of view one has of teaching and learning, my >view is that the students should teach them selves, and that is best done in >Ada. I taught myself programming. I learned with BASIC, which effectively had two data types: number and text. I didn't know the difference between an integer and a real (they're just numbers, right)? Eg, I recall wondering why I couldn't stick things into an array at position arr(1.2) -- why was that the same as arr(1)? This from a person whose first non-trivial code was a program to compute gcd and lcm. It wasn't until I was 16 when I started using QBASIC where I could specify data types, and I did so only *after* I wrote the code and wanted the performance. Ada, as I recall, doesn't have that flexibility. So I figure it would have been that much harder for me to figure things out. Part of my job now is getting research scientists to figure out that programming is fun. These are people usually with a PhD in chemistry, physics or biology who have had a bit of C or FORTRAN training and on-the-job learning of shell programming. I've seen them learning different languages (C, C++, Tcl, Perl, Python, and a slew of domain specific languages). Of those, Tcl and Python make the most sense to them. Things like the interactive mode, strong dynamic typing, exceptions, gc, readability, and a practical view of the world make things easy enough for them. Of those, Python is the only one that programmers also enjoy. So I code in Python. I can't imagine teaching them Ada. I've read through an Ada primer. It didn't give me anywhere near the joy that reading the Python tutorial gave me. Though 'tis true, they aren't children, so I've strayed off topic. I can't imagine learning Ada on my own in 7th grade. I could have done Python, except I would have needed a better editor than Python's current text version. BASIC with line numbers makes it possible to edit a single line of code. Not sure about the current IDEs either. I heard one talk where the presenter chose Tcl (withone of the object extensions) over Python because it was easier for her coworkers to change a single method interactively, rather than having to reload the whole module, with all the trickiness that entails. Andrew dalke at dalkescientific.com From ee_fhw at stu.ust.hk Mon Nov 5 10:26:15 2001 From: ee_fhw at stu.ust.hk (Calvin) Date: Mon, 05 Nov 2001 23:26:15 +0800 Subject: Solving Partial Differential equation in Python References: Message-ID: <3BE6AF97.3000308@stu.ust.hk> I need some backgound in Numeric Analysis to solve the PDE. so, hard to answer your question Trond Eivind Glomsr?d wrote: > Roman Suzi writes: > > >>Probably, if you could find library like LAPACK for linear algebra >>and use SWIG to make bindings to C for Python, you will have >>PDE solving functionality in Python. >> > > LAPACK doesn't do PDEs? > > From thomas.heller at ion-tof.com Thu Nov 22 16:02:49 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Thu, 22 Nov 2001 22:02:49 +0100 Subject: win32gui.SetWindowLong(GWL_WNDPROC) Message-ID: <9tjp3o$338db$1@ID-59885.news.dfncis.de> Are there any issues with win32gui.SetWindowLong(hwnd, GWL_WNDPROC, proc)? I've both tried a dict or a callable as proc, both should be allowed according to the docs. Executing the above code works fine, but as soon as the first WM_xxx message is dispatched to proc, Python crashes: Fatal Python error: PyThreadState_Get: no current thread abnormal program termination No, I've not mixed debug and release builds. I'm using ActiveState Python 2.1.1, build 212. Thomas From gerson.kurz at t-online.de Fri Nov 2 15:07:27 2001 From: gerson.kurz at t-online.de (Gerson Kurz) Date: Fri, 02 Nov 2001 21:07:27 +0100 Subject: installing .py-script as daemon process Message-ID: <9ruui1$in5$06$1@news.t-online.com> I don't know if this is exactly the right group, BUT: I'm writing (yet another) GPLed POP3/SMTP server, in python. On windows, I can install it as a service, which seems to work fine. On linux, how can I make it a daemon process that is controllable from outside? gets started at boot time? Has maybe someone written a common (as in: portable between win32 and unix) "server process" api that wraps this functionality? Thanks, Gerson http://p-nand-q.com From mwh at python.net Wed Nov 28 06:46:15 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 28 Nov 2001 11:46:15 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> Message-ID: Jonathan Gardner writes: > * In case you're wondering what editor I use, let me just say that it works > really well with the email client that sucks less than all the others. And the one I use *contains* the mail (and news) client that sucks less than all the others... (which is quite a nice encapsulation of the debate, really...) Cheers, M. -- If you give someone Fortran, he has Fortran. If you give someone Lisp, he has any language he pleases. -- Guy L. Steele Jr, quoted by David Rush in comp.lang.scheme.scsh From mwh at python.net Thu Nov 29 11:00:09 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 29 Nov 2001 16:00:09 GMT Subject: Strange Tkinter behaviour References: <9u4kf5$ran$1@news.onet.pl> <9u5l8i$dh9$1@news.onet.pl> Message-ID: "Tomasz Lisowski" writes: > I wonder, whether there is a mechanism suspending the Tkinter event > loop, so that other event-based applications (not using Tkinter) > could get access, and perform their duties. Unix or Windows? Have you looked at createfilehandler? What are you trying to do again? I think I've got a bit confused... Cheers, M. -- The only problem with Microsoft is they just have no taste. -- Steve Jobs, (From _Triumph of the Nerds_ PBS special) and quoted by Aahz Maruch on comp.lang.python From peter at engcorp.com Mon Nov 19 20:18:35 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 19 Nov 2001 20:18:35 -0500 Subject: Python execution speed References: Message-ID: <3BF9AF6B.6329BDF5@engcorp.com> "Morten W. Petersen" wrote: > > I started a thread about a week ago, asking about benefits of moving > from Python to Common Lisp. > > I've done some more research and 'heard' that Lisp can be up to 80% of the > speed of programs written in C (compiling the Lisp code). [...] > 1. What is the plan for psyco (inclusion in the standard distribution, etc) ? > 2. Will there be a JIT compiler for Python ? > 3. Are there any similar efforts for Jython [5] ? > 4. Are efforts made to optimize Python's execution speed in general ? Interesting questions, for which I have no answers. :) I'm curious, however, why you believe you need to optimize Python's execution speed so much? Do you have some application which is not performing adequately? The usual approach is simply to profile the code and recode the "hot spot" in C. (I'm training myself never to optimize before the code is working, and only when it is not fast enough to meet defined requirements, and only after adequate profiling. Since this means I almost never spend _any_ time optimizing code, I just keep an eye out for what sounds like too much attention paid to unnecessary speedups.) Cheers, ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From peter at engcorp.com Fri Nov 23 18:49:54 2001 From: peter at engcorp.com (Peter Hansen) Date: Fri, 23 Nov 2001 18:49:54 -0500 Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> <3BFEC93C.78DB7D98@ccvcorp.com> <29AL7.2768$nK1.269290698@newssvr14.news.prodigy.com> Message-ID: <3BFEE0A1.973356BB@engcorp.com> Keith Farmer wrote: > > "Jeff Shannon" wrote in message > news:3BFEC93C.78DB7D98 at ccvcorp.com... > > you're doing repeated runs of the same script, you can run DOSkey and then > > you can repeat the command with up-arrow. > > Actually (at least under Win2k, I think under Win98), DOS already supports > up-arrow history. Sorry, not under Win98. And under Win2K it's not really DOS... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From emile at fenx.com Tue Nov 6 17:50:25 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Nov 2001 14:50:25 -0800 Subject: Beginner in Python References: <3BE85DF9.CDF844D2@gmx.net> Message-ID: <9s9pp2$11iio5$1@ID-11957.news.dfncis.de> Hah... I got caught explaining this one last week. ;-) You are to type "python helloworld.py" at the dos prompt ("C:\Dir\Of\HelloWorld>"), not the python prompt (">>>"). I suspect that as double click it in the explorer that everything else required is already in place. -- Emile van Sebille emile at fenx.com --------- "Christian Schnell" wrote in message news:3BE85DF9.CDF844D2 at gmx.net... > Hi, > > I wanted to start programming in python today and had some problems. > I wrote the famous "Hello, world"-programm and saved it as > helloworld.py. If I open the programm directly in the explorer it works > but I cannot start it from Ms-Dos. If I type python helloworld.py I get > the message: > > File "", line 1 > python helloworld.py > ^ > > SyntayError: invalid syntax > > What is my mistak? Can anyone help me? > > Thank you, > > Christian > > -- > Don't panic. > > ICQ 116707729 > > From com-nospam at ccraig.org Mon Nov 19 08:32:23 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 19 Nov 2001 08:32:23 -0500 Subject: A modest proposal In-Reply-To: <3BF63625.33330E2A@accessforall.nl> References: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> <3BF63625.33330E2A@accessforall.nl> Message-ID: Ype Kingma writes: > There is a python to java byte code compiler that does something > quite similar for local namespaces: it maps some known locals to the > iloadN/istoreN instructions of the java virtual machine. I don't > know/understand the details, so in case you want more information it > is probably best to post at jython-dev via www.jython.org. Actually, CPython does something similar for local namespaces. The issue is with global namespaces. Local namespaces are immutable (once you compile a function, you cannot change what names it uses), which means it is quite easy to enumerate the variables. Global namespaces, OTOH, are mutable. Even after you've included a module, someone who imported your module can later add variables to it. This makes it impossible to simply use numeric indicies for them, which is why we have this proposal, and PEPs 266 and 267. -- Christopher A. Craig From sill at optonline.net Wed Nov 14 01:00:34 2001 From: sill at optonline.net (Andrei Kulakov) Date: Wed, 14 Nov 2001 06:00:34 GMT Subject: Python Vim Module - works References: Message-ID: On Wed, 14 Nov 2001 02:50:33 GMT, Tim Hammerquist wrote: > Andrei Kulakov graced us by uttering: > [ snip ] >>> $ gvim --servername TEST >>> $ python >>>>>> import vim >>>>>> vim.list() >>> ['TEST'] >>>>>> vim.send('TEST', 'iHello World!') >>> >>> You should see the string "Hello World!" neatly typed into the newly opened >>> vim window!!! >> >> I'm sorry if this is a dumb question, but what's the purpose of this? > > Jonathan wrote an extension module for Python that can access each > instance of gvim on an X display from _outside_ of vim. > > Vim can also be compiled to use Python and/or Perl as an internal > scripting language, and the Python engine has a builtin module called > 'vim' that grants access to vim internals (buffer lists, lines of > buffers, etc.) As this module is useful but unavailable outside of vim, > Jonathan wrote his own. > > Or did I misunderstand your question? Oh, I understand what it *does*. I just don't understand what is the purpose, i.e. what would be a useful application of this module? I'm asking because I love vim and I used python vim module and if someone finds this thing useful, I might too.. > > Tim Hammerquist -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From matt at mondoinfo.com Sat Nov 24 15:35:18 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 24 Nov 2001 20:35:18 GMT Subject: problem with "elif" References: Message-ID: On Sat, 24 Nov 2001 21:26:43 +0100, Pjotr wrote: Dear Pjotr, >Hello! Hi! >I started learning Python, using Python 2.1.1 and Ivan Laningham's >book "Teach yourself Python...". Cool. Welcome to Python! >I have a problem with instruction "elif": >>>> y = 1900 >>>> leap = "no" >>>> if y % 400 == 0 : > leap = "yes" > elif y % 100 == 0 : >IndentationError: unindent does not match any outer indentation level >(line 3) >What's up? This example is from Laningham's book and everything >should be OK. Please help me! elifs need to line up with the corresponding if so if you move your elif left by three spaces, you should be fine. That's a convenient way of doing things because it means that long sequences of elifs don't end up marching right across the screen until even short lines wrap. Regards, Matt From dhaaron at hotpop.com Fri Nov 23 04:25:26 2001 From: dhaaron at hotpop.com (Aaron Sterling) Date: Fri, 23 Nov 2001 09:25:26 GMT Subject: Could someone explain this multidimensional list behaviour? Message-ID: <1103_1006507526@t4q4p0> > >>> spam = [] > >>> for y in range(10): > inner = [] > for x in range(10): > inner.append(0) > spam.append(inner) > del inner > The second for loop should not be necessary. something like: spam = [] for y in range(n): spam.append([0] * n) should suffice for m X n matrices just do: spam = [] for y in range(m): spam.append([0] * n) Aaron Sterling, dhaaron at hotpop.com From mvonehr at web.de Wed Nov 28 11:48:43 2001 From: mvonehr at web.de (Markus) Date: 28 Nov 2001 08:48:43 -0800 Subject: writing to parallel port? Message-ID: <55881dd4.0111280848.3d2b38ab@posting.google.com> Hallo everybody, is it possible to write to the parallel printer port from Python? (win32 system) Thanks for any answer, Markus From shriek at gmx.co.uk Mon Nov 12 20:27:46 2001 From: shriek at gmx.co.uk (Stephen) Date: 12 Nov 2001 17:27:46 -0800 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> Message-ID: <97ae44ee.0111121727.2c023382@posting.google.com> cimarron+google at taylors.org (Cimarron Taylor) wrote in message news:<29e28c51.0111120234.35d10048 at posting.google.com>... > shriek at gmx.co.uk (Stephen) wrote in message news:<97ae44ee.0111111912.14006c7f at posting.google.com>... > > I'm developing a program which sends messages back and forth > > between two servers using sockets. The message format I've > > been given is "YYYYTTTTTTTTTTTTTTTTTTTTTTT" > > Why not save yourself a little coding and just use netstrings? > > more info: http://itamarst.org/multiplex > advogato copy: http://www.advogato.org/article/212.html > python code: http://itamarst.org/downloads/multiplex-0.2.tgz > description: http://cr.yp.to/proto/netstrings.txt Thanks for pointing this out. Is anybody actually using it though ? Would be a bit concerned with it being 0.2 release. I guess the main reason not to use netstrings is the ability to interface with other servers that don't have the netstrings package or the desire to install it. Sockets seem to be the lowest common denominator. I'll keep an eye on it though. Thanks. Stephen From sholden at holdenweb.com Tue Nov 6 07:18:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 6 Nov 2001 07:18:06 -0500 Subject: RE Module Question. References: Message-ID: "Adonis Vargas" wrote in ... > i am trying to fidn specific word within a string and am unable to > findanything suitable for it, i have tried looking into the RE module but it > just is written in hebrew, and can not grasp any of it. looked into the > python.org/howto's and under the library/module index and nothing i just > cant understand it. is there a simple example to this or simple explanation? > all i want to do is find i.e.: > > test = "this is a test" > if "test" in test: print "found string." > > this is just pseudocode to get the concept im trying to achieve. > > any help would greatly be appreciated. Adonis: For your problem the phrase "what's in a word?" is very relevant. One of the hardest things about any kind of lexical analysis is determining exactlky what comprises a word ("lexical token", more formally). However, from your example, it seems like you might be satisfied with everything between spaces in your input. For this purpose the easiest approach is probably to use the split() method to split the string into a list of "words", and then see whetehr your required target appears in the list. E.g.: >>> test = "this is a test" >>> wl = test.split() >>> wl ['this', 'is', 'a', 'test'] >>> if "is" in wl: ... print "Found 'is'" ... Found 'is' >>> Other posters have also made suggestions about using index(), but you would have to be careful there about ensuring that you found a word, and not just a part of a word. Now you can go on to start thinking about upper- and lower-case differences, apostrophes and all the other good stuff that makes string processing fun! regards Steve -- http://www.holdenweb.com/ From prabhu at aero.iitm.ernet.in Mon Nov 19 21:15:41 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 20 Nov 2001 07:45:41 +0530 Subject: Tkinter and IDE's In-Reply-To: <3BF9B512.A784475C@ccvcorp.com> References: <9t9qsb$4nd$1@slb3.atl.mindspring.net> <3BF9B512.A784475C@ccvcorp.com> Message-ID: <15353.48333.183756.139824@monster.linux.in> >>>>> "JS" == Jeff Shannon writes: JS> There are two problems with running Tkinter in most IDE's. JS> One is that Tk-based apps share the same event queue, so that JS> running a Tk app inside of another Tk app will confuse things. JS> The other is that different GUI toolkits almost never play JS> well together, so running a Tk app inside of a different GUI JS> kit's apps will confuse things. Actually, I've found that if you dont do a root.mainloop() in your application when you aren't running it as a standalone application (i.e. outside of an IDE/Interpreter) things run really well with Tkinter. For instance you can simply run the following from a Python interpreter shell or even from idle: import Tkinter r = Tkinter.Tk() def f(evt=None): print "foo" b = Tkinter.Button(r, text="test", command=f) b.pack() # click away on the button. prinf "hello world!" "hello world!" I've used this plenty of times and not with just 'toy apps' like the one above but with full fledged applications and even with VTK RenderWindows embedded in it etc. I've done this under Win32 (Idle/shell) and Linux and it has always worked. I have not tried this with PythonWin and have heard that this will not work with it. However, I do most of my work on Xemacs + an rxvt running a Python interpreter and that combination with a nice pythonstartup.py can be extremely productive. :) prabhu From brucehapman at hotmail.com Thu Nov 29 17:28:40 2001 From: brucehapman at hotmail.com (brucehapman at hotmail.com) Date: 29 Nov 2001 14:28:40 -0800 Subject: Python evangelists unite! Message-ID: Okay, I was extolling the benefits of Python to a friend of mine. He took strong exception to Python's OO model. ME: Python's great--you can add members to instances OR classes on-the-fly! FRIEND: Why would you want to do that? ME: Uh... FRIEND: Besides, that's awful Object Orientation. If I start adding attributes to an instance of a class, it ceases to be an instance of that class. If I create a bunch of instances of the same class, they should be the same; they should have the same members. ME: Yeah, but with dynamicism, I can add a new pane to a GUI while it's running. I just change an instance to include a new pane, and... FRIEND: That's pretty cool, but it's not a reason, in and of itself, to make a language so dynamic. There must be some advantage to being able to add attributes during runtime. What are they? ME: Uh... FRIEND: And another thing! What's with encapsulation? There's no private!?!?!? ME: So, I need some help. I've checked out c.l.p and some on-line articles, and I just can't find good practicle examples of a program that adds members to instances (or classes) at runtime. Anybody got any? I don't want to have to start avoiding my friend.... TIA, b. From gleki at gol.ge Tue Nov 6 19:31:57 2001 From: gleki at gol.ge (Giorgi Lekishvili) Date: Tue, 06 Nov 2001 16:31:57 -0800 Subject: old pyc with new py Message-ID: <3BE880FD.B604E77A@gol.ge> Hello! When I find an error i my scripts, and improve them, recompilation has no effect: ++++++++++++++ Traceback (innermost last): File "T:\tests\init.py", line 8, in ? d=PyPLS2DataSet(fi) File "D:\Python20\ChemoPyc\PyPLS2DataSet.py", line 20, in __init__ PyPLSDataSet.__init__(self, filename, 3, format) File "D:\Python20\ChemoPyc\PyPLSDataSet.py", line 11, in __init__ PyChemDataSet.__init__(self, filename, pr, format) File "D:\Python20\ChemoPyc\PyChemDataSet.py", line 42, in __init__ self.comment, self.Npred, self.Nobj, self.flags, self.ObjID, self.ObjNames, self.Mdata, self.headers=get_data(filename) File "D:\Python20\ChemoPyc\auxil.py", line 20, in get_data ObjID=None NameError: There is no variable named 'NONE' +++++++++++++++++++ as you see, the correct keyword is set(None instead of NONE), but python applies the old stuff. Note, that I delete the *.pyc and *.pyo files before invoking the sourcfiles like follows: from mylib import myfunc Thank you. Greetings, Giorgi From gh_pythonlist at gmx.de Sat Nov 3 18:09:32 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 4 Nov 2001 00:09:32 +0100 Subject: Freeware Python editor In-Reply-To: <3be2c653.1205904380@news> References: <3be2c653.1205904380@news> Message-ID: <20011104000929.A5082@lilith.hqd-internal> On Fri, Nov 02, 2001 at 04:14:55PM +0000, David C. Ullrich wrote: > On Wed, 31 Oct 2001 08:08:22 -0600, Kemp Randy-W18971 > wrote: > > >Check out the free Python editor at www.crimsoneditor.com. > > Not that it matters to me, but it seems like someone > should ask: What does it do that other free(?????????) > Python editors don't do? You're free to find that out yourself :-) >From a quick look at the features list I think the answer is probably "nothing", unless your other free Python editor is ed or Notepad. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From pj at sgi.com Tue Nov 27 19:11:35 2001 From: pj at sgi.com (Paul Jackson) Date: 28 Nov 2001 00:11:35 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: <9u1a3n$bmoj3$1@fido.engr.sgi.com> Marcin 'Qrczak' Kowalczyk wrote: > It's not a minority. Almost everybody uses this convention. It's > better to use the most common convention consistently than to invent > new conventions (like "tab = one indent level"). I agree. So what if tab stops every 8 columns is a silly convention that serves well none of the uses that Terry claims would justify tabs. What justifies tabs isn't these potential uses, but longstanding convention, albeit loosely followed. I'd encourage the purists to go tilt at windmills that are connected to something useful, like an electric generator or a water pump. Attempts to find purity in silly little tab conventions serve only to annoy the inmates and frustrate the purists. Meanwhile, from Parser/tokenizer.c: /* Don't ever change this -- it would break the portability of Python code */ #define TABSIZE 8 -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From mats at laplaza.org Mon Nov 26 17:02:35 2001 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 26 Nov 2001 22:02:35 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> Message-ID: <3c029caa.260513688@news.laplaza.org> On Sat, 24 Nov 2001 22:34:20 -0600, Skip Montanaro wrote: : : Manuel> I'm looking for an editor for Python.I' m interested it works on : Manuel> Windows.Can anybody help me? : :Check out : : http://www.python.org/editors/ : :for a list of stuff known at the moment. Thank you, Skip! And in future (forlorn hope), could we all resist jumping in with 50 or so conflicting opinions about editors and just point to the page, unless there's a VERY specific question. Mats Wichmann From mwh at python.net Mon Nov 26 07:15:34 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 26 Nov 2001 12:15:34 GMT Subject: Colored console on Windows References: <1712.011122@storm.ru> <9tjflj$j08$1@peabody.colorado.edu> <9tmmku$4e6$3@peabody.colorado.edu> Message-ID: Fernando P?rez writes: > Michael Hudson wrote: > > >> quick question: does your readline module handle multi-line edits? That is, > >> if I have a multi-line statement, does it bring it back as a single > >> editable entity (which would be great) or as the 'real' readline does, as a > >> series of single-line statements (clumsy). > > > > My pyrepl package > > > > http://starship.python.net/crew/mwh/hacks/pyrepl.html > > > > does that. It's unix only, and a bit rough around the edges. I have > > a new version sat on my irritatingly internet-disconnected home box > > which I'll release as soon as I remember to stick it on a floppy and > > bring it in to the department. Argh! Tomorrow, maybe. > I actually have your module in mind for a project of mine, but > haven't used it yet. Why is it unix-only, though? Because it uses lots & lots of termios stuff, to move the cursor around and such. It might work under cygwin, I guess. > My project is currently unix-only also but I'd like to offer MS > people readline-type support and was hoping that your module would > help in that respect. Well, I have an NT machine to play around on now. I think it ought to be possible to get the new version up and running using the effbot's Console library, as I've tried to factor out the platform dependent stuff (although I won't know if I've succeeded until I try it). Cheers, M. -- ZAPHOD: Listen three eyes, don't try to outwierd me, I get stranger things than you free with my breakfast cereal. -- The Hitch-Hikers Guide to the Galaxy, Episode 7 From montanaro at tttech.com Sun Nov 11 07:00:59 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Sun, 11 Nov 2001 13:00:59 +0100 Subject: Newbie: Using MySQL In-Reply-To: <200111110056.fAB0u0V02578@localhost.localdomain> References: <200111110056.fAB0u0V02578@localhost.localdomain> Message-ID: Jordan> I've tried using the MySQLdb module (I think) and I cannot Jordan> connect. I know that the server is running and that the Jordan> passwords are correct? Jordan> db = MySQLdb.Connect(host=db_host, user=db_user, passwd=db_passwd, db=db_db) Based upon what John Leach said, you might want to check for the "unix_socket" parameter. If PHP is using a unix socket but your Python program is running on another server, perhaps you mysqld is not even listening to a TCP socket. Can you successfully telnet to port 3306? -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From david at dataovation.com Thu Nov 1 18:59:36 2001 From: david at dataovation.com (David A McInnis) Date: Thu, 1 Nov 2001 15:59:36 -0800 Subject: email module Message-ID: I am looking for sample code using the new email module for Python 2.2. Does anyone have some sample code, I am newish to the world of Python. Also, I am looking for a phpbuilder.com equivilant for python. Does one exist? Thanks, David McInnis From emile at fenx.com Thu Nov 8 17:43:55 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 14:43:55 -0800 Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <9sf24f$126o9r$1@ID-11957.news.dfncis.de> wrote in message news:mailman.1005256814.9657.python-list at python.org... > > Now that the issue of transfinite cardinals has been fully resolved, isn't > it time for yet another unpopular-and-non-pythonic suggestion? I believe > it is. Are you going to suggest dropping the line ending colons? > > What if (in post-2.2) Python the tp_iter slot in the int type was defined > to return an xrange-like iterator such that one could do the following: > oh. ;-) > for i in 10: > doSomething(i) > Sounds good. -- Emile van Sebille emile at fenx.com --------- From timr at probo.com Mon Nov 19 01:56:40 2001 From: timr at probo.com (Tim Roberts) Date: Sun, 18 Nov 2001 22:56:40 -0800 Subject: Python & cgi on win98--tinyweb problems, etc References: <7x8zd7zfh8.fsf@ruckus.brouhaha.com> Message-ID: Chris Stromberger wrote: >> >>How about the HttpServer class that's already in the Python library? > >Hadn't thought of that. Do you mean CGIHTTPServer? The docs say >"Note: This module is Unix dependent since it creates the CGI process >using os.fork() and os.exec()." so that won't work for win98, unless >I'm missing something. The documentation is out of date. CGIHTTPServer checks to see if the system has fork, and if not, it does it another way. It works fine on Windows. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From katz at Glue.umd.edu Fri Nov 30 01:10:44 2001 From: katz at Glue.umd.edu (Roy Katz) Date: Fri, 30 Nov 2001 01:10:44 -0500 Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: References: <3bfd7f87@news.airtel.net> Message-ID: On Fri, 30 Nov 2001, Jonathan Gardner wrote: > Interesting... how does Python and veganism go together? Isn't veganism just > about taking care of the animals and your body? What does Python care about > the animals or your body? Well I feel that the common theme among all these ideas is control. I want more control than the average Joe over things like how I speak (Esperanto can be quite expressive), program (python), compute (GPL), and eat (that's why I'm vegan). Moreover, Python, Esperanto, GPL and Veganism (imho) are all particularly *effective* solutions to their respective problems. They're elegant, consistent and simple in philosophy. That's about it. That makes sense to me; and to paraphrase your words, I tend to "go with what works" for me :). I'll stop ranting now (otherwise, too many people start cracking vegetarian jokes and miss the point -- really, how long till someone here'll crack a joke... come on guys, don't keep me waiting, you know you're out there). > Python and Esperanto: Esperanto was invented for being a useful, simple > language that could be learned by almost any culture. Bingo > It tried to limit the > number of expressions for a single idea, making it difficult to express > things that may not be understood or misunderstood. Sorta-Bingo. I would phrase it like this: Esperanto tries to make it easier to express ideas which are hard to express in other languages. But there /are/ indeed different ways of expressing the same idea. And why should Python be any different?? Sure there is only one way to open a file (open()) and (up until recently, borkborkbork>>) one way to write to a file. BUT the fact that we can express a convolution integrals in a myriad of ways should be proof enough that even though syntax is singular, the expression of the idea is indeed plural. > Python. English and Perl (TMTOWTDI), and Esperanto and Python. oh definately, I agree 100% on that. > They'd have to be. I can't seem to find a place to get paid to work in Python > yet. I can't imagine a guy with 3 kids trying to make a living by programming > python unless he is the rare guy that has a job in it. hey, Google offers jobs for Python programmers on Linux workstations.. :) > Reminds me of the Perl community at first. They were all young, once. Young > rebels, challenging the C/awk/sed paradigm. Young rebels, willing to write a > bit of glue code in a young language developed by a young sysadmin... > > Now some of them look like they are advancing in years, and the Perl > community is almost as mainstream as it gets in programming fads. well they got lax imho. Two many bolted on features, just like Python a year from now if everyone and their dog has their way (borkborkbork>>). Roey. obnoxious Computer Engineering junior University of Maryland @ College Park, USA. From lac at strakt.com Wed Nov 28 10:24:07 2001 From: lac at strakt.com (Laura Creighton) Date: Wed, 28 Nov 2001 16:24:07 +0100 Subject: Background python thread for Pmw based GUI In-Reply-To: Message from tsshivaprasad@yahoo.com of "Wed, 28 Nov 2001 04:32:36 GMT." <9u1pd4+ioo3@eGroups.com> References: <9u1pd4+ioo3@eGroups.com> Message-ID: <200111281524.fASFO7ua006725@ratthing-b246.strakt.com> > Dear Friends, > > Hi I am new to Python programming. I would be grateful if any of > you could manage to send me a complete sample code in which a > Background python thread keeps checking some activity and display the > updates in Pmw based or Tkinter based GUI.. You may be interested in http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 Here the Tkinter Gui polls every 100 ms to see if there is something in a queue. More complicated solutions are possible, this one is very simple. Laura Creighton From emile at fenx.com Sat Nov 3 15:07:13 2001 From: emile at fenx.com (Emile van Sebille) Date: Sat, 3 Nov 2001 12:07:13 -0800 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <3be33e4e.31678681@127.0.0.1> <3be7390b.3387240@127.0.0.1> Message-ID: <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> "Fish" wrote in message news:3be7390b.3387240 at 127.0.0.1... > On Sat, 3 Nov 2001 14:08:42 +0300, Oleg Broytmann wrote: > > >On Sat, Nov 03, 2001 at 12:44:13AM +0000, Fish wrote: > >> Oleg, kindly go away. You do *nothing* to improve this newsgroup when you > > > > Boy, you are attacking me for the second time. And you are doing this > >hiding your identity under the name "Fish" and email "root at 127.0.0.1", no > >signature. You are doing like a coward. When challenging people - do it with > >open face. Otherwise shut up and go away. I am witing for you to open your > >identity or your apologies. > > And you're using a false identity and a spoofed EMail address. You're > actually "Twinky Bingham," of Pisswater, Kansas. > > Which makes you both a coward and an idiot. > Fish, Get out in front of the rock you're hiding behind or crawl back under it. -- Emile van Sebille emile at fenx.com --------- From phr-n2001d at nightsong.com Mon Nov 5 17:20:31 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 14:20:31 -0800 Subject: Converting exponential numbers to strings. References: <32921e0b.0111051350.41e35f26@posting.google.com> Message-ID: <7xpu6w6es0.fsf@ruckus.brouhaha.com> steveb at nebcoinc.com (Steve) writes: > Hi, > I'm new to python and I'm trying to write a routine to determine > whether or not an object is numeric like so: How about this: try: x = float(s) result = 1 except: result = 0 From __x__ll at yahoo.com Sun Nov 25 15:30:55 2001 From: __x__ll at yahoo.com (Fred Flintsone) Date: Sun, 25 Nov 2001 20:30:55 GMT Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> Message-ID: <3c015433.778200@news> On Sun, 25 Nov 2001 20:19:46 GMT, Power-Tech >knows about a good tutorial online for someone in my situation? >Is this group too advanced for me? >I appreciate your attention >Willie Hey, Willie...I hope this group isn't too advanced for you, because I just joined an hour ago and I'm as green as they come. I first did the 2.1.1 version, but uninstalled and went for the Active version. I noticed right away that the work screen is Windows-oriented rather than the DOS-type screen I had with 2.1.1 I just bought the "Learning Python" O'Reilly book and it recommended the www.python.org page for all kinds of reference materials. Someone in this group also recommended to me http://diveintopython.org/ but the subtitle "For Experienced Programmers" has me trembling. Hope I helped. FF Please post any responses to this to this newsgroup. From slinkp23 at yahoo.com Mon Nov 12 12:08:17 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Mon, 12 Nov 2001 17:08:17 GMT Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: On Mon, 12 Nov 2001 17:02:38 +0100, Laura Creighton wrote: (snip) >I have a new problem. I've just lost a major amount of precision in my >language usage. What is the collective noun for 'attributes that aren't >methods (you can't call them)'? Good question! Makes me realize that I have no specific word in my mind for that. Data attributes? Non-callables? Yuck. Must be something better. --PW From peter at engcorp.com Tue Nov 13 09:41:31 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 13 Nov 2001 09:41:31 -0500 Subject: Request for Validation of Python as Development Language References: Message-ID: <3BF1311B.89916FA@engcorp.com> "A. Keyton Weissinger" wrote: > > I'm pretty new to the language and I'd like to use it for more stuff at > work. I'm beginning to feel some of the stigma of it being a "scripting > language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for > those who care) and I'd like to introduce Python into the mix. But I say > "scripting language" and people head to the hills yelling "PERL!" which is a > bit disconcerting (especially since I like Perl too, though not as much as > Python). They need to hear "object oriented application development > language" or I need to buck up and realize I'm barking up the wrong tree. We use Python for writing our largest, most complex applications, which run in embedded PC104 modules in industrial controller products. We also use it (via Zope) for a web interface to the equipment in the field (web front end, Python back end to the embedded stuff). We use it for GUI-based utilities which are used in production during calibration and testing of the equipment (Tkinter and wxPython). We use it (with XML) for processing the test results and printing them as PDF files. We use it for a variety of GUI and command-line utilities which would otherwise have been coded in C or some such, traditionally. Oh yeah, we write a few "scripts" with it too. It helps us avoid the unmaintainable and expensive mess of Perl scripts... Worried about the rubrik "scripting language"? Don't be. Get over it. Python is by no means "just" a scripting language, and after all, what's in a name? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From sabren at manifestation.com Thu Nov 22 17:14:11 2001 From: sabren at manifestation.com (Michal Wallace) Date: Thu, 22 Nov 2001 17:14:11 -0500 (EST) Subject: Web hosts and Python 2.1 In-Reply-To: <20011122.082840.1253263156.7318@localhost.localdomain> Message-ID: On Thu, 22 Nov 2001, Harold Shore wrote: > So my question is: does anyone on this group know of a > North American web host who offers an up-to-date python > package? I've got 2.0 installed, and I'm more than happy to upgrade. http://www.cornerhost.com/ I've also got mod_python.... :) Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From tim at vegeta.ath.cx Mon Nov 26 23:14:38 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Nov 2001 04:14:38 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3c029caa.260513688@news.laplaza.org> Message-ID: Skip Montanaro graced us by uttering: [ snip ] > Well, if you have a fast internet connection, you can install Emacs, which > has a vi emulation mode, so you really only need one editor. ;-) > > from-someone-who-struggled-with-vi-for-a-couple-hours-today-ly, y'rs, I'm a vi man myself. I've made great strides recently in compiling vim (my fave clone) with a python interpreter (ie, I can script Vim with Python), as well as several other aspects. I've learned, however, never to dog on Emacs in this ng. Emacs appears to be very widely used among some Pythonistas, and I'm in the penalty box as it is being a double agent (Python _and_ Perl!). Besides, all I'd really need to run Emacs is 10 fingers...per hand. =) Tim Hammerquist -- Hackers who anthropomorphize are expressing not a vitalistic view of a program behavior but a mechanistic view of human behavior. -- Jargon File 4.3.1 From pobrien at orbtech.com Tue Nov 27 16:57:47 2001 From: pobrien at orbtech.com (Patrick K. O'Brien) Date: Tue, 27 Nov 2001 21:57:47 GMT Subject: Python Persistant Object Shell References: Message-ID: PyCrust does some of what you want - in particular, the first two items in your list. http://sourceforge.net/projects/pycrust/ -- Patrick K. O'Brien Orbtech.com - Your Source For Python Development Services "Lucio Torre" wrote in message news:mailman.1006462649.22406.python-list at python.org... > Hello, > > I want to write an aplication that is a python shell plus: > + a visible tree of the namespace > + everything is persistant > + a visual object inspector > + remote access > + multi user permissions > [snip] > > any ideas? comments? similar proyects you know of? something to add to > this loose description? questions? > > thanks in advance. > > lucio. > > > From nhodgson at bigpond.net.au Mon Nov 12 17:08:51 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Mon, 12 Nov 2001 22:08:51 GMT Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: Wolfgang Strobl: > >>> Traceback (most recent call last): > File "H:\Python21\Pythonwin\pywin\framework\intpyapp.py", line 349, > in OnFileRun > dirOfScript, starter) > TypeError: CreateProcess() takes exactly 9 arguments (7 given) But there are 9 arguments (as there are 8 commas): win32process.CreateProcess(sys.exec_prefix + "\\python.exe", "python -i " + pathToRun, None, None, 0, win32process.CREATE_NEW_CONSOLE, None, dirOfScript, starter) Maybe there was some line-end failure in transit - try adding \ at the end of the lines to force it all on one logical line. Neil From johnroth at ameritech.net Fri Nov 9 18:02:37 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 9 Nov 2001 15:02:37 -0800 Subject: Teaching python (programming) to children References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> Message-ID: "Michael Hudson" wrote in message news:u4ro4nddv.fsf at python.net... > Laura Creighton writes: > > > Paul Rubin writes: > > > I think a big goal of the Mindstorms crowd is teaching the concept of > > > debugging. Most skills are taught with the idea that you master > > > something by learning it well enough to do it perfectly, so if you > > > make a mistake at it you haven't learned the skill yet. Teaching > > > programming to young kids is supposed to develop the cognitive skill > > > of diagnosing and correcting errors. That's more fundamental than > > > "applications" like cataloging mp3's or even understanding math > > > concepts. > > > > In the same vein, if any of you out there are writing (or revising) > > 'how to program in Python' books or papers, could you please put > > the section on exception handling _early_, say, right after 'what > > is a loop', rather than in the last chapter? > > That's what my tech review for one such said over the summer :) This > may have been too late, of course. > > But Laura is right here. Very very right. Then possibly the decision to make exceptions classes was wrong from a tutorial veiwpoint? Technically, it was the right decision, but it does shove exception handling rather late, after classes have been introduced. John Roth From dcinege at psychosis.com Sun Nov 25 19:35:25 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Sun, 25 Nov 2001 19:35:25 -0500 Subject: 11-15 new Python Books on the way! In-Reply-To: <3C017B53.EE277644@earthlink.net> References: <3C017B53.EE277644@earthlink.net> Message-ID: On Sunday 25 November 2001 18:08, Ron Stephens wrote: > A few days ago I posted book reviews on the 15 Python books I have read. > Embarrassed by having read so many, and wondering how close I was to > "completion", I decided to do some research and see how many total > Python books were out there and how many more were soon to be published. > I have now chronicled all I could find on my website. > > There are fully 11 new Python books I found, three at book stores, which > another 8 more coming almost immediately! These new books include a > Deitel and Deitel, two Python/web books, a text processing book, two XML > books, and a lot more. That makes 15 + 11 = 26. Great, as quality books have been lacking for a long time now. I just picked up Python 2.1 Bible (Brueck/Tanner) and was over joyed to have finally gotten a 'good one'. I already have used much from it. IMO this book is a must have. -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From phd at phd.pp.ru Sun Nov 18 15:39:01 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sun, 18 Nov 2001 23:39:01 +0300 Subject: Scripting for both object and non-object In-Reply-To: <9t94ss$3st$1@samba.rahul.net>; from eosn@rahul.net on Sun, Nov 18, 2001 at 08:15:24PM +0000 References: <9t94ss$3st$1@samba.rahul.net> Message-ID: <20011118233901.A20129@phd.pp.ru> Hello! Python (www.python.org) is a great programming lnguage! It is object oriented, but the OO is not enforced, and wht is more, it includes elements of functional programming, so you can choose apropriate style - OO, plain structured programming or FP. On Sun, Nov 18, 2001 at 08:15:24PM +0000, Ed Ohsone wrote: > I would like to know names of general purpose scripting languages which > are capable of going both object and non-object oriented. > > I know tcl is one of that kind. > If you know any others, please let me know URL of their home pages. > The reason I am asking this question is we want to select > a language which best suits our future projects. > One of their requirements is freedom from object-oriented shackles. > Object-oriented design is a great idea but we are going to waters > where it can be impediments. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From nas at python.ca Thu Nov 8 14:18:46 2001 From: nas at python.ca (Neil Schemenauer) Date: Thu, 8 Nov 2001 11:18:46 -0800 Subject: GC question In-Reply-To: <8891.011108@storm.ru>; from warkid@storm.ru on Thu, Nov 08, 2001 at 09:24:26PM +0300 References: <8891.011108@storm.ru> Message-ID: <20011108111846.A12007@glacier.arctrix.com> Kerim Borchaev wrote: > can someone, please, explain what does it mean and why it happens? The DEBUG_LEAK setting sets DEBUG_SAVEALL. That means that all objects in unreachable cycles are added to gc.garbage. If nested scopes are used reference cycles can easily be created (they are in your program). Other than the fact that DEBUG_LEAK is badly named if you enable nested scopes, is there a problem? What are you trying to achieve? Neil From MarkH at ActiveState.com Thu Nov 1 06:31:17 2001 From: MarkH at ActiveState.com (Mark Hammond) Date: Thu, 01 Nov 2001 11:31:17 GMT Subject: Python extension modules References: <7fd99f9.0110311606.7e0a5836@posting.google.com> Message-ID: <3BE132BE.3030305@ActiveState.com> [posted and mailed] emdpek wrote: > I need Python objects to contain and "represent" native C > structs. Is there a way to do this *without* defining a new > type? Check out the struct module. It allows you to pack and unpack "blobs" of data (usually in a string), given a format string. So one approach would be to define a Python class in a .py file, that wraps up the struct module. import struct class Foo: def __init__(self, int1=0, int2=0): self.int1=int1 self.int2=int2 def __getattr__(self, attr): if attr=="_value_": return struct.pack("ii", self.int1, self.int2) raise AttributeError, "%r.%s" % (self, attr) f=Foo(int2=1) f.int1=255 print "Data is", repr(f._value_) -- Yields: Data is '\xff\x00\x00\x00\x01\x00\x00\x00' Your extension module could create instances of this class to return to callers. Something like: (error checking omitted, but _do_ add it :) { ... CSTRUCT cs; PyObject *mod = PyImport_ImportModule("foo"); PyObject *cls = PyObject_GetAttrString(mod, "Foo"); PyObject *args = Py_BuildValue(cs.int1, cs.int2); PyObject *instance = PyEval_CallObject(cls, args); Py_DECREF(args); Py_DECREF(cls); // instance is a new object ready to return, with a new reference } It could accept class instances as params - use something like: { ... PyObject *inst, *str; CSTRUCT cs; PyArg_ParseTuple("O", &inst); str=PyObject_GetAttrString(inst, "_value_"); if (!PyString_Check(str)) ... if (PyString_Length(str)!= sizeof(cs)) // eek... memcpy(&cs, PyString_AsString(str), sizeof(cs)); Py_DECREF(str); ... } The other alternative, as you discovered, is what you outline below: > Question about defining a new type, then. Functions > (package-scoped functions not tied to a class) are declared > via the PyMethodDef array, right? So, this is where an > instance constructor might go? [snip lots of stuff that looked correct, but I really didn't look too hard] > static PyObject* > MyNew_getattr(MyNew *self, char *name) You should use Python declarations exactly - use "PyObject" instead of "MyNew". MyNew may fail in some C++ scenarios. > { > return Py_FindMethod(MyNew_methods, (PyObject *)self, name); > } > > > So, now you can: "rv = instance.method()" Yep. You can also add simple checks to getattr to make it look more like a struct: static PyObject* MyNew_getattr(PyObject *self, char *name) { if (strcmp(name, "int1")==0) return PyInt_FromLong( ((MyNew *)self)->pcs->int1); else if ... // try methods last. return Py_FindMethod(MyNew_methods, (PyObject *)self, name); } > Is this (use of "getattr" method, which calls Py_FindMethod) > the accepted convention? > > Am I on the right track? Thanks in advance... Yep :) > P.S. There is perhaps a train-of-thought missing from the > Extending tutorial that I lost hair figuring out this > morning. I would be more than happy to offer possible > improvements, if there is interest... Sure is! If submit patches to the documentation to the source-forge patch manager, you would be loved by many :) Mark. From talon at www.tempestnetworks.net Fri Nov 30 09:28:07 2001 From: talon at www.tempestnetworks.net (talon at www.tempestnetworks.net) Date: Fri, 30 Nov 2001 14:28:07 GMT Subject: xmlrpc tutorial? References: <3C063569.8230ADD0@snakefarm.org> <3C07961D.9A7970FA@snakefarm.org> Message-ID: On Fri, 30 Nov 2001 15:22:21 +0100, Carsten Gaebler wrote: >Dave Butler wrote: > >> http://www.onlamp.com/pub/a/python/2000/11/22/xmlrpcclient.html > >Thanks for the link. The corresponding server documentation is exactly >what I was looking for: >http://www.onlamp.com/pub/a/python/2001/01/17/xmlrpcserver.html > >However, there seems to be a problem with restarting the server. I >have to wait a minute or so to avoid an 'address is already in use' >error. I vaguely remember this has been addressed in the past on >c.l.py. Is there any solution? > >cg. >-- >For dealing with Matrix you need something more powerful than Python. >Otherwise ... Matrix has you! -- scenes from comp.lang.python Use the setsockopt function on the socket objet, pass it the value SO_REUSEADDR (defined in the socket module). HTH, Steve -- -- Visits always give pleasure: if not on arrival, then on the departure. -- Edouard Le Berquier, "Pensees des Autres" From com-nospam at ccraig.org Thu Nov 1 09:03:57 2001 From: com-nospam at ccraig.org (Christopher A. Craig) Date: 01 Nov 2001 09:03:57 -0500 Subject: Future division detection Message-ID: I am in the process of porting my cRat module to take advantage of some of the new features in Python 2.2 (and possibly making a patch out of it to address PEP239 (though not for Python 2.2 obviously)). While doing this I was thinking that I would change true_division on ints and floats to return a rational and change the rational code to return a long if the denominator is 1. This works great, except that if future division is off then rationals can suddenly become longs and do not automatically cast back. This makes it virtually impossible to guarantee a correct result to nearly any rational computation that involves a division. So I wanted to know if there is some way to detect, at the object level, if the CO_FUTURE_DIVISION feature is active. rational'ly y'rs -- Christopher A. Craig From skip at pobox.com Wed Nov 14 04:28:57 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 10:28:57 +0100 Subject: DNS, DB server based on Python? In-Reply-To: <20011114164611.A18129@jupiter.senux.com> References: <20011114164611.A18129@jupiter.senux.com> Message-ID: <15346.14681.841216.146246@beluga.mojam.com> Brian> I'm looking for DNS and DB server based on Python language. I Brian> use bind version 9 and mysql 3.24 on Linux but want to change Brian> other server which is coded by Python language. I don't know about DNS, but you should check into Gadfly as a Python-only database server. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From garrett at bgb.cc Mon Nov 5 16:14:34 2001 From: garrett at bgb.cc (Don Garrett) Date: Mon, 05 Nov 2001 21:14:34 GMT Subject: Library wish: rchown and rchmod References: <9p69ni$e0m$1@neon.noos.net> Message-ID: <3BE70137.14C586E0@bgb.cc> I've had to do things like this several times, but I always need to have some extra's thrown in, such as wanting directories to have the set-gid mask set, but not files, etc. I have never come up with a one-size fits all utility for managing this, but the os.path.walk seems to work well for me. I have to admit that realizing that the single argument it will pass along to the visitor function could be list with an arbitrary number of values was very useful. In fact, it was something of a Python epiphany about how to solve a long standing problem I've had with separating traversal and visitor code (and other similar problems). If only that trick worked in C++. ;> Gerhard H?ring wrote: > > On Sun, Sep 30, 2001 at 07:10:57AM +0200, Boyd Roberts wrote: > > "Gabriel Ambuehl" a ?crit: > > > rchown and rchmod (recursive chown and recursive chmod) (I don't care > > > for the name but only for the functionality ;-). > > > > i'd suggest something like ftw(3) and call 'em with that. > > We already have os.path.walk. Though I'm anything but happy with this > interface. I normally build my recursive tree walking myself. > > Other than that, I'd find the originally proposed functions useful. > That's something I often need on the shell. > > Gerhard > -- > mail: gerhard bigfoot de registered Linux user #64239 > web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 > public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 > reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) > > ------------------------------------------------------------------------------ > Part 1.2Type: application/pgp-signature -- Don Garrett http://www.bgb-consulting.com/garrett/ BGB Consulting dgarrett at acm.org From kragen at canonical.org Sat Nov 24 01:31:26 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 24 Nov 2001 01:31:26 -0500 Subject: Python Persistant Object Shell References: Message-ID: <83lmgwvfwh.fsf@panacea.canonical.org> Lucio Torre writes: > I want to write [a really cool application]... > it has something of excel and access also. something of self would be nice. > > any ideas? comments? similar proyects you know of? something to add to > this loose description? questions? I hope you write it -- I'd love to try it out! I'm not familiar with any familiar projects. Good luck! From db3l at fitlinxx.com Wed Nov 21 14:43:53 2001 From: db3l at fitlinxx.com (David Bolen) Date: 21 Nov 2001 14:43:53 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFB34A9.565BBF2E@engcorp.com> <20011121000734.48b85dde.sthiyaga@operamail.com> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: Jeff Shannon writes: > Dave Cinege wrote: > > > Rule of God: > > The punishment for non-tab based indentation is death. > > This is exactly backwards. > > Tabs are wrong, because different editors will treat them differently. > > Spaces are right, because a space is a space is a space, everywhere you > go. What Jeff said :-) It's also useful to note that regardless of how you may choose to display them, the Python parser is defined in the language reference (section 2.1.7) to treat a hard tab as if it were an indentation to the next multiple of 8 column. So it's not treated as a fixed number of spaces but moving to one of a fixed number of column positions. Thus having an environment that displays hard tabs with some other form of indentation risks looking different than the parser will see the code, albeit its typically an innocuous error as long as everything is kept consistent and only tabs are used. Pure space based indentation (preferably at multiples of 4 columns by convention) is best and least likely to cause problems during exchanges. Pure tab based indentation (preferably where a tab moves to a multiple of 8 columns, but the parser would work with anything consistent) is less preferable, and mixed tabs and spaces are evil and just asking for trouble :-) -- -- 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 grzegorz at ugrad.cs.ualberta.ca Mon Nov 5 08:29:30 2001 From: grzegorz at ugrad.cs.ualberta.ca (Grzegorz Dostatni) Date: Mon, 5 Nov 2001 06:29:30 -0700 Subject: Process intercommunication In-Reply-To: References: Message-ID: For interprocess communications You have a couple of options. If A can start B at a proper time You could solve Your problem with pipes. (using popen I believe). If B is started differently, You could look into signals to catch A's attention. The easisest thing though it so make A a server and make B connect on a given port. An example of a server and a client is at: http://www.python.org/doc/current/lib/socket-example.html It is quite possible to have a client and a server on the same machine. If You're not going to have more than 10 processes trying to access Your server (at a time) I'd recommend using the threading module to make things a bit easier on Yourself. (watch out for mutual exclusion though ;-) ). A reading list (assuming You'd like to go with sockets) http://www.python.org/doc/current/lib/module-socket.html (socket module) http://www.python.org/doc/current/lib/module-thread.html (thread module) http://www.python.org/doc/current/lib/module-threading.html (threading module) The last one is a higher level version of the second one. Hope this helps. Greg From boud at rempt.xs4all.nl Thu Nov 15 14:07:15 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 15 Nov 2001 19:07:15 GMT Subject: GUI toolkit References: Message-ID: <9t13p3$1v9$1@news1.xs4all.nl> Cary Coulter wrote: > While I've learned a lot of Python in the last year, all my scripts > have run from the command line or as CGI programs. I'm very happy > with it all. > I am interested in developing gui wrappers for a couple of my command > line scripts to make them easier to use, especially under Windows. I > don't have any experience with the gui toolkits yet. I'm looking for > some hints on the pros/cons to help make a good choice. I'm really > looking at just learning one of them. > I have looked at the demos for wxPython. Have to say I like what I > see, but I haven't tried to develop anything yet. > Platforms would be Linux (primary), Windows, and AIX (didn't see any > prebuilt code for wxPython). Regulars to this newsgroup won't be surprised to hear me chiming in :-). You should be able to use PyQt on all these platforms - but you will have to build Qt and PyQt yourself of AIX. Qt includes a great designer module, which generates XML that can be used to generate Python. And PyQt is very well documented... I've just finished writing and editing a book on the subject - it should be going to the printer any day now, but you can read a previous version (which strangely enough doesn't include the screenshots) at http://stage.linuxports.com/projects/pyqt/. As soon as the book is in printing, Opendocs will be setting up a webforum where all the sample code be downloaded. -- Boudewijn Rempt | http://www.valdyas.org From logiplexsoftware at earthlink.net Wed Nov 7 14:50:07 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 7 Nov 2001 11:50:07 -0800 Subject: Focus problem In-Reply-To: <9sb4bj$smv$1@sunce.iskon.hr> References: <9sb4bj$smv$1@sunce.iskon.hr> Message-ID: <01110711500700.21497@logiplex1.logiplex.net> On Wednesday 07 November 2001 03:05, Danijel wrote: > Is there a way to track focus change on window/control? I can't find that. > ...and second question: > > How can I create "user defined" events? (possibly one of solution of my > problem)... wxPython, Tkinter... PyQt... what are you using? -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From kdahlhaus at yahoo.com Tue Nov 20 08:21:11 2001 From: kdahlhaus at yahoo.com (Kevin Dahlhausen) Date: 20 Nov 2001 05:21:11 -0800 Subject: Free Python Server References: Message-ID: <283adf56.0111200521.66b2e538@posting.google.com> Skip Montanaro wrote in message > I hate to play the devil's advocate here, but if they don't charge for their > web hosting and don't put up ads, how are they supposed to make the money > necessary to keep offering their services to you? Oh, right, they take your > personal info and sell it to direct marketing folks. Agreed. (Although I did have a free account at twu for awhile until too many goofballs abused the administrator). So let's rephrase the question: "What is your favorite low-cost, low-frills web hosting that provides access to Python for CGI scripting? Bonus points for long-running Python processes." From jf.richard at videotron.ca Wed Nov 21 23:16:12 2001 From: jf.richard at videotron.ca (Jean-Francois Richard) Date: 21 Nov 2001 20:16:12 -0800 Subject: Memory leak in my extention Message-ID: <8c39194f.0111212016.33844aa6@posting.google.com> I am trying to export a c function that build a tuple and return it to python, everything is working perfectly except that it leak like hell :( It is the first time I write a python extention and I can not seem to find the method to do it right! Here is a code snippet: int minx, miny, minz, maxx, maxy, maxz; Font->BBox(text.c_str(), minx, miny, minz, maxx, maxy, maxz); PyObject* result = Py_BuildValue("((iii) (iii))", minx, miny, minz, maxx, maxy, maxz); return result; What have I forgotten?? From stephen at stephencox.org Fri Nov 23 11:01:01 2001 From: stephen at stephencox.org (stephen cox) Date: Fri, 23 Nov 2001 16:01:01 GMT Subject: Newbie question Message-ID: <1puL7.12600$MI2.1847665@typhoon.jacksonville.mediaone.net> I just started with Python. Have some basic questions. For work, I wanna develop some data entry screens for our sql server - so I assume there's a database library out there that gives me functions to connect to a sql server? Also, for the web, does Python run as a CGI with II5 or is there some dll that hooks into IIS5? Last question, does Zope need the zserver? I keep reading that it can run on any server but, I haven't found anything that tells me how to run it with IIS. Is it just a matter of running Python? -- Stephen Cox web.net geek for non-profits, political campaigns, and a few socially conscious businesses. stephen at stephencox.org From dale at riverhall.NOTHANKS.co.uk Wed Nov 21 06:03:52 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Wed, 21 Nov 2001 11:03:52 +0000 Subject: String formatting char References: Message-ID: Martin von Loewis wrote: >Dale Strickland-Clark writes: > >> Is there some way to alter the format escape character from % to >> something else? > >Sure. > >def format_with_tilde(msg, args): > assert msg.find('\200') == -1 > msg = msg.replace('%','\200').replace('~','%') > msg = msg % args > return msg.replace('%','~').replace('\200','%') > >print format_with_tilde("~d is ~f% of ~d",(3,3.0/8,8)) > >Regards, >Martin Yeah. I thought of that, too. But it's an awful cludge and much slower than being able to use an alternative character directly. -- Dale Strickland-Clark Riverhall Systems Ltd From skip at pobox.com Fri Nov 16 11:44:49 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 17:44:49 +0100 Subject: Am I a troll? Split personality? In-Reply-To: <3bf53f5f@207.229.64.20> References: <9t1ii2$es0$1@peabody.colorado.edu> <3BF48BA4.D03A627C@engcorp.com> <3bf53f5f@207.229.64.20> Message-ID: <15349.17025.805879.929005@beluga.mojam.com> Peter> I use Outlook express. I was using a news account to post the Peter> messages. I have multiple mail accounts, one using my web Peter> "handle". When I post to the news account, there is no "from" Peter> input box, and I never know from which mail account the post will Peter> come from. I can't figure out how to specify from whom the Peter> message is being sent. I am new to windows, if anyone knows the Peter> answer I'd appreciate help. Well, when someone admits to using Windows and having trouble, they often get "switch to Linux or MacOS or ". ;-) If you register at Google, you can post there. (Registration is just so they have some confidence you aren't registering with a completely bogus email address.) When I don't have mailing list access for one reason or another or need to post the odd message to a Usenet newsgroup, I find that works fine. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From peter at engcorp.com Thu Nov 15 00:28:22 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 15 Nov 2001 00:28:22 -0500 Subject: anonymous functions,classes? References: <3bf2a42f$1@207.229.64.20> Message-ID: <3BF35276.AA0E5961@engcorp.com> Peter Bismuti wrote: > > Anonymous was the word I was looking for in my previous post. I want to > pass a function as an argument but don't want to have to define it globally. > The way I don't want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) Although I can't think why you would want to do this, technically the following ends up with roughly the same effect: def foo(): pass callFunction(foo) del foo At least, by the time the del executes, the situation looks the same as it does after your version, except for the temporary use of the name foo... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From aaldv97 at student.remove-this-part.vxu.se Wed Nov 7 12:07:36 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Wed, 7 Nov 2001 18:07:36 +0100 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> Message-ID: <9sbpr1$c4f$1@news.lth.se> Java, C and C++ got there after a while, but they where not to begin with. Ada was well documented and with lots of RFC before the actually implementation of Ada83. Considering that it took 7 years of design before the next version of Ada to be finnished, it started in '88. I might be wrong, but I'm not aware of a language that was publicly designed for years before its first implementation, if you know something I don't, please enlighten me. Yes, most languages are designed, but not from start to finnish, more like version 1.0 and forward, that is not _what I call design_, maybe because I'm schooled in software architectures, I don't know. Maybe we have different opinions of design, I think of design as in architectural design. From logiplexsoftware at earthlink.net Mon Nov 12 18:35:27 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 12 Nov 2001 15:35:27 -0800 Subject: OT: Mobile Internet Toolkit EULA (was: IsPython really O-O?) In-Reply-To: References: <9sph0u$gj7$02$1@news.t-online.com> Message-ID: <01111215352702.01958@logiplex1.logiplex.net> On Monday 12 November 2001 15:24, Rainer Deyke wrote: > > It makes perfect sense to me. BSD licensed code plays along nicely with > closed source. The GPL, on the other hand, is designed to give open source > developers a competitive advantage over closed source developers, with the > ultimate goal of forcing closed source developers out of business. > On the plus side, this may end the debate over BSD vs GPL vs Python license vs whatever: if Microsoft says the BSD license is okay, it must not be . -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From fperez528 at yahoo.com Mon Nov 26 07:30:51 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 11:58:51 +2328 Subject: Integer Overflow References: <9u0jor$2li$1@peabody.colorado.edu> Message-ID: <9u0nqs$5kc$1@peabody.colorado.edu> Ursus Horibilis wrote: >> If it's just an academic >> algorithm exercise > > It's not. Such computations are routinely used in algorithms > like PRNG's and cryptography. > Ok. Then, I suspect you'll end up writing it in C. I took a quick look at Numeric's randomarray module, and it's basically a python wrapper around a C module, ranlib. >> Out of curiosity, though: I've never written a rng myself. In > C, an integer >> overflow silently goes to 0. > > No. In C, an integer overflow silently throws away the > high-order bits, leaving the low-order bits just as they would > be if you had a larger field. As an illustration, assume we > are working with 8-bit integers instead of 32-bit. Then here's > what happens with integer overflows: > Right. I haven't written C in a while, and I typically do floating point stuff. Thanks for the reminder. > The algorithm relys on the ability to ignore the fact that > overflow has occurred and continue with the computation using > the low-order bits. This is not my algorithm; it's as old as > computer science, and then some. Well, unfortunately it does seem like Python's builtin handling of ints just precludes this. The alternative would be to operate with longs and mask off 2^32, but again speed goes out the window. > > Here is how we implement one particular 32-bit Linear > Congruential Pseudo Random Number Generator in C: > > unsigned int Lcprng(unsigned int *seed) > { > *seed = 29 * (*seed) + 13; > return (*seed); > } > > How do you do this in Python? Dunno. From what I can tell, you can't explicitly. On the other hand, wrapping simple C functions for use from python is *very* easy. Take a look at SWIG for details. Cheers, f From warkid at storm.ru Thu Nov 22 09:05:46 2001 From: warkid at storm.ru (Kerim Borchaev) Date: Thu, 22 Nov 2001 17:05:46 +0300 Subject: Colored console on Windows Message-ID: <1712.011122@storm.ru> Hello! They say python can't output colored text to Windows console? Are they right? Best regards, Kerim mailto:warkid at storm.ru From loewis at informatik.hu-berlin.de Tue Nov 13 05:02:37 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 13 Nov 2001 11:02:37 +0100 Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> <9sp10u$h36$1@slb0.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > Python calls them "members". > > http://www.python.org/doc/current/lib/specialattrs.html#l2h-113 In the same context, it also calls them "data attributes". This is what I normally use. Regards, Martin From dalke at dalkescientific.com Tue Nov 13 13:59:00 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 11:59:00 -0700 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> Message-ID: <9srqem$vt2$1@slb0.atl.mindspring.net> Adam Spitz wrote a bunch, including: >First example that comes >to mind: adding methods to an existing class. In Smalltalk, I'd just >browse over to that class and add the method. In Ruby, I'd just write: > >class MyClass > def newMethod() > print "new method" > end >end [in Python] >def MyClass_newMethod(self): > print "new method" >MyClass.newMethod = MyClass_newMethod I've been toying around with proposing def MyClass.newMethod(self): print "new method" but I've never really needed it. Better I think would be if Python's IDE's offered a reload() which was closer to Smalltalks's, where a modified class definition propagates even to existing instances of that class. So someone could edit a module and manipulate things interactively without having to reload and rerun everything. > In Python, it feels like I'm sneakily hacking an >extra method into a class against its will. (Does that make any sense? >Maybe I'm being too touchy-feely. :) When I first started Python, I wrote a class like: class Spam: def __init__(self, x): self.x = x def show(self): print self.x After I figured out it worked, I wanted to add a new method, so I did class Spam: def double(self): self.x = self.x * 2 then was annoyed that it didn't work the way I expected. So I don't think you are alone in this view. I bring it up here because I suspect for many people this is forgotten amoung all the other confusions in the early stages of learning Python. >Oh, and I've been meaning to ask - is there a way for me to add >methods to Dict or List or String? I couldn't figure out how to do it, >and that's where I *really* want it. No. You can only add them to subclasses of those types, and only in Python 2.2. You *can* add them to UserDict, UserList, and UserString. I've never liked that idea though (which Smalltalk and Ruby both have). I think adding methods to an existing class is like playing around with global variables. What's to keep two different libraries from adding a method with the same name but which does different things? Andrew dalke at dalkescientific.com From sandskyfly at hotmail.com Tue Nov 20 15:06:03 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: Tue, 20 Nov 2001 20:06:03 -0000 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> <3BF9D791.BEA22D61@engcorp.com> Message-ID: <3bfab7ae_3@mk-nntp-1.news.uk.worldonline.com> "Morten W. Petersen" wrote in message news:Pine.LNX.4.21.0111201815190.6229-100000 at bcryachts.atsat.com... > One of Python's advantages is a consistent (simple) design, (not counting > small quirks like 'def function(): return 1' and 'function = > lambda: 1'. Consistent design says 'less complexity' in my ears, along > the same lines of the simpleness (ease of maintenance, readability, > portability) of a python application if it can always be coded in Python. Excuse my curiosity but what's quirky about 'def function(): return 1' and 'function = lambda: 1'? Sandy From skip at pobox.com Fri Nov 16 03:02:10 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 09:02:10 +0100 Subject: PEP 276 Simple Iterator for ints In-Reply-To: References: Message-ID: <15348.51202.514777.21710@beluga.mojam.com> David> Skip Montanaro wrote: [ examples elided ] David> You seem to be inconsistent here about whether you want these David> ranges to be open or closed on the right. I think closed is the David> only reasonable choice for this syntax. Yes, running on too little sleep. Skip From niemeyer at conectiva.com Wed Nov 14 10:41:14 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Wed, 14 Nov 2001 13:41:14 -0200 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) In-Reply-To: <20011114084843.C22086@gerg.ca> References: <20011112175357.F26476@phd.pp.ru> <20011112102612.A1723@gerg.ca> <20011112203150.A8294@ibook.distro.conectiva> <20011114084843.C22086@gerg.ca> Message-ID: <20011114134114.A2111@ibook.distro.conectiva> > OK, I think I'll add this feature. Still haven't decided to enable it > by default, but I'm leaning that way right now -- it improves usability > and shouldn't ruin anyone's day, especially since "--" can always be > used for "stop processing options now". Very nice! > I'll also see about adding "store_many" as a standard action. Sounds > like it would be useful. Those two features should be enough to justify > Optik 1.1. Yes, I can think about some uses for it. [...] > Just keep the name and the copyright message intact, please! Hey... I'd never remove it. :-) Btw, we're using part of distutils (you're the main author, afaik) in two "semi-internal" projects (semi, because it is for our own use, but it's being published on sourceforge). Since there was no copyright notice in the files, I've just included a reference to distutils in all "borrowed" files. I've also changed the line parsing mechanism to do some extra features (multiple options with same name and mixed options and arguments). See ya! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From neil at cxchange.co.za Wed Nov 14 09:23:06 2001 From: neil at cxchange.co.za (Neil Fryer) Date: Wed, 14 Nov 2001 16:23:06 +0200 Subject: Shell commands from within a script In-Reply-To: <20011114150211.A8432@cruciatuz.de> References: <20011114150211.A8432@cruciatuz.de> Message-ID: Thank you Regards Neil Fryer neil at cxchange.co.za On Wednesday 14 November 2001 10:02 pm, Stefan Antoni wrote: > On Wed, Nov 14, 2001 at 03:42:12PM +0200, Neil Fryer wrote: > > I'm really new to python so if you could please let me know how to > > execute a command like say, ftp, from within a script it really would be > > appreciated. As I'm only about half way through my first Python tutorial. > > import os > os.system('ftp') > > ... this executes ftp from within your script. > have a closer look into the os module, there are many other interesting > ways to use commands, pipes, fork()'s and so on. From lac at strakt.com Fri Nov 9 12:45:16 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 09 Nov 2001 18:45:16 +0100 Subject: newbie tkinter question In-Reply-To: Message from jared@hwai.com (Jared) of "08 Nov 2001 11:46:51 PST." <480f610.0111081146.72a92cb0@posting.google.com> References: <480f610.0111081146.72a92cb0@posting.google.com> Message-ID: <200111091745.fA9HjGua009806@ratthing-b246.strakt.com> David Mertz found Tinter for me, so I am replying to my own mail. Tinter can be found at http://home.iximd.com/~dwalker/tinter.htm Laura Creighton From mgerrans at ix.netcom.com Sat Nov 17 01:55:28 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Fri, 16 Nov 2001 22:55:28 -0800 Subject: Tkinter idle? References: <3daa1aa8.0111161434.775b58fa@posting.google.com> Message-ID: <9t51km$h3c$1@slb6.atl.mindspring.net> Do you mean when the IDLE shell is running or do you mean when the CPU is idle? - mfg Jeffrey wrote in message news:3daa1aa8.0111161434.775b58fa at posting.google.com... > Hi All, > This might be an easy question you all. I'm just looking for a way > to create a function that is called whenever the Tkinter Tk() is idle. > > Thanks, > Jeff From wurmy at earthlink.net Sat Nov 17 10:05:46 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sat, 17 Nov 2001 15:05:46 GMT Subject: identity = lambda x: x -- a Pythonic idiom? References: Message-ID: <3BF67CD5.1380F667@earthlink.net> George Demmy wrote: > > I do a bunch of list-oriented programming with a bunch of one-off > programs. For a variety of reasons these lists tend to have a bit > of cruft associated with them (I don't write it -- just process > it!). So stuff like this shows up quite a bit: > > data = filter(lambda x: x, crufty_list) > > I did it so often, that stuff like this shows up: > > identity = lambda x: x # like this in practice (lazy) > > def identity(x): # Pythonic -- shows up in profiler, etc > return x > > data = filter(identity, crufty_list) Note that this can be written as data = filter(None, crufty_list) with the same result. > There are, of course, other nifty things to do with identity, and I > find it used all the time -- far more often than many Python > built-ins. How prevalent is identity usage in the Python community? Is > there anyone that would rather suffer hellfire and damnation that do > something like this? I don't really know what you mean by identity here... lambda x: x, or None, in a filter function filters out everything that evaluates as "false". From root at rainerdeyke.com Wed Nov 28 21:44:55 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Thu, 29 Nov 2001 02:44:55 GMT Subject: how to call external functions from python References: <3C046A11.175B9FB5@engcorp.com> Message-ID: "weeang" wrote in message news:c506ca7a.0111281823.42781e9f at posting.google.com... > My general objectives are: > To zip all files in a directory and copy the zipped file to a remote > directory. > > The design is as follows, i.e. simulating a ms outlook functionality: > 1)Zip all the files in a local 'inbox' directory > 2)Move the zipped file to local 'outbox' directory > 3)Copy the zipped file to a remote directory > 4)Moving the zipped file to a local 'sent' directory > > I hope I have made myself clear?? Not really. It is not clear why you want to move the zipped files to the 'outbox' directory and later move them to the 'sent' directory (which is not listed in your objectives). Maybe you are refering to different files here? Regardless, the modules 'os' and 'zipfile' should have everything you need. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From fn at panix.com Wed Nov 7 20:57:27 2001 From: fn at panix.com (Felicia Neff) Date: Wed, 7 Nov 2001 20:57:27 -0500 Subject: NetBSD and threading errors Message-ID: I am working with Python-2.1.1 on NetBSD-1.5.1. I am building python with the unproven-pthreads library (0.17 with and without NetBSD patches). I am encountering a number of problems with the program after it has compiled. First, 'make test' fails on test-fork1 and then hangs after a few more tests (although which test it stops at seems to vary). Once it produced the following error: Unhandled exception in thread: Traceback (most recent call last): File "./Lib/test/test_fork1.py", line 35, in f time.sleep(SHORTSLEEP) AttributeError: 'None' object has no attribute 'sleep' Unhandled exception in thread: Traceback (most recent call last): File "./Lib/test/test_fork1.py", line 35, in f time.sleep(SHORTSLEEP) AttributeError: 'None' object has no attribute 'sleep' Unhandled exception in thread: Traceback (most recent call last): File "./Lib/test/test_fork1.py", line 33, in f alive[id] = os.getpid() AttributeError: 'None' object has no attribute 'getpid' Unhandled exception in thread: Traceback (most recent call last): File "./Lib/test/test_fork1.py", line 33, in f alive[id] = os.getpid() AttributeError: 'None' object has no attribute 'getpid' This python binary appears to do threading correctly, but fails on this code: #!/usr/local/bin/python2.1 import sys,os pwdpipe = os.popen("/bin/pwd | /bin/cat", "r") cwd = pwdpipe.readline() print cwd ## print adds a newline if not cwd or cwd == "": sys.stderr.write("arrgh!\n") sys.exit(-1) pwdpipe.close() with this error: arrgh! cat: stdout: Bad file descriptor It does not fail with the same version of python compiled without threads. Any help would be greatly appreciated. -- Felicia From sdelafond at vertical.net Fri Nov 16 21:19:24 2001 From: sdelafond at vertical.net (Sebastien Delafond) Date: 16 Nov 2001 18:19:24 -0800 Subject: CGI output Message-ID: <63343bfd.0111161819.14263d83@posting.google.com> Hi, I'm using python to write a CGI interface providing my users with the ability to run a specific command, a.k.a. "command". This command takes about 3 to minutes to complete under normal conditions, and the current Python solution I'm using to run it prevent users to see its output before it's fully completed. I've tried calling this command with commands.getstatusoutput(command) execv(command,[]) but I still can't manage to do it... How would I call my command so that the output is displayed "continuously" to my user on the web page ? Any input welcome, --Seb From jeremy at zope.com Mon Nov 12 13:35:47 2001 From: jeremy at zope.com (Jeremy Hylton) Date: Mon, 12 Nov 2001 13:35:47 -0500 (EST) Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <15344.4849.71643.868791@monster.linux.in> References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> Message-ID: <15344.5763.557118.787529@walden.zope.com> >>>>> "PR" == Prabhu Ramachandran writes: >>>>> "JH" == Jeremy Hylton writes: JH> I haven't followed this thread closely. Is there some reason JH> that explicit names in imports is not sufficient? PR> Yes indeed there is. I've already explained my reasons twice. PR> Eric also explained why this was important for Scipy. I've gone back through the messages on python-dev, but don't seem a clear summary of the issues that lead to your proposed change. The best I can come up with are: 1) packages that are re-nested are a pain and 2) complex package structures also cause problems. Eric has a specific set of issues with SciPy that involve packages that are developed and used externally but also included in SciPy. I have had a hard time trying to figure out precisely what the problems are. PR> Anyway, in short, its a big pain re-nesting packages. Also for PR> any package that has a deep enough structure its a real pain PR> accessing packages. What does "re-nesting" mean? It get the impression you mean putting one package inside another after it was developed and pacakged for use as a top-level package. If so, it doesn't seem like a problem that occurs that often, right? I'd be hesitant to add features to the import mechanism to cater to an infrequent case. I'd rather see the imports be explicit "import root.a.b.c" than "import b.c". Then re-nesting requires all the import statements to be edited. It's more typing and might even require a simple script to do search-and-replace, but it doesn't sound like a prohibitive burden. I expect there is more to the issue than just wanting to avoid some extra typing. A short PEP that describes the specific problems being solved and discussing alternatives would help. PR> from pkg import subpkg is also not the best way to do imports. I PR> personally prefer import pkg.subpkg and I believe this is the PR> recommended way of doing imports. Why do you think this is the recommended way of doing imports? I use both in my code and haven't been able to come up with a clear rationale for doing one or the other. The from ... import form seems useful when the name of the package/module is long or when it's only one or two names I'm using. Jeremy From kragen at pobox.com Tue Nov 27 16:38:55 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 16:38:55 -0500 Subject: Two questions about Python.. References: <3BF99E55.2C300858@hotmail.com> Message-ID: <83r8qj6gi8.fsf@panacea.canonical.org> Ville Vainio writes: > Ken writes: > > I'm looking into using Python for a project, and was wondering how does > > Python rank up against other scripting languages for speed? It's about as fast as Perl, much faster than Tcl or sh, and much slower than Lua, a good Scheme, FORTH, or GhostScript, in my experience. HTH. From gh_pythonlist at gmx.de Tue Nov 13 22:10:42 2001 From: gh_pythonlist at gmx.de (Gerhard Haering) Date: Wed, 14 Nov 2001 04:10:42 +0100 Subject: Enanito si, pero con que pedazo! In-Reply-To: <0GMR006NJT62I7@SMTP.Prodigy.Net.mx> References: <0GMR006NJT62I7@SMTP.Prodigy.Net.mx> Message-ID: <20011114041041.A72426@lilith.hqd-internal> On Tue, Nov 13, 2001 at 09:19:58PM -0600, Hahaha wrote: > Faltaba apenas un dia para su aniversario de de 18 a?os. Blanca de > Nieve fuera siempre muy bien cuidada por los enanitos. Ellos le > prometieron una *grande* sorpresa para su fiesta de complea?os. Al > entardecer, llegaron. Tenian un brillo incomun en los ojos... This is an intelligence test, erh. a virus. So you Windows users, don't open it. For the Unix users, Wine doesn't handle this yet :-) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From Pieter_Claerhout at CreoScitex.com Fri Nov 30 08:51:13 2001 From: Pieter_Claerhout at CreoScitex.com (Pieter Claerhout) Date: Fri, 30 Nov 2001 14:51:13 +0100 Subject: Embedded Python interpreter in Kylix Message-ID: <490316A24CC5D411ACD700B0D078F7F00147127E@cseexch01.cse.creoscitex.com> Yes it can. The readme for the Python for Delphi package contains a section that explains you how to use it. The URL is: http://www.multimania.com/marat/delphi/python.htm Cheers, Pieter pieter claerhout, application support @ www.creoscitex.com -----Original Message----- From: Alan Jay. [mailto:blujay at .no.spamntlworld.com] Sent: Friday, November 30, 2001 2:37 PM To: python-list at python.org Subject: Embedded Python interpreter in Kylix I have read an article on embedding Python in Delphi, but this relies upon com objects. Does anyone know if a Python interpreter can be embedded into a Kylix application, and if so, how? Alan. -- http://mail.python.org/mailman/listinfo/python-list From peter at engcorp.com Wed Nov 28 20:47:21 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 20:47:21 -0500 Subject: PEP 276 Simple Iterator for ints References: Message-ID: <3C0593A8.430CDEDC@engcorp.com> James_Althoff at i2.com wrote: > > Jeff Shannon wrote: > >Better still, and already valid: > > > >if index >= len(mylist): > > print 'index out of range' > > ... although you would probably want to add the other condition as well: > > if index >= len(mylist) or index < 0: Or just: if not 0 <= index < len(mylist): print 'index out of range' -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From brueckd at tbye.com Tue Nov 6 13:32:07 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Tue, 6 Nov 2001 10:32:07 -0800 (PST) Subject: Teaching python (programming) to children In-Reply-To: <9s6ecs$1u7$1@news.lth.se> Message-ID: On Mon, 5 Nov 2001, David Andreas Alderud wrote: > Python is without doubt a very good language, but it's not good for the > beginner because they will pick up bad practices, mostly because of the > loose type paradigm. And what bad practices would those be? > For teaching programming I strongly belive that Ada95 is by far the best Ugh. At least teach them something that they can use elsewhere. ;-) > teaches the students how to write good code Define "good" code, please. -Dave From ballabio at mac.com Fri Nov 9 11:24:30 2001 From: ballabio at mac.com (Luigi Ballabio) Date: Fri, 09 Nov 2001 16:24:30 +0000 Subject: iters on ints? (reducing the need for range/xrange) In-Reply-To: References: Message-ID: <5.1.0.14.0.20011109161808.00a73a20@mail.mac.com> At 02:08 PM 11/9/01 +0000, Rainer Deyke wrote: >"Luigi Ballabio" wrote in message >news:mailman.1005305487.25887.python-list at python.org... > > This said, while it makes sense in english to say "do this for every line > > IN this file", it just doesn't sound right to me to say "do this for every > > number IN 10"---even though I've been once familiar with the definitions > > of the set of all integers. > >I consider that a fairly weak argument. Programming languages should be >simple, internally consistent, fairly easy to learn, well defined, and able >to express programs with minimum redundacy. Let me rephrase that without the "english" part. "for line in file" maps exactly the language-independent representation of the process which I form in my mind, which makes such expression simple, consistent, easy to learn and all that. "for i in 10" doesn't map any of my representations of an enumeration up to 10, much less one from 0 to 9. >English is none of these, so English should not be used a basis for >creating a programming language. You don't have to tell me that. I'm Italian :) Bye, Luigi From tim at vegeta.ath.cx Mon Nov 26 22:19:06 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 27 Nov 2001 03:19:06 GMT Subject: Editor for Python: A PLEA References: <3bfd7f87@news.airtel.net> <3c029caa.260513688@news.laplaza.org> Message-ID: Mats Wichmann graced us by uttering: > And in future (forlorn hope), could we all resist jumping in with 50 > or so conflicting opinions about editors and just point to the page, > unless there's a VERY specific question. There need not be 50 conflicting opinions. One only needs two editors: - Vim - Emacs =) Tim Hammerquist -- LISP programmers know the value of everything and the cost of nothing. -- Alan Perlis' corruption of an Oscar Wilde quote From tyler at tylereaves.com Tue Nov 20 08:31:58 2001 From: tyler at tylereaves.com (Tyler Eaves) Date: Tue, 20 Nov 2001 13:31:58 GMT Subject: Still on python GUI toolkit References: Message-ID: Unless you used Tkinter's canvas widget, this wasn't a fair test. From jae at jerhard.org Sat Nov 10 17:48:33 2001 From: jae at jerhard.org (=?ISO-8859-1?Q?=22J=FCrgen_A=2E_Erhard=22?=) Date: Sat, 10 Nov 2001 23:48:33 +0100 Subject: Freeware Python editor In-Reply-To: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> (message from Kemp Randy-W18971 on Fri, 2 Nov 2001 08:25:04 -0600) References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> Message-ID: >>>>> "Kemp" == Kemp Randy-W18971 writes: Kemp> Now there are probably other variations above, but from the Kemp> philosophy of pragmatism, I can have my cake, and eat it to. I'd rather have my Kate, and Edith too. Bye, J -- J?rgen A. Erhard (juergen.erhard at gmx.net, jae at users.sf.net) Invasion! http://invasion.jerhard.org Bill Gates brought you Windows. Linus brought you the whole DAMN HOUSE! -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 248 bytes Desc: not available URL: From fperez528 at yahoo.com Sun Nov 18 10:36:21 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 19 Nov 2001 15:04:21 +2328 Subject: Numercial Reduction question References: Message-ID: <9tbvq1$kon$1@peabody.colorado.edu> Sue Giller wrote: > I am working with Numerical arrays, and I need to be able to do > some reductions along axis to aggregate data. The reduction needs > to be able to skip cells that have a given value in them, denoting a > missing value. > Look into using Masked Arrays (it's in the Numeric docs). That's the proper way of handling missing data. Cheers, f From jolsen at mailme.dk Wed Nov 21 03:29:47 2001 From: jolsen at mailme.dk (Jesper Olsen) Date: 21 Nov 2001 00:29:47 -0800 Subject: Microphone input Message-ID: Does python have e.g. a "Multimedia" module, with functions supporting input from a microphone? Java has this, but I have not been able to find something like it for python. Jesper From mjais at web.de Tue Nov 27 03:41:05 2001 From: mjais at web.de (Markus Jais) Date: Tue, 27 Nov 2001 09:41:05 +0100 Subject: [OT] PostgreSQL Book References: Message-ID: On Tue, 27 Nov 2001 03:07:49 +0100, python wrote: > Hello, > > Well, we didn't want to do what the Addison Wesley book did. The A&W > book is about 500 pages and IMHO doesn't cover any topic in depth. Not > to mention most of it is regurgitated from the website. > > We were able to produce 600 pages or original in depth material. The > only chapter than could probably use some real beefing up is the JDBC > chapter. > > Basically we want to present a solid book. If we were going to produce a > python chapter, I would prefer (and we are talking about it) to have a > book that covered say, Python and Perl... for a total of about 500/600 > pages. > > J this sounds great. but as somebody already said, please do not mix up perl and python in one book. although I like Python and Perl (and Ruby), I think it would be better to do a smaller and cheaper book which focuses only on python (or Ruby, or Perl) for example, newriders has a great book called "mysql and perl for the web" a book like this covering python + postgresql would be great. I would definitely buy it. markus From donn at u.washington.edu Tue Nov 13 12:19:55 2001 From: donn at u.washington.edu (Donn Cave) Date: 13 Nov 2001 17:19:55 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> Message-ID: <9srknr$qe8$1@nntp6.u.washington.edu> Quoth "Frederic Giacometti" : | "Michael Hudson" wrote in message | news:uu1w0e0vo.fsf at python.net... ... |> I must be missing something. Can you sketch how, say, socket.send() |> would be implemented? Would you spawn a new OS thread for every C API |> call? I'm afraid I don't understand you to this point... | | As I mentioned, two thread pools would be maintained. | To the extent that send() is reentrant on the underlying OS, it would | beexecuted in one of the threads of the reentrant thread pool. | This is the 'thread pool' pattern; where threads are kept up (i.e. active) | from one call to the next. It's a standard pattern and concurrent | programming algorithm. | | Of course, this requires a non-blocking thread library (i.e. with OS | support); not a 'green thread' library (blocking, no OS support). Currently, | Python is always build on non-blocking threads when they exist anyway. But while it requires OS thread support, it collides with support of OS threads, doesn't it? For example, the threaded applications I write use one thread per window, threads created by Window.Show(). Those threads call back into the interpreter on window events, and the interpreted code calls right back into the C level graphics library; that library is built around this multi-threaded system and the calling thread isn't something to select arbitrarily from a pool, it has to be the thread that supports the Window object that noticed the event. I can't tell if this proposal is really incompatible with that - maybe a diagram would work better for me, too! Donn Cave, donn at u.washington.edu From db3l at fitlinxx.com Thu Nov 29 16:56:09 2001 From: db3l at fitlinxx.com (David Bolen) Date: 29 Nov 2001 16:56:09 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> <8ef9bea6.0111291148.1c5d4fa@posting.google.com> Message-ID: hungjunglu at yahoo.com (Hung Jung Lu) writes: > (...) Given the long track record of CVS, I really don't > understand why the windows adaptation is still so primitive, why > documentations are so badly written. It's probably one of those open-source laws of supply and demand, and how there's often a mismatch between the two. I'm a heavy CVS user and the _last_ think I care about is a nice GUI for it. I'm completely command line (even on Windows) and perfectly happy :-) But I'm sure there are lots of folks who would prefer the GUI; perhaps there are fewer of them that are developers who want to work on CVS itself. Or perhaps since there are products such as SourceSafe that cater to that audience, there's less of a demand to try to move CVS into that space. > (...) . I am sure CVS will get better, but I'll > give it a few more years. Meanwhile, I use SourceSafe. I don't know how much to expect over time - CVS has been around quite a while (at least 10+ years) and I'd guess is unlikely to undergo major shifts quickly at this point, but perhaps I'm wrong. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From chrishbarker at home.net Tue Nov 13 15:14:59 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 13 Nov 2001 12:14:59 -0800 Subject: Scientific Libraries in Python References: Message-ID: <3BF17F43.6066667F@home.net> Horatio Davis wrote: > What I am advocating is a standard extension library for doing scientific > computing in Python, in the same way that Numeric is the de-facto standard > extension library for doing number crunching in Python. > > Of course, this thread has seen no comment yet from the authors of scipy > and Scientific Python (which seem to be the two key codebases), or the > other software projects which build on these. There might be some > perfectly obvious reason why this is a horribly bad idea... But Scientific Python already is exactly what you are advocating! It isn't the least bit complete, but as far as I can tell, it's goals are exactly what you want. The only question is why other folks are still doing their own little projects, rather than contibuting to SciPy. One anser, with Scientific Pyhton at least, is that it waws around long before the SciPy project got started. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From jason at tishler.net Fri Nov 30 12:55:46 2001 From: jason at tishler.net (Jason Tishler) Date: Fri, 30 Nov 2001 12:55:46 -0500 Subject: std. python from cygwin: the final word (?) In-Reply-To: Message-ID: <20011130125546.A1244@dothill.com> John, On Thu, Nov 29, 2001 at 02:22:32PM +0000, John J. Lee wrote: > On Wed, 28 Nov 2001, Jason Tishler wrote: > [...] > > On Wed, Nov 28, 2001 at 12:22:05PM +0000, John J. Lee wrote: > > > After several, surprising long, threads, the collective brain power of > > > c.l.python and the cygwin mailing list has produced the following magical > > > shell incantations: Shame on me for not reading all of the above before responding, but my procmail recipes only matched your previous email. Additionally, since I read "all" Cygwin mailing list messages, I don't know how I missed the ones posted to that list. > Thanks, but: > > 1. why does it help to use pythonw? Nevertheless, I did not fully grok the point of your shell script. I thought that you were only interested in invoking a Win32 Python instead of the Cygwin one. > 2. why does your solution require rxvt (rather than the std. windows > terminal used by cygwin)? Unfortunately, if who uses pythonw in cmd/command/bash, then stdout will not be displayed. pythonw under rxvt does not have this problem. > Just to make sure we're not talking at x-purposes: the shell script I sent > was intended to be run instead of python, so that it can munge the > (possibly cygwin-style) path of the script before passing it to the real > python, while still getting sys.argv right at the same time, so you can > type Ah, I understand now -- sorry, for the noise. Jason From zope at thewebsons.com Wed Nov 21 14:12:50 2001 From: zope at thewebsons.com (Ben Ocean) Date: Wed, 21 Nov 2001 11:12:50 -0800 Subject: Tinkering With Tkinter Message-ID: <5.1.0.14.0.20011121110847.00a44010@thewebsons.com> Hi; I can't get tkinter installed. I'm running 2 different versions of python and I need to install it with 2.1. [root at hermes i386]# rpm -i python2-tkinter-2.1.1-1.i386.rpm error: failed dependencies: python2 = 2.1.1-1 is needed by python2-tkinter-2.1.1-1 libtcl8.3.so is needed by python2-tkinter-2.1.1-1 libtk8.3.so is needed by python2-tkinter-2.1.1-1 I've tried the -nodeps flag but that gives me a non-operational tkinter! [root at hermes i386]# python2.1 h.py Traceback (most recent call last): File "h.py", line 3, in ? from Tkinter import * File "/usr/lib/python2.1/lib-tk/Tkinter.py", line 35, in ? import _tkinter # If this fails your Python may not be configured for Tk ImportError: libtk8.3.so: cannot open shared object file: No such file or directory How do I specify which python to build with when I install this rpm? TIA, BenO From phr-n2001d at nightsong.com Wed Nov 14 19:31:28 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 14 Nov 2001 16:31:28 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <7xadxo27tr.fsf@ruckus.brouhaha.com> David Eppstein writes: > > > > for i in 0 .. len(sequence)-1: > > This is very common in C, but is it so common in Python? > Isn't it usually more idiomatic to do > for item in sequence > ? Sometimes you want to use the index in the loop. Maybe the loop syntax should be extended somehow to easily let you do that. From danielk at aracnet.com Sat Nov 17 15:45:44 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sat, 17 Nov 2001 12:45:44 -0800 Subject: Instantiating a class from its name Message-ID: I need to create a class factory such that passing the 'name' of the class to the method will produce an instance of that class. In Java, you do this with Class c = Class.forName("name_of_class"); MyClass m = c.newInstance(); What is the Python equivalent? Thanks, Daniel Klein From peter at engcorp.com Thu Nov 15 21:45:38 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 15 Nov 2001 21:45:38 -0500 Subject: Newbie questions part 2, thanks References: <7xzo5ojdqd.fsf@ruckus.brouhaha.com> <32SI7.34143$wd1.2586689@news20.bellglobal.com> Message-ID: <3BF47DD2.FC476DFC@engcorp.com> David Grenier wrote: > > (still this is in class cons) > > Whenever I call cons.mappe(lambda x:2*x, cons(1,[])) > I get the folowing error. > > Traceback (most recent call last): > File "", line 1, in ? > cons.mappe(lambda x:2*x, cons(1,[])) > TypeError: unbound method mappe() must be called with instance as first > argument Don't call the method on the class. Call it on an instance. You have not created an instance of the class you defined. You are doing this: class A: def func(a): print 'here' A.func() instead of this: class A: def func(self): print 'here' a = A() a.func() If you don't understand the difference, follow Paul's advice and go back to read the full tutorial before you try to finish the assignment... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Wed Nov 21 12:51:05 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Wed, 21 Nov 2001 17:51:05 GMT Subject: application scripting Message-ID: Introduction: AppleScript is the only ScriptingArchitecture that I know about that allows recording. An application is recordable when all (or most) user-interface handling results in the generation of one or more AppleEvents, which are directly routed to the application itself for execution. The AppleScript system can record these AppleEvents in a script, which the user can then edit. This can be a very user-friendly way for a user to start scripting, but of the relatively few applications that support AppleScript, even fewer support recordability. Mac Applications that are scriptable, but not recordable, have an architecture something like this: [GUI] -> commands -> [Model] <- commands <- [ScriptEngine] Scripts or AppleEvents --^ but recordable applications have an architecture like this: [GUI] -> AppleEvents -> [ScriptEngine] -> commands -> [Model] Scripts or AppleEvents --^ Questions: Can anyone describe how recordability would be implemented in a C++ application with (embedded) Python? Would a Python-embedded application have to generate Python source code, to implement the recordability pattern shown above? From peter at engcorp.com Sat Nov 10 20:53:59 2001 From: peter at engcorp.com (Peter Hansen) Date: Sat, 10 Nov 2001 20:53:59 -0500 Subject: IsPython really O-O? References: Message-ID: <3BEDDA37.CF603EDE@engcorp.com> kentsmith at dxsys.com wrote: > > A Smalltalk guru in our organization looked at Python last weekend (after I > had made a big scene saying that it may be a solution to some of our > cross-platform issues) and came away saying that it was no more > object-oriented than Java. I sputtered around a bit but could hardly make a > decent argument, as I'm a mere designer. We do very large-scale industrial > work here, all O-O, with object databases (I thought the ZODB business > looked great). Is my friend right? Is Python not "really" appropriate for > true O-O applications, in the sense that Viz-Age Smalltalk and Eifel and so > on are??? What is it about "true O-O" applications (never heard the term) which requires the features of Smalltalk and Eiffel? More likely, depending on what you mean by "large-scale industrial work" (also a term I've never heard except when applied to heavy machinery) you will find Python slower than Smalltalk, and unacceptable to your anti-non-Smalltalk people... (I use Python for industrial work, use ZODB, and write what I thought, until now, were "true O-O" applications, and I've been very happy with it until now. Maybe I should stop? ;-) > Kent Smith > I'd be embarrassed to be living in Toronto too. No, wait! I *am* living in Toronto! :) Strange home page you people have... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From a11w at SoftHome.net Mon Nov 26 19:42:53 2001 From: a11w at SoftHome.net (Jiba) Date: Mon, 26 Nov 2001 19:42:53 -0500 Subject: Become Message-ID: <3c028dfc$0$26362$7a628cd7@news.club-internet.fr> Here is a module that reproduce the Smalltalk "become" capability. Become can replace (quite) all references to an object by a reference to another object. It relies on gc.get_referents(). There's still work to do, e.g. for tuple or frame object, ... Jiba -------------- next part -------------- A non-text attachment was scrubbed... Name: become.py Type: text/x-python Size: 1956 bytes Desc: not available URL: From sasoft at gmx.de Fri Nov 23 19:34:58 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Fri, 23 Nov 2001 19:34:58 -0500 Subject: syntax-error? Message-ID: <20011123193458.A7362@cruciatuz.de> I got the following script and it produces a syntax error which drives me crazy. it says: File "", line 24 j = 0 # a counter ^ SyntaxError: invalid syntax Why? is j = 0 invalid? here's the script (anybody who can help me?): import httplib # request the page and get it def GetUrl(ServerAdr, PagePath): http = httplib.HTTP(ServerAdr) http.putrequest('GET', PagePath) http.putheader('Accept', 'text/html') http.putheader('Accept', 'text/plain') http.endheaders() httpcode, httpmsg, headers = http.getreply() if httpcode != 200: raise "Could not get document: Check URL and Path" doc = http.getfile() data = doc.read() doc.close() return data # parse the page and return the content between the start and end token def ExtractData(in_string, start_line, end_line): lstr = in_string.splitlines() j = 0 # a counter for i in lstr: j = j+1 if i.strip() == start_line: slice_start = j # find slice start elif i.strip() == end_line: slice_end = j # find slice end return lstr[slice_start:slice_end] # return the slice # handle the returned stuff and generate a new page def main(): # parameter and constants ServerAdr = 'www.onlinekosten.de' PagePath = '/' StartLine = '' EndLine = '' Head1 = '' Head2 = '' Foot = '' # call functions RawData = GetUrl(ServerAdr, PagePath) v = ExtractData(RawData, Startline, EndLine) # return result and construct page print Head1.strip() + ServerAdr.strip() + Head2.strip() for i in v: print i.strip() print Foot.strip() if __name__ == '__main__': main() -- thx in advance, Stefan Antoni ---------------------------- Fre Nov 23 19:31:54 EST 2001 From johnroth at ameritech.net Fri Nov 23 22:27:34 2001 From: johnroth at ameritech.net (John Roth) Date: Fri, 23 Nov 2001 19:27:34 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: "Michael Kelly" wrote in message news:g7utvt809nbioe3g23qeqcsvk6l8dqkn44 at 4ax.com... > On Fri, 23 Nov 2001 17:31:51 +0000 (UTC), Marcin 'Qrczak' Kowalczyk > wrote: > > >This would be a bad idea: > >- using tab width of any other size than 8 is evil, > >- 8 is too much for indentation in programming; 2 to 4 is good. > > I have to agree. In any event, the amount of space one can save > by using hard tabs is trivial compared to compressing the script. > With fast cheap reliable compression components and huge > hard drives we have these days it would seem that any benefit > to using hard tabs doesn't justify the hassles they cause. I'm > sure there are situations where one is stuck with them due to > the "backward compatibility" dragon, like CR/LF in Dos-derived > systems. But if you don't gadda' use 'em I wouldn't. :) > > > Mike Does this look like an opportunity for a PEP to provide support for a compressed .py format? John Roth From ngps at madcap.dyndns.org Tue Nov 27 10:26:27 2001 From: ngps at madcap.dyndns.org (Ng Pheng Siong) Date: 27 Nov 2001 15:26:27 GMT Subject: postgresql triggers to update GUI? References: <20011126.145234.816620091.2222@localhost.localdomain> <3C02C509.1020608@emc.com> Message-ID: <9u0bb3$9ig$1@coco.singnet.com.sg> According to Mikhail Terekhov : > Look for LISTEN/NOTIFY in the Postgres documentation. > You need: > 1. Create trigger on the tables in question which sends > a notify > 2. In your application use LISTEN > after connecting to the database and then periodically > check for notify. Look at pgnotify: http://www.post1.com/home/ngps Cheers. -- Ng Pheng Siong * http://www.post1.com/home/ngps From keyton at weissinger.org Sat Nov 17 23:26:00 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Sat, 17 Nov 2001 23:26:00 -0500 Subject: Python IDE Opinion Request In-Reply-To: <2a6e94ef.0111170759.5fe7027a@posting.google.com> Message-ID: Hello All, I am a recent inductee into the Pythonista Cult. I use MicroEdge's Visual SlickEdit (mostly so I can go back and forth with Python and Java, and Perl and Java, and HTML and Java, etc). However, I've played with a few of the Python IDEs out there. Some are nice, some are cute. None soom the "obvious" choice. Questions: 0) This question must have been asked before. Can someone point me in the direction of the last set of answers? [If not:] 1) Do you use a code editor (SlickEdit, emacs, etc) or an IDE (IDLE, etc)? Why? 2) Are there any IDEs out there that allow me to do UIs easily (ala VB)? I don't want a big code generator, but being able to drag and drop some simple forms would be nice... 3) Does anyone out there use SlickEdit for Python? Any tips and tricks for that combo? Thank you all. I know I'm telling you nothing you don't already know, but Python rocks! Why is it not out there more???? Regards, Keyton From jdadson at ix.netcom.com Sun Nov 4 23:51:31 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 04:51:31 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: <3BE61AAE.A9DF2368@ix.netcom.com> Tim Peters wrote: > > [Jive Dadson] > > I work in robotics. Our robots have several rotary axes, each of which > > can turn considerably more than 360 degrees. The positions 5 degrees > > and 365 degress are not equivalent, because the arms can contain wires > > and tubes that can only be twisted so many times. I am continually > > using the following function, often to "mod out" multiples of 360 > > degrees. > > > > // "Floating point modulus" function > > inline double fpMod(double x, double modulus) { > > return x-floor(x/modulus)*modulus; > > } > > Why do you use that instead of the platform fmod() function? Is it > important that the result be non-negative in this application? It is (semi) important that it always return a number in SOME canonical span of 360. It would be okay if it always returned a number in the range -180 to 180, for example. But if it returned a number in the range -360 to 360, I would have to put extra tests in the code. Now a confession. I didn't know about fmod(). If I had, I might have coded fpMod as follows, sticking the unavoidable test into the function itself: double fpMod(double x, double modulus) { double retval = fmod(x,modulus); if(retval < 0) { retval += modulus; } return retval; } From logiplexsoftware at earthlink.net Fri Nov 16 12:49:54 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 16 Nov 2001 09:49:54 -0800 Subject: MultiThread Socket on NT In-Reply-To: References: Message-ID: <01111609495401.02629@logiplex1.logiplex.net> On Thursday 15 November 2001 23:22, GT wrote: > Hi, > > I have a Simple Thread Socket Server. But if I lunch the Socket Server, > and many clients connect to this server, I must wait a long time for an > answer. I use in this case a simple Thread. > > while 1: > conn, addr = s.accept() > if fail: > thread = threading.Thread(target=burp, args=(conn,addr)) > thread.start() > else: > burp(conn,addr) > > But how can I set up a multithread Socket ? > > > Thanks for any help, > > GT Be sure you are using at least SP5. NT 4 had serious threading issues prior to that. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From andy47 at halfcooked.com Thu Nov 8 01:45:53 2001 From: andy47 at halfcooked.com (Andy Todd) Date: 8 Nov 2001 06:45:53 GMT Subject: Steve Irwin (was: Australian Disco) References: Message-ID: "Delaney, Timothy" wrote in : >> From: Fredrik Lundh [mailto:fredrik at pythonware.com] >> >> Gary Stephenson wrote: >> > Umm, I'm not really sure this is a claim we should be >> making! Next thing >> > you'll have us claiming responsibility for making disco >> popular - and then >> > they'll just have to shoot us! ;-) >> >> but Steve Irwin is your fault, right? > >Actually, much as Steve Irwin is a joke, he's also bloody good at what >he does. His over-the-top "Australian" antics are soley for the benefit >of his US viewers. > Hey, the crocodile hunter doesn't put on an act, that *is* him. Have you seen him on the Sydney Footy Show? That man is the very definition of the word 'bloke'. >I still get a shakey feeling in my stomach when I think of him being >tasted by a fierce snake - even knowing that he lived, that really >scared me. Now if that had been Fatty Vautin the cheering would have been heard all the way to New Zealand, but I digress. > >For those who don't know, the fierce snake is the eastern banded taipan, >the most venomous snake in the world. Immediately after hatching, it >contains enough venom to kill 100 rats (or was it 100 humans? I forget). >An adult human generally has time to walk about 50 metres before death >... > [snip story of Steve Irwin being, well, Steve Irwin] > > Getting this conversation back on track, has anyone noticed that the Australian cricket team seems to have been taking lessons from their English counterparts? What a spectacular batting collapse at the Gabba this afternoon. It makes this particular expatriate Pom proud. and-lets-not-even-start-on-Bardot-ly y'rs, Andy -- Content free posts a speciality From scholey at totalise.co.uk Fri Nov 30 13:21:42 2001 From: scholey at totalise.co.uk (Sam Scholey) Date: Fri, 30 Nov 2001 18:21:42 -0000 Subject: Using Python with a webserver Message-ID: Hey Folks I was interested in the prospect of using python with my webserver but a search on the python site and on deja produced virtually zero results. Can it be done? is it as easy as editing a few lines of code in the apache httpd.conf file? I am using Windows xp pro, apache 1.3.22 (for windows) Thanks Very Much From m.gehling at gmx.de Tue Nov 6 14:41:48 2001 From: m.gehling at gmx.de (Marc Gehling) Date: Tue, 06 Nov 2001 20:41:48 +0100 Subject: Use a COM-server with python Message-ID: <3BE83CFC.7060103@gmx.de> Hello, I installed a comserver and i can use it with VB. I would like to use the server with python. I read some artikels and take a look at "python programming on win32". Can someone translate this vb into python ? Dim oRepo As MXLib.MXRepository Dim oNewFolder As MXFolder Set oRepo = New MXRepository oRepo.dbUserName = "rep" oRepo.dbPassword = "rep" oRepo.repUserName = "Administrator" oRepo.repPassword = "Administrator" oRepo.dbConnectString = "Inf ora8" oRepo.repositName = "data" oRepo.connect oRepo.CreateFolder "testfolder", "folderdescr", 0, "Administrators", oNewFolder oRepo.Disconnect From emile at fenx.com Fri Nov 2 16:16:02 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 2 Nov 2001 13:16:02 -0800 Subject: Freeware Python editor References: <9ruu6l09ah@drn.newsguy.com> Message-ID: <9rv2o6$vgjpo$1@ID-11957.news.dfncis.de> "Cliff Wells" wrote in message news:mailman.1004733969.11971.python-list at python.org... > On Friday 02 November 2001 12:03, Grant Griffin wrote: > [snip] free [snip] free [snip] .... [snip] > > Since you mentioned the word "free", I'd like to take this moment to disagree > with you. No, no, no. You're wrong. -- Emile van Sebille emile at fenx.com --------- From max at alcyone.com Fri Nov 23 03:37:58 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Nov 2001 00:37:58 -0800 Subject: Is curses.wrapper standard? Message-ID: <3BFE0AE6.8C78E6B@alcyone.com> Is curses.wrapper standard? I've seen it in a few scripts but don't see any mention of it in the Python library documentation. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From brian.j.geddes at intel.com Tue Nov 20 00:10:48 2001 From: brian.j.geddes at intel.com (Brian Geddes) Date: Mon, 19 Nov 2001 21:10:48 -0800 Subject: Environment variables in Windows 2000 Message-ID: <9tcobh$qql@news.or.intel.com> All - I've been trying to store/pass information in environment variables in Windows 2000, but things aren't working the way I expect them to. The docs state that by making changes to the os.system dictionary, the changes should be carried over in environment space automatically by os.putenv(). However, the following which looks like it should work, does not: import os import sys os.system["HELLO"] = "Testing" sys.exit() # Run Python again import os print os.system["HELLO"] The second os.system call generates a KeyError. I've also tried using the os.putenv() and os.getenv() functions directly, but these don't seem to work either. I've tried on both 1.5.1 and 2.1.1 with the same results both ways. Has anyone had any experience with this? Thanks, - Brian Geddes From bit_bucket5 at hotmail.com Thu Nov 15 21:13:57 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Fri, 16 Nov 2001 02:13:57 GMT Subject: Python & cgi on win98--tinyweb problems, etc References: <7x8zd7zfh8.fsf@ruckus.brouhaha.com> <7xbsi3328v.fsf@ruckus.brouhaha.com> Message-ID: <4et8vt8nf0q5ghqj19stioep5gtc9o1ohr@4ax.com> On 15 Nov 2001 17:58:56 -0800, Paul Rubin wrote: >Chris Stromberger writes: >> Hadn't thought of that. Do you mean CGIHTTPServer? The docs say >> "Note: This module is Unix dependent since it creates the CGI process >> using os.fork() and os.exec()." so that won't work for win98, unless >> I'm missing something. > >I don't see how to run cgi's without forking. That's more or less the >definition of a cgi. So I was thinking more in terms of extending >BaseHTTPServer to run your Python code directly on parsing the request. Well, I'm not familiar with BaseHTTPServer (obviously), but it sounds intriguing. I'll look into it. Thanks for the suggestion. From loewis at informatik.hu-berlin.de Mon Nov 19 10:49:50 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 19 Nov 2001 16:49:50 +0100 Subject: newbie in threading References: <9t93vi$6gi$1@slb7.atl.mindspring.net> Message-ID: Stefan Antoni writes: > 1. threads will never terminate in python, the'll live=20 > on during the whole runtime, Wrong. Threads terminate when their thread function completes. > but i can modify them to be inactive using an "threading.Event" There are different synchronization mechanisms; Events are one of them. > 2. what does thread.join exactly? Just like the documentation says # Wait until the thread terminates. This blocks the calling thread # until the thread whose join() method is called terminates - either # normally or through an unhandled exception - or until the optional # timeout occurs. > 3. is a bunch of inactive threads able to slow down my program, or will > the gc clean them up for me? should i do a "del myThread" for saving > memory? Neither, nor. Inactive threads won't slow down other threads, but they won't be collected. They have to terminate themselves. Regards, Martin From gh_pythonlist at gmx.de Sat Nov 17 02:49:55 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sat, 17 Nov 2001 08:49:55 +0100 Subject: CGI output In-Reply-To: <63343bfd.0111161819.14263d83@posting.google.com> References: <63343bfd.0111161819.14263d83@posting.google.com> Message-ID: <20011117084954.A1110@lilith.hqd-internal> On Fri, Nov 16, 2001 at 06:19:24PM -0800, Sebastien Delafond wrote: > Hi, > > I'm using python to write a CGI interface providing my users with the > ability to run a specific command, a.k.a. "command". > > This command takes about 3 to minutes to complete under normal > conditions, and the current Python solution I'm using to run it > prevent users to see its output before it's fully completed. I've > tried calling this command with > > commands.getstatusoutput(command) > execv(command,[]) > > but I still can't manage to do it... How would I call my command so > that the output is displayed "continuously" to my user on the web page > ? If you want to do this, you cannot use commands.getstatusoutput, because this returns the full output from the command. You could use os.popen and read the results line by line, then print them. Or just use something like os.system and start the command as a subprocess. I'd also recommend to start Python with the option "-u" to avoid any stdout buffering. This works with my Apache configuration. If it doesn't work as expected, it might be a webserver configuration problem. For example, the following CGI script is displayed line by line in my browser: #!/usr/local/bin/python #import cgi #cgi.test() import sys, time print 'Content-type: text/plain\n\n' while 1: print '-' sys.stdout.flush() time.sleep(1) Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From grey at despair.dmiyu.org Fri Nov 30 16:38:58 2001 From: grey at despair.dmiyu.org (Steve Lamb) Date: Fri, 30 Nov 2001 21:38:58 -0000 Subject: A modest indentation proposal References: <3C0773C2.A12D0BAC@pacific.net.hk> Message-ID: On Fri, 30 Nov 2001 08:19:02 -0800, Erann Gat wrote: > Yes, of course we test our mission critical applications. Please extend > me the courtesy of not immediately assuming I'm an idiot just because I > make a proposal that you don't like. I didn't call you an idiot or presume you were an idiot. I just pointed out that in light of testing done on mission critical applications your point is moot since such problems should be found then. > No, that's not true. Consider the following two alternative code fragments: > if x: > foo() > baz() > if x: > foo() > baz() > They both look right, but they can't both be right. Ok. Rebuttal. if x: foo(); baz(); if x: foo(); baz(); Both of these look right, but they can't both be right. > Well, that's actually what I meant by "backwards compatible." I know that > semicolons can be used at the end of statements, but at the moment doing > so is a no-op. (All it does is betray you as still thinking in C/Java.) > I want to take syntax that is currently legal but useless and make it > useful. {grey at antelope:~} cat ga ; python ga x = 1 if x: print "1" print "2" if x: print "3"; print "4"; if x: print "5"; print "6"; 1 2 3 4 5 6 It is not backwards compatible if it solves your problem and if it is it doesn't solve your problem. As you can see in the second test the first line does not denote the end of the block because of the semicolon at the end. This is legal now. Under your proposal it would become illegal breaking compatibility. -- Steve C. Lamb | I'm your priest, I'm your shrink, I'm your ICQ: 5107343 | main connection to the switchboard of souls. To email: Don't despair! | -- Lenny Nero, Strange Days -------------------------------+--------------------------------------------- From James_Althoff at i2.com Wed Nov 14 17:23:02 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 14 Nov 2001 14:23:02 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: William Tanksley wrote: >An important point. "for i in 10,:" is an enormously different thing >under this proposal that "for i in 10:" Agreed, it is different. I would suggest that it is different in the same way that the following valid Python statements are different: for string in 'hello': print string for string in 'hello',: print string One needs to understand that "spam," is not the same as "spam" in the context of a for-loop regardless of whether or not types.IntType has an iterator. Jim From James_Althoff at i2.com Thu Nov 15 14:19:04 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 15 Nov 2001 11:19:04 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Ken Seehof wrote: >Hey, what ever happened to the int[:10] iterator idea? > >>>> for i in int[2:10:2]: print i, >2 4 6 8 Nothing actually *happened* to it. ;-) It needs a PEP (or needs to be added to an existing PEP). Among the issues that the PEP should probably address are: - Does int[] return a list or an iterator? (Or an iterator that implements some or all of the sequence protocol?) A list would be useful in many cases and would be a bit more consistent in the sense that slicing applied to current builtins returns actualized sequences not iterators. But iterators are more useful for for-loops (because you don't have worry about generating large sequences unnecessarily). So both are useful. Do we need two mechanisms? What would be the proposal for that? - Does int[] do anything more than act as a new spelling for the "range" function? (Or "xrange", depending on the answer to the issue above). - Issues from PEP 204 "Range Literals". PEP 204 proposed using slice syntax to create lists of integers. That PEP has been rejected. It included some issues such as: how do you handle [:] which is valid slicing syntax but contains no end value? Because the "int[]" proposal is less drastic than PEP 204 -- calling for the implemetation of __getslice__ as a class method on types.IntType rather than new syntax -- most of the issues in PEP 204 are probably not a big deal. But the PEP author should probably give them consideration. Finally, it should be noted that PEP 276 -- adding an iterator to types.IntType -- doesn't preclude implementing __getslice__ as a class method of types.IntType as suggested above. Jim From m.faassen at vet.uu.nl Sun Nov 4 16:26:36 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 4 Nov 2001 21:26:36 GMT Subject: Freeware Python editor References: <9ruu6l09ah@drn.newsguy.com> Message-ID: <9s4bqc$heq$1@newshost.accu.uu.nl> Grant Griffin wrote: [snip long discourse on free beer] I think this post extended the lifetime of the universe by a couple of million years at least, single handedly. I'm impressed. :) Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From slinkp23 at yahoo.com Thu Nov 22 00:51:14 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Thu, 22 Nov 2001 05:51:14 GMT Subject: Tkinter without the window References: <6hu1vn92lb.fsf@hare.demon.co.uk> <3BFC41ED.4C0EFB37@ccvcorp.com> Message-ID: >Les Smithson wrote: > >> I have a working Tkinter application that uses a canvas to draw >> graphics in an X window. Is it possible for Tkinter to draw the same >> graphics straight to a PNG/JPG/whatever file without going through a >> windowing system? >> >> I have in mind using this application for an External script in a Zope >> server. This would be called to generate a img tag on the fly. I want >> to do this in the server, rather then in the browser. Any ideas how I >> can generate PNG/JPG directly from Python, other than Tkinter? If you want to generate vector graphics, sping might be good: sping.sourceforge.net It can output to bitmap files such as JPG or PNG (via PIL), Tkinter, postscript, PDF, or SVG, all using one simple API. It's nice. --PW From peoter_veliki at hotmail.com Thu Nov 29 20:02:11 2001 From: peoter_veliki at hotmail.com (Peoter Veliki) Date: Thu, 29 Nov 2001 17:02:11 -0800 Subject: extracting a pattern using RE Message-ID: In perl you can use variables within regular expressions to extract patterns, something like this: string ~= /\((.*)\)/g pattern = $1 Probably not correct, but it is attempting to extract text surrounded by parenthes if string equals '(hello)', pattern would equal 'hello'. How can this be done in Python? I also am having problems with recursive patterns, what if I want to do the same thing with string = '(hello (there))' , I want to be able to extract both 'hello (there)' and 'there'. Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From s713221 at student.gu.edu.au Fri Nov 9 04:32:38 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Fri, 09 Nov 2001 19:32:38 +1000 Subject: Gratuitous post References: <_OEG7.910$Yh.66599@atlpnn01.usenetserver.com> <9sfd3g$12j0d7$1@ID-11957.news.dfncis.de> Message-ID: <3BEBA2B6.813B9F2E@student.gu.edu.au> Emile van Sebille wrote: > > Hitler! > Oops. Now you've done it. We'll have to keep this thread alive for a week, just to ensure that it doesn't end with somebody mentioning Hi__er. Just-doing-my-part-ly yrs. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From sholden at holdenweb.com Thu Nov 15 15:34:55 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 15 Nov 2001 15:34:55 -0500 Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> Message-ID: [posted & mailed] "Peter Bismuti" wrote in ... > I want to pass a function as an argument but don't want to have to define it > globally. > I think the proper terminology for this is "anonymous". > > The way I *don't* want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) > > > I'm guessing this can't be done because of Python's indenting syntax. > In ECMAscript you can send a function as an argument that is defined on the > fly such as: > > callMyFunction( new Function(){ blah blah }) > > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? > Peter: The answer is the same as yesterday: you must either define a function or use a lambda. Didn't you see all those posts in reponse to your previous questions? regards Steve -- http://www.holdenweb.com/ From m.hadfield at niwa.cri.nz Wed Nov 7 18:41:16 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Wed, 7 Nov 2001 23:41:16 +0000 (UTC) Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) References: <9sacsk$r82$1@bugstomper.ihug.com.au> <8_dG7.4760$R43.760797@newsb.telia.net> <9sbvsa$925$1@newsg2.svr.pol.co.uk> <9scc8a$g8b$1@bugstomper.ihug.com.au> Message-ID: <005f01c167e5$af19f450$d938a8c0@Hadfield> From: "Gary Stephenson" > Rolf, otoh, is a national treasure. I mean anybody who could > give us such classic masterpieces as "Jake the Fake" (with my > extra leg, deedle-ee deedle-um)... Jake the *Peg*, damn you! (It rhymes better that way.) --- 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 nikander at mindspring.com Wed Nov 14 11:28:35 2001 From: nikander at mindspring.com (Robert Nikander) Date: Wed, 14 Nov 2001 11:28:35 -0500 Subject: regex difficulty ? Message-ID: <20011114.112834.189124975.7396@localhost.localdomain> Hi, I am trying to write a program that scans the GTK headers. I am getting confused about the following regular expression, and was hoping someone could help explain... Here is some simplified code that illustrates my problem. I am trying to match a prototype and extract the return type... the problem is I am matching against the second one, when I don't think my regex says that... str = 'char * gtksomething' str2 = 'extern "C" { } gtksomething' regex = re.compile(r'([\w\s*]*?)gtk') m = regex.search( str ) print m.group(0) print m.group(1) m = regex.search( str2 ) print m.group(0) print m.group(1) On my system that second one matchs... ? Output is: char * gtk char * extern "C" { } gtk extern "C" { } How the heck is the [\w\s*] class matching the chars { } and " From ungrzr2 at ubatxbat.pbz Wed Nov 28 09:29:50 2001 From: ungrzr2 at ubatxbat.pbz ({-- Rot13 - Hateme) Date: 28 Nov 2001 14:29:50 GMT Subject: [2.2b2]: class variable and classmethod, subclass References: <83u1vf6gua.fsf@panacea.canonical.org> Message-ID: Andreas Kostyrka wrote in news:mailman.1006931558.4505.python-list at python.org: > > "{-- Rot13 - Hateme" writes: >> In 2.2B2 >> Inside a class,I did a change to a class variable inside the class' >> classmethod. If the variable has not been changed in the subclass >> before, the class variable in the subclass of the class is also >> changed. Is this behavior intentional or a bug? > > Well, it is the Pythonish way. Actually class variables in Python never > had anywhere the semantics one might be used from other languages. > (*grin* Never forget, Python is THE Lisp of Hashtables, instead of Cons > cells ;) ) > Thanks for your guys' answers. It sucks though. :) At least subclasses should not share the class variables with their parents. Why does it make sense? From teg at redhat.com Sun Nov 18 21:43:56 2001 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 18 Nov 2001 21:43:56 -0500 Subject: Python IDE Opinion Request References: Message-ID: "A. Keyton Weissinger" writes: > 1) Do you use a code editor (SlickEdit, emacs, etc) or an IDE (IDLE, etc)? > Why? Emacs. It's the editor I prefer (and use for everything else), it's extremely customizable and there is a nice python mode available for it. > 2) Are there any IDEs out there that allow me to do UIs easily (ala VB)? I > don't want a big code generator, but being able to drag and drop some simple > forms would be nice... While not an IDE, glade is a nice UI designer which matches great with python - it's what we use in many programs for Red Hat Linux. It's included in Red Hat Linux, the website is http://glade.gnome.org/ -- Trond Eivind Glomsr?d Red Hat, Inc. From tim.one at home.com Fri Nov 2 00:36:40 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 2 Nov 2001 00:36:40 -0500 Subject: Freeware Python editor In-Reply-To: Message-ID: >> FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS [Delaney, Timothy] > The PSU failed! A post about the PSU escaped to the world in its > entirety! > > We are fre In case the intended word was "free", I'd like to point out that there are different philosophies about free software, only one is correct, and c.l.py's mission is to educate the world about which one that is. Don't forget that extremism in defense of freedom is no vice. just-following-orders-but-don't-feel-good-about-it-ly y'rs - tim From logiplexsoftware at earthlink.net Tue Nov 6 20:39:07 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 6 Nov 2001 17:39:07 -0800 Subject: Teaching python (programming) to children In-Reply-To: <9s9qie$rer$1@news.lth.se> References: <9s9qie$rer$1@news.lth.se> Message-ID: <01110617381203.19608@logiplex1.logiplex.net> On Tuesday 06 November 2001 15:07, David Andreas Alderud wrote: > Having a non-declarative language as a first choice is bad, teaches them to > write sloppy code. Yes and no. Like many others, my first language was BASIC (on an Apple //e). Later, I took some CS classes where we learned Pascal. I had indeed developed some bad habits due to language deficiencies in BASIC (everything global, no argument passing, jumping in and out of routines, etc). However, it was a good, simple introduction to programming and I like to think I wasn't permanently crippled by the experience. Later, I took up C, and what do you know? Pascal gave me "bad" habits (mostly in the area of counting upon the compiler to warn me about bad things I was about to do). However, I would never have moved back to Pascal from C because C's flexibility allowed me to code things that would have been extremely difficult in Pascal. Yes, I could shoot myself in the foot, but at least I had a gun. > Having dynamically typed language such as Python does even more damage to > the understanding of how to write good code, thankfully python types are > strong which helps to avoid part of the problem. That depends upon your perspective on what "good code" is. Code that is easy to read? Easy to modify? One of Python's strengths is that almost every line of code is related to solving the programmer's goal rather than telling the compiler how to compile the code. Not having a lot of extra statements that have nothing to do with solving the problem results in cleaner, easier to understand code. The skills you are referring to are difficult to teach in any language (although, I can't comment on Ada - perhaps it makes designers out of neophytes in no time ;-) . These come with time and experience. > Ada is used quite a lot, especially in the military and general embeded > markets, and it's a gigant in realtime system programming. Not really areas of interest for beginners. > Ada is fantastic, with it I write inline Assembly(can even do inline > Fortran, C, C++, etc, etc), combine it with Python, Java, etc, etc. It may be. Many excellent languages languish in specialized niches. However I would hesitate making one of those excellent languages a teaching tool since people learning it would undoubtedly have to later move to another language anyway (possibly due to lack of availability on a specific platform), so most of the features they've come to depend upon would no longer be available and their reliance upon them would show up as "bad programming practices" in their new language. > Ada is very strict, so sloppy code is very rare, sloppy written code is bad > code, because it's hard to maintain, debug and extend. Not knowing Ada makes me reluctant to disagree, but I wonder how a language so strict that writing sloppy code is difficult can be a very flexible language. Usually those things are mutually exclusive. Training-wheels on a bicycle are a common comparison... safety over flexibility. Maybe this is why you need inline Fortran/C/Assembly in your Ada code - to get around the restrictions of the language. > Ada a high level OO language that still remains close to hardware, while > code is still portable across platforms, what more can you ask for? Widespread use? A promising future? Guido himself suggested (in Linux Journal) that perhaps Dylan was slightly better than Python in some respects, but I don't see anyone jumping ship just yet (maybe when Visual Dylan hits the market). > People underestimate Ada95 because they either don't know jack about Ada or > just know Ada83, use the right tool for the right job, you can after all > use Ada with Python. :-) True, I don't know jack about Ada. I don't know jack because I've never known anyone (other than yourself) who claims to use it. This doesn't make it a bad language, just an impractical one. The unfortunate fact is that the best design doesn't always win (otherwise where would Microsoft be today?). I think Ada had its chance and failed to claim enough interest to make it relevant today. And please, I'm not trying to offend you, just disagree with you (a little), so let's not make this another flame war - this list has had too many the last couple of days. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From morten at thingamy.net Sun Nov 11 15:07:40 2001 From: morten at thingamy.net (Morten W. Petersen) Date: Sun, 11 Nov 2001 21:07:40 +0100 Subject: Benefits of moving from Python to Common Lisp? Message-ID: Hello, I'm currently doing some research, to see if it could be an advantage to use Common Lisp instead of Python (currently Python and Zope [1] are used to build web applications). While doing this, Google has provided two interesting documents (search for 'lisp vs python'): http://www.strout.net/python/pythonvslisp.html http://www.norvig.com/python-lisp.html First off, to save everyone some time, I'm wondering if there are more papers documenting the difference between the two; if there aren't any, I'd like to continue the discussion and summarize the findings in a paper accessible on the net. Regards, Morten [1] http://www.zope.org From ws-news at gmx.at Sun Nov 25 17:03:33 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Sun, 25 Nov 2001 23:03:33 +0100 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> <3C014329.7B828AE8@alcyone.com> <3c014926.1812080@news> Message-ID: <3c016b7b$1@brateggebdc5.br-automation.co.at> Hi Fred, "Fred Flintsone" <__x__ll at yahoo.com> wrote in message news:3c014926.1812080 at news... ... > I did download the 2.1.1 but noticed afterwards a suggestion for me to > d/l "ActiveState," which is a larger d/l, so I'm assuming it has > important goodies bundled in it. Before I get going here, should I > uninstall 2.1.1 and go for the ActiveState d/l? (This message refers > to Gillou's post above.) This depends if you would like to use the Windows extensions (which allow you to interoperate with ActiveX / COM stuff, use most of the Windows function, etc.) or the PythonWin IDE that comes with those extensions as well. Personally I find the PythonWin IDE a very nice environment for learning Python, it even includes autocomplete of method names (almost like VB editor) and a debugger. If you already have a good editor and do not like to dive into Windows programming right away, you can just continue with what is already running. The Windows extensions are also available as a seperate download, but I don't know how easy it is to install (I always used ActivePython install on Win so far). Hope the confusion did not increase to much ;-) Werner From m.faassen at vet.uu.nl Thu Nov 8 17:58:41 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 8 Nov 2001 22:58:41 GMT Subject: I just got in! References: <9sep77$eg6$1@slb4.atl.mindspring.net> Message-ID: <9sf2n1$c4u$3@newshost.accu.uu.nl> Andrew Dalke wrote: > One thing about Python people is we are less (outwardly ;) smug > then your phrase seems to suggest. Perhaps that derives from the > influence of Dutch tolerance in the early days. That's a nice compliment, though my limited experience on Dutch forums makes it seem implausible. :) I am not sure where the generally nice atmosphere comes from. I think the audience is just fairly mature. It may have settled the atmosphere early on. Small languages generally attract a more mature audience, where the average newcomer has a fair number of languages under their belt already, with more knowledge of language theory but also language pragmatism. Python is clean and pragmatic enough at the same time to be useful for such people. It's where theory and pragmatism meets peacefully. Perhaps that's why the newsgroup is relatively peaceful as well. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From sill at optonline.net Wed Nov 14 01:08:44 2001 From: sill at optonline.net (Andrei Kulakov) Date: Wed, 14 Nov 2001 06:08:44 GMT Subject: os.mkfifo in linux vs freebsd Message-ID: Hello, I noticed mkfifo works differently in linux and freebsd. In linux, I can do os.mkfifo(file); f = open(file) and then read from f, etc.. Under freebsd, when I try to open created fifo, it hangs.. Anyone know how to deal with this? Is this the right place to ask? Should I go to some freebsd groups (I hear they don't like to answer questions, though)? - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From kfarmer at thuban.org Fri Nov 23 05:48:17 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Fri, 23 Nov 2001 10:48:17 GMT Subject: AppBars in Win32 -- SUCCESS Message-ID: After beating my head against various things, I have successfully created an AppBar under Win32. What's an AppBar, you ask? An AppBar is a window docked at the edge of the screen, such that Windows knows about it, and adjusts the desktop boundaries accordingly. The taskbar is one such example. Currently, I've managed to get it to dock and undock on various sides of the screen. I haven't done anything fancy, like dragging it to dock/undock, nor has the window been more complex than a blank frame under wxPython. The extension I wrote interfaces to the SHAppBarMessage function, and uses part of the win32 extensions to determine screen size. I've borrowed some constants from an attempt by Bill Bell to perform the same task. If I'm correct, this extension should work with both PythonWin and wxPython. I'll next be trying to put widgets in the frame. ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org From bill-bell at bill-bell.hamilton.on.ca Wed Nov 7 08:10:48 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 7 Nov 2001 08:10:48 -0500 Subject: help - Create dll In-Reply-To: <1005099231.1026.13836.m10@yahoogroups.com> Message-ID: <3BE8EC88.2628.7A4FDB8@localhost> "Glauco Silva" > How can i create a dll file ( C dynamic library) from windows to be > imported by python. You have a few options: 1. My favourite: use MS VC to create the DLL as an in-process COM server with the default dual interfaces. This is not as difficult as it might sound: in particular, if your app needs to pass strings then look for posted articles about processing BSTR objects. Means for working with COM objects are discussed in the help files that come with the Activestate.com distribution of Python. Better still, buy "Python Programming on Win32" from O'Reilly. 2. Build your DLL as you normally would and use Sam Rushing's interfacing code for using DLL's (www.nightmare.com). As useful as this approach is for passing simple values back and forth it's somewhat difficult to learn as a consequence of the paucity of documentation. 3. Build your DLL as you normally would and use SWIG. Well documented, beautiful system that is heavily used by many who create libraries for use from Python. A lot to learn, though, if you're new to this area of programming. Good luck! Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From maxm at normik.dk Wed Nov 28 09:22:54 2001 From: maxm at normik.dk (Max M) Date: Wed, 28 Nov 2001 15:22:54 +0100 Subject: Database in a simple ascii file References: Message-ID: <3c04f33a$0$31411$edfadb0f@dspool01.news.tele.dk> You could also just use the anydb module. It should do the same thing. Or you could pickle a dictionary. Regards Max M "Rafael Mentz Aquino" wrote in message news:mailman.1006944636.11546.python-list at python.org... > Hi, > > How many lines can I have in a simple ascii file before > I start to loose performance when I open this file and > put all the lines in a dict, turning the first column into the key > and the rest of the line into a list associated to that key. > > (my file has just 100 lines, but that question starts to bother me ;-) > > Thanks! > > Rafael Mentz Aquino > > From ws-news at gmx.at Fri Nov 16 05:59:12 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 11:59:12 +0100 Subject: MultiThread Socket on NT References: Message-ID: <3bf4f244$1@brateggebdc5.br-automation.co.at> Hi, did you notice, that the SocketServer module contains a ready-made socket server? It even includes a threaded server (2 in fact, ThreadingTCPServer and ThreadingUDPServer). Your problem with performance could come from creating a new thread for every request. Depending on the OS, creating threads may be an expensive operation. (e. g. Windows calls the DllMain() function in all loaded DLLs, unless they explicitely specified they do not want this) To have a better scalable solution, you could use a thread pool. hth Werner "GT" wrote in message news:e253b770.0111152322.7a1933c5 at posting.google.com... > Hi, > > I have a Simple Thread Socket Server. But if I lunch the Socket Server, and > many clients connect to this server, I must wait a long time for an answer. > I use in this case a simple Thread. > > while 1: > conn, addr = s.accept() > if fail: > thread = threading.Thread(target=burp, args=(conn,addr)) > thread.start() > else: > burp(conn,addr) > > But how can I set up a multithread Socket ? > > > Thanks for any help, > > GT From bernhard at intevation.de Mon Nov 5 07:30:54 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 5 Nov 2001 12:30:54 GMT Subject: test References: Message-ID: <9s60pu$1136nf$5@ID-89274.news.dfncis.de> [Posted and mailed] Please do not use the regular newsgroup for tests. There are special *.test newsgroups. And while you are at it, switch off HTML posting, it is considered rude. Bernhard ps.: This seems to be not known widely enought, though my post. In article , "Alves, Carlos Alberto - Coelce" writes: > This message is in MIME format. Since your mail reader does not understand > this format, some or all of this message may not be legible. > > ------_=_NextPart_001_01C16231.D7156E30 > Content-Type: text/plain; > charset="ISO-8859-1" > > test > > ------_=_NextPart_001_01C16231.D7156E30 > Content-Type: text/html; > charset="ISO-8859-1" > > -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From mkelly2002NOSPAM at earthlink.net Fri Nov 23 20:38:46 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Sat, 24 Nov 2001 01:38:46 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: On Fri, 23 Nov 2001 17:31:51 +0000 (UTC), Marcin 'Qrczak' Kowalczyk wrote: >This would be a bad idea: >- using tab width of any other size than 8 is evil, >- 8 is too much for indentation in programming; 2 to 4 is good. I have to agree. In any event, the amount of space one can save by using hard tabs is trivial compared to compressing the script. With fast cheap reliable compression components and huge hard drives we have these days it would seem that any benefit to using hard tabs doesn't justify the hassles they cause. I'm sure there are situations where one is stuck with them due to the "backward compatibility" dragon, like CR/LF in Dos-derived systems. But if you don't gadda' use 'em I wouldn't. :) Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From richardSPAM at geotek.co.uk Thu Nov 22 07:30:30 2001 From: richardSPAM at geotek.co.uk (Richard Chamberlain) Date: Thu, 22 Nov 2001 12:30:30 -0000 Subject: Tkinter displaying an image in a button References: <3BFC3295.20FC3F02@alex2.labs.agilent.com> <%Y2L7.14855$QC5.2230883@news20.bellglobal.com> Message-ID: <6qvit9.p68.ln@servant.geotek.co.uk> I believe he's using pil to support jpg. This garbage collection problem has been around for quite a while, it's just clearing up local variables and taking your image with it. You could also make img and phi an attribute of the class as in: from Tkinter import * import Image, ImageTk class App: def __init__(self, master): self.img = Image.open('c:/water.jpg') self.phi = ImageTk.PhotoImage(self.img) button = Button( master, image=self.phi ) button.pack() root = Tk() app = App(root) root.mainloop() Richard "S?bastien Cabot" wrote in message news:%Y2L7.14855$QC5.2230883 at news20.bellglobal.com... > First in Tkinter.py we have: > > class PhotoImage(Image): > """Widget which can display colored images in GIF, PPM/PGM format.""" > > This mean for me no ".jpg". > > Now for the problem: > > Look's like the PhotoImage object got a sys.getrefcount(img) == 0 and is > garbage collected right away, even if the Button object still need this > object. > > So this work: > > from Tkinter import * > root = Tk() > i = PhotoImage(file="but1.gif") > Button(root, image=i).pack() > root.mainloop() > > And this don't work: > > from Tkinter import * > root = Tk() > Button(root, image=PhotoImage(file="but.gif")).pack() > root.mainloop() > > No doubt, this is a refcount bug in Tkinter. > > Now a quick patch to get around this bug is to keep your PhotoImage allocate > for all the duration of your application. > Be carefull, PhotoImage must be call only after the Tk() call. > > So a solution could be: > > from Tkinter import * > > class App: > def __init__(self, parent): > global BUT1 > Button(parent, image=BUT1).pack() > > root = Tk() > BUT1 = PhotoImage(file="but1.gif") > App(root) > root.mainloop() > > Hope this will help. > > (Note: I tested this with Python 2.1.1 on Debian) > > Good Luck! > Bye. > > "David R. Smith" wrote in message > news:3BFC3295.20FC3F02 at alex2.labs.agilent.com... > > The first code snippet below successfully displays an image, whereas the > > second just shows gray where the image should be. What's wrong with the > > class version, and what do I have to do to get it to work? > > (I am using Python 2.0.1 on Debian.) > > > > adTHANKSvance > > David Smith > > > > > > > > from Tkinter import * > > import Image, ImageTk > > root = Tk() > > img = Image.open('SonicCruiser.jpg') > > phi = ImageTk.PhotoImage(img) > > button = Button(root, image=phi) > > button.pack() > > root.mainloop() > > > > > > > > from Tkinter import * > > import Image, ImageTk > > class App: > > def __init__(self, master): > > img = Image.open('SonicCruiser.jpg') > > phi = ImageTk.PhotoImage(img) > > button = Button( master, image=phi ) > > button.pack() > > root = Tk() > > app = App(root) > > root.mainloop() > > From rerhol at gmx.de Tue Nov 6 12:53:57 2001 From: rerhol at gmx.de (Georg Lohrer) Date: 6 Nov 2001 09:53:57 -0800 Subject: How to set a runtime-variable in pdb-session? Message-ID: Hi, I'm just trying to set a variable of a script during a pdb-session. But whatever I do, the variable does not been setted accordingly. For example: (1) import pdb (2) class foo: (3) def show(self, name_of_var): (4) pdb.set_trace() (5) x = name_of_var (6) print x (7) if __name__ == '__main__': (8) f = foo() (9) f.show('myfoo') Running with 'python foo.py' stops at pdb.set_trace(); after entering one 'n', the current line will be (5). Now I want to change the value of name_of_var to 'not_my_foo'. (pdb) name_of_var 'myfoo' (pdb) name_of_var='not_my_foo' (pdb) name_of_var 'myfoo' (pdb) locals()['name_of_var']='not_my_foo' (pdb) name_of_var 'myfoo' I don't know how to evaluate that local variable to a specific value on-time. Do you have any ideas or knowledge? Ciao, Georg From phd at phd.pp.ru Thu Nov 8 06:23:50 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 8 Nov 2001 14:23:50 +0300 Subject: Shelve problem: why so big? In-Reply-To: <9sdol4$2te$1@samos.cs.uu.nl>; from geert@cs.uu.nl on Thu, Nov 08, 2001 at 11:00:52AM +0000 References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: <20011108142350.H6242@phd.pp.ru> On Thu, Nov 08, 2001 at 11:00:52AM +0000, Geert-Jan Giezeman wrote: > I am trying to create a shelve from a table of 1100 by 1100 floating > point numbers, which I want to store as 1100 lists of length 1100, > indexed by a key. Unfortunately, I get an error when I try to create > this: > bsddb.error; (22, Invalid argument) http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.099.htp Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From daves_spam_dodging_account at yahoo.com Thu Nov 8 16:51:16 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Thu, 8 Nov 2001 13:51:16 -0800 (PST) Subject: DDE in Windows? Message-ID: <20011108215116.41584.qmail@web21107.mail.yahoo.com> Hello, Is it possible to use DDE from within Python on Windows? I'd like to run a script that can send DDE commands to a server, and possibly to register a service and listen as well. Thanks, -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Find a job, post your resume. http://careers.yahoo.com From myemail at any.where.com Mon Nov 26 23:42:57 2001 From: myemail at any.where.com (myemail at any.where.com) Date: Tue, 27 Nov 2001 04:42:57 +0000 (UTC) Subject: ¥þ´ä­º­Ó Music Video ¼½©ñ°Q½×ª© Message-ID: <9tv5kh$25k$1577@news.net-yan.com> ???????? Music Video ?????Q???? http://forum.hkhost.net/forumdisplay.php?fid=75 ?????U?????a???~?a?? Music Video, ????????, ?u???N?n???????q?????????????m?K?W?Y?i?A?{???? ASF/MPG/MPEG ...?w???o??... ?????? [mtv]???????}[/mtv] ???J MTV ?v?? From logiplexsoftware at earthlink.net Fri Nov 9 15:47:32 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 12:47:32 -0800 Subject: newbie Python OO vs Tcl In-Reply-To: References: Message-ID: <01110912473202.01414@logiplex1.logiplex.net> On Friday 09 November 2001 12:44, b t wrote: > Is there anything similar in Tcl? So far I can only think of its lax > syntax... I believe Incremental Tcl adds some OO features to Tcl, but I've never used it so I don't know to what extent. IMHO, it'll still be ugly =) Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From sholden at holdenweb.com Mon Nov 5 07:47:29 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 5 Nov 2001 07:47:29 -0500 Subject: Exception holes, again. References: Message-ID: "Dale Strickland-Clark" wrote in ... > On a related subject to the earlier exceptions wart thread. > > I want to trap the specific 'api_error' exception raised by win32api. > > I can't find where that exception is defined so how do I catch it? > > I have searched the whole Python installation for the string > 'api_error' but it isn't there. Dale: If you can persuade the Python interpreter to raise this error, surely the exception traceback tells you exactly what you need to check for in terms of module.exceptionname? Or am I mistaken? The exception is probably defined in an extension library. regards Steve -- http://www.holdenweb.com/ From db3l at fitlinxx.com Thu Nov 22 00:25:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Nov 2001 00:25:28 -0500 Subject: Non-Indented python References: Message-ID: Chris Liechti writes: > tabs are specified as 8 characters. only programmers that use tabs to > indent make them 4 or 3 characters... Well, you have to be a little careful how you phrase this. I'm not aware of any global document or specification that actually makes a pronouncement that tabs are 8 characters (and I presume you actually mean up to 8 characters, not 8 characters fixed). What we've really got is a legacy from at least the early visual terminals (and particularly the VTxx class from DEC) that defaulted that way. Maybe it goes further back, but my first video display was a VT52, so I can't say for sure :-) But the oldest definitions were just that a TAB character moved the cursor to the next active tab position. The fact that these positions defaulted to every 8 characters didn't change the fact that they could be reprogrammed in software and then the tab would be anything you wanted. It was one of the ways to minimize the output over (then) slow terminal lines to rapidly generate columnar output. Those defaults pretty much percolated through later systems, and in particular, typical Unix tty drivers. I believe that the language reference for Python makes mention of Unix as its model for the parser's interpretation of tabs as 8 column boundaries. > the Java styleguide says that you should use 4 characters indentation and > that you can write a tab for 8 characters, so they made it correct, same as > python has it correct too. "correct" is too absolute (although personally I agree that using 8 - not a fixed 8, but a multiple of 8 - is the most logical choice), since tab widths have been "correctly" changeable back to very early video displays. But to move slightly more on topic, I do think the most relevant point is that _if_ tabs get used within Python source, it is advisable to match visually what the parser is going to see logically (just to keep things sane), which implies that any use of tab should in fact move to a column multiple of 8. -- -- 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 jdadson at ix.netcom.com Fri Nov 2 20:08:08 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 03 Nov 2001 01:08:08 GMT Subject: Getting started Message-ID: <3BE34358.8819E585@ix.netcom.com> Okay, easy question: How do I write a Python module and load it into the interactive console application? MS Windows. For example, if I put the script in a directory called, 'D:\\my python hacking', how do I tell the interactive console window I want to load the module 'hacking.py' from that directory? BTW, I tried putting setting a MS Windows system variable PYTHONSTARTUP to "print 'Hello, world.'", but it had no effect. Jive From BPettersen at NAREX.com Tue Nov 20 14:26:04 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Tue, 20 Nov 2001 12:26:04 -0700 Subject: sscanf ? Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192215112@admin56.narex.com> > From: Bruce Edge [mailto:bedge at troikanetworks.com] > > In <3BFAA0FC.EB3CB91B at alcyone.com>, Erik Max Francis wrote: > > > Bruce Edge wrote: > > > >> I know about all the regex stuff, but I have the format > string that > >> was used to generate a string, which I'd like to use to > decompose it > >> back into it's source data: > >> > >> fmtstr = "%02d.%02d" > >> > >> str = fmtstr % ( x, y ) > >> > >> # Now get x any y back using only str and fmtstr: > >> > >> (x, y ) = ? > > > > x, y = map(int, str.split('.')) > > > > OK, that works for this case, I was looking for something > more generic. > > What about for this case: > > fmtstr = "x=%02d and y is %02d" > > currently I'm looking at converting the %02d into \d{:2} for > use with the re module. Maybe the re module will help? >>> s = 'x=%02d and y is %02d' >>> s % (10,12) 'x=10 and y is 12' >>> import re >>> m = re.match(r'x=(\d+) and y is (\d+)', s % (10,12)) >>> m.groups() ('10', '12') >>> -- bjorn From phr-n2001d at nightsong.com Tue Nov 6 02:26:05 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 23:26:05 -0800 Subject: Teaching python (programming) to children References: <7xvggph61y.fsf@ruckus.brouhaha.com> <9s67gd$874$00$2@news.t-online.com> <7x4ro9un0c.fsf@ruckus.brouhaha.com> Message-ID: <7x668os6lu.fsf@ruckus.brouhaha.com> Brian Elmegaard writes: > And I thought about the ages inbetween, I guess. At 8 they don't have > the reading and writing skills to program, at 10 I believe they > do. I will look at pygame. You could look at Papert's stuff. He was teaching Logo to very young kids. From sandskyfly at hotmail.com Sat Nov 10 18:48:29 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 10 Nov 2001 15:48:29 -0800 Subject: Using browser as interface to python app References: <3BED2723.B42B68EE@letterror.com> Message-ID: Yup...pydoc does work... I wonder if it'll accept input from forms.... I think the redfoot project looks promising as well. I'll look into the code in both modules and hopefully discover a path of least pain. BTW: The DHTML backend for the Anygui project is still in planning mode... Many thanks for all responses. Sandy Sandy Norton wrote: > > I'm intrigued by the possibility of running a simple local webserver which > > would serve a set of webpages (with checkboxes, text fields, etc..) > > directly to a browser which would then allow the user to interact with > > the running python app. Just van Rossum wrote: > Does pydoc -p work under Windows? If yes, it might be a good > http server demo. From __x__ll at yahoo.com Sun Nov 25 14:40:44 2001 From: __x__ll at yahoo.com (Fred Flintsone) Date: Sun, 25 Nov 2001 19:40:44 GMT Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> <3C014329.7B828AE8@alcyone.com> Message-ID: <3c014926.1812080@news> Yes, that is the one I picked up..."Learning Python." It seems to be intended for those with little or no programming experience. I am that, though I have done a little work with macros in Access...the operative word is LITTLE. Thanks for the references. I've added the tutorials to my BMs. I did download the 2.1.1 but noticed afterwards a suggestion for me to d/l "ActiveState," which is a larger d/l, so I'm assuming it has important goodies bundled in it. Before I get going here, should I uninstall 2.1.1 and go for the ActiveState d/l? (This message refers to Gillou's post above.) I'm very excited about this. Thanks for your help. FF Please post any responses to this to this newsgroup. From lac at strakt.com Tue Nov 13 04:06:48 2001 From: lac at strakt.com (Laura Creighton) Date: Tue, 13 Nov 2001 10:06:48 +0100 Subject: Opening sockets on multiple ports In-Reply-To: Message from Alain =?iso-8859-1?Q?D=E9silets?= of "Wed, 12 Nov 2014 16:00:07 CST." Message-ID: <200111130906.fAD96mua015712@ratthing-b246.strakt.com> We handle multiple clients with both sides initiating conversation using http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 There is nothing Tkinter or Gui specific about this approach, despite the title. Laura Creighton From marfadeu at gmx.de Fri Nov 9 16:42:13 2001 From: marfadeu at gmx.de (Markus Faust) Date: Fri, 9 Nov 2001 22:42:13 +0100 Subject: mayavi installation problem on Win NT References: <9sdh9v$hgq$01$1@news.t-online.com> Message-ID: <9shiki$gjl$04$2@news.t-online.com> Prabhu, I played a bit around with mayavi. It is one of the greatest programs I saw this year! Astonishing how you can rotate and manipulate 3D views. Very good user interface! I also saw that I'll need more graphics performance ... Markus From ajs at ix.netcom.com Sun Nov 25 00:54:38 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 25 Nov 2001 00:54:38 -0500 Subject: A permutation on permutations Message-ID: <001101c17575$aea5a800$a9e1fea9@carol> >> I am feeding control points to a curve function, and >> want all permutations that result in unique curves. > >For this purpose a sequence is duplicative > >of its reverse, i.e. [1,2,3,4] == [4,3,2,1], etc. >> Tyler asks: >Would [1,3,2,4] be a duplicate? Nope. BTW, I just gave an example of a list of length 4. The class itself can accept a list of arbitrary length as an argument. True enough, I am not fully confident that I have a full handle on what will create duplicate curves in all cases. But I believe I am correct that for the function as written only list == list.reverse() will create duplicate curves. Art From joeyahoo at gmx.de Fri Nov 2 02:37:55 2001 From: joeyahoo at gmx.de (Andreas) Date: 1 Nov 2001 23:37:55 -0800 Subject: Zugriff auf Windows Dateieigenschaften References: Message-ID: Hi Martin, well I haven't used newsgroups and stuff like that so often up to now ... but English should be no problem ... thanks for this friendly advice ... ;-) Yesterday I had a look at the different modules again and found the time modul which will return the date but in a format like " Thu Nov 01 16:30:25 2001". Does anybody know how Python handles internally dates because one cannot work with the date as it appears there. I guess internally it should be transfered to a number refering to a special dateline like under UNIX. Thanks in advance Andreas Martin von Loewis wrote in message news:... > joeyahoo at gmx.de (Andreas) writes: > > > ich bin der totale Pythonanf?nger und muss ein Skript schreiben > > Hallo Andreas, > > Bist Du auch neu im Usenet? In comp.lang.python ist es ?blich, > englisch zu schreiben. > > > In welchen Modulen finde ich denn Funktionen zum Zugriff auf die > > Dateieigenschaften wie zum Beispiel Erstellungsdatum, ?nderungsdatum > > etc. Bis jetzt habe ich nur os.path gefunden. > > os.stat gibt ein n-Tupel zur?ck, das diese Informationen enth?lt. Das > Modul stat enth?lt verschiedene ST_-Konstanten, um die Indizes dieses > Tupels symbolisch anzusprechen. > > Ciao, > Martin From rxg218 at psu.edu Thu Nov 22 11:01:45 2001 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 22 Nov 2001 11:01:45 -0500 Subject: syntax question Message-ID: <9tj7et$oi2@r02n01.cac.psu.edu> Hi, I saw this code snippet in teh Google archives: def V(*vals): return array(vals) c = V(256,256) And then c is a Numpy array. I can see that the *vals takes in a tuple - is this orrect or are there any other significances of this sytnax? TIA -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 152 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- All seems condemned in the long run to approximate a state akin to Gaussian noise. -- James Martin From buzzard at urubu.freeserve.co.uk Sat Nov 3 12:24:25 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Sat, 3 Nov 2001 17:24:25 -0000 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: Message-ID: <9s198i$fh6$1@newsg3.svr.pol.co.uk> "Steven D. Majewski" wrote in message news:mailman.1004728088.20694.python-list at python.org... > > > On Thu, 1 Nov 2001, Tim Hammerquist wrote: > > > You mean "the humour is lost on _some of_ us Americans," right? > > > > Of course, I had a non-standard American growth in which I was exposed > > to many things British, including but not > > limited to: > > Dr. Who (mainly Tom Baker) (recorded). > > Red Dward (1st season, carrier did not renew) (recorded). > > Monty Python's Flying Circus and any of the movies I could find. > > How to Irritate People (John Cleese et al.; not "officially" Monty > > Python). (purchased) > > ...et cetera. > > Peter Cushing horror movies. ;) > > Susan Cooper's The Dark Is Rising sequence including dialects from > > Cornwall and Wales. > > A great many movies and series taking place in Yorkshire, probably > > responsible for my ability to understand more dialects than > > usual. :) > > Neil Gaiman novels. :) > > Far too many others to count. > > You're missing one important link that is well represented in the > python-list archives: The Goon Show -- with Spike Milligan and > Peter Sellars. The Goon Show was a BBC radio show that was the > inspiration for Monty Python. And Peter Cook!!!! John Cleese once said something along the lines of, "It takes me a week to write a 30 minute script; it takes Peter 30 minutes". > > Spike Milligan beat out John Cleese for 1st place in the BBC's > millenium poll of the top 10 funniest people: > > > He has written a lot of books, many of which are out of print -- my > favorite (besides his children's poems) is "Hitler: My Part in his > Downfall", which is the first of his series of WWII memoirs. > ( Which continues with several volumes, including "Mussolini: His Part > in My Downfall" ) > > [ List and description of his books on the "Cardboard and String Spike > Milligan Home Page" : ] > > > A google search will find you lot's of Goon Show pages (including > the easiest to remember: ). And just in time > for the invasion of Afghanistan, you can download an MP3 of "The Red > Fort" from Robert Dickson's Goon Show Page: > > ( It's the "show of the week", so hurry! ) > > > > Many foreigners call America's culture (or lack thereof) bland. Well, > > from this American's perspective, they tend to be correct. > > Bland American Culture ??? -- how about (while we're on the subject of > humor): > the Firesigh Theatre > Mad Magazine (the good old years) > The Onion > The Marx Brothers Excellent. > Abbott and Costello ( "Who's on First": > ) > Harry Shearer ( "Who's on First" -- (a tradition in American Humor!): > > [Don't blame me if you're not old enough to get this one!]) > the Simpson's > Robert Crumb > the Coen Brothers > George Bush (What other country has such a dedication to Humor!) Don't forget Ronnie and Dan Quayle. (I couldn't remember Dan's name, but a search for 'potatoe' soon revealed it.) Duncan Smith > > .... > > -- Steve > > > > From andymac at bullseye.apana.org.au Tue Nov 6 04:44:29 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Tue, 6 Nov 2001 20:44:29 +1100 (EDT) Subject: Exception holes, again. In-Reply-To: Message-ID: On Mon, 5 Nov 2001, Dale Strickland-Clark wrote: > Here's a little program to provoke an error: > > import win32api > import win32con > > key = win32api.RegOpenKeyEx(win32con.HKEY_CURRENT_USER, "Software", 0, > win32con.KEY_READ) > print win32api.RegQueryValueEx(key, 'Spam') > > ..and here's the traceback: > > Traceback (most recent call last): > File "I:\BATCH\tests\testreg2.py", line 6, in ? > print win32api.RegQueryValueEx(key, 'Spam') > pywintypes.api_error: (2, 'RegQueryValueEx', 'The system cannot find > the file specified.') > > Doesn't tell you much, does it! > > I've tried to find pywintypes but can't and I had a hunt through the > Python directories to see if I could find the definition but came up > with nothing. I think you'll find that this exception is registered in the initialisation of one of the win32??? extension modules. It is standard practice for C extensions needing "their own" exceptions to do this. I might have expected the PythonWin documentation to note things like exceptions. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From gh_pythonlist at gmx.de Sun Nov 4 00:30:06 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Sun, 4 Nov 2001 06:30:06 +0100 Subject: Jews or Muslims? Who's a better hacker? Or phreaker? In-Reply-To: <5I3F7.9918$ND1.818724@brie.direct.ca>; from ptaylor@hellmann.net on Sun, Nov 04, 2001 at 04:43:45AM +0000 References: <5I3F7.9918$ND1.818724@brie.direct.ca> Message-ID: <20011104063006.A4911@gargamel.hqd-internal> On Sun, Nov 04, 2001 at 04:43:45AM +0000, Peta Ylorhovik wrote: > Jews or Muslims? Who's a better hacker? Or phreaker? If you're interested in this question, I recommend you use a least Python 2.1 - it supports rich comparisons. You might also be interested in the new twisted.religion module, which will part of one of the next versions of Twisted Python. Meanwhile, you can try to abuse twisted.reality for this philosophical question. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From cliechti at gmx.net Fri Nov 9 15:39:22 2001 From: cliechti at gmx.net (Chris Liechti) Date: 9 Nov 2001 22:39:22 +0200 Subject: Strange __str__ behavior References: <9shev1$136lad$1@ID-11957.news.dfncis.de> Message-ID: [posted and mailed] "Emile van Sebille" wrote in news:9shev1$136lad$1 at ID-11957.news.dfncis.de: > I don't get the same thing on win2k yes you get the same... > F:\Python22>python > ActivePython 2.2 Alpha 2 build 1 (ActiveState) > Python 2.2a2+ (#22, Sep 5 2001, 14:10:41) [MSC 32 bit (Intel)] on > win32 >>>> class Test: > ... def __str__(self): > ... print "in __str__" > ... return "str(self)" > ... >>>> test = Test() >>>> print test > in __str__ ^ its this space thats the problem > str(self) >>>> -- Chris From kragen at canonical.org Tue Nov 20 15:42:41 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 20 Nov 2001 15:42:41 -0500 Subject: How to marshal a function? References: <83adxhu0sk.fsf@panacea.canonical.org> Message-ID: <83itc5mawu.fsf@panacea.canonical.org> Cliff Wells writes: > On Tuesday 20 November 2001 03:41, Kragen Sitaker wrote: > > To know whether something is "a security hole" requires, > > at least, that you know what threats you want to defend against and > > what threats might actually exist. > > Actually, I read his post _very_ carefully and decided that what he was > saying is that he is routing the port that his server is listening on over > ssh. This is probably reasonably secure for most circumstances. Well, it probably won't introduce any significant new insecurities, anyway (assuming ssh is letting him run arbitrary commands, which he says it is.) But using ssh for remote execution is neither necessary nor sufficient for security. > Additionally, since his attitude was similar to yours (annoying), I > decided to end it by agreeing with him, which I find to be the quickest > way to avoid wasting my time with people who flame rather than discuss. > > You are absolutely right: no one can decide except him whether his > security is sufficient, hence everyone should avoid offering advice on the > subject in case someone may disagree with you. I disagree with your above statements; they are not what I said in my post. I said you need to know more information than he posted to evaluate whether or not a particular trust relationship represents a security vulnerability. I wouldn't have bothered to follow up (I'm not fond of flaming either) if you hadn't misstated my position above. (If that's what you thought my position was, it's no wonder you were annoyed.) From david at dataovation.com Mon Nov 19 14:45:31 2001 From: david at dataovation.com (David A McInnis) Date: Mon, 19 Nov 2001 11:45:31 -0800 Subject: Cookies In-Reply-To: <15353.22846.720200.562431@beluga.mojam.com> Message-ID: That is what I understood. Just checking. Thanks for the quick response. David -----Original Message----- From: Skip Montanaro [mailto:skip at pobox.com] Sent: Monday, November 19, 2001 11:11 AM To: david at dataovation.com Cc: Python Subject: Re: Cookies David> I want to read the values of a cookie that was placed on my David> computer by a web site. I opened it up and it appears to be David> encoded. Is there anyway to decode the values? Cookies are nothing more than key/value pairs. Subject to certain limitations (length, character set), I believe web sites are welcome to encode the values any way they want, so the short answer is, "no". If you know what steps were taken to encode the value, you may be able to decode it, but that's not always going to be trivial. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From tim at vegeta.ath.cx Tue Nov 13 16:56:53 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Tue, 13 Nov 2001 21:56:53 GMT Subject: OT: Mobile Internet Toolkit EULA References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> Message-ID: Steve Holden graced us by uttering: [ snip ] >> Limitations on the product distributed is nothing new. OTOH, Microsoft >> has just attempted to make it _ILLEGAL_ to use a python binary I've >> compiled myself (though ActivePython is probably alright). _This_ is >> what a _huge_ number of people are upset about. [ snip ] >> Rebuttals? >> > Since the Python license is as liberal as it is, there is no reason why a > Python binary has to be GPL, just because (say) you compiled it with gcc. > But that apart, your description of the terms and conditions of Microsoft's > EULA seems fair, and less biased than, say, my own sclerotic reactions. I was referring more to, say, a copy of Python 1.6.1 I might have laying around whose license is _explicitly_ GPL-compatible, making the above license even more averse to it than Python's current release. Also, the license does not limit 'Publicly Available Software' to GPL; it includes, as stated previously, software that #v+ contains, or is derived in any manner (in whole or in part) from any software that is distributed as free software, open source software ... or _similiar_licensing_or_distribution_model_. #v- I cannot (under this license): - _use_ any OS software to develop the project. This includes: * editing any MIT file in Vim * search/modify/operate on any MIT files using tar, gzip, perl, etc. * telnet into a Win32 box from a linux box to view and/or edit any MIT files. - distribute anything created using MS MIT under and GPL "or similar licensing or distribution model." (of course) - I cannot include anything under the aforementioned licenses in the same package as anything developed using MS MIT. M$ has required that it be a separate product, thereby dictating what my package contents may/may not include. And AFAIK, a program compiled by gcc (GPL) is _not_ required to be GPL itself. So you are correct in this. Microsoft may still whine that you are _using_ a GPL'd product with their system, whether or not that product affects your end-product's license. Tim Hammerquist -- "Supported" is an MS term that means the function exists. The fact that it always fails means that it is an exercise for the programmer. -- Sarathy, p5p From jjl at pobox.com Fri Nov 30 13:42:09 2001 From: jjl at pobox.com (John J. Lee) Date: Fri, 30 Nov 2001 18:42:09 +0000 (GMT) Subject: std. python from cygwin: the final word (?) In-Reply-To: <20011130125546.A1244@dothill.com> Message-ID: On Fri, 30 Nov 2001, Jason Tishler wrote: [...] > > > On Wed, Nov 28, 2001 at 12:22:05PM +0000, John J. Lee wrote: > > > > After several, surprising long, threads, the collective brain power of > > > > c.l.python and the cygwin mailing list has produced the following magical > > > > shell incantations: [...] > Shame on me for not reading all of the above before responding, but > my procmail recipes only matched your previous email. Additionally, > since I read "all" Cygwin mailing list messages, I don't know how I > missed the ones posted to that list. [...] It was a while back now: IIRC, I had to get around to fixing the case where you just type 'python' at a shell prompt. John From usenet at thinkspot.net Mon Nov 26 01:46:38 2001 From: usenet at thinkspot.net (Sheila King) Date: Mon, 26 Nov 2001 06:46:38 GMT Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> <3c015433.778200@news> Message-ID: <9trs5o.3vvf63f.1@kserver.org> [posted and mailed] On Mon, 26 Nov 2001 06:18:08 GMT, "stephen cox" wrote in comp.lang.python in article : : If so, I have a simple question: :isn't a list just an array? Not exactly. Arrays usually require that all entries are of the same type. There is no such restriction on lists in Python. You can use Python lists, however, to serve the purpose of an array from other programming languages, in many situations. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From nomad*** at ***freemail.absa.co.za Thu Nov 1 05:55:23 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Thu, 01 Nov 2001 12:55:23 +0200 Subject: What about background? References: Message-ID: <8ba2utofr79esiih1ujqveuaea4a8df61p@4ax.com> On Thu, 01 Nov 2001 11:31:13 +0100, lukoc at zeus.polsl.gliwice.pl wrote: >Hi! >I would like to change background color in my Pythonwin editor (white is to sharp for me), but it's not available from options. >Can you help me with this really small problem? > > AFAIK, the pythonwin editor is set up as a standard windows 'View' window. So what you could do is go to "Control Panel | Display | Appearance" and change the colour for the 'Window' item to something more pleasing to your eyes. Of course, this will then be global to windows (explorer, notepad etc.etc.), but if the white is to bright in Pythonwin, it'll be too bright in everything else to. HTH -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From root at rainerdeyke.com Thu Nov 8 21:59:32 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 09 Nov 2001 02:59:32 GMT Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: "Steven D. Majewski" wrote in message news:mailman.1005260651.24404.python-list at python.org... > If "for i in 10:" was legal, I'ld guess it meant the same thing as > "for i in [10]:" or "for i in (10,):" Guessing is no substitute for reading the docs, even in Python. > A file *IS* a sequence -- although you could just as easily slice it > by characters as lines -- or by any arbitrary object for binary files, > as Pascal does. If the integer 10 suggests any sort of sequence, it's > the singleton sequence containing: 10. The Pythons docs define "sequence" as something which supports the sequence interface. If 's' is a sequence, then 's[i]' is a defined operation that either returns a value or raises 'IndexError' (unless some other error occurs). A file isn't that. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From daniel.dittmar at sap.com Mon Nov 12 05:59:07 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 12 Nov 2001 11:59:07 +0100 Subject: IsPython really O-O? References: Message-ID: <9soa1t$m1a$1@news1.wdf.sap-ag.de> Perhaps one should list the differences between Smalltalk and Python. This would make it easier to decide which of these differences are really important. This list is based on Digitalk SmallTalk of 7 years ago, so it might be dated. - no strict data encapsulation in Python: true, but I would rate this in the same area as static type checks - Classes are objects in Python, but there are used in a different way, especially when constructing objects. In Python, the runtime creates a new object and calls the appropriate __init__ method (this is similar to Java). In Smalltalk, you call a class method. If this method somehow manages to call 'Object new', then a new object gets created. This approach makes it somewhat easier to create multiple constructor methods. I didn't say it is impossible to have multiple object creation routines in Python. - no multiple return values in Smalltalk (still true?). One could argue that having a separate class for all such cases is more object oriented. One could also argue that such nonessential helper classes are simply fluff. - no code blocks in Python: Python allows to pass callables around, but lambdas are simply too limited for most purposes. Handling collections in Python has more of a functional heritage (applying filter to a UserList will return a list, not a UserList). With all the elements available in Python 2.2 (nested scopes, inheritance from C-classes), it is probably possible to implement something similar to the Smalltalk collection hierarchy. - calling conventions are very different (has really nothing to do with O-O). The Smalltalk syntax does not allow for default arguments (yes, you can fake them with additional methods) or passing of dictionaries through keyword arguments. On the other hand, I still believe a listing of Smalltalk methods gives me a better idea of the functionality than the equivalent in Python (compare 'from:for:' or 'from:to:' with 'substring') - adding of code at runtime: Smalltalk allows this, but at least commercial implementions will remove this from the freely redistributable runtime. - With Carlton University nearby, anything other than Smalltalk will be a tough sell. Daniel From mjackson at wrc.xerox.com Thu Nov 1 10:27:34 2001 From: mjackson at wrc.xerox.com (Mark Jackson) Date: 1 Nov 2001 15:27:34 GMT Subject: Monty Python (was: Freeware Python editor) References: Message-ID: <9rrpl6$nhi$1@news.wrc.xerox.com> Mikael Olofsson writes: > > On 01-Nov-2001 Oleg Broytmann wrote: > > On Thu, Nov 01, 2001 at 07:39:31AM -0500, Steve Holden wrote: > > > [Makes note to remember that Oleg isn't a Monty Python viewer.] > > > > Few years ago I tried to view the scetches - there was Russian > > translation of them on TV - but found them stupid and boring. Well, I was > > in bad mood those days, may be now I'd find it more interesting :) > > You should really watch them in their original language. And I admit, > some of them are not that great (those where legs and arms are cut off > and blod everywhere). But then there are the others (for instance the > dead parrot sketch), where the humour is in the language. And they are > fantastic. Evidently Monty Python is funny in French. We once went to see Holy Grail in Paris and it's a good thing we knew the dialog by heart; since the audience could read French subtitles faster than the actors spoke in English there wasn't a single punchline that wasn't drowned out by audience laughter. Could be a contextual mismatch; I can imagine that the (no cheese in the) cheeseshop sketch might not seem funny in St. Petersburg. . . -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson After a recent trip to New York one French journalist remarked that leafing through a copy of /Forbes/ or /Fortune/ is like reading the operating manual of a strangely sanctimonious pirate ship. - Adam Gopnik From timo.savola at iki.fi Fri Nov 9 11:09:08 2001 From: timo.savola at iki.fi (Timo Savola) Date: 09 Nov 2001 18:09:08 +0200 Subject: Defining inheritance in C extensions In-Reply-To: References: Message-ID: <1005322148.2323.19.camel@whiz-bang> On Fri, 2001-11-09 at 15:08, Martin von Loewis wrote: > However, I'd argue that you don't need to reflect the C++ hierarchy in > the Python types at all: just make the Python types completely > unrelated to each other. I could do the type checking apart from the Python types, but I think it would be a good idea to do it "properly" since it's apparently possible. If my types are be compatible with their base types, PyArg_ParseTuple(args,"O!:abc",&basetype,&ptr) would do the checking for me, or does it check for the *exact* type? Also, I like player with powerful RTTI. :) Timo From loewis at informatik.hu-berlin.de Tue Nov 27 03:37:15 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 27 Nov 2001 09:37:15 +0100 Subject: question: metaclass and C - a new general style References: <3c02343d@netnews.web.de> Message-ID: cuiod-tec at web.de (Jens Gelhaar) writes: > I dont like to create an class and make instance of it, to get > callable object and use it as ancestor. In the original hook, you couldn't use a Python object as the base class, only a C function, so it was restricted to C only. Today, you don't have to create a class and make an instance of it. A plain Python function would do as well. Of course, you still don't have to like it :-) > What do you thing about it? If you want to use proper metaclasses, I think you should use Python 2.2. Regards, Martin From steve at ferg.org Thu Nov 15 09:30:18 2001 From: steve at ferg.org (Stephen Ferg) Date: 15 Nov 2001 06:30:18 -0800 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> Message-ID: Of possible interest to those reading this thread. I'm a REXX programmer who is transitioning to Python. I've started a small web page with information to help other folks who are also making the transition from REXX to Python. It is: http://home.att.net/~stephen_ferg/rexx2python/ If you have something that you think might be useful to put there, let me know. I can be reached at steve at ferg.org -- Steve Ferg From ws at mystrobl.de Fri Nov 30 17:40:08 2001 From: ws at mystrobl.de (Wolfgang Strobl) Date: Fri, 30 Nov 2001 23:40:08 +0100 Subject: Non-Indented python References: Message-ID: On Fri, 30 Nov 2001 14:57:20 -0500, "Tim Peters" wrote : >[Michael Abbott] >> There doesn't seem to be an environment variable which can pre-set >> command line options, so I'll have to do something more tricksy to get >> -tt set by default. > >A .bat file is easiest on Windows. I prefer changing the registry key HKCR/Python File/Shell/Open/Command from "H:\Python21\python.exe" "%1" %* to "H:\Python21\python.exe" -tt "%1" %* on W2K. E:\>test.py TabError: inconsistent use of tabs and spaces in indentation (test.py, line 3) -- Thank you for observing all safety precautions From a.baan at fokkerspace.nl Fri Nov 2 11:20:27 2001 From: a.baan at fokkerspace.nl (Arno Baan) Date: Fri, 02 Nov 2001 17:20:27 +0100 Subject: Embedding Python in C/C++ References: <3BDE8130.CB1CE86B@fokkerspace.nl> <3BDE877B.37D1E09@fokkerspace.nl> <1004460136.619849@rexx.com> Message-ID: <3BE2C7CB.FE50D8E3@fokkerspace.nl> Thanx, but for now I think I have all the answers I need. I found a very helpful example on: http://www.btinternet.com/~benjamin.geer/python/embedding.html I'm sure I'll have a whole lot of other questions soon. But for now, Thanx. arno Dave Kuhlman wrote: > Yes it is possible to embed the Python interpreter in a C/C++ > application. Yes it is possible to evaluate Python scripts from > within C/C++ code. And yes, Python was intended for this purpose. > > Suggestions: > > 1. Read "Extending and Embedding the Python Interpreter" in the > standard Python documentation. > > 2. Work with the examples in Demo/embed in the Python source code > distribution. > > 3. Look at the function PyRun_SimpleString (in Section 2 of > "Python/C API Reference Manual" in the standard Python > documentation). > > 4. Ask some more questions. > > - Dave > > Arno Baan wrote: > > >I'm trying to find out wether Python is the answer to my problem. > >I want to write a C/C++ program wich takes a XML input. > >This input will also contain functions in a scripting language > >(python?), that can > >directly access objects in the main C program. > >Is this possible and can someone perhaps give me an example of > >something > >like this being done? > >I'm completely new to Python. > > > > > Oeps Sorry, > > > > wrong name and e-mail adress above the preivious mail. > > The name should be arno baan and the adress a.baan at fokkerspace.nl > > Help is still needed though. > > > > thanx arno > > > > -- > Dave Kuhlman > dkuhlman at rexx.com > > -----= Posted via Newsfeeds.Com, Uncensored Usenet News =----- > http://www.newsfeeds.com - The #1 Newsgroup Service in the World! > -----== Over 80,000 Newsgroups - 16 Different Servers! =----- From kuran42 at yahoo.com Thu Nov 15 14:26:30 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Thu, 15 Nov 2001 14:26:30 -0500 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> <97ae44ee.0111140921.281c4b7@posting.google.com> Message-ID: <3BF416E6.8060603@yahoo.com> If you're looking for maximum performance, dump threads. SocketServer's documentation itself points out that the synchronous implementation is not the best way to go. But before you abandon the SocketServer module, try twiddling the listen parameter. You can do this most easily by overriding the BaseServer method server_activate. Try setting it at about the value of NUMTHREADS. Stephen wrote: > [snip] > > Results ~ > > When NUMTHREADS = 2, 200 requests are handled in < 0.5 secs > When NUMTHREADS = 5, 500 requests are handled in 2.5 secs > > But when NUMTHREADS = 20, half the threads die with this error : > Unhandled exception in thread: > Traceback (most recent call last): > File "", line 6, in send_request > File "", line 1, in connect > socket.error: (10061, 'Connection refused') > > and it just gets worse when NUMTHREADS = 50. > > I'm guessing this means that the server is max'ed out and > can't handle any more. > > How should I handle this error ? Yes, with a "try/except" > but what should the "except" do, because if the server is > too busy, it's probably no point retrying immediately. > > So, you see, I was looking for something more immediate than > SMTP, that also takes care of the message queueing. Writing > code to manage the queue and buffering could be horrendous. > > Is there any way to get this up to say 1,000 requests/sec peak load ? > > In reality, I'm going to want to put some Database query > into the RequestHandler too so it'd be even slower. > Does this sound possible ? > > Am-I-asking-too-much-of-Python-ly-your's, > > Stephen > -- 1.79 x 10^24 furlongs per picofortnight - It's not just a good idea, It's the law! -- 2:06pm up 12 days, 16:25, 2 users, load average: 0.00, 0.01, 0.01 From jgardn at alumni.washington.edu Wed Nov 28 10:03:10 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 29 Nov 2001 00:03:10 +0900 Subject: [OT] Flame War (python, perl, vi, emacs, the works!) In-Reply-To: References: <3bfd7f87@news.airtel.net> Message-ID: <01112900031006.13207@linux> Now let us begin the monthly flame war... > > Real Programmers use Emacs. > IANARP =) But I play one on TV. > [So do I. But not usually for Python; I hardly ever write any Python, > and when I do I usually just type it at the prompt -- no editor] AACK! You should be using *perl* for that... Python is great for large projects; perl is great for one liners. Rinse, repeat. [no editor??? I'll pass on that...] > > * In case you're wondering what editor I use, let me just say that it > > works really well with the email client that sucks less than all the > > others. > > That's Gnus. So you use Emacs! > Err... you *DO* know the slogan for mutt, right? "The email client that sucks less than all the others." > Right? Do I win a chocolate fish? :-) <>< Enjoy. Have another... <>< Jonathan * No harm intended... just fun for fun's sake. From emile at fenx.com Thu Nov 1 16:08:00 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Nov 2001 13:08:00 -0800 Subject: Why 'self' ? References: Message-ID: <9rsdsv$ucnqc$1@ID-11957.news.dfncis.de> wrote in message news:mailman.1004637301.1483.python-list at python.org... > > Tim wrote: > >plus-llambda-will-be-spelled-with-two-els-ly y'rs - tim > > Finally! BTW, do we pronounce that "yam-duh" ? > > Jim > > > Yes, when it's with 2-l's, but when you use 3-l's, the d goes silent as well, giving: 3-l-ahm-ah Which-is-a-really-big-fire-ly y'rs -- Emile van Sebille emile at fenx.com --------- From skip at pobox.com Fri Nov 16 03:35:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 09:35:40 +0100 Subject: Are there any list comparison optimizations in Python? In-Reply-To: References: <3BF0883B.62473129@engcorp.com> Message-ID: <15348.53212.143300.926158@beluga.mojam.com> Huaiyu> So my question really is this: Is there any major practical use Huaiyu> for an object to be unequal to itself? Would it be better to Huaiyu> just define (a==b) to take a shortcut of (a is b), always? The "is" operator is defined to just do pointer comparisons. Here are just three different ways to generate objects that are equal but not "is": >>> a = 457 >>> b = 99+358 >>> a is b 0 >>> a == b 1 >>> a = "now is the time..." >>> b = " ".join(a.split()) >>> a is b 0 >>> a == b 1 >>> a = [1] >>> b = [1] >>> a == b 1 >>> a is b 0 In the first two cases perhaps Python could make sure that a and b shared references to the same object, but I think that would require the interpreter to do a lot more work just to maintain that consistency. In the last case you most definitely don't want "is" and "==" to be synonyms. That would imply that a and b referred to the same object. If they did, any list-modifying methods applied using one name would be reflected when that object was viewed using the other name, which is generally not what you want for mutable objects. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) It's only a 25% solution to our problems. Of course, we only want to solve 25% of our problems, so it becomes a 100% solution. From ngps at post1.com Tue Nov 27 11:02:45 2001 From: ngps at post1.com (Ng Pheng Siong) Date: Wed, 28 Nov 2001 00:02:45 +0800 Subject: HOWTO: Programming S/MIME in Python with M2Crypto In-Reply-To: ; from graeme@saebex.com on Tue, Nov 27, 2001 at 08:48:44AM +0200 References: <20011127001748.B783@madcap.dyndns.org> Message-ID: <20011128000245.C1025@madcap.dyndns.org> On Tue, Nov 27, 2001 at 08:48:44AM +0200, Graeme Longman wrote: > From my understanding you don't need to make any changes to Outlook to > receive digitally signed mail. I think you do need to install your own CA cert, at least. The ZSmime HOWTO describes the procedure for Netscape Messenger. I don't remember off-hand if the S/MIME HOWTO does so. > I have been using your your HOWTO to generate the certificates and the mime > string of the signature. I have also managed to get the example, Sending > S/MIME messages via SMTP, working with Outlook. I can't seem to get the > earlier examples working though. I have tried fiddling with the mime string > before sending it via SMTP but haven't had much luck. The same error > message, "Can't open this item. An error occured in the underlying security > system" always seems to 'pop-up', even though the actual mime of the email > seems to correspond exactly to a working example. Which ones fail: sign only, encrypt only, sign and encrypt? Self-signed certs or plain certs signed by your home-grown CA? > I know that in the HOWTO you don't actually send the example in 'Sign' but > have you managed to send and receive this example. If you have successfully > then maybe it is the 'Outlook' issue. The function sendsmime() in sendsmime.py works: I've used this to send to Netscape Messenger successfully. sendsmime() sends plain, signed, encrypted or signed-and-encrypted mail. I remember being quite pleased with myself when I got that done. ;-) Also, in demo/smime (not demo/smime.howto), there are the files ns.p7 and ns.se.p7 which are generated by Messenger. M2Crypto.SMIME groks these. (Although no longer, I think those demo certs have expired.) And, you may have noticed ZSmime, which is a S/MIME-sending product for Zope. ZSmime interoperates with Messenger, too. (Well, it should, since ZSmime is based on M2Crypto.SMIME.) -- Ng Pheng Siong * http://www.post1.com/home/ngps From tim at bladerman.com Thu Nov 1 07:59:20 2001 From: tim at bladerman.com (Tim Gahnström /Bladerman) Date: Thu, 01 Nov 2001 12:59:20 GMT Subject: Dictionaries, popitem() method example References: <9rr6p5$psi$1@usenet.otenet.gr> Message-ID: "Antonios B. Kaklis" skrev i meddelandet > In the Python Library Reference, Section 2.1.6 "Mapping Types" > It says: "a.popitem( )" --->Note 6: Is useful to destructively iterate over > a dictionary as often > used in set algorithms! > > I don't understand 1) what is "Destructively iteration over a dictionary" This means that popitem() will return an item from the dictionarry and also remove it from the dictionarry. eg. >>> a={1:"a", 3:"b", 5:"c"} >>> a {5: 'c', 3: 'b', 1: 'a'} >>> a.popitem() (5, 'c') >>> a {3: 'b', 1: 'a'} first we creat a dictionary called a Then we look what is in it Then we pop out one item, Then we look what is left in a wich is the dictionarry - what we popped out. usually you use it to loop (=itterate) over all elements in a dictionarry. eg. >>> def loop(dict): ... print dict.popitem() ... loop (dict) ... >>> loop(a) (5, 'c') (3, 'b') (1, 'a') Here comes an errormessage because we have printed all elements in the dictionarry and now it is empty so we canot pop anymore. > 2) Set Algotithms A set is a colection of items, usually representet in Python by Dictionarys. Algorithms involving Dictionarrys can therby be called Set algorithms. Gl Tim From julien.keable at polymtl.ca Wed Nov 21 13:28:51 2001 From: julien.keable at polymtl.ca (Julien Keable) Date: Wed, 21 Nov 2001 18:28:51 GMT Subject: Py_Initialize / Py_Finalize crash Message-ID: <3BFBF264.ADB09F47@polymtl.ca> Hello, I'm trying to run python scripts from a c++ program. I need to have a fresh interpreter everytime I run a script, because the script can be modified between two runs (think of my program as a debugger). It works, but after 7-8 runs, python breaks on a invalid DECREF (internal to python code) or something like that. After trying to pinpoint the problem, I came up with this rather simple snippet, which still produces the error: for(int i=0;i<1000;i++) { Py_Initialize(); Py_Finalize(); } I'm using python 2.0 debug version. Is there another way I can "reset" the interpreter state without having to call initialize and finalize? Julien Keable From johannh at uclink.berkeley.edu Thu Nov 29 18:05:24 2001 From: johannh at uclink.berkeley.edu (Johann Hibschman) Date: 29 Nov 2001 15:05:24 -0800 Subject: A modest indentation proposal References: Message-ID: gat at jpl.nasa.gov (Erann Gat) writes: > 2) Parser support. It would be enough to simply give a warning if there > is a discrepancy between the block structure defined by indentation and > that defined by the semicolon-at-end-of-line convention (i.e. "Warning: > end of block detected without trailing semicolon"). Making this optional > so that die-hard indentation fans could turn it off would also be fine. This just seems to add extra complexity to me, without any useful payoff. I'd rather not have to worry about semicolons messing up the nice, clear indentation-based blocking. In short, I'd rather that you not be able to screw up the indentation and still have it work. If you use pure spaces, no tabs, then there is no problem with indentation at all, so I recommend doing that. Well, the only problem is the occasional whitespace-eating nanovirus. How often do you really cut and paste code? And if you do, what's wrong with simply indenting to fit its current locale? If this is harder than highlighting the pasted code and hitting some command key, I'd recommend a different editor. --Johann From simonb at webone.com.au Tue Nov 13 19:19:00 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Wed, 14 Nov 2001 11:19:00 +1100 Subject: Python Vim Module - works References: Message-ID: <3BF1B874.3060506@webone.com.au> Well this sounds interesting... i compiled vim60 with CONF_OPT_PYTHON = --enable-pythoninterp in the Makefile, but "import vim" fails. what next? Simon Burton Jonathan Gardner wrote: >I got it all to work. Thanks to a contribution by Tomas Zellerin, and a few >more hacks, I think it all looks good. > >I need some help to make it professional. > >It's 2:00 AM here in Seoul, so I won't be getting any answers out for a few >hours... =) >If you can get it to compile (just edit the Makefile to make it point to >the right place...) try this with Vim 6.0: > >$ gvim --servername TEST >$ python > >>>>import vim >>>>vim.list() >>>> >['TEST'] > >>>>vim.send('TEST', 'iHello World!') >>>> > >You should see the string "Hello World!" neatly typed into the newly opened >vim window!!! > >Sorry, X11 only right now... > >Jonathan > >[ Note: This was cross-posted to vim-dev and python-list so I can go to bed >sooner... ] > From s713221 at student.gu.edu.au Sat Nov 3 18:51:49 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sun, 04 Nov 2001 09:51:49 +1000 Subject: python development practices? References: Message-ID: <3BE48315.8BFFA63E@student.gu.edu.au> James_Althoff at i2.com wrote: > > Peter Wang wrote: > >thanks for the warning. we're adopting the convention of all data is > >default private (unless in a rare, commented exception case), using > >get/set functions, and the rule of "if it ain't in the unit test, > >don't use it." > > Bravo. (Yet another victory for the _Anti_Underscore_Secret_Society__) > > Jim Don't be fooled everyone, the AUSS is just a front for the PS... -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From jmsun at bioeng.ucsd.edu Mon Nov 5 18:55:06 2001 From: jmsun at bioeng.ucsd.edu (Jeffrey) Date: 5 Nov 2001 15:55:06 -0800 Subject: importing a tcl/tk widget Message-ID: <3daa1aa8.0111051555.125dbd8e@posting.google.com> Hi All, I wanted to know if anyone knew of a way to import a tcl/tk widget into a Tkinter canvas widget. I know that you can write a Tkinter wrapper function but I don't really know how to do this. If anyone can help, and/or point me to a good website/book that would be great thanks. Jeff From hfoffani at yahoo.com Thu Nov 1 09:31:49 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Thu, 1 Nov 2001 15:31:49 +0100 Subject: hola nesesito su ayuda References: Message-ID: <20011101093233.323$pg@news.newsreader.com> "fernando orellana" escribi? en el mensaje news:mailman.1004561073.27938.python-list at python.org... > hola que tal soy leandro vivo en un pueblito de argentina y > estudio analista de sistemas. Hay una lista de correo de python en castellano: python-es la vas a encontrar en: http://www.aditel.org/listas_correo/ Segu? las instrucciones en esa pagina para suscribirte. python-es is a mailing list in spanish that covers python language issues. -Hernan hfoffani at yahoo.com From phr-n2001d at nightsong.com Mon Nov 5 20:38:24 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 17:38:24 -0800 Subject: Program very slow to finish References: <3BE737A8.8CF867A5@chello.nl> Message-ID: <7xwv1465m7.fsf@ruckus.brouhaha.com> Roeland Rengelink writes: > An optional object allocator has been included. This allocator is > optimized for Python objects and should be faster and use less memory > than the standard system allocator. It is not enabled by default > because of possible thread safety problems. The allocator is only > protected by the Python interpreter lock and it is possible that some > extension modules require a thread safe allocator. The object > allocator can be enabled by providing the "--with-pymalloc" option to > configure. I'm surprised Python doesn't already do something like this. I hope it can be on the wish list for a future release. From Georg.Bisseling at pallas.com Fri Nov 9 09:22:38 2001 From: Georg.Bisseling at pallas.com (Georg Bisseling) Date: Fri, 09 Nov 2001 15:22:38 +0100 Subject: Calling Ghostscript from Python References: Message-ID: <3BEBE6AE.C7A33CF4@pallas.com> Kerstin wrote: > > Hi, > > I'm trying to call the ghostscript to convert some PS to PDF. I'm > working on Win95, so the os.system() always returns '0'. > When the cmd is running, the DOS-Box opens and I get the error message > "File or directory not found". > I also checked if the PS are readable; and when I change the cmd to > something else (like "md new_dir") it works. > > ghost_dir = 'c:\ghost\gs\gs7.00\lib' > cmd = ghost_dir + '\ps2pdf13.bat ' + ps_file + ' ' + pdf_file > os.system(cmd) > > I think there must be something wrong with the pathname or rather the > ghost environment. How can I check this? > I'm using full pathnames for 'ps_file' and 'pdf_file' too! Might this > cause problems? > > Can anybody help me? > Thanx, > Kerstin ghost_dir = 'c:\\ghost\\gs\\gs7.00\\lib' cmd = ghost_dir + '\\ps2pdf13.bat ' + ps_file + ' ' + pdf_file should do the trick. You should use os.path.join to join pathnames platform independent. From jim at interet.com Mon Nov 12 10:02:59 2001 From: jim at interet.com (James C. Ahlstrom) Date: Mon, 12 Nov 2001 10:02:59 -0500 Subject: [Python-Dev] Re: Proposal for a modified import mechanism. References: <3BED6E5B.8E142057@arakne.com> <033301c16a1a$59c1c690$c300a8c0@ericlaptop> <3BED9F9A.30F77DB3@arakne.com> <038301c16a73$70c5f790$c300a8c0@ericlaptop> Message-ID: <3BEFE4A3.63DF1A21@interet.com> eric wrote: > (and see) 0% overhead for importing standard modules (by far the most > common case). Adding 10% overhead to importing a very large package > with 10-15 nested sub-packages is just not a big deal. The 350% cost I > saw (noted in a response to Gordon) is a *huge* deal and would need to be > solved (moving to C would help) before this became standard. I have code which caches directory contents, and related benchmarks. This might help, and could be combined with a new Python module for importing packages, say, as a new method "importer" in __init__.py. Please see python-dev, "Caching directory files in import.c". JimA From root at [127.0.0.1] Sun Nov 4 08:23:13 2001 From: root at [127.0.0.1] (nobody) Date: Sun, 4 Nov 2001 23:23:13 +1000 Subject: Raw input buffer Message-ID: <3be54141$0$15992$afc38c87@news.optusnet.com.au> How would 'peek' to see if there's data waiting to be read in the input (stdin, or I suppose any such stream like a tty) buffer, and optionally read it raw (ie. just what is currently in the buffer, without waiting for a )? thanks. From a.clarke11 at pop.ntlworld.com Wed Nov 28 18:40:40 2001 From: a.clarke11 at pop.ntlworld.com (a.clarke11) Date: Wed, 28 Nov 2001 23:40:40 +0000 Subject: 1st day newbie question. References: <_79N7.7778$Wd.2905531@news1.rdc1.az.home.com> Message-ID: <3C0575F8.A208F8C6@pop.ntlworld.com> I found that most of them are written as modules, and can be opened up with a text editor, or any word processor eg MS Word, as long as they are saved afterwards as text. It's a great way to learn how a program works, as you can alter the text file, and then run it in the interaxtive interpreter, and see the changes you made taking effect. I hope this answers your question. I've been learning Python for four months, its great. Tony Clarke From ws-news at gmx.at Tue Nov 20 08:30:09 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 20 Nov 2001 14:30:09 +0100 Subject: object identity and equivalence References: <3bf9532b_1@mk-nntp-1.news.uk.worldonline.com> Message-ID: <3bfa5ba6@brateggebdc5.br-automation.co.at> Hi, it obviously depends if the two occurences are fed into the compiler at the same time or not. Trying the following script (not interactive shell) x = 10.0 y = 10.0 print "x is y", x is y outputs x is y 1 on my machine. hth Werner "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9vkjt8.i79.qrczak at qrnik.zagroda... > Mon, 19 Nov 2001 18:44:16 -0000, Sandy Norton pisze: > > >>>> x = 10.0 > >>>> y = 10.0 > >>>> x is y > > 0 > > The result is different when the first two statements are written in > one line: > > >>> x = 10.0; y = 10.0 > >>> x is y > 1 > > So identity of builtin immutable types is indeed very ill-defined. > It depends on line breaks. It depende whether statements are entered > interactively or they come from a script. And of course it may be > different in other versions of the interpreter. > > -- > __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ > \__/ > ^^ > QRCZAK From prabhu at aero.iitm.ernet.in Mon Nov 5 03:13:24 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 5 Nov 2001 13:43:24 +0530 Subject: Python packages - problems, pitfalls. In-Reply-To: <3be602d3.635600718@news1.on.sympatico.ca> References: <3be602d3.635600718@news1.on.sympatico.ca> Message-ID: <15334.18980.964206.847919@monster.linux.in> hi, >>>>> "RR" == Robert Roy writes: Thanks for the response. >> package. Inside this directory I have a sub-package, called >> sub. So its something like: >> >> pkg/ __init__.py a.py sub/ __init__.py b.py >> >> Now, from b I'd expect to be able to import 'a' straight away. >> RR> Why would you expect that? a.py has no relationship to RR> b.py. It is not a sibling module, it is not a parent. I beg to differ. It depends on how you look at it. a.py is certainly in the same package. a is part of pkg b.py is also part of pkg. Atleast, it should be possible to access b by using something like os.pardir without having to know what package a is part of. Apparently ni[1] used to do this. But this was removed later. Allowing for this also makes sense, IMHO. The syntax was a little dirty, I'll admit, but it makes sense. Let me put it this way. How are names looked up in normal Python code? First you check in the local namespace, then you keep going higher and higher up the tree until you are out of all local namespaces, then you try with the global namespace. This makes sense and is consistent. So, why isn't the same thing implemented for packages? >> Say in b.py I do >> >> import a >> >> This will not work! I know why it happens but shouldn't Python >> be smart enough to avoid such problems? Why I consider this a >> major problem is that the importing of a sub-package depends on >> where its parent package is!! RR> Its a good thing it doesn't. It would be a maintenance RR> nightmare. Please elaborate. Atleast provide one example. Its easy to say "its bad" - please elaborate as to how it is bad. RR> See Tim Peter's rules of python programming: Explicit is RR> better than implicit Hmm, this is violated when you speak of 'sibling' packages. As per the above rule why should this be valid? par_pkg/ __init__.py sub/ __init__.py a.py b.py b.py: import a ? Which is correct but is _definitely_ not explicit. Technically by wanting explicit names you are saying that b.py should say: import par_pkg.sub.a and not (and in the above path lies madness since if par_pkg is re-nested you have to refactor everything) import a IMHO this completely violates the above rule. If you suggest to use explicit names - do it all the time. Why is it correct for packages in the same directory to access each other without using explicit names?? If this is consistent then it certainly makes sense to check higher up the package structure as well. RR> Frankly if I had a situation as you describe above, I would RR> take a good look at why I had structured my modules that RR> way. Most likely I would find that the module structure had RR> outlived its usefulness and needed to be redefined/refactored. Well, in my reply to Chris Gonnerman[2] I gave another example of a problem and mentioned a real world project that had problems with this issue. Let me add -- the problem with SciPy[3] was that several packages that were developed standalone were being put together into another bigger package. Each package had a perfectly valid package structure. The problem arose simply because the packages were put inside another larger package. So this problem is not merely an issue with the correctness of a particular packages structure but with the handling of packages and names as a whole. >> So if pkg is no longer the root of the package and say its put >> inside another BigPkg then to make pkg's sub packages work >> you'd have to edit *all* the sub packages and change every >> reference to pkg.a to BigPkg.pkg.a. This is a huge pain. RR> Use a ".pth" file to tell it where the package resides. Say RR> you re-nest pkg into BigPkg, place a file called pkg.pth in RR> the root directory of your distribution and put the location RR> of pkg in it. See the documentation on module "site". Of course, and this will truly be a maintenance nightmare. Doing this will mean that you have exposed all names inside BigPkg to the outside world as such. This might be the problem you are trying to address in the first place by putting pkg and friends inside BigPkg! In fact this is something like simply doing the following inside the __init__.py of my pkg example: sys.path.append(os.path.dirname(__file__)) I did not even mention this as a solution since this is definitely incorrect and bad practice. RR> for example (not tested!): Python root RR> pkg.pth (contents would be Lib/BigPkg/pkg) RR> Lib/ BigPkg/ __init__.py pkg/ __init__.py RR> This will allow old pkg references to continue working. Sure, but this does not solve the problem I mention in [2] and has problems that I mentioned above. >> Are there better ways to get around this packaging problem? >> Is this a know problem that folks are working on?? Why is it >> that Python does not deal with this issue more sensibly? RR> Python does, it is not terribly well documented though... Sorry, I don't agree. Python does not do it the way I'd expect. As to whether my expectation is reasonable or not is a different issue but I find no reason as to why my expectation is not reasonable. Thanks again for the response, prabhu References: 1. http://www.python.org/doc/essays/packages.html 2. http://mail.python.org/pipermail/python-list/2001-November/070766.html 3. http://www.scipy.org -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 From db3l at fitlinxx.com Tue Nov 6 17:39:18 2001 From: db3l at fitlinxx.com (David Bolen) Date: 06 Nov 2001 17:39:18 -0500 Subject: split(None) References: <9s98o6$ilj$1@isp-m-srv06.izb.net> <9s9aii$121pt9$1@ID-11957.news.dfncis.de> <9s9b17$ilj$2@isp-m-srv06.izb.net> Message-ID: Oliver Fromme writes: > Yes. I've just exited from the python interpreter, restarted > it, and now it works fine, too. I guess I must have broken > something during experimentation in my previous interpreter > session. Don't ask me how I did that ... :-( Maybe accidentally rebound "None"? :-) -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From db3l at fitlinxx.com Mon Nov 5 18:33:28 2001 From: db3l at fitlinxx.com (David Bolen) Date: 05 Nov 2001 18:33:28 -0500 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> <7xn1257h0d.fsf@ruckus.brouhaha.com> <9s1n66$co7$1@bob.news.rcn.net> Message-ID: "David Abrahams" writes: > (...) In general it is not so > important to know exactly which exceptions can be thrown -- you can always > handle anything with except: (or catch(...) in C++); all that's lost is the > ability to report errors accurately. That's a loss, but not as serious a > loss as what you give up when you don't know: You should still be able to report the cause of the exception accurately even in the catch-all case. You've got the sys.exc_info() information to decode and/or print a traceback if you want. Or, you could use something like: except Exception, value: (...) to get a normal exception instance. Of course, the latter will only catch class-based exceptions, so you'd still need a raw except: if you might get string exceptions. This sort of thing can be very helpful as a last ditch catch-all exception handler in an application that can print out a nice traceback to a log or something, and then restart a master loop in an application to provide at least a restart mechanism in the event of unanticipated failure. -- -- 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 James_Althoff at i2.com Thu Nov 8 18:33:27 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 8 Nov 2001 15:33:27 -0800 Subject: iters on ints? (reducing the need for range/xrange) Message-ID: [jim] for i in 10: doSomething(i) [Rainer and Emile] I like it. Sounds good. [Steve] If "for i in 10:" was legal, I'ld guess it meant the same thing as "for i in [10]:" or "for i in (10,):" A file *IS* a sequence -- although you could just as easily slice it by characters as lines -- or by any arbitrary object for binary files, as Pascal does. If the integer 10 suggests any sort of sequence, it's the singleton sequence containing: 10. [jim] On the other hand, 2.2 takes us away from the concept of "suggesting a sequence" in the context of for-loops. Instead, the new for-loops are *iterator*-protocol based (not *sequence*-protocol based). They iterate over something that *is* or *can return* an iterator object. So under the proposed scenario, if one looks at 10 and asks "if 10 were to return an iterator, what would that iterator iterate over?", then it seems that range(10) would be a more *useful* answer than a sequence of one element 10. Jim From fdrake at acm.org Fri Nov 9 03:23:16 2001 From: fdrake at acm.org (Fred L. Drake) Date: Fri, 9 Nov 2001 03:23:16 -0500 (EST) Subject: [development doc updates] Message-ID: <20011109082316.750AD28697@beowolf.digicool.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ A variety of miscellaneous updates have been made over the past several days, most involving typographical or grammatical corrections. Some small clarifications have been made. From jdadson at ix.netcom.com Mon Nov 5 21:49:47 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 06 Nov 2001 02:49:47 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: <3BE74FA6.8AFC0D95@ix.netcom.com> Tim Peters wrote: > ... > > BTW, the "exactly 3 of each quotient" goes a long way toward explaining why > floor division is less error-prone in practice (for newbies and experts): > the "weird lump" around 0 doesn't exist. I liken it to a kink in a hose. The mod operator (in Python at least) wraps the number line into a coil. If you use the other semantics, the coil has a kink in it at zero where the coil changes direction, like a clock suddenly deciding to run backwards. Jive From jgardn at alumni.washington.edu Thu Nov 29 20:38:00 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Fri, 30 Nov 2001 10:38:00 +0900 Subject: The Ideals of a Python Hacker (was: Poll Results) In-Reply-To: References: <3bfd7f87@news.airtel.net> Message-ID: <200111300141.fAU1f8T21380@my.knctv.co.kr> On Friday 30 November 2001 07:39 am, Roy Katz wrote: > (and I find that Python fits in with my youthful ideals nicely among > others such as Esperanto & being vegan) > Interesting... how does Python and veganism go together? Isn't veganism just about taking care of the animals and your body? What does Python care about the animals or your body? > I remember a long thread about Esperanto and Python ideals. I rather > enjoyed that. In fact there are some Esperantists here (Bill Harris > of the Python Tutorial in Esperanto, Erik Max Fancis, Peter > Hansen (?), Konrad Hinsen); I wonder if there any vegens here, > too. > Python and Esperanto: Esperanto was invented for being a useful, simple language that could be learned by almost any culture. It tried to limit the number of expressions for a single idea, making it difficult to express things that may not be understood or misunderstood. That is the same with Python. English and Perl (TMTOWTDI), and Esperanto and Python. Personally, the only ideal I agree with in Python is Practicality. It really *is* easier, it really *is* useful, and it really *is* debuggable, so why would you want to use C++ when you have Python? Go with what works, and avoid what doesn't. > it'd also be cool to see the relative age of new pythonistas -- I suspect > that they're young, but this is completely unfounded. > They'd have to be. I can't seem to find a place to get paid to work in Python yet. I can't imagine a guy with 3 kids trying to make a living by programming python unless he is the rare guy that has a job in it. Reminds me of the Perl community at first. They were all young, once. Young rebels, challenging the C/awk/sed paradigm. Young rebels, willing to write a bit of glue code in a young language developed by a young sysadmin... Now some of them look like they are advancing in years, and the Perl community is almost as mainstream as it gets in programming fads. Jonathan From kevin at cazabon.com Fri Nov 16 14:00:32 2001 From: kevin at cazabon.com (Kevin Cazabon) Date: 16 Nov 2001 11:00:32 -0800 Subject: Extending with C/C++ References: <5a4226f0.0111142234.33ea1590@posting.google.com> <3BF36FE4.EAC8F175@ieee.org> Message-ID: <5a4226f0.0111161100.79c43d00@posting.google.com> Thanks John, I appreciate the help. I think I've got it mostly worked out manually in the meantime, but I'll probably have to start over again to get it "clear" for next time. I do keep getting an unresolved external when I try to compile, relating to PyInitModule... very frustrating. I guess all these years programming in Python makes it very frustrating to do anything in C/C++ any more! q:] Kevin. "John D. Gorman" wrote in message From fredrik at pythonware.com Wed Nov 7 12:14:45 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 17:14:45 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> Message-ID: <9_dG7.4762$R43.760792@newsb.telia.net> Samuel Krempp wrote: > I figure it should be quite simple to implement a program that > translates scripts where blocks are expressed by traditionnal block > markers like '{' and '}' (or whatever else..) into a well indented > python script. Tools/scripts/pindent.py From dlakelan at sil-no.spam-con.com Thu Nov 15 13:00:40 2001 From: dlakelan at sil-no.spam-con.com (Daniel Lakeland) Date: Thu, 15 Nov 2001 10:00:40 -0800 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> Message-ID: In article , "Tim Bradshaw" wrote: > Paul Rubin wrote in message > news:<7xy9l9ne1b.fsf at ruckus.brouhaha.com>... >> >> However, most Lisp compilers have depended on type declaration pragmas >> to generate good code, AFAIK. Python would need a language extension >> to support something like that. > > I don't think this is really true for many interesting programs. It is > very definitely true for *some* kinds of programs, for instance things > that do heavy numerical work, and almost all of the trivial, stupid, > non-benchmarks that people use to decide that `language x is faster than > language y' so they can flame on inappropriate newsgroups (cll readers > will be familiar with this). > > However a lot of programs spend a lot of time doing stuff where the > typechecking overhead seems to be in the noise. Anything that's > building and manipulating large complex data structures is probably > spending a lot of its time chasing pointers and worrying much more about > cache misses and so on than exact details of types. > > As an example, I have a system (in Lisp) which parses structures from a > stream, amd then does various manipulations on them. It has bnasically > no declarations in it. I spent a little time profiling it, and someone > else did some more work. He found a few places where type declarations > help some - mostly declarations that things are better-sorts-of-arrays > so array ndexing can do better (the parser reads into buffers which are > arrays because a lot of what it generates is strings). We got between 1 > and 5% speedup. We might not have found the big problems of course, but > really, it looks like type declarations don't help here much at all. On a similar type of program I worked on in CMUCL it would run plenty fast at home on my 233 MHz PII and then when I took it to work and ran it on a 400 Mhz Sparq or something like that, it would be a dog. Turned out that consing was a big problem, and the x86 had a generational collector, whereas the Sparq had a mark-sweep. changing some functions to be non-consing, and changing the interval between GCs to be about equal to the expected image size made it MUCH faster. (I was GC'ing every 2MB on an image that had about 25-30 MB of static in-RAM data, Every 10 seconds or so I'd cons up about 100 MB, so GCing every 30 MB makes consing amortized to O(n) instead of O(n^2). With the generational collector, consing was already O(n). -- Daniel Lakeland dlakelan at endpointcomputing.com http://www.endpointcomputing.com From bh at intevation.de Tue Nov 6 10:17:15 2001 From: bh at intevation.de (Bernhard Herzog) Date: 06 Nov 2001 16:17:15 +0100 Subject: Python packages - problems, pitfalls. References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: Prabhu Ramachandran writes: > I have an application that is shipped as part of a package. I'd like > the application to run right off the main directory or when the > package is installed. Also lets add to the problem by saying that the > project is under CVS and its a pain putting everything into another > directory. Something like this: > > pkg_root/ > __init__.py > app.py > # app is the application that is not part of the package If it's not part of the package, why is it in pkg_root? Put it somewhere outside of pkg_root, make sure pkg_root is in a directory on Python's path and everything should be fine. > Also, irrespective of whether people have run into such problems or > not, don't you think it makes sense for modules to be searched the way > I had suggested earlier?? Or is there some serious issue with this. The name search rules for packages are more or less the same as for local variables in functions, at least when packages were introduced. With nested scopes that similarity will be gone, though. Anyway, you may want to search a bit through Python's history. Python 1.3 introduced the first stab a packages of modules with a mechanism called "ni" which had a much more elaborate name resolution scheme. One part of it was "expanding search" which would automatically look in a package's parent package and so forth and it had a way of referring to a module's package (by the variable __) and to package's parent (__.__). The ni module is still there, but it's deprecated since the new builtin package support was added in 1.5 and therefore now lives in lib-old. Guido's essay about the builtin package support has some comments on the reasons behind the differences between ni and the current scheme: http://python.org/doc/essays/packages.html Bernhard -- Intevation GmbH http://intevation.de/ Sketch http://sketch.sourceforge.net/ MapIt! http://mapit.de/ From barry at zope.com Tue Nov 6 01:06:30 2001 From: barry at zope.com (Barry A. Warsaw) Date: 06 Nov 2001 01:06:30 -0500 Subject: python-mode for Emacs 21.1? References: Message-ID: >>>>> "RS" == Roman Suzi writes: RS> * I wonder why python-mode not in standard Emacs distro... Stupid licencing issues. :( Grab it from http://www.python.org/emacs/python-mode/ -Barry From tim at vegeta.ath.cx Tue Nov 27 20:01:19 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 28 Nov 2001 01:01:19 GMT Subject: Perl to Python References: <9u0si9$hc1$1@slb7.atl.mindspring.net> Message-ID: Andrew Dalke graced us by uttering: > > Tim Hammerquist: >>Pipes can be opened using os.popen(). Pipes can be read/written >>by reading from/writing to the file object returned by >>os.popen(). Read from this as normal in Python, just as you're >>reading from the SQL filehandle in the perl code. >> >> # Perl open PIPE, "ls /etc" or die "can't read from pipe: >> $!\n"; print while ; close PIPE; >> >> # Python (roughly) pipe = os.popen('ls /etc') while 1: line >> = pipe.readline() if not line: break print line retval = >> pipe.close() > > The Python isn't quite equivalent to the Perl since 'print' adds > the newline after printing. You'll either need to chomp off the > final newline or use sys.stdout.write(line). Why not just print line, ?? Or you could be really counterintuitive and do: print line[:-1] # ;) (yes, only in *nix/mac) > Assuming Python 2.2 iterators, this can be written > > pipe = os.popen('ls /etc') > for line in pipe: > sys.stdout.write(line) > retval = pipe.close() Is the "for var in fileobj:" syntax new in 2.2? Right on! Thx. Tim Hammerquist -- It has been truly said that hackers have even more words for equipment failures than Yiddish has for obnoxious people. -- Jargon File 4.3.1 From grante at visi.com Tue Nov 27 13:05:24 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 27 Nov 2001 18:05:24 GMT Subject: smtplib help References: Message-ID: In article , David A McInnis wrote: > I do call quit(). Is is possible that the script is moving too fast for the > smpt server to keep up? If so, how can I slow it down? The "address in use" error isn't caused by the server, it's returned by the TCP/IP stack on your end when there are no free "outgoing" ports available from which you can originate the connection to the server. It's your TCP stack that can't keep up. If you're sending all of the mail to the same server, then you should be able to do it in a single connection... -- Grant Edwards grante Yow! .. I'll make you at an ASHTRAY!! visi.com From andreas at mtg.co.at Thu Nov 29 12:46:25 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Thu, 29 Nov 2001 18:46:25 +0100 Subject: Python 2.2: socket.ssl documentation? Message-ID: <200111291746.fATHkeY24178@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi! Is there any documentation about the ssl support in the socket module? If so where? Does it support writing servers? Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8BnR8HJdudm4KnO0RAg8bAJ4tXpAryhcEy3x7avzlUvtVj4Ko5ACfWdQ2 nkPBOJrEB9VwwN7sWJLHPmA= =DKwE -----END PGP SIGNATURE----- From hungjunglu at yahoo.com Tue Nov 6 11:38:53 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 6 Nov 2001 08:38:53 -0800 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: <8ef9bea6.0111060838.24996280@posting.google.com> How soon does a beginner run into the following problem? (see also the "How much is set in stone?" thread) #------------------ flag = 0 def f(x): flag = 1 return 2*x y = f(3) print y, flag #------------------ output: 6 0 I'd say, most run into this problem soon after they learn to use functions. It does not matter whether they have seen any other programming language before or not. Some have said "don't teach them about 'from xyz import *'". Should we also not teach beginners about using functions? Python's namespace feature is such an integral part of the language, that you can't really neglect it. Sequence of events: (1) Teacher goes through the whole song and dance about global, local namespace. How assignment actually means name binding, etc. etc. It is fun to do it once, it is fun to do it twice, but after doing it a few dozen times, teacher gets exhausted, and starts to cast doubt: "... maybe Python is not such a trivial language, after all." (2) After being shocked by the above example, students start to put 'global' statements in every single function for every single variable. They don't understand what is going on, they just don't want to be bitten by the same bug, again. (3) After a long (and it can be very long) time stepping on other namespace landmines, a few students finally come to realize how namespaces and dictionaries really work. They become teachers, and go to step (1). (4) The above is repeated for thousands and thousands of average-level Python users. So, given a language that does not have to deal with global/local namespace pitfalls, and a language that has to deal with it, which one would you choose as the first language to teach? Hung Jung From ddart at doradosoftware.com Fri Nov 2 14:47:53 2001 From: ddart at doradosoftware.com (DD) Date: 2 Nov 2001 11:47:53 -0800 Subject: SWIG/Python on Windows Message-ID: Has anybody used SWIG with Python on Windows without Microsoft Visual C++? I'm having problems getting the hellolib example in the Extending Python chapter from "Programming Python" to compile with gcc. I'm getting undefined reference errors to "Py..." functions, ex: PyString_FromString. All the examples I can find on the web use MSVC and I can't find an example for compiling a DLL using a makefile. BTW: Has anybody on this list done an integration between Perforce and PVCS Tracker? The above issue is holding me up from using P4DTI, which otherwise looks like a decent solution. thanks, DD From syt at gemini.logilab.fr Thu Nov 8 08:04:25 2001 From: syt at gemini.logilab.fr (Sylvain Thenault) Date: Thu, 8 Nov 2001 13:04:25 +0000 (UTC) Subject: unicode strings?! References: <3bea7e5f$0$36516$5039e797@newsreader01.highway.telekom.at> Message-ID: On Thu, 08 Nov 2001 13:42:48 +0100, Philipp Schmid wrote: >hi, > >can anyone help me with this little example program? > >#!/usr/bin/python2 > >lala = "aslfjaslkjf lasjflasjkfals faslkfj aljfa?ljfkal?fjal? jflajf" >print lala >lala = u'%s' % lala >print lala > > >if i run it I get the following error, why? > >aslfjaslkjf lasjflasjkfals faslkfj aljfa?ljfkal?fjal? jflajf >Traceback (most recent call last): > File "./test.py", line 5, in ? > lala = u'%s' % lala >UnicodeError: UTF-8 decoding error: invalid data To convert a string to unicode, python supposes your string is encoding with UTF-8 if you don't specify encoding. You got this error because your string isn't UTF-8 but latin1 (iso-8859-1). replace line 5 with: lala = unicode(lala, 'ISO-8859-1) or lala = unicode(lala, 'latin1') and it should works. -- Sylvain Thenault LOGILAB http://www.logilab.org From kuran42 at yahoo.com Thu Nov 15 14:39:28 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Thu, 15 Nov 2001 14:39:28 -0500 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) References: <20011112102612.A1723@gerg.ca> <20011112203150.A8294@ibook.distro.conectiva> <9suls6$8b1on$1@fido.engr.sgi.com> Message-ID: <3BF419F0.2030801@yahoo.com> Ahhh, but - sorts before most other characters. Any files matching -* will probably show up first when * is expanded, and the problem remains. Just one of the reasons I prefer to parse all - and -- options up until a -- is found. Who knows what you'll get after wildcards are expanded. Best to explicitly terminate option parsing. Paul Jackson wrote: > Greg wrote: > |> [me, on allowing interspersed options and args in Optik] > |> ... > |> OK, I think I'll add this feature. Still haven't decided to > |> enable it by default, but I'm leaning that way right now -- it > |> improves usability and shouldn't ruin anyone's day, especially > |> since "--" can always be used for "stop processing options now". > > Well, I for one would not like to see such. It's just > a preference issue for me, so feel free to count votes and > declare a winner (or just imagine counting them, and cast the > final vote yourself ;). > > But as an old Unix hacker, I'd not expect that arguments past > the first non-option arg would be scanned for further options > (with a few annoying exceptions ...). > > Better to solve the problem of inserting an option after you've > already typed further in the line by using a shell that allows > more flexible command line editing. > > Better not to encourage yet more gratuitous differences in the > non-essential details of how commands parse their command line. > > Also, adding such a feature will result in the following sequence > of events, leading to frustration: > 1) Optik parses interspersed options by default > 2) Nice New Command is written using Optik > 3) User happens to invoke Nice New Command with interspersed > options, not even aware that this is "special". > 4) Same user can't figure out why some other (not so blessed) > command is misbehaving (they interspersed options). > > And it can lead to yet another frustation: > 1) Directory contains (admittedly rare) instance of file > whose name matches the pattern '-*'. > 2) User invokes Nice New Command using shell wild cards: > nicenewfoo -a -b -c * > 3) Nice New Command behaves most unexpectedly > > Like I said - one "no" vote here. > -- Seduced, shaggy Samson snored. She scissored short. Sorely shorn, Soon shackled slave, Samson sighed, Silently scheming, Sightlessly seeking Some savage, spectacular suicide. -- Stanislaw Lem, "Cyberiad" -- 2:33pm up 12 days, 16:52, 2 users, load average: 0.19, 0.12, 0.09 From cliechti at gmx.net Sat Nov 17 18:38:55 2001 From: cliechti at gmx.net (Chris Liechti) Date: 18 Nov 2001 00:38:55 +0100 Subject: How to know when a variable is set References: Message-ID: [posted and mailed] madsurfer2000 at hotmail.com (-) wrote in news:fef0a228.0111171234.6f4b19e7 at posting.google.com: > Michael Hudson wrote in message > news:... >> madsurfer2000 at hotmail.com (-) writes: > I like the idea of structs, and I was planning to use a class the same > way, like > > class info: > pass > ... > info.name = ... > > These would be set in an event driven GUI, and I needed to know if an > attribute had been set before I saved the information. Now that I have > thought more about it, an hash table would be a better choice. i usualy initialize undefined attributes with "None" and later i can test if it's still "None" or a real value. its easier to understand how a class works when all attributes exist from the beginning (__init__). it's more complicated to see that an attribute is created dynamicaly. class Info: def __init__(self): self.name = None def check(self): if self.name is None: print "Name is not set" i = Info() i.check() i.name = 'hello' i.check() -- Chris From bas.vangils at home.nl Wed Nov 21 09:18:55 2001 From: bas.vangils at home.nl (Bas van Gils) Date: Wed, 21 Nov 2001 15:18:55 +0100 Subject: dictionary-question Message-ID: <20011121151855.B24412@kub.nl> Hi, I just found some dictionary-behavior that I don't quite understand: Python 2.1.1 (#1, Nov 3 2001, 19:19:22) [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> foo = {} >>> type(foo.get("bar",0)) >>> foo.get("bar",0) += 1 SyntaxError: can't assign to function call My current "workaround" is this: >>> if foo.has_key("bar"): ... foo["bar"] += 1 ... else: ... foo["bar"] = 1 ... >>> foo {'bar': 1} (this is just an demonstration of the behavior I don't get ... I want to use it in a bigger script). Now, can someone please explain why the foo.get("bar",0) += 1 won't work ... and what might be a better sollution then my current workaround? many thanks in advance yours Bas -- Bas van Gils - http://members.home.nl/bas.vangils Build a system that even a fool can use, and only a fool will want to use it. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From seb at tesco.net Sun Nov 4 19:11:21 2001 From: seb at tesco.net (seb) Date: Mon, 05 Nov 2001 00:11:21 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s2rob$5p8$1@bugstomper.ihug.com.au> Message-ID: <3be5d7b5.186523676@news.tesco.net> On Sun, 4 Nov 2001 18:58:09 +1100, "Gary Stephenson" wrote: >I think in fact it was > > "There once was a man from Peru, > Whose limericks always ended at line two" > >cheers > >gary > > Milligan was brill. My fave: Dr O'Dell fell down a well And broke his collar bone But doctors should attend the sick And leave the well alone seb From martin.franklin at westgeo.com Thu Nov 1 05:51:18 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Thu, 1 Nov 2001 10:51:18 +0000 Subject: File upload in python module? References: Message-ID: <9rr9l2$art$1@news.sinet.slb.com> DeepBlue wrote: > Wayne > Yes, there is an excellent script that can do that. It is by Tom > Middleton > and it does a great job. In addition, it is highly configurable. > The zip file if pyuploadfile.zip and you can find it on the Python Vaults > archive under CGI. > Always look there and see what they have and make a Google search too and > you are going to find many things. > DeepBlue > > "Wayne Ringling" wrote in message > news:mailman.1004447070.3098.python-list at python.org... >> >> I am working on a web project that needs a way to upload a gif or jpg >> (or >> any file I guess) to a web server via the web interface. I have seen them > in >> perl and java. I am trying to use all python. Is there a python module > or >> script already done to handle this? I looked thru the module list at >> python.org but didn't see anything that looked like it would handle it. >> Maybe I missed it. Any pointers or ideas. Thanks >> >> Wayne >> >> > > > Read this:- http://www.python.org/doc/essays/ppt/sd99east/index.htm From mkelly2002NOSPAM at earthlink.net Sun Nov 25 10:10:16 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Sun, 25 Nov 2001 15:10:16 GMT Subject: Windows Scripting Host Python Engine not registered/installed?? References: <1drvvtc91jnbmfoqpn2qdrg37km6ggk9sl@4ax.com> <3c00210b$1@brateggebdc5.br-automation.co.at> Message-ID: On Sat, 24 Nov 2001 23:33:41 +0100, "Werner Schiendl" wrote: >After that procedure, .pys files should run directly in WSH using Python >language (like .vbs runs VB script). Hi Werner. I must have mixed build versions or done something when I installed stuff. I just removed everything and downloaded the 12 MB ActivePython dist. and everything worked out of the box. I'm glad I installed that anyway since the html help is all nicely done in 8 MB worth of.chm files for the Win32 platform. Very nice. Hmm, maybe I'll go back and see if they updated the ActivePerl help to .chm files now. Anyway, I'm finding Python much less frustrating than Perl. I'm sure Perl is great for people who use it every day but for occasional hacks I find I can't remember the syntax and spend too much time fighting through docs where Python is more intuitive. Pardon me for blathering on but I'm a newbie to Python and I'm still enthusiastically discovering new stuff about it. :) Thanks for your reply. Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From danielk at aracnet.com Wed Nov 28 21:49:13 2001 From: danielk at aracnet.com (Daniel Klein) Date: Wed, 28 Nov 2001 18:49:13 -0800 Subject: Super-newbie needs help! References: <70c31206.0111280950.7ebe06ae@posting.google.com> Message-ID: <688b0ugij04trlh2aufriqil00nklvje80@4ax.com> Without looking at any of the responses so far, this is what I've come up with... while 1: try: sum = int(raw_input("Enter your number: ")) except ValueError: print "You did not enter a number!" else: if sum < 100: print "You haven't reached 100 yet! continue else: break Hope this helps, Daniel Klein On 28 Nov 2001 09:50:00 -0800, snowcrash3 at hotmail.com (SnowCrash) wrote: >Hello all, >Let me just preclude this posting by saying i am a Web Designer who's >decided that she wants to learn programming, and this is my first stab >at it. i don't pretend to understand what i am doing. Thats what you >guys are here for. > >Anyhow, i am reading through this nice tutorial provided at >hetland.org, called "instant hacking". Just the basics on Python. i am >presented with my very first exercise, and am stuck-- >"Write a program that continually reads in numbers from the user and >adds them together until the sum reaches 100. " > >Now, i have some code: >total = 100 >sum = input ("Enter your number.") >while sum < total: > print "You haven't reached 100 yet!" > sum = input ("give me another number") + sum > >print "Ok, you got me!" > >HUH? i don't think its right, i've changed it about 4 times before >posting it, and i've downloaded the Python 2.2 but can't seem to >figure out how to use the thing to check my code. i know its WILDLY >simple and feel like "well, gee, if i can't understand this much, then >i should quit before i feel REALLY stupid", but i am just going to >keep on truckin'....Hopefully with some help from comp.lang.python. > >Thanks in advance, >-snow- From michael at rcp.co.uk Mon Nov 5 12:01:07 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Mon, 5 Nov 2001 17:01:07 +0000 (UTC) Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Martin von Loewis wrote in news:j4zo6cixu2.fsf at informatik.hu-berlin.de: > No. It is not the feature set that prevents its incorporation; it is > the implementation strategy chosen. The patch is too intrusive. > I would have thought that the nature of the beast is likely to require quite substantial modifications to key parts of Python. Can you describe what you mean by "intrusive" in this context? I don't know the basic statistics of the Stackless patch (number of files patched, lines of code modified, etc), so it would be interesting to understand just how severe a hurdle Stackless Python really has to jump to be integrated. I keep wishing I had something like this, so I'm interested... From logiplexsoftware at earthlink.net Fri Nov 16 12:40:07 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 16 Nov 2001 09:40:07 -0800 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) In-Reply-To: <3BF5010C.9090707@bigfoot.com> References: <97ae44ee.0111150043.4382fe2f@posting.google.com> <3BF5010C.9090707@bigfoot.com> Message-ID: <01111609400700.02629@logiplex1.logiplex.net> On Friday 16 November 2001 04:05, Cezary Biernacki wrote: > Stephen wrote: > > Thanks for the help, Cezary > > > >>So, for really testing server you should launch clients from another > >>machine(s). > > > > Sorry, you've lost me here. If the server can't generate > > threads quick enough to deal with the incoming connections, > > how will moving the clients to another machine give the > > server more time (except perhaps in introducing a network > > delay) ? > > Your client threads also use processor time. When NUMTHREADS > 5 they > can be sheduled before a server starts accepting connections. It doesn't > depend on speed of the machine - faster processor -> faster clients > generates new connections. I haven't seen mention of which OS this server is running on, but I know NT 4 prior to SP5 had serious threading issues and would fail (I don't remember in what way) if you created more than a few threads (nor do I recall the exact number of threads). -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From ajs at ix.netcom.com Fri Nov 9 01:50:00 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Fri, 9 Nov 2001 01:50:00 -0500 Subject: Teaching python (programming) to children Message-ID: <000001c1697b$19b0de00$a9e1fea9@carol> Paul writes - >I think a big goal of the Mindstorms crowd is teaching the concept of >debugging. Most skills are taught with the idea that you master >something by learning it well enough to do it perfectly, so if you >make a mistake at it you haven't learned the skill yet. Teaching >programming to young kids is supposed to develop the cognitive skill >of diagnosing and correcting errors. That's more fundamental than >"applications" like cataloging mp3's or even understanding math >concepts. Again, IMO - the acceptance of programming instruction incorporated somehow into core curricula is up against enough - without making its acceptance dependent on the acceptance of some particular educational theory/philosophy. Let's accept that learning math, for example, is a good thing, and demonstrate an enhanced curricula incorporating some programming that will accelerate and deepen that process. "The cognitive skill of diagnosing and correcting errors" might in fact be more fundamental (and important) than understanding math concepts - who am I to argue with the MindStorms crowd. I will tell you that to the untrained ear, it sounds like horeshit. Which is the point, because those of us serious about seeing some progress made are not willing to wait until the rest of the educational world happens to see the light on this and similar points. Art From jeff at ccvcorp.com Thu Nov 15 17:18:24 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 14:18:24 -0800 Subject: How to marshal a function? References: <01111412544105.04702@logiplex1.logiplex.net><0111141538420B.04702@logiplex1.logiplex.net> Message-ID: <3BF43F30.54F1D89F@ccvcorp.com> Paul Winkler wrote: > On Thu, 15 Nov 2001 08:55:14 -0800, John Roth wrote: > >Uh, this isn't a mailing list. It's a newsgroup. I fail to > >see what 'procmail', 'mailer agent' and other > >such things have to do with it. > > "Ha ha ha ha! You're Both Right! New Shimmer is a floor wax - AND a > dessert topping!" > I swear, I did *not* see this before sending my reply to the previous post. :) Jeff Shannon Technician/Programmer Credit International From laurent.szyster at q-survey.be Mon Nov 5 14:20:05 2001 From: laurent.szyster at q-survey.be (Laurent Szyster) Date: Mon, 05 Nov 2001 20:20:05 +0100 Subject: Jews or Muslims? Who's a better hacker? Or phreaker? References: <5I3F7.9918$ND1.818724@brie.direct.ca> Message-ID: <3BE6E665.6F3E0088@q-survey.be> Gerhard H?ring wrote: > > On Sun, Nov 04, 2001 at 04:43:45AM +0000, Peta Ylorhovik wrote: > > Jews or Muslims? Who's a better hacker? Or phreaker? > > If you're interested in this question, I recommend you use a least Python 2.1 - > it supports rich comparisons. answer are both "it is very, very runny" and "fuck the fucking fuckers". Laurent Szyster > You might also be interested in the new twisted.religion module, which will > part of one of the next versions of Twisted Python. Meanwhile, you can try to > abuse twisted.reality for this philosophical question. > > Gerhard > -- > mail: gerhard bigfoot de registered Linux user #64239 > web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 > public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 > reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From david at dataovation.com Sun Nov 18 18:19:23 2001 From: david at dataovation.com (David A McInnis) Date: Sun, 18 Nov 2001 15:19:23 -0800 Subject: Pulling out Message-ID: I am writing a script to catalog about 30,000 html pages on my site and need to pull out the value of . I guess this is possible with htmllib, but I cannot figure it out. Thanks, David From wolfson at uchicago.edu Thu Nov 29 00:42:36 2001 From: wolfson at uchicago.edu (Ben Wolfson) Date: Wed, 28 Nov 2001 23:42:36 -0600 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <3C03275E.2C4D8149@engcorp.com> <3C045C07.BA7B3FE6@engcorp.com> <3C05AE56.E2261313@engcorp.com> Message-ID: On Wed, 28 Nov 2001 22:54:52 -0600, Rainer Deyke wrote: > You can run but you can't hide! > > What's up with that saying anyway? Is hiding more difficult than running? We already know all possible places you could hide. Your attempts to conceal yourself are bootless. Soon the hounds will be upon you. -- BTR Why does this Wolfson person see fit to clutter up Usenet with such absurd nonsense? -- Bob Cunningham in From ajs at ix.netcom.com Mon Nov 26 20:53:30 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Mon, 26 Nov 2001 20:53:30 -0500 Subject: list.remove for Novices Message-ID: <001301c176e6$53657c00$a9e1fea9@carol> Steves comments on my post: >> But the Reference Manual is for the Legal profession. I'd suggest a > > tutorial warning. >Along the lines of "Sitting on the branch you are sawing off the tree is not >a good idea"? But you need to understand that for someone like myself, Python is almost my only point of reference. If I read about immutable and mutable, it was some hint, but actually *meant* little. That is documentation for folks who are in the game, not entering it. And even understanding the behavior now, its hard for me not to consider it a wart. I *don't* want the language to baby-sit me - but ... Well maybe I can't have all ways. >Art, surely you've been using Python long enough to realize that assignment >never creates copies? Again, if you are starting out with a reference point understanding that there are assignments which behave such and so, and copies which behave such and so, then understanding which '=' creates is easy. But do realize that a beginner does not come to the table with that understanding - which is why I sometimes feel that in this one important respect Python is not for beginners. But again - Python is my only real point of reference - so I can't say the concepts would get across better using some other language. >Isn't Python FUN? Yup! >> The >> >>for p in x: >> x.remove(p) >> >> surprise just being a new dessert topping. >> >>>Surprise? There you go, sawing away at that branch again. I realize I won't >>>convince you, because you've been bitten, that this isn't a situation where >>>further documentation is necessary. Seems obvious to me, but clearly I'm not >>>typical of *all* users (thank heavens). But the only thing I truly try to bring to the Python table is a vocal novice voice. Not ashamed to be dumb, because I am getting smarter all the time. So I can promise you it is not obvious for the folks like myself - until *after* one gets bit. The x.remove(dup) behavior on iteration never occurred to me. And I *did* know that, for example, that list.reverse() was in place. >> Is anyone aware of a reference where these issues are given >> focus and covered clearly and comprehensively > >for the Python novice?? > >> Not that someone like me is likely to read it carefully. Just > >so much damage one can do screwing up a bezier curve, and > >I tend to live dangerously - and learn by messing up enough > >times until something eventually clicks. >So you ADMIT that warnings wouldn't do you any good. I suppose they'd be >useful for "other people", though? Being a little tongue and cheek. I constantly have used the Python tutorial as a source. I do have a few Python books which I also use as reference - but I am admitting that I mostly use a trial and error approach. The fact that Python seems so amenable to that approach is a good part of why we get along so well. >> My first PEP? >I wouldn't even think about it, but of course the point of the PEPs is to >encourage discussion. How about this one. A copy operator - <=> or something. So now all the world is on notice from day one = is different that <=>. Which do you mean? Its a stupendous idea. I am sure all agree. Its OK, I'm getting used to ducking. ARt From jriveramerla at yahoo.com Wed Nov 14 11:54:43 2001 From: jriveramerla at yahoo.com (Jose Rivera) Date: 14 Nov 2001 08:54:43 -0800 Subject: Zope - ZODBCDA Error...python15.dll not found!! Message-ID: <11e94203.0111140854.53119ea0@posting.google.com> I want to retrieve data from MS SQL Server 7.0 that is running on NT server on another machine where it's not installed ZOPE... In the machine where I installed Zope there is an ODBC DataSource that works to connect to the SQL Server Database... but I want to be able to make querys from Zope... so what am I missing here?... When I reset tho machine where zope is installed, Zope is defined as a NT service, it reports that can not find PYTHON15.DLL, and ZODBCDA it's not listed in the list of products of ZOPE. Thanks in advance for your help... From bruce at hoult.org Sun Nov 11 18:13:58 2001 From: bruce at hoult.org (Bruce Hoult) Date: Mon, 12 Nov 2001 12:13:58 +1300 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> Message-ID: In article <7xlmhddlr3.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: > My own quick comparison: CL is a much more complete system. Writing > Python code is often an exercise in figuring out how to combine Python > features in some clever way that nobody has done before, to accomplish > your task. In CL, you more often get the impression that the > designers had anticipated your needs. > > On the other hand, CL contains several decades worth of accumulated > junk. Just about every feature in Python is present in some form in > CL, but Python has a cohesive, smooth design, while in CL the features > feel somewhat bolted on. Dylan has most of the advantages over Python that CL does. In a lot of ways it's a more cohesive and smooth redesign of CL -- or at least that's what its designers (many of whom were genuine CL gurus) intended. The Dylan language is more mature than Python, and has better compilers (it *has* compilers!), but Python has had more work put into libraries thus far. -- Bruce From gat at jpl.nasa.gov Thu Nov 29 17:09:28 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Thu, 29 Nov 2001 14:09:28 -0800 Subject: A modest indentation proposal Message-ID: The subject of syntactically-significant indentation seems to dominate a lot of discussions on Python. Personally I've found it to be less of a problem than I thought it would be, but annoying nonetheless. It also IMO makes the language unsuitable for mission-critical applications. It's just too easy to screw up indentation (particularly when cutting and pasting large blocks of code) without realizing it. I have a suggestion for how to make people like me who are uneasy with syntactically significant indentation feel more comfortable while at the same time not alienating those who thing that it's a really cool feature. The proposal is based on the observation that Python already has the equivalent of an open-brace for code blocks. It's the colon. To see that this is so you have only to observe that a good editor can automatically indent code properly at the beginnings of blocks, but not at the end. The solution to the problem is to add an optional end-of-block identifier. I propose to use a semicolon at the end of a line to denote the end of a block, e.g.: for i in l: # Colon signals beginning of block foo() baz(); boff() # Semicolon separating statements works as usual bar(); # Semicolon at end of line signals end of block biff() This convention is 100% backwards-compatible with current practice, that is, code written using this convention runs with no problems in Python as it currently stands. What I would like to see in terms of support for this convention from the Python community is two things: 1) Editor support for this convention so that a semicolon at the end of a line causes the editor to unindent, and 2) Parser support. It would be enough to simply give a warning if there is a discrepancy between the block structure defined by indentation and that defined by the semicolon-at-end-of-line convention (i.e. "Warning: end of block detected without trailing semicolon"). Making this optional so that die-hard indentation fans could turn it off would also be fine. Comments? Erann Gat gat at jpl.nasa.gov From donod at home.com Wed Nov 7 03:03:25 2001 From: donod at home.com (Don O'Donnell) Date: Wed, 07 Nov 2001 08:03:25 GMT Subject: Exception handling wart in Python References: Message-ID: <3BE8EAB9.B2165334@home.com> Leo Lipelis wrote: [snip] > ... Point is, Python can be made better by getting rid of > the "self.__" in front of every object attribute. For instance, why not > assume that ALL variables are instance variables, and have the other ones > use some special notation? The absolute majority of attributes you will > use are instance attributes. That's just not true. The majority of variables in most of the method defs I've seen are local variables: method arguments, loop counters, indexes, temporary variables, etc. And rightfully (by your own reasoning) local variables are the ones which should not need any qualification, as indeed they don't. And, in fact, since local variables are faster to access in execution time than instance, class or module variables, which require a dictionary lookup, I often make a local out of a frequently used instance variable to speed up execution (or just use arg rather than self.arg for module arguments): class Person: def __init__(self, name, gender, dateOfBirth): self.name = name if len(name) == 0: # use name not self.name raise NameError self.gender = gender.lower() gender = self.gender # make instance var local if gender != 'm' and gender != 'f': # for quicker access raise GenderError ... > Why penalize the common case? That's bad > engineering. You should always penalize the fringe case. Doesn't that > make sense to you? It certainly does, and the common case is the local variable. > If you have 2 class attributes and 20 instance > attributes, why would you penalize the 20 instead of 2? That's insane. I don't understand your argument here, both class and instance attributes need to be qualified. Cheers, Don From mgerrans at ix.netcom.com Sun Nov 11 02:09:55 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Sat, 10 Nov 2001 23:09:55 -0800 Subject: IsPython really O-O? References: Message-ID: <9sl891$eik$1@slb7.atl.mindspring.net> Roy, I really would like to know why, specifically, your Smalltalk guru (snob, dare I say) thinks Java (especially) and Python are not OO. I find it ridiculous when people write off valuable tools with a stupid, unverifiable and unquantifiable (i.e. subjective) one-liner (eg. "that's just syntactic candy"), when in fact what they are really trying to hide is the truth: they are too lazy or afraid to learn something new! I think the real problem is that this "guru" heard you mention a subject in which he was not a "guru" and felt insecure. He felt you were trying to steal his thunder and he lashed out, naturally. I find this sort of silly writing off of tools very annoying. The one thing in the (otherwise good) book "The Pragmatic Programmer" that really pissed me off was when they wrote off Python because its syntax is "slightly quirky." I later came to understand that the reason they said this was financial: they wanted to sell their upcoming Ruby book. No intelligent and unbiased person could call Python's syntax quirky. "Innovative," perhaps, but certainly not quirky. Anyway, my point is, writing off a valuable tool with a one-liner is foolish, defensive behavior and has no place in an engineering environment. The more tools you have in your toolbox, the better you are at solving problems. Period. - Matt wrote in message news:AbkH7.41130$bf1.4968343 at news20.bellglobal.com... > A Smalltalk guru in our organization looked at Python last weekend (after I > had made a big scene saying that it may be a solution to some of our > cross-platform issues) and came away saying that it was no more > object-oriented than Java. I sputtered around a bit but could hardly make a > decent argument, as I'm a mere designer. We do very large-scale industrial > work here, all O-O, with object databases (I thought the ZODB business > looked great). Is my friend right? Is Python not "really" appropriate for > true O-O applications, in the sense that Viz-Age Smalltalk and Eifel and so > on are??? > > Kent Smith > From Gareth.McCaughan at pobox.com Wed Nov 28 17:55:56 2001 From: Gareth.McCaughan at pobox.com (Gareth McCaughan) Date: Wed, 28 Nov 2001 22:55:56 +0000 Subject: Integer Overflow References: <9u0jor$2li$1@peabody.colorado.edu> Message-ID: "Ursus Horibilis" wrote: [I said:] > > - using a 1-element list is about the nearest equivalent > > we have to passing in a pointer as your C code does. > > It's not necessarily good style (but then, neither is > > the pointer-passing thing). > > Could you expand on that? It sounds like it has all the > makings of a religious war (;-) Would the following be a > preferred way of doing things: > > def Lcprng(state): > """Pass this a variable containing the seed. Don't forget to > update the seed with the returned value each time this > function is called.""" > return int((29L*state+13L) & 0x0FFFFFFFL) > > .......Calling Program...... > RanNum = 987654321 # Initialize Random Number Seed > > ............................................ > > RanNum = Lcprng(RanNum) # Keep updating seed with value I'd prefer an approach in which you don't need to pass the state in explicitly at all. In C, that would usually mean using a static variable. In Python, more natural would be to define a class whose instances have the job of dispensing random numbers: class RandomNumberGenerator: def __init__(self, seed=1): self._seed = seed def next(self): self._seed = (29L*self._seed+13) & 0xFFFFFFFFL return self._seed and then you'd say >>> rng = RandomNumberGenerator() >>> x = rng.next() >>> print "I got", x I got 42L This way you can, for instance, have more than one instance of the RNG, updating their states independently. Is this useful? I'm not sure. :-) If you prefer just to have a function that spits out a new "random" number every time, you can then say >>> get_random_number = RandomNumberGenerator().next >>> get_random_number() 42L >>> get_random_number() 1231L If you don't like getting longs back from the RNG, by the way, it unfortunately won't do to call int() on the result as you do above, because you'll get an overflow once the result is 0x80000000 or above. Instead you'd have to say something like return int(self._seed - 2*(self._seed & 0x80000000L)) to convert to a *signed* number before intifying. > > - After one iteration, the value in "state" will be a > > long integer and there will therefore be no danger > > of overflow. But you should make sure you start it > > off with a long anyway. > > What will happen if I do this: > > state[0] = int((29L * state[0] + 13L) & 0x0FFFFFFFFL) > > ? See above. (But it's sufficient to guarantee that whatever you pass in you won't get an overflow.) > > By the way, that's not a very good random number generator. > > :-) > > Yes, you're right. Linear Congruential PRNG's are not very > good, but they are widely used because of their simplicity. I > just whipped an equation off the top of my head that would > generate maximal-period pseudo random numbers. I wasn't > worried much about the quality. Well, what I actually meant was that even for a LCG that's a pretty poor one. It fails the spectral test disastrously, for instance. > Better is: > > state = 179418817 + 179419969 * state Yes, that's better. By the way, Python does have its own RNG module. It generates better random numbers than either of the generators mentioned in this article. :-) -- Gareth McCaughan Gareth.McCaughan at pobox.com .sig under construc From root at rainerdeyke.com Fri Nov 9 09:08:11 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Fri, 09 Nov 2001 14:08:11 GMT Subject: iters on ints? (reducing the need for range/xrange) References: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Message-ID: "Paul Rubin" wrote in message news:7xlmhg6sbs.fsf at ruckus.brouhaha.com... > Really the ellipsis should make an iterator: for i in 0...10. Just say "no" to extra syntax. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From sholden at holdenweb.com Mon Nov 19 11:08:16 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Nov 2001 11:08:16 -0500 Subject: Python & cgi on win98--tinyweb problems, etc References: <3jhbvtolcur3sn3ali0r2er16dgddfaaca@4ax.com> Message-ID: "Chris Stromberger" wrote ... > On Fri, 16 Nov 2001 09:46:10 -0500, "Steve Holden" > wrote: > > >"Chris Stromberger" wrote ... [ ... ] > >> Any other recommendations for small simple web servers for this > >> project? > >> > >Run, do not walk, to www.xitami.com, and download the freeware load. > > > >It runs well, with a very small footprint, and besides allowing CGI > >scripting and having web-based administration it also lets you build > >long-running web processes in Python! Naturally you can specify which > >interfaces you want to use to serve web content (and naturally you will want > >to limit yourself to 127.0.0.1). I ditched PWS a year ago and have never > >looked back. > > > >regards > > Steve > > I'll check it out. Could you expound a bit on your statement that "it > also lets you build long-running web processes in Python"? What does > that imply? It's another way to implement web process persistence similar to mod_python and mod_apache. The Xitami server listens for LRWPs, which connect with an announcment that they are prepared to handle a given class of URLs. When such requests come in, instead of being handled in the "traditional" (file store or CGI) way, the request is passed to the appropriate LRWP over a CGI-like interface. Because Xitami is based on a threaded library, several LRWPs can register to serve the same URLs, and such a set of processes can be treated as a pool. There's a Python example towards the end of http://www.imatix.com/html/xitami/index12.htm which was written by Robin Dunn. His name, if you know anything about wxPython, should be some indication of the quality of the Xitami/Python LRWP solution. I've been very impressed. but-maybe-i'm-too-easy-to-impress-ly y'rs - steve -- http://www.holdenweb.com/ From nospam at bigfoot.com Mon Nov 12 18:06:16 2001 From: nospam at bigfoot.com (Gillou) Date: Tue, 13 Nov 2001 00:06:16 +0100 Subject: Newbie: Using MySQL References: Message-ID: <9spk9d$1f4o$1@norfair.nerim.net> "Jordan Elver" a ?crit dans le message news: mailman.1005440233.15939.python-list at python.org... > Hi, First post to the list :-) Welcome... > Could someone point me in the right direction for MySQL using Python > ... > db = MySQLdb.Connect(host=db_host, user=db_user, passwd=db_passwd, db=db_db) > > Thanks for any help. > Your connection object constructor sounds good. What's the error message ? Did you try this from a shell on your console: $ mysql -h db_host -u db_user -p db_passwd db_db Then play with any "mysql> select ..." If any problem, ask your mysql admin to add: mysql> grant all on db_db.* to db_user%your_client_hostname_or_IP identified by "db_passwd"; And retry your script HTH --Gillou > Jord > -- > Jordan Elver > http://www.jordanelver.co.uk > "Only wimps use tape backup: _real_ men just upload their important stuff on > ftp, and let the rest of the world mirror it ;)" --- Linus Torvalds > From olli at secnetix.de Tue Nov 6 13:04:54 2001 From: olli at secnetix.de (Oliver Fromme) Date: Tue, 6 Nov 2001 18:04:54 +0000 (UTC) Subject: split(None) Message-ID: <9s98o6$ilj$1@isp-m-srv06.izb.net> The library reference says the following about the "split" string method: | If sep is not specified or None, any whitespace string | is a separator. So I thought that foo.split() and foo.split(None) should return the same result. However: >>> "foo bar baz".split() ['foo', 'bar', 'baz'] >>> "foo bar baz".split(None) ['foo bar baz'] The problem is, I have to specify None because I also need to specify the optional second argument "maxsplit" (and in my case, I cannot simply use a single space character, because words can be separated by arbitrary whitespace). So, next thing I tried was to specify maxsplit as a named argument. Surprise ... didn't work as expected, either: >>> "foo bar baz".split(maxsplit = 1) ['foo', 'bar', 'baz'] Looks like I'll have to use re.split(), unless I'm missing something (I guess I am). Is there a bug in string.split(), or in the documentation, or in my brain? Regards Oliver (still python newbie and eager to learn) PS: This is Python 2.1.1, if it matters. PPS: string.split.__doc__ says: "If maxsplit is given, splits into at most maxsplit words". This is clearly wrong: It splits into at most maxsplits + 1 words. -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From montanaro at tttech.com Mon Nov 5 11:49:52 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Mon, 05 Nov 2001 17:49:52 +0100 Subject: Teaching python (programming) to children In-Reply-To: <8ef9bea6.0111050832.4474d66a@posting.google.com> References: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: Hung> I have my doubts about Python being the first programming language Hung> to teach. I see all too many newbies running into the problem of Hung> namespaces. How do you explain to them that "from xyz import *" is Hung> a bad thing, if they don't even understand what's going on behind Hung> the scene? Also, how in the world can beginners understand what a Hung> hash table mean? Are we going to tell them something like: "oh Hung> well, think of Python dictionary as a magic black box, you'll Hung> understand it later when you take a course in C/C++"? I think the assumption is that you don't give them everything at once, and you can simply avoid teaching them the "bad" stuff like "from m import *". Regarding dictionaries, I would tell them, "Think of a Python dictionary as a regular dictionary. You look up a 'word' and it gives you the 'definition' of that word." The correspondence is good enough to get them going I think. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From maxm at normik.dk Tue Nov 27 10:26:34 2001 From: maxm at normik.dk (Max M) Date: Tue, 27 Nov 2001 16:26:34 +0100 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> Message-ID: <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> "Yong Lu" wrote in message news:n118xmrp.fsf at ailab.pku.edu.cn... > A newbie question. Where can I find documentation of this usage? > I've searched a bit in the Python manual, but the only section > on print doesn't mention this. Python library reference: 2.1.5.2 String Formatting Operations regards Max M (I had to search long and hard for it too. Sometimes the manual could be a bit more cross referenced.) From bryan at eevolved.com Fri Nov 30 12:42:27 2001 From: bryan at eevolved.com (Bryan) Date: Fri, 30 Nov 2001 12:42:27 -0500 Subject: CryptKit 0.9 released In-Reply-To: References: Message-ID: Your interest is appreciated Phil. > If i included this kit in my programs, how ease would it be for a user to > install it? Well, that would depend on your client's platform. Seeing as the kit is based on C modules, those modules need to be compiled for each platform ( posix, win32, alpha, etc ). The good news is that the kit uses distutils, which would permit a potential packager to build the modules from source with a one-line command. (*hint* *hint*). You can expect the win32 binary installers to appear within a few days. If the packages for your platform exist, installation is a one-line command: # python setup.py build_ext install > Would it be more difficult than as pure Python solution? Yes C extension modules are more difficult to distribute and install, but a pure python implementation would not provide sufficient speed for real-world applications at today's average machine speeds. Maybe when we all have 1 THZ boxes :) > What are ECC and NR? Elliptic Curve Cryptography permits public/private key encryption and signing. Smaller keys == faster operations. For instance, the security of a 1024 bit RSA is approximately equivalent to that of a 160 bit ECC. http://www.rsa.com/rsalabs/ecc/elliptic_curve.html Nyberg-Rueppel is a signature scheme that is well suited to use with elliptic curves. http://crypto.ee.ncku.edu.tw/pdf/41.pdf > Can this be used for digigal sugnatures as well as encryption? Sure, couldn't be easier: >>> from ecc.ecc import ecc >>> e,f=ecc(1),ecc(2) >>> e_pub_key, f_pub_key = e.publicKey(), f.publicKey() >>> # Signing / Verification >>> msg = 'Hello World!' >>> sig = e.sign(msg) >>> f.verify(msg,e_pub_key,sig) 1 >>> # Tamper with the message >>> msg += 'a' >>> f.verify(msg,e_pub_key,sig) 0 > Sounds reasonable. But what about including others, for backward > compatibility e.g. with OpenPGP? The kit doesn't aim for compatibility with other protocols and standards. If you are looking for that type of library, consider M2Crypto and the like. Instead, Cryptkit's intended users are developpers who need small, fast secure sockets for their applications. Implementing extraneous algorithms would greatly increase the library size while really only being of use to a select few programmers. You're welcome to code support for other standards and send me patches, but I will bundle them seperately from the main release. Take care and happy coding, -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "A human being is a part of a whole, called by us _universe_, a part limited in time and space. He experiences himself, his thoughts and feelings as something separated from the rest... a kind of optical delusion of his consciousness. This delusion is a kind of prison for us, restricting us to our personal desires and to affection for a few persons nearest to us. Our task must be to free ourselves from this prison by widening our circle of compassion to embrace all living creatures and the whole of nature in its beauty."-- Einstein From dwetzel at altern.org Thu Nov 22 10:50:07 2001 From: dwetzel at altern.org (damien Wetzel) Date: 22 Nov 2001 07:50:07 -0800 Subject: extracting html table rows into a list Message-ID: <9aadf0f.0111220750.719466de@posting.google.com> hi , does any body has a script which parse a big table from an html file and create a list of rows ? thanks for any responses From achim.domma at syynx.de Fri Nov 9 11:21:44 2001 From: achim.domma at syynx.de (Achim Domma) Date: Fri, 9 Nov 2001 17:21:44 +0100 Subject: Calling Ghostscript from Python References: <3BEBE6AE.C7A33CF4@pallas.com> <3bebe987$1@netnews.web.de> Message-ID: <9sgvln$gq2$04$1@news.t-online.com> Hi Kerstin, "Kerstin Dressler" wrote in message news:3bebe987$1 at netnews.web.de... > Georg Bisseling wrote: > >Kerstin wrote: > >> ghost_dir = 'c:\ghost\gs\gs7.00\lib' > >> cmd = ghost_dir + '\ps2pdf13.bat ' + ps_file + ' ' + pdf_file > >> os.system(cmd) [...] > That's not working. > Also I have another file with full pathname ("c:\python21\programs\ps2pdf\input. > txt") where it was working before. '\' marks special meaning for some following characters. For example '\n' means a linebreak. But if there's no special meaning for a character (for example '\g') the '\' is taken as a 'normal \'. Where do your ps_file or pdf_file come from ? Is it possible that they contain special escape sequences like '\n' or '\t' like 'myFolder\test.txt' ? To check this simply write a 'print cmd' befor you call 'os.system(cmd)'. Does the string looks like you expected it ? greetings Achim From johnmc at grohl.vels-int.com.au Thu Nov 15 19:36:06 2001 From: johnmc at grohl.vels-int.com.au (John McMonagle) Date: Fri, 16 Nov 2001 10:36:06 +1000 (EST) Subject: Returning values from a lambda Message-ID: I wish to return values from a lambda function which is bound to the Tkinter button command option. For example, def operations(a,b): return a+b, a*b from Tkinter import * root = Tk() btn = Button(root, text='Press Me', command=lambda a=2, b=5: operations(a,b)) btn.pack() How do I assign the returned values to variables, say x,y ? I guess I want to do something like, lambda a=2, b=5: x,y=operations(a,b) but this gives me the error: SyntaxError: can't assign to lambda Is this possible ? I'm using RedHat 7.0, python 1.5.2 Thanks John From loewis at informatik.hu-berlin.de Thu Nov 15 06:18:33 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 15 Nov 2001 12:18:33 +0100 Subject: Python .elc and /etc/magic References: Message-ID: Gustavo Niemeyer writes: > We should also have something like that for python: > > 0 string/b #!\ /bin/bash Bourne-Again shell script text executable > 0 string/b #!\ /usr/local/bin/bash Bourne-Again shell script text executable Why is that necessary? porthos loewis 24 ( /tmp ) > cat a.py #! /usr/bin/python print "Hallo, Welt!" porthos loewis 25 ( /tmp ) > file a.py a.py: a /usr/bin/python script text Regards, Martin From jgardn at alumni.washington.edu Wed Nov 28 10:52:00 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Thu, 29 Nov 2001 00:52:00 +0900 Subject: Should we trust .NET? In-Reply-To: References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: <01112900520009.13207@linux> > > Look at Visual C++. Portability? Compatability? Ha. > > > > Look what they did to Java, HTTP, HTML, and JavaScript. > > What did they do to Java, HTTP, HTML, and JavaScript? HTML/JavaScript: Non-compliant web pages that only work for IE and not for the other. Trying to add stuff to HTML without going through the standard process, and then advertising it as if everyone does it. HTTP: They still haven't built a server that actually works. Java: C# is the result of their failed efforts to commandeer this language. Sun had to take them to court to get them to stop. And we should all know what they did to C++. The declaration of variables inside a for loop survives outside of the loop. You can't compile anything that works with windows without enabling this "feature"... they still don't support templates properly... they didn't implement exceptions hardly at all, and they don't even use it. > > > Microsoft is in the business of making money, not software. > > Is Sun and Netscape any different? Sun and Netscape make(made) software as well as money. Jonathan From phr-n2001d at nightsong.com Mon Nov 5 13:59:14 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 10:59:14 -0800 Subject: Solving Partial Differential equation in Python References: <3BE6AF97.3000308@stu.ust.hk> Message-ID: <7x3d3tt56l.fsf@ruckus.brouhaha.com> "John J. Lee" writes: > All I know about numerical solution of PDEs is that it isn't a > one-size-fits-all problem: it's a big subject, and there is no single > algorithm, or even LAPACK-sized collection of algorithms, that will solve > all PDE problems. I'm no numerics expert, but the OP asked specifically about an Euler-Lagrange equation. If that's the same type as found in classical mechanics then it's likely there's some libraries around specifically aimed at it. Yes, PDE's in general are a very complicated subject but this may be a special case. From fredrik at pythonware.com Tue Nov 27 08:35:02 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 27 Nov 2001 13:35:02 GMT Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> <9tttl6$2uj0$1@nntp6.u.washington.edu> Message-ID: Russell E. Owen wrote: > One way to look at it is that the various collection classes do NOT > inherit from a single base class (which would be a logical place to > define a join method). Footnote: join takes a sequence, not a collection. Sequences are defined by an informal protocol, not a base class. > Hence to have all kinds of collections learn to "join" requires a lot of > repeat coding. Making join a string method solves this problem. If you look at this from the implementation perspective (I wrote that code), and try to take everything into account, it's obvious that the separator is the only thing that we can rely on for the dispatch. You cannot dispatch on the type of the sequence (because it's not a type!), and you cannot dispatch on the first element (the sequence may be empty). And forcing the user to use different join function for different string types didn't feel right. So the first implementation did something like this: # from string.py def join(seq, sep=" "): return sep.__join__(seq, sep) where the first sep was only used to quickly find the internal join implementation, without having to figure out what module to import. In the next iteration, I removed the extra argument: def join(seq, sep=" "): return sep.__join__(seq) ...and from there, it was only a matter of minutes before someone argued that "why bother using a secret name; people will find out anyway", leaving us with: def join(seq, sep=" "): return sep.join(seq) (fwiw, you'll hardly ever find the sep.join(seq) form in my code) From ajs at ix.netcom.com Sun Nov 25 17:12:03 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 25 Nov 2001 17:12:03 -0500 Subject: list.remove for Novices Message-ID: <000701c175fe$580a5660$a9e1fea9@carol> Tim writes - >I expect every newbie gets bit by this at least once. This is the first >time I've seen it called "apparent", though (nobody actually said that, >right?). It's a subtlety, as the Reference Manual points out in a bold >Warning. But the Reference Manual is for the Legal profession. I'd suggest a tutorial warning. I would say, in fact, that whether I am working on the thing itself, or a copy of the thing itself, and leaving the thing unchanged, is the #1 issue of confusion for the novice - if I am typical (and I have always posited that I am). Especially when there are few thing1=thing2 thingies floating around. >>>b=[1,2,3,4] >>>a=b.reverse() >>>b=a >>>print b None ??? I get it, but it takes a while - and errors were rampant, and this form of confusion comes in many flavors. I have had occasion to savor many of them already. The for p in x: x.remove(p) surprise just being a new dessert topping. Is anyone aware of a reference where these issues are given focus and covered clearly and comprehensively for the Python novice?? Not that someone like me is likely to read it carefully. Just so much damage one can do screwing up a bezier curve, and I tend to live dangerously - and learn by messing up enough times until something eventually clicks. > If you mutate a container while traversing its contents, every >language supporting such a thing does something that will surprise someone >(can't help it -- some people will be surprised if their mutations aren't >visible during the traversal, while others will be surprised if they are, >and the rest will complain if you raise an exception). Backwards compatibility issues aside (are there actually folks who take advantage of the current behavior?) isn't it pretty clear that the current behavior is probably the most surprising of the possibilities - at least to the naive eye. My first PEP? Art From cliechti at gmx.net Wed Nov 21 20:16:02 2001 From: cliechti at gmx.net (Chris Liechti) Date: 22 Nov 2001 02:16:02 +0100 Subject: redirecting sys.stdout and threads Message-ID: the standard way to redirect outputs of print statements is to assign an other file to sys.stdout and/or sys.stderr. the editors (idle, pythonwin, wxWindows pyshell, etc.) are an example for this. but what can you do if more than one thread wants to use redirection? i'm writing a server that writes it's messages on the screen (original sys.stdxxx). but the same server is listening on a TCP port and can receive strings for execution in a rexec environment. i want that print statements that come from a remote command are captured and redirected to the client, but at the same time the main thread should continue to write out his messages on the screen. (this is also a problem when i want to run two interactive prompts in the same interpreter.) i've attached a sample script that shows my problem. thread 1 and 3 should write to stdout, but thread 2 should write to a buffer. the buffer is printed at the end, after all threads have finished and a line was printed. i tested it on python 2.0 and 2.1 on win32, with negative results. -- Chris From barry at zope.com Thu Nov 1 02:46:24 2001 From: barry at zope.com (Barry A. Warsaw) Date: 01 Nov 2001 02:46:24 -0500 Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> Message-ID: >>>>> "MF" == Martijn Faassen writes: MF> The double underscore is required for name mangling, but I MF> don't really like the name mangling; it gets in the way. I MF> just want to give the programmer a hint that some attribute is MF> private, and I use a single underscore for this, and many MF> Python programmers with me. FWIW, the double-leading-underscore-no-trailing-double-underscore name mangling rule wasn't added specifically for data hiding. It was so that a class that was designed to be subclassed could have a namespace that subclasses couldn't accidently trample on: -------------------- snip snip -------------------- class A: def __init__(self): self._my_private_counter = 0 def countup(self): self._my_private_counter += 1 print self._my_private_counter class B(A): def __init__(self): A.__init__(self) self._my_private_counter = 10 def countdown(self): self._my_private_counter -= 1 print self._my_private_counter >>> b = B() >>> b.countup() 11 # huh, why isn't this 1? class A: def __init__(self): self.__my_private_counter = 0 def countup(self): self.__my_private_counter += 1 print self.__my_private_counter class B(A): def __init__(self): A.__init__(self) self.__my_private_counter = 10 def countdown(self): self.__my_private_counter -= 1 print self.__my_private_counter >>> b = B() >>> b.countup() 1 # ah that's better! -------------------- snip snip -------------------- IOW, B's designer shouldn't have to know anything about A's private interface in order to be correctly implemented. Name mangling preserves the integrity of A's private API. Of course, B's designer must know about A's inherited (i.e. protected) API in order to be correctly implemented. In that situation, many different conventions exist. My own personal one is to prefix protected API attributes with a single underscore (and document them ;). -Barry From pinard at iro.umontreal.ca Mon Nov 26 18:18:24 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 26 Nov 2001 18:18:24 -0500 Subject: string.join() syntax quirky? In-Reply-To: <3C02AF2D.943951FA@home.net> References: <3C02AF2D.943951FA@home.net> Message-ID: > > > One way to look at it [...] > > So instead of doing what's right we're doing what's convenient? Doesn't > > sound very Pythonic > Another way to look at is is that joining and splitting are inherently > string functionailty [...] I still wonder why the string is optional for `string.join()' and `string.split()'. If it was inherent, the string would be prominent. My belief is that people are looking for "one way to look at it" and "another way to look at it", but this is still torture from clever minds. > I don't think join() belongs with sequences at all, as sequences can > hold anything, not just strings. Right. Nevertheless, I think we should keep our mind a bit relax, when working with a pleasurable language. Deep down, we are still joining a sequence of strings into a resulting string with a separator; we just never join a separator over a sequence of strings: this is ugly thinking. No doubt that we can invent lots of justification for it, it stays ugly. I just decided to have confidence in the collective wisdom, as many promised all the others that we will get used to that ugliness. The truth is that, for one, I do not foresee the day I will get used to this one. I guess history will eventually list ''.join() together with lambda's, as being a few poor choices that would have better been left out of the Python language. Happily enough, there are nicer ways in Python. But it is now less true that it once was that There-Is-Only-One-Way-To-Do-It in Python. Python became a bit more Perlish by providing such ugly alternatives. Moreover, through this added diversity, in the long run, Python is triggering a little loss in legibility (reading Python of others). So, the decision stays debatable. Of course, it will stay. Newcomers will often inquire about that stain... -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From syt at gemini.logilab.fr Fri Nov 9 11:11:02 2001 From: syt at gemini.logilab.fr (Sylvain Thenault) Date: Fri, 9 Nov 2001 16:11:02 +0000 (UTC) Subject: gtk, clist & python References: <3BE4EBD9.1719C3D4@freesbee.fr> Message-ID: On Sun, 04 Nov 2001 02:18:49 -0500, jm wrote: >hello, > >how can i know the number of rows in a "clist"? clist.rows -- Sylvain Thenault LOGILAB http://www.logilab.org From bjoufj at getcash.net Thu Nov 22 15:21:37 2001 From: bjoufj at getcash.net (bjoufj at getcash.net) Date: 22 Nov 2001 12:21:37 -0800 Subject: MAKE OVER $ 4.800 PER MONTH WHIT OUT INVERSION 3173 Message-ID: <6056f5abfe9b0ab864bd7e934cdc960c@spamfreenews.com> Check out this website, they pay people for receiving SMS's on their mobiles and pay the people who referred them a commission as well. You can join even if you don't have a mobile phone. The network (called DynamicSMS) charges advertisers for sending advertisements to their members. The examples on the website are that if you introduce 10 people who each introduce 10 people who each introduce 10 people, you can make $826.70 per month - not bad for introducing 10 people. If you introduce 30 people who introduce 20 people who introduce 10 people, you could be earning $4,893.70 per month or $58,724.70 per year !!!! They also let you setup a lifestyle profile so that you receive ads best targetted to what you are interested in. To find out more or to join, click on the link below URL : http://www.dynamicsms.com.au/intro.asp?ref=650339058&refc=406 http://www.dynamicsms.com.au/intro.asp?ref=650339058&refc=406 http://www.dynamicsms.com.au/intro.asp?ref=650339058&refc=406 http://www.dynamicsms.com.au/intro.asp?ref=650339058&refc=406 http://www.dynamicsms.com.au/intro.asp?ref=650339058&refc=406 Payments are made electronically by direct deposit into any account you choose. WORK WITH ALL COUTRIES AD IS 100% FREE! wrjnbmmyvhtjdvbzzhvdbylxjdynfejckzwqrsjnkmkqppdnczubwuebzgm From loewis at informatik.hu-berlin.de Thu Nov 1 07:02:27 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Nov 2001 13:02:27 +0100 Subject: How to read a xml-file sequentially References: Message-ID: "Thomas Weholt" writes: > I'm looking for an alternative to Pyxie, cuz. that's what I'm using now. > It's easy to use etc. but it's an extra module for users of my software to > download. My goal is to use as much of python standard-base as possible. Did you try xml.sax.parse? Regards, Martin From DeepBlue at DeepBlue.org Tue Nov 6 08:48:16 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Tue, 6 Nov 2001 07:48:16 -0600 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> Message-ID: Let me add to this that in such a boring predictable world, I have always appreciated Oleg's Pushkin-Lermentov-like sensibility and idealism :) DeepBlue "Cliff Wells" wrote in message news:mailman.1004992447.16369.python-list at python.org... > On Sunday 04 November 2001 10:24, Fish wrote: > > >"Fish" wrote in message > > > news:3be7390b.3387240 at 127.0.0.1... > > > > > >> On Sat, 3 Nov 2001 14:08:42 +0300, Oleg Broytmann wrote: > > >> >On Sat, Nov 03, 2001 at 12:44:13AM +0000, Fish wrote: > > >> >> Oleg, kindly go away. You do *nothing* to improve this newsgroup > > >> >> when > > As an interesting aside, I notice that you've posted to this list 6 times, > (in the 7000+ messages I have archived) and every one of these 6 messages is > in regard to the "free speech vs free software" debate. Oleg at least > contributes useful knowledge in other threads, so who is really doing > "nothing" to improve this newsgroup? > > -- > Cliff Wells > Software Engineer > Logiplex Corporation (www.logiplex.net) > (503) 978-6726 x308 > (800) 735-0555 x308 > From logiplexsoftware at earthlink.net Fri Nov 2 16:27:16 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 13:27:16 -0800 Subject: Freeware Python editor In-Reply-To: <9rv2o6$vgjpo$1@ID-11957.news.dfncis.de> References: <9rv2o6$vgjpo$1@ID-11957.news.dfncis.de> Message-ID: <01110213271607.09296@logiplex1.logiplex.net> On Friday 02 November 2001 13:16, Emile van Sebille wrote: > No, no, no. You're wrong. No, you are. But the GPL gives you that freedom, as long as you don't prevent others from being wrong as well. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From fperez528 at yahoo.com Tue Nov 20 14:24:26 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 21 Nov 2001 18:52:26 +2328 Subject: Cross platform catalog References: <20011121204933.09924.00000994@mb-fg.aol.com> Message-ID: <9thlu3$6p6$1@peabody.colorado.edu> Decks1998 wrote: > I was wondering if python can be used to create a compact disk catalog for > images with some interaction capabilities. I'd like for both mac and window > users to be able to use the cd without the need to install additional > applications or software. I know little about programing but thinking about > taking the plung into python if it's a step in the right direction. Any > suggestions would greatly be appreciated. > Thanks, There are many good reasons to learn a language, and definitely doing a hobby project you want to do is one of the best. So don't take this as me discouraging you: if you want to learn to program and do this project in the process, by all means go ahead. But keep in mind there's already 2500 similar half-done programs out on the internet. Some of them work reasonably well, others never got too far off the ground. Use google to find them if curious. So my point is: as a way to learn a language, what you propose is a great idea. But if what you want is to have such a program available, you might first want to look at what others have already done. Either it's already there or you can contribute and have something useful faster. Just a suggestion so you make the most efficient use of your time. Cheers, f From gmcm at hypernet.com Tue Nov 27 16:51:39 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 27 Nov 2001 21:51:39 GMT Subject: sys.prefix in COM References: Message-ID: Sue Giller wrote: [...] > I have finally looked into this, and I wonder if there might be a > problem in sys.prefix in COM. I am a python wannabe, so I am not > sure if the following is expected or what. > > I created a simple COM object in python that returns the state of > sys.prefix, and sys.path. [...] > If I run a test case in python that makes the COM object using > win32com.server.dispatch, it nicely prints out a good sys.prefix and > a path. [...] > However, if I create the COM object in VB6, I get a blank string back > for sys.prefix. > Prefix: : > C:\Python21\scripts\com > etc..... > > With the blank prefix, the path has dropped any items that are > located via *.pth files in my base python directory, thus loosing > things like Numeric that is installed in my c:\python21 directory. Excellent detective work. > I am unsure what exactly sys.prefix should be pointing to (I am > assuming it is where my python 'stuff' is installed to; c:\python21 in > my case), but I can't believe the string should be blank. > > Does anyone have any insights into this? I don't want to have to > hardwire my base python directory into my various com objects to > get them to find these other libraries, etc. I have done that up to > now, but I need to make these objects more general so they will > work on any python site. There is a reason for this. sys.prefix is really only meaningful on *nix. On Windows it is usually taken (correctly) to mean "where the executable is". site.py & friends can be picked up from there. If you registered your COM objects as CLSCTX_LOCAL_SERVER you would indeed have a sys.prefix. But if it's inprocess, the executable isn't Python. In fact, pythoncomXX.dll loaded pythonXX.dll for you, and without knowing where their python.exe lives, they're lost. Well, only a little. I've never encountered this problem, but I'd guess you could tweak Python's registry entries to get around this. -- Gordon http://www.mcmillan-inc.com/ From jjl at pobox.com Tue Nov 6 09:04:22 2001 From: jjl at pobox.com (John J. Lee) Date: Tue, 6 Nov 2001 14:04:22 +0000 Subject: 2.1 nested scope SyntaxWarning In-Reply-To: References: Message-ID: > "John J. Lee" writes: > > > However, the GracePlotter class works fine. Why? > > Could it be that grace_np is also imported globally (i.e. on the > module level)? That would explain it. [...] That's it. Thanks! (shouldn't have been imported, but it was) John From mwh at python.net Fri Nov 16 05:19:54 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 16 Nov 2001 10:19:54 GMT Subject: Size of an object in memory? References: <9sspa2$ku3$1@peabody.colorado.edu> <9t1djl$b00$1@peabody.colorado.edu> Message-ID: Fernando P?rez writes: > Michael Hudson wrote: > > > Fernando P?rez writes: > > > >> Is there any way (at runtime, dynamically) to obtain the size in > >> bytes of a given object in memory? > > > > Didn't we do this a few days ago? See this thread: > > > > > http://groups.google.com/groups?hl=en&threadm=_6FG7.33159%24i4.5175661%40news0.telusplanet.net&rnum=1 > > > > but, in short, no, and you don't really want to know. > > > > Sorry to bug, but I'm new to the list and I'm not sure which thread you're > talking about. If I hit the link you provide I get a blank in google. Could > you repost the correct link if you have it handy? Damn, I was sure I checked that. What's even wierder is that I can't find the relavent thread any more, either. There's a bit of it here: http://groups.google.com/groups?hl=en&threadm=j4snbl79ts.fsf%40informatik.hu-berlin.de&rnum=1&prev=/groups%3Fas_ugroup%3Dcomp.lang.python%26as_usubject%3Ddata%2520size%26as_scoring%3Dd%26hl%3Den (I haven't tried to trim the URL this time...). It started with the message-ID <_6FG7.33159$i4.5175661 at news0.telusplanet.net> which is still on my news server if that's any help. This article isn't on google (any more). Wierd. Maybe it'll turn up soon? perplexed-ly yr's M. -- 93. When someone says "I want a programming language in which I need only say what I wish done," give him a lollipop. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From dalke at dalkescientific.com Thu Nov 29 11:44:35 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Thu, 29 Nov 2001 09:44:35 -0700 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> <9u37pb$7dk$1@slb7.atl.mindspring.net> <13285ea2.0111290659.25cc6bf2@posting.google.com> Message-ID: <9u5omj$tuf$1@nntp9.atl.mindspring.net> J.Jacob: >Oh I forgot that functions can be assigned to variables in Python, >elimination lookup. As a dutch saying has it I was "comparing apples >with pears". > >version_6: > add = operator.add > mul = operator.mul > for j in range_nh: > wij = wi[j] > sum = reduce(add, map(mul, ai, wij)) >Takes 71 seconds The 'reduce' and 'map' are doing a lookup in builtins, which is much slower than doing a local variable lookup. Try this: add = operator.add mul = operator.mul local_reduce = reduce local_map = map for j in range_nh: wij = wi[j] sum = local_reduce(add, local_map(mul, ai, wij)) Also, the j index is only use to look up elements from wi, so you can replace that with 'for wij in wi' add = operator.add mul = operator.mul local_reduce = reduce local_map = map for wij in wi: sum = local_reduce(add, local_map(mul, ai, wij)) Andrew dalke at dalkescientific.com From warkid at storm.ru Fri Nov 9 11:52:02 2001 From: warkid at storm.ru (Kerim Borchaev) Date: Fri, 9 Nov 2001 19:52:02 +0300 Subject: GC question In-Reply-To: References: Message-ID: <12827.011109@storm.ru> Hello Martin, Friday, November 09, 2001, 4:05:49 PM, you wrote: MvL> Kerim Borchaev writes: >> I'm trying to control memory leakage in my code. >> I need to know which objects wasn't deallocated in proper moment. MvL> Then using DEBUG_LEAK is the right approach. I still don't know what MvL> "problem" you've encountered. The essence of the problem you explained below I suppose? ;-) MvL> When you write MvL> def fun(): MvL> class C: MvL> def m(self): MvL> g = C() MvL> fun() MvL> you *will* create an unreferenced cycle. You should know that the MvL> implementation of nested scopes creates "cell" objects, which are MvL> holders for variables in nested scopes. Since "C" is a name used in a MvL> nested scope, a cell object is introduced for C. That gives you the MvL> cycle cellobject ->> class C -> C.__dict__ -> C.m -> C.m.co_freevars -> cellobject Now I get it. But (may be only for me) the code above didn't look obviously "wrong". Although it's pretty simple. But, again, may be it's only for me... Best regards, Kerim mailto:warkid at storm.ru From tatebll at aol.com Sun Nov 18 16:20:26 2001 From: tatebll at aol.com (Bill Tate) Date: 18 Nov 2001 13:20:26 -0800 Subject: Speed Comparisons: Python vs Java References: Message-ID: "A. Keyton Weissinger" wrote in message news:... > I've seen some Java/Python comparisons, but none that show side by side > performance tests of any real depth. Has anyone seen any? If so, where? > > Thank you. > > Keyton Keyton, I would keep an eye on psyco - if development on that keeps gaining steam (which I pray it does), oh man what a ride that's going to be. From jdadson at ix.netcom.com Thu Nov 8 17:15:26 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 08 Nov 2001 22:15:26 GMT Subject: OT Re: C-extension in Python -- returning results References: <3BE9F266.A2794615@ix.netcom.com> Message-ID: <3BEB03D1.6895E5F@ix.netcom.com> Keith Farmer wrote: > > A word on the original function. One of the reasons this function is > able to be approximated by the polynomial is that given a reasonably > short period of time (a year for the outer planets, weeks for the > inner), the path described is very roughly a straight line (<70deg > arc), which with only a few minute's calculation (a thousand or two > samples) I can get accuracies to within 0.001%. > > The choice of polynomial was based on the prior existance of these > datasets. It provides a convenient way to check the method, if > nothing else. This is now way off topic, but one more comment... If the data form an approximate straight line, a 5th degree polynomial is under-determined. The fitting algorithm may "try" to use the extra degrees of freedom to fit noise in the data or roundoff error. Even if the algorithm "succeeds", you may get a fit that is very wild, not at all approximating a straight line. Followup-To: sci.stat.math. Jive From eppstein at ics.uci.edu Wed Nov 28 15:30:29 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Wed, 28 Nov 2001 12:30:29 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: In article , James_Althoff at i2.com wrote: > ... Although PEP 276 has stimulated much interesting discussion about new > syntax for specifying integer intervals, PEP 276 itself does not call for > any such syntactic changes to Python. It (merely) suggests adding an > *iterator* to types.IntType (using stuff that is already fully supported in > Python 2.1) to make more convenient the common case of using an index to > access items in a sequence (in a for-loop) when direct access to said items > is not practical (as in the case of a multi-dimensional table, for > example). > > With such an iterator one could write (with *no* syntax changes to Python): > > for i in table.rowcount: > for j in table.colcount: > print table.value(i,j) I don't care for it -- is it really natural and intuitive that "x in y" should be equivalent to "0 <= x < y" when x and y are both ints? E.g. that "3 in 5" is true but "-2 in 5" is false? Is this a natural mathematical operation to include as one of the fundamental ones in a language? If the goal is to make it easy to avoid range() in for loops, I'd prefer to see it done in a way that makes sense semantically and not just because it's a short previously-unused syntax. Hence my continued contribution to the discussion of alternatives. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From jeff at ccvcorp.com Thu Nov 15 15:47:45 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 12:47:45 -0800 Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> Message-ID: <3BF429F1.146759EA@ccvcorp.com> Gernot wrote: > Hi, > > I want to implement the functions myand, myor and mynot. They should have > the same effect as the known boolean operators and, or and not. > > The trick is that I am not allowed to use the boolean operators and, or and > not. > > This is what I tried: > ----------- > x = raw_input("Type something (x): ") > y = raw_input("Type something (y): ") > > def myand(x,y): > if bool(x) == 1: > if bool(y) == 1: > return 1 > return 0 > > if und(x,y) ==1: > print "true" > else: > print "false" > -------------- > > I think, the idea is not that wrong, but anyway, it doesn?t work! It has > something to do with "bool (x)", I think. Maybe this is something like a > module which i have to "activate" first?? There is no bool() in Python. You'll have to build your own. But at least you've got a decent start on your homework. Jeff Shannon Technician/Programmer Credit International From prabhu at aero.iitm.ernet.in Tue Nov 13 14:09:48 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 14 Nov 2001 00:39:48 +0530 Subject: IsPython really O-O? In-Reply-To: <9srqem$vt2$1@slb0.atl.mindspring.net> References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> Message-ID: <15345.28668.739560.621797@monster.linux.in> >>>>> "AD" == Andrew Dalke writes: AD> but I've never really needed it. Better I think would be if AD> Python's IDE's offered a reload() which was closer to AD> Smalltalks's, where a modified class definition propagates AD> even to existing instances of that class. So someone could AD> edit a module and manipulate things interactively without AD> having to reload and rerun everything. That would be incredibly cool but is most probably very hard to do? prabhu From mikael at isy.liu.se Tue Nov 6 02:33:22 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Tue, 06 Nov 2001 08:33:22 +0100 (MET) Subject: Process intercommunication In-Reply-To: Message-ID: On 05-Nov-2001 Graham Dumpleton wrote: > Depending on your requirements, you might consider an XML-RPC based > solution. There are a number of toolkis available for Python which > support XML-RPC and by using such an approach you need not have to > worry about writing any significant code to respond to socket > requests nor to handling the marshalling > or unmarshalling of data as the toolkits do this for you. > > For a complete example of a simple XML-RPC based system have a look at: > > http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81612 > > If you search around on the same site you should find other XML-RPC > examples using other server side toolkits as well. Thanks. I'll look into that. For the moment I'm considering sockets. It's simple enough for my brain to grasp. But nothing is carved in stone yet. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 06-Nov-2001 Time: 08:30:05 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From phr-n2001d at nightsong.com Fri Nov 9 07:29:11 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 09 Nov 2001 04:29:11 -0800 Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <7xlmhg6sbs.fsf@ruckus.brouhaha.com> Luigi Ballabio writes: > This said, while it makes sense in english to say "do this for every > line IN this file", it just doesn't sound right to me to say "do this > for every number IN 10"---even though I've been once familiar with the > definitions of the set of all integers. I'd rather say "for every > number UP TO 10" but that would mean introducing a new keyword which > I'm not going to suggest, not me, sir. Really the ellipsis should make an iterator: for i in 0...10. From alanmk at hotmail.com Fri Nov 30 06:47:35 2001 From: alanmk at hotmail.com (Alan Kennedy) Date: 30 Nov 2001 03:47:35 -0800 Subject: ZPT and WYSIWYG HTML tools. References: Message-ID: missive at frontiernet.net (Lee Harr) wrote in message > > Does anyone have any details of such ZPT/DreamWeaver problems? > > You should really look at the zope mailing list for questions > such as these. Those people really know zope. (zope at zope.org) Thanks Lee, you were of course right, the Zope mailing list was the place to look. The reason I didn't go to the Zope mailing list first was because I don't actually intend to use Zope, just ZPT. > One problem I remember them talking about was trying to load files > that do not end in .html or .htm or .gif or .jpg or etc >From my reading of the Zope archives, it appears that there are (solvable)problems with DW, Zope and WebDav, which arise when users try to upload files to a Zope server. However, since I'm not using Zope, these problems don't affect me. So I think I'm going to give ZPT (not Zope) a try as a Page Template language. I'll report back on my experiences sometime in the future, if anyone is interested. Regards, Alan. From fperez528 at yahoo.com Mon Nov 12 16:15:05 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 13 Nov 2001 20:43:05 +2328 Subject: Size of an object in memory? Message-ID: <9sspa2$ku3$1@peabody.colorado.edu> Is there any way (at runtime, dynamically) to obtain the size in bytes of a given object in memory? Since multiple names may be bound to the same object, is it possible to obtain the size of the underlying object and a list of all other names bound to it? I'm writing a runtime object inspector, using the very nice inspect module, but inspect doesn't seem to provide this kind of information. Thanks for any help, f. From ws-news at gmx.at Sun Nov 25 17:12:24 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Sun, 25 Nov 2001 23:12:24 +0100 Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> <3c015433.778200@news> Message-ID: <3c016d8f@brateggebdc5.br-automation.co.at> Hi, one more resource I heard recommended a lot - at least some month ago http://www.freenetpages.co.uk/hp/alan.gauld/ The Title is 'Learning to Program' and it uses the Python programming language. AFAIK, there are no particular prerequisites for this tuturial. hth Werner From cliechti at gmx.net Thu Nov 1 19:27:47 2001 From: cliechti at gmx.net (Chris Liechti) Date: 2 Nov 2001 02:27:47 +0200 Subject: Exception handling wart in Python References: Message-ID: "Leo Lipelis" wrote in news:pan.2001.11.01.19.35.44.23.979 at myrealbox.com: > Hi Pythoneers, > > I'd like some help with an issue I have with Python. Simply put, I > think having an exception mechanism is a waste if there is no tool that > will let you know which unhandled exceptions exist at point foo. I > have spoken about this issue briefly with Neal, of the PyChecker fame, > and he seemed to agree with me. > > I realize that it's a difficult problem to solve, but I think it would > be worth solving at the language level, similarly to the way it's done > in Java. on the other hand java has "Errors" which are thrown/raised like exceptions but those are not enumerated in a "throws" statement. you'll always find cases where you don't know which exceptions could be thrown in a method (think of dynamicaly created methods, remote objects,...) and python is a very dynamic language. ... > I think relying on documentation for this is not an option. First, > there is never a guarantee of documentation, and I would like this > feature to be guaranteed. Second, it becomes very problematic with > deeply nested functions and inheritance. Why should I have to search > through all those docs for something that compiler should tell me > anyway? This is just the kind of monotonous task that needs to be done > by a computer program instead of a human. most of the arguments for dynamic typing apply to to the exceptions too. return types are only in the documentation, parameter types too if you want to be sure you have to consult the docs anyway (and the sources aswell, as docs aren't allways up to date). if you don't trust python's dynamic typing stay to a staticaly typed language like java. ... > I agree with whoever said that a race horse doesn't belong in the glue > factory. It seems like Python is being used for serious programming, > and it seems to me, if it supports exceptions, it should support them > all the way. It's fairly pointless to provide exceptions if you really > never know whether you handle all the relevant exceptions or not, > without the ugly, bad, and stupid except: foo() statements to catch > *all* exceptions. nice and useful "except:", especially if you need a program that runs unatended for months ;-) > > Leo "__who_doesnt_like_underscores_and_many_selves_at_all__" Lipelis > > P.S.: The double leading underscore is the ugliest thing I've ever > seen in language syntax. I've been writing some Python code that uses > that feature, and man, it looks ugly. For a language that prides > itself on indentation based code blocks for readability, double > underscore is an ugly wart that needs to be fixed. That, and having to > constantly type self.__quax, self.__foo, self.__bar(), > self.__foobar()... That's *SEVEN* whopping useless characters on every > line. "private" is 7 characters per method decalration too in java (and then the return type, parameter types, throws... ";{}" every now and then, no thanks, i want to write functionality, code that does something and not zillions of characters just to get the compiler happy) and python has the advantage that i see that a method is private when i read the call. in java you have to consult the object documentation or scroll around just to see if a method is private, (or private, publ.. etc). a win for python writing "self" explicitly is important for a distiction for object attributes and global variables. (ever tried to explain "this" (and "super") and that its optional sometimes to a java beginner?) > > P.P.S.: Otherwise Python is a very pleasant and productive language. absolutely agreed chris -- Chris From erno-news at erno.iki.fi Tue Nov 13 02:35:05 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 13 Nov 2001 09:35:05 +0200 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> <7x8zddnroj.fsf@ruckus.brouhaha.com> <7xwv0vl1lh.fsf@ruckus.brouhaha.com> Message-ID: In article <7xwv0vl1lh.fsf at ruckus.brouhaha.com>, Paul Rubin writes: | Erno Kuusela writes: || | In fact it does the opposite--both the documentation and the pickle || | implementation (look at the "security" check for pickled strings) || | appear written with the idea that unickling is intended to be safe for || | untrusted strings. || || i can't see that idea in the documentation even if i try. | The pickle docs mention the non-pickle-ability of code objects as a | security advantage of pickle over marshal. Clearly the doc writer | wasn't aware that unpickling is insecure for other reasons. Also, the | docs for marshal recommend using pickle instead of marshal for RPC. i see it now. quite amazing! || the fact that pickle shouldn't be fed untrusted data has been common || knowledge in the python user and developer communities as long as i || can remember. | It sure shocked the heck out of me! I discovered it as a result of | making a sourceforge bug report (#467384) requesting that marshal be | documented so it could be used for RPC, and Tim suggested I use pickle | instead. So even Tim (one of the main authorities on Python's | implementateion) wasn't aware of the problem at the time. The authors | of the Cookie and Pyro modules weren't aware of it either. So this | type of "common knowledge" needs, at the very least, to be clearly | documented! It's not reasonable to expect programmers of a supposedly | easy to learn language to absorb all kinds of unwritten folklore | before they can safely write as common an application as a simple cgi | script. indeed. it seems this common knowledge was more local to my friends than i thought. guido seems to have known about it long ago though (the google archives only go back to 1995): || iirc the cookie module had this erroneous code before it was accepted || into the library. || || when it was put in the library, warnings were put in its documentation || to warn against anyone ever using the functionality. | However, "Cookie" is still aliased to SmartCookie in the module, | supposedly for backward compatibility. [...] i'd guess this is a bug. -- erno From jeff at ccvcorp.com Tue Nov 20 15:41:42 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 20 Nov 2001 12:41:42 -0800 Subject: displaying an Image using PIL w/o Image.show References: <3sjjvt0c8rnq3iuhtnlqvb1a3ekpr4ac0d@4ax.com> Message-ID: <3BFAC006.CFE9FE@ccvcorp.com> Tech wrote: > How do to show an Image in PIL without calling the Image.Show() > Method? I tried to use Image.Show() but I don't have some lib that I > need. Anyway the online docs seemed to suggest the there may be a > better way but did not say what it was. What lib does it say that you need? What platform are you using? What GUI toolkit are you using, or intending to use? (You can't display an image without a window to display it in.) Jeff Shannon Technician/Programmer Credit International From terabaap at yumpee.org Mon Nov 12 23:33:16 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Tue, 13 Nov 2001 04:33:16 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> Message-ID: <3BF0A2C1.4030007@yumpee.org> Chris Tavares wrote: > "Manoj Plakal" wrote in message > news:3BF07BC8.3090405 at yumpee.org... >> Basically, we need a portable, light-weight messaging >> protocol with a simple way of finding out how >> to connect to an application and calling some >> of the methods it exposes. Without having to >> do HTTP and XML and all that stuff that comes >> with XML-RPC and SOAP. > This is pretty much the goal of COM on Windows systems. It's potentially > very light weight - for simple addins, it's an inprocess function call. > > You might want to look at the Mozilla XPCOM stuff. Thanks for reminding me, I'll take a look. Anyone have experiences using XPCOM? ActiveState is using it for Komodo, are there others? Manoj From nhodgson at bigpond.net.au Thu Nov 15 16:48:24 2001 From: nhodgson at bigpond.net.au (Neil Hodgson) Date: Thu, 15 Nov 2001 21:48:24 GMT Subject: [È«º¸] Æú¶ó·ÎÀ̵å Ä«¸Þ¶ó³ª ·Î¸¸¼Õ Ä¿ÇýðèÁß ¿øÇϽô °ÍÀ» µå¸³´Ï´Ù. ³õÄ¡Áö ¸¶¼¼¿ä!!! References: Message-ID: Steve Holden: > Don't you just hate being spammed in languages > you'll never understand? And > I *didn't* mean HTML... There was an ActiveX too although it appears to only be a harmless scriptlet (http://itnsoft.com/ad/down/down.html). > turning-japanese-oh-yes-i'm-turning-japanese- > oh-yes-i-think-so'ly yrs - steve I think you actually need to turn Korean for this one. so-many-spammers-so-many-languages-ly y'rs, Neil From skip at pobox.com Tue Nov 27 13:38:40 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 27 Nov 2001 12:38:40 -0600 Subject: Integer Overflow In-Reply-To: References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: <15363.56752.182837.280872@beluga.mojam.com> >> Use longs: Ursus> Okay. My next project was to do the same thing with 64-bit Ursus> numbers. So how do I disable trapping for integer overflow? Ursus> (And don't tell me to use very longs ;-) Python's long are already very long. ;-) To be precise, their size is limited only by how much (virtual) memory you have available. Example (wrapped for readibility): >>> 3L**1000 132207081948080663689045525975214436596542203275214816766492036822682 859734670489954077831385060806196390977769687258235595095458210061891 186534272525795367402762022519832080387801477422896484127439040011758 861804112894781562309443806156617305408667449050617812548034440554705 439703889581746536825491613622083026856377858229022841639830788789691 855640408489893760937324217184635993869551676501894058810906042608967 1438864102814350385648747165832010614366132173102768902855220001L >>> (3L**1000) % (2L**32) 3552074529L In the current 2.2 beta, int operations that would overflow silently return longs: >>> 3**100 515377520732011331036461129765621272702107522001L You will have to force values back to ints when you know they will fit, however. >>> (3**1000) % (2**31) 1404590881L >>> int((3**1000) % (2**31)) 1404590881 I suggest you grab the latest beta and start having some fun... -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From erno-news at erno.iki.fi Sun Nov 11 09:10:48 2001 From: erno-news at erno.iki.fi (Erno Kuusela) Date: 11 Nov 2001 16:10:48 +0200 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> Message-ID: In article <7xpu6plw08.fsf at ruckus.brouhaha.com>, Paul Rubin writes: | Erno Kuusela writes: || | The security issue with pickle.loads that we spent a long time || | discussing is something I think the perl developers would not have || | tolerated. || || could you describe the security issue in some detail? | Basically if you unpickle a string that came from an untrusted source | (say, a browser cookie from the Cookie module), the string can make | pickle load arbitrary modules and call arbitrary object constructors | in your application. The docs for the cookie module mention this and | there's an bug open on sourceforge to fix the pickle docs. oh, that. but it is a deliberate design choice. if you want to take python to task for these sorts of features, eval() or input() are much "worse". or even marshal. i agree the pickle documentation should mention this as the first thing in big friendly letters. -- erno From eppstein at ics.uci.edu Sun Nov 11 23:21:57 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Sun, 11 Nov 2001 20:21:57 -0800 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> Message-ID: In article , Martin von Loewis wrote: > It *does* have a problem with " ", since it does not allow > a space character between the exclamation mark and the first character > of the directive. I believe you must not have a space in there, in > SGML, either, so this is not a problem with Python, but an error in > the document. He is parsing HTML. Of course he is going to have errors in the documents. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From blujay at .no.spamntlworld.com Fri Nov 30 08:37:23 2001 From: blujay at .no.spamntlworld.com (Alan Jay.) Date: Fri, 30 Nov 2001 13:37:23 +0000 Subject: Embedded Python interpreter in Kylix Message-ID: I have read an article on embedding Python in Delphi, but this relies upon com objects. Does anyone know if a Python interpreter can be embedded into a Kylix application, and if so, how? Alan. From timr at probo.com Sat Nov 24 00:56:45 2001 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Nov 2001 21:56:45 -0800 Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> Message-ID: "Brian Geddes" wrote: > >I've been trying to store/pass information in environment variables in >Windows 2000, but things aren't working the way I expect them to. The short and rather unsatisfactory answer is that you just cannot do this in a Win32 application. You cannot change an environment variable in a Win32 program in a way that outlives the process (except for the registry hack mentioned earlier, which affects ALL processes from that point forward). You can affect the environment in your CHILD processes, but not in your SIBLINGS. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From edgue at web.de Mon Nov 19 10:37:07 2001 From: edgue at web.de (Edwin =?iso-8859-1?Q?G=FCnthner?=) Date: Mon, 19 Nov 2001 16:37:07 +0100 Subject: [IO] Communication between Java and Python References: <3BF91867.3BBDD486@hik.fzk.de> Message-ID: <3BF92723.7EC0019@web.de> Hi Cris, maybe you should have a look at Jython (www.jython.org), a Python implementation written in Java. and btw: de.comp.lang.java is a german newsgroup. no needs for x-posts in english. regards, eg From rmfw at fast.net Sat Nov 10 21:54:34 2001 From: rmfw at fast.net (Ryan Wendt) Date: Sat, 10 Nov 2001 21:54:34 -0500 Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> Message-ID: I have an idea, but considering the fact that I just learned python yesterday, it probably won't help. Is it possible that it could be storing each number as larger ubit, such as a word, or even dword? That could be a possible explanation, though I don't know much about defining words or dwords in python. "Geert-Jan Giezeman" wrote in message news:9sdol4$2te$1 at samos.cs.uu.nl... > > I am trying to create a shelve from a table of 1100 by 1100 floating > point numbers, which I want to store as 1100 lists of length 1100, > indexed by a key. Unfortunately, I get an error when I try to create > this: > bsddb.error; (22, Invalid argument) > > When I store smaller lists (I tried up to size 1100*600), there is no > problem. > > My guess is that this has to do with the file size. Even with the > shorter list the size of the file is 1.01 GB (1,090,331,648 bytes). > Continuing in guessing mode, it could be that at a certain moment the > size of the file is doubled and that this fails. (I don't know exactly > how large files can get on an NTFS file system, but a 2GB maximum does > not sound unreasonable). > > Now on to the questions: > > 1) Are those large filesizes for shelves normal? A bare minimum for > storing the data would be 8*1100*1100 = 9,681,000 bytes. So pickling > and database overhead would be a factor 100. > > 2)Are there ways to circumvent those problems? Use a different > database (I like shelves, though), ... From sholden at holdenweb.com Tue Nov 13 16:19:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 16:19:05 -0500 Subject: Just installed wxPython References: Message-ID: "Julian Tibble" wrote in ... > Having played around with Tkinter and not liked it very much, I installed > wxPython to see what that was like. > > This program from the tutorial works fine if I run it as root, and seems to > work if I run it as a normal user, but I get an error message on the console: > > Gtk-WARNING **: Unable to locate loadable module in module_path: "libmac2.so", > > I have found the file, and the user has read permissions to it. How do I > change the path so this module can be found? > I think you'll find you need to add another directory to your LD_LIBRARY_PATH environment variable, or move the specified library to a directory already listed on the library path. regards Steve -- http://www.holdenweb.com/ From tjreedy at home.com Sat Nov 24 13:59:45 2001 From: tjreedy at home.com (Terry Reedy) Date: Sat, 24 Nov 2001 18:59:45 GMT Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFC0182.7DDF6B4E@ccvcorp.com> Message-ID: "Huaiyu Zhu" wrote in message news:slrn9vv07k.1f7.hzhu at mars.localdomain... > There are really two issues involved: I see at least three questions with respect to indents and cursor placement: 1. What should one type -- space or tab? 2. What should be displayed (if you type a tab)? 3. What should be transmitted and stored (in electronic versions)? There are at least two purposes for tabs: 1. place cursur (or typewriter platen) where you want to put next character; 2. save transmission time and electronic storage space by compressing spaces. The second purpose is essentially obsolete, making the first the correct one. This gets to the question: What is or should be the meaning of . Lets consider some of the possible contexts: prose, tables, code (omitting poetry ...). For prose using paragraph indents, the first tab stop should be that indent. For typescripts and printer versions thereof, the American standard is/was 1/2 inch or 5 spaces. Printed books often use fewer. A logical tab can be variably interpreted more easily than multiple spaces. For tables, the ideal (based on my considerable experience preparing published tables) is one tab per column, using tab variants that right justify columns of integers and align columns of decimal numbers. The physical interpretation of such logical structure markers should be defined by a separate tabstop definition, which can be adjusted as needed. For code, the visual indent should be enough to differentiate levels but not so much as to jam (short) lines up against the right margin of the display surface. > If everything can be redesigned from scratch, what would be the best > indentation method for languages like Python's? When I do code Python, which is currently not often, I use double spaces as being barely adequate, quick to type, and preferable to tabs that become 8 spaces. When I start using an adjustable-tab code editor, I'll switch to 3 or 4 spaces. > There is a strong argument for one tab character per indent level. > When indentation is encoded as the number of tab charactors, > code can be exchanged between different programmers > completely unaffected by the display style. Though this is not what I currently do, and even though I currently use a stupid news reader (Outlook Express) that deletes tabs, I find myself agreeing. This is the same argument I made above with respect to prose and tables: tabs should be regarded at logical structure markers rather that as fixed-meaning format characters. It is also one of the driving forces behind the development of XML and related standards: the realization that logical structure is distinct from physical format and that premature formating cramps possible uses of electronic files. > In this situation, what's the best distance between tab stops? No such thing as a general absulute. > If tabs were used to help reducing key strokes while typing a table on a typewriter, 8 > makes most sense, because 8x8=64. Nonsense. 5x16 = 80. Trying to ascribe a fixed-format meaning to tabs contradicts the argument made above for treating them as logical markers. In any case, defining as "move to the next multiple-of-8 position (+ 1 if using 1-based indexing)" is possibly never right from a functional viewpoint. It is wrong for prose, where just about the only tab needed is for paragraph indents. It is wrong for tables, except by accident, since it leads to the hell of mixed spaces and tabs (speaking from experience, again). It is wrong (too large) for coding. Maybe some poets would find it useful. It is sadly ironic that the 'standard' interpretation is almost never right. Terry J. Reedy From mbonnifait at wanadoo.fr Tue Nov 13 09:07:46 2001 From: mbonnifait at wanadoo.fr (Michel Bonnifait) Date: Tue, 13 Nov 2001 15:07:46 +0100 Subject: help for beginner ! Message-ID: <9sr9g4$gik$1@wanadoo.fr> i want to directly print the list or the result of my program i'm working with idle and i don't know how to do it without copying in one printable document From flynt at gmx.ch Mon Nov 26 09:40:31 2001 From: flynt at gmx.ch (flynt) Date: Mon, 26 Nov 2001 15:40:31 +0100 Subject: Zope database vs. MySQL References: Message-ID: <3C02545E.EE9AC4@gmx.ch> Mich Hiker wrote: > > I'm a new Zope user - developing web-based curriculum materials for a school > district. Can anyone tell me the advantages of configuring MySQL to use in > tandem with Zope over using Zope's built-in database? I've heard Zope is > faster using it's own DB, but others have told me it is limited and I should > go with MySQL. Any thoughts? > > Thanks. Hi Mich I think the question is not so much about the performance in first place but how you design your application and especially the persistence layer part. The Zope built-in database (ZODB) is an object database whereas MySQL is a relational database. You can use both approaches (combined or ZODB only) for industrial-strength applications. I do not agree with a statement like *... the ZODB is limited...*. This is too much of a simplification and misses the essential point completely: Do you want to use an object oriented database for your persistence layer or do you want to use a relational one ? It might be worth the effort to play around a little bit with Zope (and the ZODB) to make your own experiences. You can could follow the examples in the Zope book for example, especially the chapters about Databases and about ZClasses. You can have a look at the Zope Book here: http://www.zope.org/Members/michel/ZB/ Maybe there is someone in the Zope mailing list, who did something similar already. You might wish to subscribe and post your question again there. Here is the link to the subscription page of the Zope mailing list: http://lists.zope.org/mailman/listinfo/zope Regards --- Flynt From qrczak at knm.org.pl Sun Nov 4 16:39:11 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Sun, 4 Nov 2001 21:39:11 +0000 (UTC) Subject: bg and fg References: <20011104112551.A14309@cruciatuz.de> <001101c1653f$3f9a33e0$0101010a@local> <20011104172118.A15499@cruciatuz.de> Message-ID: Sun, 4 Nov 2001 19:37:12 +0100, Andreas Kostyrka pisze: >> if os.fork() == 0: >> os.setsid # what does THAT mean? it was in the example. >> # i looked into "pydoc os" but i didn't understand >> # find an explantation > This makes the process it's own session leader. ;) But only when called: os.setsid(), not merely referenced: os.setsid. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From christophertavares at earthlink.net Mon Nov 12 21:59:24 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Tue, 13 Nov 2001 02:59:24 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> Message-ID: "Manoj Plakal" wrote in message news:3BF07BC8.3090405 at yumpee.org... [... snip ...] > > Basically, we need a portable, light-weight messaging > protocol with a simple way of finding out how > to connect to an application and calling some > of the methods it exposes. Without having to > do HTTP and XML and all that stuff that comes > with XML-RPC and SOAP. > > I came across Scarab at http://casbah.org/Scarab/ > This is interesting though the project's been abandoned. > > Any comments? > > Manoj > This is pretty much the goal of COM on Windows systems. It's potentially very light weight - for simple addins, it's an inprocess function call. You might want to look at the Mozilla XPCOM stuff. -Chris From pfenn at mmm.com Fri Nov 2 10:20:21 2001 From: pfenn at mmm.com (Tom Fenn) Date: 2 Nov 2001 07:20:21 -0800 Subject: Need to improve COM performance Message-ID: <13b4aacf.0111020720.1f12039c@posting.google.com> Hello, I'm working on an application that involves calculating some statistics for data produced by a commercial scientific instrument (ion trap mass spectrometer). The code works, but takes longer than I expected to execute. I ran the profiler on it, and got the following results (which are sorted on cumtime and percall). Access to the data file is through a COM control provided by the manufacturer. I've wrapped it using genpy, and then wrapped an easier to use class around the component. If I read the profile data right, the program is spending 14 of its 15 minutes of execution time in the ApplyTypes routine from PythonCOM. Is there anything I can do to speed this up from within Python? Would implementing the Python class in C++ improve performance significantly in this case? Happily, the application is spending only a few seconds in my own code. ncalls tottime percall cumtime percall filename:lineno(function) 0 0 0 profile:0(profiler) 1 0.245 0.245 893.4 893.4 profile:0(r 1 0 0 893.155 893.155 :1(?) 1 1.103 1.103 893.155 893.155 coda.py:4(score) 926 2.159 0.002 888.736 0.96 xcalibur.py:240(XIC) 3704 879.47 0.237 882.8 0.238 __init__.py:342(_ApplyTypes_) 926 0.094 0 875.341 0.945 2DDE1FB3-A60F-11D2-BD82-0060978EEB9Cx0x1x0.py:1412(GetChromatogram) 2778 0.295 0 7.848 0.003 __init__.py:345(__getattr__) 3704 0.539 0 3.854 0.001 __init__.py:91(Dispatch) 3704 0.714 0 3.33 0.001 __init__.py:365(_get_good_object_) 926 1.08 0.001 3.285 0.004 coda.py:19(mcq) 12038 0.571 0 1.921 0 __init__.py:359(_get_good_single_object_) 3704 0.863 0 1.762 0 __init__.py:17(__WrapDispatch) 1852 0.2 0 1.589 0.001 stats.py:231(__call__) 3704 0.327 0 1.553 0 dynamic.py:75(_GetGoodDispatchAndUserName) 3704 1.226 0 1.226 0 dynamic.py:67(_GetGoodDispatch) 926 0.132 0 1.163 0.001 stats.py:2730(astdev) 9260 0.695 0 1.061 0 __init__.py:369() 926 0.281 0 1.031 0.001 stats.py:2705(avar) 3704 0.443 0 0.718 0 gencache.py:117(GetClassForCLSID) 1852 0.361 0 0.548 0 stats.py:2040(amean) 926 0.293 0 0.369 0 Numeric.py:181(convolve) 926 0.196 0 0.366 0 stats.py:4835(ass) 2778 0.36 0 0.36 0 __init__.py:351(__setattr__) 926 0.328 0 0.328 0 xcalibur.py:56(__init__) 1852 0.293 0 0.293 0 stats.py:4774(asum) 1852 0.247 0 0.247 0 Numeric.py:565(sum) 3704 0.182 0 0.182 0 __init__.py:310(__init__) 3704 0.139 0 0.139 0 CLSIDToClass.py:52(HasClass) 3704 0.135 0 0.135 0 CLSIDToClass.py:45(GetClass) 1852 0.126 0 0.126 0 Numeric.py:514(ravel) 1852 0.09 0 0.09 0 __init__.py:129(__getattr__) 926 0.076 0 0.076 0 Numeric.py:122(asarray) 926 0.073 0 0.073 0 2DDE1FB3-A60F-11D2-BD82-0060978EEB9Cx0x1x0.py:4501(IsTraceValid) 930 0.033 0 0.033 0 UserDict.py:14(__getitem__) 926 0.03 0 0.03 0 xcalibur.py:81(AsArray) From andreas at mtg.co.at Fri Nov 30 05:43:21 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Fri, 30 Nov 2001 11:43:21 +0100 Subject: Copy operator (was list.remove for Noivces) In-Reply-To: <000901c1786f$cba9f260$a9e1fea9@carol> References: <000901c1786f$cba9f260$a9e1fea9@carol> Message-ID: <200111301043.fAUAhQY27804@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Donnerstag, 29. November 2001 01:49 schrieb Arthur Siegel: > Andreas writes - > > >Well, I never had a problem with understanding the Python semantics. There > >are other languages that do have similiar semantics. (Actually most OO > >languages use only object references, not values) > > I am asking you to imagine coming to Python as a blank slate. I happen not > to need to imagine it. I am quite sure I would have no trouble with the > Python semantics, if I had the concepts. It is getting the concepts down, > *with > Python*, that is the subject matter. Well if you come with a blank slate, then it's note more difficult to understand "reference variables" then "value variables". > >Python 2.2b1 Standard library: > >.py size: 183031 6110941 > >import copy: 9 times > >shallow [:] copy: 75 times > > How many times did they make the wrong choice between [:] and > =, or some such. I expect None. That's where I want to be. Well, it's quite easy. One usually knows when one needs a copy. (Cannot tell about Numerics, perhaps they've got it somehow wrong *eg*) Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8B2LMHJdudm4KnO0RAia7AJ9PqrFGNph+PG4uDHq3HX8l39TPyQCggAAp caIrJtw5Cs4ZmieViml4Fnk= =JtNq -----END PGP SIGNATURE----- From emile at fenx.com Thu Nov 1 11:54:46 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Nov 2001 08:54:46 -0800 Subject: references ??? References: Message-ID: <9rrv24$vk148$1@ID-11957.news.dfncis.de> "Thomas Weidner" wrote in message news:pan.2001.11.01.17.30.27.280.2271 at gmx.net... > Hi, > > I think anybody here knows what references,like in java,c++ or perl, are. > How can i use references in python ? > > 2.Question: > l=[1,2,3,4,5,6] > for i in l:i=0 > print l > > l is still [1,2,3,4,5,6]. How to make changes made to i also apply to l ? for i in len(l): l[i] = 0 -- Emile van Sebille emile at fenx.com --------- From dalke at dalkescientific.com Wed Nov 28 12:44:30 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Wed, 28 Nov 2001 10:44:30 -0700 Subject: list math for version 1.5.2 without Numeric References: <13285ea2.0111280621.3da71a55@posting.google.com> Message-ID: <9u37pb$7dk$1@slb7.atl.mindspring.net> J.Jacob wrote: >but i am not at all used to optimization wizardry so i have no idea if >i can find a good solution. You have for j in range(self.nh): sum = 0.0 for i in range(self.ni): sum = sum + self.ai[i] * self.wi[i][j] This can not be written easly in functional form because the indicies of wi are in the wrong order. If you instead had the transpose for j in range(self.nh): sum = 0.0 for i in range(self.ni): sum = sum + self.ai[i] * self.wi[j][i] #^^^^^^ difference here then you could write it as for j in range(self.nh): sum = reduce(operator.add, map(operator.mul, self.ai, self.wi[j]) For what you have, a faster implementation is ni_range = range(self.ni) # compute the list only once ai = self.ai # turn attribute lookups into (faster) wi = self.wi # local lookups for j in range(self.nh): sum = 0.0 for i in ni_range sum = sum + ai[i] * wi[i][j] or even (assuming self.ni == len(self.ai)) # precompute ai[i] and wi[i] as a list of 2-ples ai_wi_pairs = zip(self.ai, self.wi) for j in range(self.nh): sum = 0.0 for ai_val, wi_val in ai_wi_pairs: sum = sum + ai_val * wi_val[j] Note: no testing, no performance comparsions -- just suggestions. Andrew dalke at dalkescientific.com From db3l at fitlinxx.com Fri Nov 2 18:20:27 2001 From: db3l at fitlinxx.com (David Bolen) Date: 02 Nov 2001 18:20:27 -0500 Subject: win32 - create/access file properties on NTFS References: <446d315.0111020046.2fc5c1d1@posting.google.com> Message-ID: datalim at email.com (Data) writes: > How do I create/access the extra information while > we right click a file on NTFS at the "Summary" tab? Just to follow up to my other post - I just realized that I think the "Summary" tag is application specific, so the odds are that the information is just stored in the file in an RCDATA (application defined raw data) resource. So the prior functions I mentioned ought to let you detect the data in the file, but not necessarily decode the contents. I'm not that familiar with how the shell decodes those resources - perhaps by using the owning application or something? If this is for office documents (e.g., Word, Excel) then I believe that information is considered "Properties" of the document, and access to them would be through some published COM interfaces (IPropertySetStorage and IPropertyStorage). Or you can automate the office application itself. Microsoft also has a downloadable add-on (dsofile.dll) that adds an automatable COM object layer above this. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From ajs at ix.netcom.com Sun Nov 25 13:19:44 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 25 Nov 2001 13:19:44 -0500 Subject: list.remove for Novices Message-ID: <000701c175dd$c2f2d180$a9e1fea9@carol> I see that my - >>>foo = [1, 2, 3, 4, 5] >>>for bar in foo: ... foo.remove(bar) issue which I ran into trying to follow suggestions for my permutations problem was addressed beginning at: But damn it to hell. Even when I try to be a normal Python guy, and just post up "technical" problems, I get into- or raise - issues/controversary. Because I am being asked to accept that the list.remove behavior is somehow apparent - rather than a true trap for the novice. At the same time I'm being told that I can't be expected to be able to handle 1/4=0 - though that behavior is clearly documented and shared with many other languages. Wish I could be hooked up to electrodes which would read-out the *real* issues a novice faces with Python. Because I have to accept that the desire to address those issues is real, just often being based on misinformation. Art From loewis at informatik.hu-berlin.de Tue Nov 6 03:37:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 06 Nov 2001 09:37:57 +0100 Subject: Is Stackless Python DEAD? References: Message-ID: "Frederic Giacometti" writes: > Yes, but the word 'intrusive' normally refers to a negative > connotation; and the expression 'too intrusive' means what it > means... I see. Looking up "intrusive" in Webster's, I find that this is not what I meant: in-tru-sive \in-'tr:u-siv, -ziv\ adj (15c) 1 a : characterized by intrusion in-tru-sion \in-'tr:u-zhen\ n [ME, fr. MF, fr. ML intrusion-, intrusio, fr. L intrusus, pp. of intrudere] (15c) 1 : the act of intruding or the state of being intruded; esp: the act of wrongfully entering upon, seizing, or taking possession of the property of another It is not the act of wrongfully taking possession of the property of another that has prevented stackless from being integrated. It is the way in which the property is turned upside down that is bothersome (now I ask myself whether bothersome will be misunderstood as well :-( Regards, Martin From fperez528 at yahoo.com Mon Nov 12 13:20:57 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 13 Nov 2001 17:48:57 +2328 Subject: Non-obvious name bindings References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> <3BF1BB43.6B4E667B@bgb.cc> Message-ID: <9ssf3h$dfh$1@peabody.colorado.edu> Don Garrett wrote: >> > >> > I mean this: >> > >> > >>> [e for e in ['exists']] >> > ['exists'] >> > >>> e >> > 'exists' >> > >> > And I'm still confused - those "temporary" variables declaration >> > looks so "innocent", and in most cases (in every case for list >> > comprehensions I guess?) it's everyones intension not to use this >> > variable somewhere outside the loop. >> > This is a bug in Python 2.1, very recently fixed. I posted about it a few days ago, and this is the reply Tim Peters gave me: See This was a bug, and was fixed last month (for 2.2; perhaps also for 2.1.2). Cheers, f. From zen at shangri-la.dropbear.id.au Fri Nov 2 01:58:18 2001 From: zen at shangri-la.dropbear.id.au (Stuart Bishop) Date: Fri, 2 Nov 2001 17:58:18 +1100 Subject: Python 2.1 syntax to Python 1.5.2 Message-ID: Before I rewrite all my lovely list comprehensions and 'print >>' statements into python 1.5 syntax, I don't suppose anyone has code that automagically does the translation? I'm trying to generate UML from some Python source, and ObjectDomain seems to be doing quite a good job except for the files that use Python 2.1 specific syntax (I guess because it is still using JPython 1.1). -- Stuart Bishop http://shangri-la.dropbear.id.au/ From peter at engcorp.com Mon Nov 26 08:37:11 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 26 Nov 2001 08:37:11 -0500 Subject: wavelet References: <3C028962.D467D83D@gol.ge> Message-ID: <3C024587.930528F1@engcorp.com> Giorgi Lekishvili wrote: > > Perhaps, here is someone who knows where can I get the python module(s) > for wavelet transforms? This might be the first place to try. Wait, I mean second place: http://www.google.com/search?q=python+wavelet+transform -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jrfsousaREMOVE00594ACC at esoterica.pt Sat Nov 17 17:01:15 2001 From: jrfsousaREMOVE00594ACC at esoterica.pt (José Rui Faustino de Sousa) Date: Sat, 17 Nov 2001 22:01:15 -0000 Subject: float( ) inconsistency? Message-ID: <1006034457.123813@isis.esoterica.pt> Hi! I am a little bothered by float( ) behaviour. I think float( '1.0e' ) or float( 1.0e-' ) should not raise an error. After all x = 1.0e or x = 1.0e- both are legal floats. Should not this be fixed? Best regards Jos? Rui -- ======================================================================== Oh, Lord, we thank Thee for the Oxygen Gas; we thank Thee for the Hydrogen Gas; and for all the gases. We thank Thee for the Cerebrum; we thank Thee for the Cerebellum; and for the Medulla Oblongata. Amen! - John Wheelock. ======================================================================== Iam://Jos? Rui Faustino de Sousa http://homepage.esoterica.pt/~jrfsousa/ mailto://jrfsousaREMOVE00594ACC at esoterica.pt phone://+351-239444940 address://rua Carlos A. Pinto de Abreu n? 30C, 1? 3040 Coimbra Portugal ======================================================================== Real Programmers do sig blocks in Fortran 95. ======================================================================== From graz at mindless.com Fri Nov 30 01:57:35 2001 From: graz at mindless.com (Graham Ashton) Date: Fri, 30 Nov 2001 06:57:35 +0000 Subject: Design tips requested for OOP forum system (using pickle) References: <56zN7.139$Jm.5630@stones> Message-ID: In article , "Andy Todd" wrote: > "Graham Ashton" wrote in <56zN7.139$Jm.5630 at stones>: > > Let me save you a whole line of code here; > > try: > import cPickle as pickle > except ImportError: > import pickle Ah, of course. I've been using 1.5.2c1 too much at work (yeah, I know!). -- Graham From tatebll at aol.com Mon Nov 12 20:24:04 2001 From: tatebll at aol.com (Bill Tate) Date: 12 Nov 2001 17:24:04 -0800 Subject: XML Schema References: <87vggivo5r.fsf@strindberg.maisel.enst-bretagne.fr> Message-ID: Jesper Holmberg wrote in message news:<87vggivo5r.fsf at strindberg.maisel.enst-bretagne.fr>... > Hi All, > > I'm trying to get some overview of xml tools in Python, but I'm a little > overwhelmed by the large number of sometimes half-finished, often poorly > documented, libraries and toolkits. I guess this in part is due to XML being a > relatively new technology. > > However, I'm more specifically looking for Python implementations of > XML Schema-validating parser. Does anyone here know of any tool-kit/parser that > supports XML Schema? > > TIA > > Jesper Jesper, I think you will find most support for validation is limited to DTD's - AFAIK, Sean McGrath's book XML processing with Python, provides one utility in particular, XMLV, that will validate an XML document against a DTD but NOT a xml schema. If the parser cannot locate the DTD, it reverts to a non-validating version (essentially the equivalent of his XMLN tool - a non-validating parser). Sean's book does not address validating documents against XML schemas at all - pretty understandable given the state of the schema standard at the time it was published. Sean's book does have a number of very useful tips nevertheless. I presume you've checked out Fourthought's FourSuite product. While it does have tools for XSLT, XPATH, RDF, SAX and DOM - I'm pretty sure it also doesn't provide tools to validate documents against a schema - but I would definitely check that site out first to be certain. You might also want to check out sourceforge - I seem to recall a recent post about a couple projects to build wrappers to make Apache's xerces and xalan tools available to python - I can't speak to that effort or whether it addresses your specific question. From kragen at canonical.org Mon Nov 26 14:04:41 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 14:04:41 -0500 Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> <3c015433.778200@news> Message-ID: <833d31tkty.fsf@panacea.canonical.org> "stephen cox" writes: > Anyway, down to business - Have you gotten to the Lists section yet (it's > located in the beginning of the book)? If so, I have a simple question: > isn't a list just an array? Yes. From max at alcyone.com Sun Nov 25 13:29:02 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 25 Nov 2001 10:29:02 -0800 Subject: How To Kill a Python References: Message-ID: <3C01386E.16856AB5@alcyone.com> Ben Ocean wrote: > I continually run into problems adding new software to my server that > is > dependent on Python because I have 2 versions, one of which is > completely > unnecessary; namely, 1.5.2. I want to kill it, or at least make it so > that > when Python is called it automatically calls 2.1 instead of 1.5.2, but > I > don't want to screw anything else up on the server. How should I go > about this? You don't say what operating system you're using. If it's UNIX-like, just remove execute privileges on the old executable. Under UNIX-like systems, Python is pretty clean about where it installs stuff. It should install /usr/local/bin/pythonX.Y, /usr/local/lib/pythonX.Y, and additionally /usr/local/bin/python, which is just a copy of the first. It's easy to keep multiple ones around by keeping, say, python1.5 and python2.1 and maintaining /usr/local/bin/python as a symbolic link to whichever one you want to run by default. That way you can run `python' to get the latest, or `python1.5' to deliberately get an old version. These all assume your configure prefix was /usr/local; adjust accordingly if you chose something else. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From malcolm at commsecure.com.au Sun Nov 11 22:06:30 2001 From: malcolm at commsecure.com.au (Malcolm Tredinnick) Date: Mon, 12 Nov 2001 11:06:30 +0800 Subject: AM_PATH_PYTHON m4 macro In-Reply-To: <20011111.143636.1080416554.8081@localhost.localdomain>; from nikander@mindspring.com on Sun, Nov 11, 2001 at 02:36:37PM -0500 References: <20011111.143636.1080416554.8081@localhost.localdomain> Message-ID: <20011112110630.D11398@csport07.commsecure.com.au> On Sun, Nov 11, 2001 at 02:36:37PM -0500, Robert Nikander wrote: > I have been trying to build the latest pygtk. It complains that it can't > find the AM_PATH_PYTHON m4 macro. It doesn't seem to come with Python 2.0 > or 2.2. > Does anyone know where it is? It's part of the automake package. You will need automake 1.5 for the absolutely latest pygtk releases. Malcolm -- Many are called, few volunteer. From rdsteph at earthlink.net Fri Nov 30 21:43:56 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 01 Dec 2001 02:43:56 GMT Subject: MIT AI Mailing List Message-ID: <3C08452E.9186F46@earthlink.net> http://www.ai.mit.edu/~gregs/ll1-discuss-archive-html/threads.html The above is a link to recent archives of an MIT mailing list that I got on recently because of attending the LLL conference. I am finding it to be most interesting. Among many other things, Jeremy Hylton is participating in a thread discussing technical issues which were brought to his attention by academics at the conference having to do with garbage collection and other things. There is mostly though discussion on newer, more experimental academic languages, as well as Scheme, Lisp, Ruby, etc. etc. etc. The mailing list can be subscribed to as below::: LL1-Discuss at ai.mit.edu Mailing List There is a mailing list for continuing discussions started at the workshop. To subscribe, send mail to majordomo at ai.mit.edu with the command subscribe ll1-discuss in the body. For more help, send mail to majordomo at ai.mit.edu with the command help in the body, or send mail to owner-ll1-discuss at ai.mit.edu . Archives of the ll1-discuss list are available. ________ I hope some of you will enjoy this academic maling list as I do, even if some of it is above my head. Ron Stephens http://www.awaretek.com/plf Python web site for newbies and unregenerate code hackers, just for fun... From igor.stroh at wohnheim.uni-ulm.de Tue Nov 6 16:50:04 2001 From: igor.stroh at wohnheim.uni-ulm.de (Igor Stroh) Date: Tue, 06 Nov 2001 22:50:04 +0100 Subject: Reading PDF files . References: Message-ID: <3be85b7e$1@sol.wohnheim.uni-ulm.de> On Tue, 06 Nov 2001 20:05:56 +0100, "Martin von Loewis" wrote: > Amit Weisman writes: > >> Is there a module for reading PDF files ? > > Please have a look at www.reportlab.com reportlab module doesn't support reading PDFs, it's rather a PDF generator, and I don't think that Amit is willing to pay $1000,- for the PageCatcher :) Amit, you might want to check the possibility to extract text with pdftotext (it's distributed with the Xpdf package): >>>from os import popen >>>text = popen('pdftotext %s -' % ).read() 'text' contains now only raw text data from specified PDF file, with a whole bunch of control chars though... but since all you want is to look up a word, this should be enough :) HTH, Igor From lac at strakt.com Thu Nov 29 07:34:18 2001 From: lac at strakt.com (Laura Creighton) Date: Thu, 29 Nov 2001 13:34:18 +0100 Subject: Python, licenses and CVS In-Reply-To: Message from David Bolen of "28 Nov 2001 18:15:15 EST." References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <200111291234.fATCYIua008335@ratthing-b246.strakt.com> Does anybody have any favourite alternatives to CVS? I'm constantly looking for something which is not file oriented, or which is better able to handle multiple people editing the same file on the same day. Just a way to insist 'I just moved that class into its own file. Nobody gets to reinsert their old hacked versions of this class _back_ into this file -- if you are changing this class you now need _that file_' would be incredibly useful. Laura Creighton From ny_r_marquez at yahoo.com Sat Nov 10 09:53:40 2001 From: ny_r_marquez at yahoo.com (R.Marquez) Date: 10 Nov 2001 06:53:40 -0800 Subject: Get file owner in Windows References: <8a27e309.0111081046.5bafb354@posting.google.com> <9selkh$12bvbo$1@ID-11957.news.dfncis.de> Message-ID: <8a27e309.0111100653.c3e304d@posting.google.com> Thak you for the response, but I get an empthy string as a result. (What is the /q switch supposed to do?). Any way, I was able to find that in ActiveState's site there is a way to do this, with Perl. Here is the link: http://aspn.activestate.com/ASPN/Mail/Message/perl-NTAdmins/680179 I was also able to find a solution by Microsoft, in VB. http://support.microsoft.com/support/kb/articles/Q218/9/65.asp The summary of that article says: Retrieving the owner of a file requires obtaining the security descriptor for the file, then using the security descriptor to get a pointer to the owner's Security Identifier (SID). Finally, you use the owner's SID to obtain the owner and domain name of the file. Someone named Itamar posted this same question to the Python-win32 mailing list: http://mail.python.org/pipermail/python-win32/2001-May/000053.html Here is what it says: lets say I want to get the security information on a file. So I do: >>> o = win32security.GetFileSecurity(r"c:\mingc.pyd", win32security.OWNER_SECURITY_INFORMATION) >>> o So what do I do with 'o' now in order to get the owner? I tried: >>> s = win32security.SID(o) >>> win32security.LookupAccountSid(None, s) Traceback (innermost last): File "", line 1, in ? api_error: (1332, 'LookupAccountSid', 'No mapping between account names and security IDs was done.') What am I doing wrong? No one responded to his post. I get the same results that he does. I have also looked through Mark's "Pyhton Programming on Win32" (good book, by the way), but it does not seem to have this information either. Does anyone have the knowhow to make Itamar's code work? Thanks. PS: Just testing. From pc at acs.co.nz Thu Nov 22 16:49:55 2001 From: pc at acs.co.nz (Peter Campbell) Date: Fri, 23 Nov 2001 10:49:55 +1300 Subject: extracting html table rows into a list References: <9aadf0f.0111220750.719466de@posting.google.com> Message-ID: I have something that does this (sort of), I extract data from a web site for stock prices. The main code revolves around the regexp function, I am looking for SPAN tags here but you will want to change so you are looking for TR or TD tags plus any other stuff as appropriate. # stock price grabber (c) Peter Campbell, 5th July 2001. Email pc at acs.co.nz package require http 2.3 load ./fbsql.so sql connect localhost fbase "" sql selectdb STOCKS # grab the data for each letter of the alphabet set letters {A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} set date [clock format [clock seconds] -format "%Y-%m-%d"] foreach code $letters { set token [http::geturl "www.nzse.co.nz/market/price_by_stock/[string tolower $code].html"] set data [set $token\(body)] http::cleanup $token # remove all non-breaking spaces regsub -all { } $data {} data set matches [lrange [regexp -inline -all {]*\>([^<]*)\ wrote in message news:9aadf0f.0111220750.719466de at posting.google.com... > hi , > does any body has a script which parse a big table from an html file > and create a list of rows ? > thanks for any responses From jriveramerla at yahoo.com Tue Nov 13 10:33:53 2001 From: jriveramerla at yahoo.com (Jose Rivera) Date: 13 Nov 2001 07:33:53 -0800 Subject: ZODBCDA Error...python15.dll not found!! References: <11e94203.0111121610.63995fae@posting.google.com> Message-ID: <11e94203.0111130733.1fcb93c4@posting.google.com> I want to retrieve data from MS SQL Server 7.0 that is running on NT server on another machine where it's not installed ZOPE... In the machine where I installed Zope there is ODBC DataSource that works to connect to the SQL Server Database... but I want to be able to make querys from Zope... so what am I missing here?... When I reset tho machine where zope is installed, Zope is defined as a NT service, it reports that can no find PYTHON15.DLL, and ZODBCDA it's not listed in the list of products of ZOPE. Thanks in advance for your help... From gmcm at hypernet.com Tue Nov 27 14:15:53 2001 From: gmcm at hypernet.com (gmcm at hypernet.com) Date: Tue, 27 Nov 2001 14:15:53 -0500 Subject: ANN Installer Release 5 Message-ID: <3C03A019.473.CF412A77@localhost> Release 5 of the McMillan Installer is here: http://www.mcmillan-inc.com/install5_ann.html Release 5 is a rewrite of the analysis and building code from earlier releasess. The result is much smaller, faster and more capable. Major changes include: - Instead of using an ini-file configuration (with a host of confusing options), Release 5 uses Python syntax specification files. - An extensible hooks mechanism for modules / packages that use import hacks. - Ability to run on non-ELF platforms (should run on most Unix systems, although I have not been able to test much of this). - Linux users get full binary dependency analysis (so you can include a private installation of TCL/TK or wxWindows, for example). - Windows users can now create "frozen" in-process COM servers. - Refactored C code (many thanks to Alan Green) so embedders can make use of Installer's capabilities. There is also an Installer mailling list. Subscribe at: http://trixie.triqs.com/mailman/listinfo/installer Supported systems include: - Windows - Linux - Unix (alpha quality) Supported Python versions: - Python 1.5 to 2.1 (2.2b2 appears to work too). What is it: The Installer package is any easy way to deploy Python apps to systems without Python installed (or with incompatible Pythons installed). License: MIT style. Contact: gmcm at hypernet.com

Installer Release 5Easy Python app deployment. (27-Nov-2001). From pzw1 at cor-no-spam-nell.edu Thu Nov 1 13:54:41 2001 From: pzw1 at cor-no-spam-nell.edu (Peter Wang) Date: Thu, 01 Nov 2001 13:54:41 -0500 Subject: verifying type of socket object? References: <+YrhO+rceV33qbXjWckIp8NUkWP4@4ax.com> Message-ID: how very odd. i'm running PythonWin version 2.1: "PythonWin 2.1 (#15, Apr 16 2001, 18:25:49) [MSC 32 bit (Intel)] on win32." this may be a windows socket issue. when i run the test code on Python 2.0 under linux, i get the same results as you. perhaps someone more familiar with the python socket library under windows can shed some light here? -peter On Thu, 01 Nov 2001 18:02:33 GMT, Thomas Jensen wrote: >Peter Wang wrote in >news:+YrhO+rceV33qbXjWckIp8NUkWP4 at 4ax.com: > >> in my code, i'd like to verify that i get passed a socket object. >> however, i'm having some trouble figuring out what exactly >> represents the "socket type". the main problem is that >> socket.socket() doesn't return instances of socket.SocketType: > >It does here, se below > >>>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>>>> socket.SocketType isinstance(x, >>>>> socket.SocketType) 0 x >>>> 011232A4> isinstance(x, socket._socketobject) 1 > >Whats your system and Python version? >(Mine is Python 2.1.1 on FreeBSD4.4-RELEASE) >Here's what I got: > >>>> x = socket.socket(socket.AF_INET, socket.SOCK_STREAM) >>>> socket.SocketType > >>>> isinstance(x, socket.SocketType) >1 >>>> x > >>>> isinstance(x, socket._socketobject) >0 > >And adding: > >>>> type(x) == socket.SocketType >1 From lyongu at ailab.pku.edu.cn Tue Nov 27 13:34:41 2001 From: lyongu at ailab.pku.edu.cn (Yong Lu) Date: 28 Nov 2001 02:34:41 +0800 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> <2NPM7.568$_06.167730@newsb.telia.net> Message-ID: "Fredrik Lundh" writes: > Yong Lu wrote: > > Agree, and maybe the index should be a little more comprehensive. > > what did you look for? "formatting, string" and "string formatting" > and "string documentation" are all in the library reference index... > > ...and there's an entire chapter dedicated to output formatting > in the tutorial. > > I simply looked up "%" itself. I thought this would be listed as a special operator. Regards, Yong From loewis at informatik.hu-berlin.de Thu Nov 1 07:17:03 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 01 Nov 2001 13:17:03 +0100 Subject: Zugriff auf Windows Dateieigenschaften References: Message-ID: joeyahoo at gmx.de (Andreas) writes: > ich bin der totale Pythonanf?nger und muss ein Skript schreiben Hallo Andreas, Bist Du auch neu im Usenet? In comp.lang.python ist es ?blich, englisch zu schreiben. > In welchen Modulen finde ich denn Funktionen zum Zugriff auf die > Dateieigenschaften wie zum Beispiel Erstellungsdatum, ?nderungsdatum > etc. Bis jetzt habe ich nur os.path gefunden. os.stat gibt ein n-Tupel zur?ck, das diese Informationen enth?lt. Das Modul stat enth?lt verschiedene ST_-Konstanten, um die Indizes dieses Tupels symbolisch anzusprechen. Ciao, Martin From GeorgLohrer at gmx.de Thu Nov 8 02:05:14 2001 From: GeorgLohrer at gmx.de (Georg Lohrer) Date: Thu, 08 Nov 2001 08:05:14 +0100 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> Message-ID: Edy, beneath all the others said about the number of values for the c'tor, the > add.UserPlan = input("Username: ") seems to be wrong or not desired, too. The 'input' statement is realized as eval(raw_input()) So, you have to enter a valid Python-statement to satisfy the needs of input. Is that what you want? For example, you have to enter something like: Username: 'MyName' and not a simple Username: MyName Ciao, Georg From leovd at pacbell.net Thu Nov 8 12:19:25 2001 From: leovd at pacbell.net (Ray Van Dolson) Date: Thu, 08 Nov 2001 17:19:25 GMT Subject: Problem with httplib and POST References: <01b6b30b-d975-4ec1-a6f5-8e341dc13a3b@zigzag.magnetic-ink.dk> Message-ID: Klaus Alexander Seistrup wrote in <01b6b30b-d975-4ec1-a6f5-8e341dc13a3b at zigzag.magnetic-ink.dk>: >Have you tried > >h.putrequest("POST", "/management/editdns.asp") > [???] >params = urllib.urlencode({'hostname': HOST_HERE, 'hostip': NEW_IP, > 'B1': 'Update DNS Record', 'Update': '1', 'sld_nsrec_id': > '4444'}) > >? Yeah, I tried that. 502 Server Error was the result. I managed to set up stunnel on my server and could then sniff the connection as I ran it through my web browser. I decided to do it with an HTTP/1.0 browser (in this case, Netscape 3.04). Here's what I sniffed: POST /management/editdns.asp?Update=1&sld_nsrec_id=37792 HTTP/1.0 Referer: http://www.bludgeon.org:8080/management/editdns.asp?sld_nsrec_id= 37792 Connection: Keep-Alive User-Agent: Mozilla/3.04 (WinNT; U) Host: www.bludgeon.org:8080 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* Cookie: SessionTest=enabled; ASPSESSIONIDQQQQGTKQ=GOCGOAOAGANGAMHCEMBACCMB; Domain=Name=BLUDGEON%2EORG Content-type: application/x-www-form-urlencoded Content-length: 66 hostname=TRISTRAM.BLUDGEON.ORG&hostip=4.3.2.1&B1=Update+DNS+Record After enabling h.set_debuglevel(1) in my code, here's what it appears I'm sending out: POST /management/editdns.asp?Update=1&sld_nsrec_id=37792 HTTP/1.0\r\n' Accept: text/html\r\n' Referer: https://www.dotster.com/management/editdns.asp&sld_nsrec_id=37792 \r\n' Accept-Language: en-us\r\n' Content-type: application/x-www-form-urlencoded\r\n' Accept-Encoding: gzip, deflate\r\n' Host: www.dotster.com\r\n' Content-Length: 66\r\n' Cache-Control: no-cache\r\n' Cookie: SessionTest=enabled; ASPSESSIONIDGQGGGTVY=IEPDIPIDNJAAEFOPCFOMGDIN; Domain=Name=BLUDGEON%2EORG \r\n' \r\n' hostip=9.9.9.9&B1=Update+DNS+Record&hostname=TRISTRAM.BLUDGEON.ORG' Things that are different--Netscape uses a Keep-Alive connection. I didn't think this was supported by HTTP/1.0. In any case, when I use it in my script, (and use a correspondding h.close() statement--it still won't work. Also, the parameters in my POST urlencode string are in a different order. I doubt this would make the difference, and in any case, I can't seem to preserve the order of things in dictionaries. Other than that, and the order of the headers (shouldn't matter?), everything seems to be exactly the same! Any other ideas? I guess I may email dotster and see if anyone is willing to help me out. Thanks much, Ray Van Dolson From qrczak at knm.org.pl Fri Nov 2 13:00:30 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 2 Nov 2001 18:00:30 +0000 (UTC) Subject: Converting perl to python available? References: Message-ID: Sat, 27 Oct 2001 13:03:57 +0200, Gerhard H?ring pisze: > Seriously, has there ever been a translator from one language to > another that did not produce an absolute mess? p2c converts Pascal to readable C. OTOH the result is not necessarily fully equivalent to the original (by design). For example it replaces Pascal's length-prefixed strings with C's null-terminated strings and is even clever enough to replace s[0] := Chr(n); with s[n] = '\0'; but it won't work when the program relies on string representation in a harder way. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From pehr at alum.mit.edu Sun Nov 4 10:01:06 2001 From: pehr at alum.mit.edu (pehr) Date: Sun, 04 Nov 2001 15:01:06 GMT Subject: ANNOUNCE: PySteroids 2.0 References: Message-ID: <3BE558CA.6040904@alum.mit.edu> Also, the URL you give is broken, http does not work. I had to trace back to http://vampira.dyndns.org and then shop around to find your file. You seem to be serving only through HTTPS. -pehr Lucio Torre wrote: > Im happy! this is public release of pysteroids 2.0. my asteroids game > done with pygame. > > Nothing near paradigm shifting in games, but its my baby. > > check it out at: > > http://vampira.dyndns.org/zope/software/ > > lucio. > > From niemeyer at conectiva.com Wed Nov 14 13:53:29 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Wed, 14 Nov 2001 16:53:29 -0200 Subject: Python .elc and /etc/magic In-Reply-To: References: Message-ID: <20011114165329.A4132@ibook.distro.conectiva> > We found that adding [...] > will help. We should also have something like that for python: 0 string/b #!\ /bin/bash Bourne-Again shell script text executable 0 string/b #!\ /usr/local/bin/bash Bourne-Again shell script text executable -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From boud at rempt.xs4all.nl Sat Nov 3 13:06:58 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 3 Nov 2001 18:06:58 GMT Subject: Python/QT Book no in final edit References: <7xady4cxng.fsf@ruckus.brouhaha.com> Message-ID: <9s1bo2$goc$1@news1.xs4all.nl> rand0m wrote: >>Looks nice. It would be nice to have a link to render it all on one web > page. > why not just wgetting it! (wget exists also for ms-dos and it's a really > cute software) > wget -m -c -np http://stage.linuxports.com/projects/pyqt Or you could pre-order it, and have it delivered at your doorstep in a convenient format that would be an adornment to the shelves of even the most refined library! Please note that the version on the website is not the definitive version - the editor and I are taking the text through the final edit just now... Bringing the text up to date for Qt 3.0, for instance, and getting the last pesky little bugs out of the example code. When the book has gone to the printers, we'll be setting up a webforum at linuxports, with all the sourcecode, and a q&a forum. -- Boudewijn Rempt | http://www.valdyas.org From phd at phd.pp.ru Wed Nov 14 06:06:33 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Nov 2001 14:06:33 +0300 Subject: Mimetools and how to use it In-Reply-To: <3BF25ABF.27201.B52A60@localhost>; from printers@sendme.cz on Wed, Nov 14, 2001 at 11:51:27AM +0100 References: <3BF25ABF.27201.B52A60@localhost> Message-ID: <20011114140633.L11497@phd.pp.ru> On Wed, Nov 14, 2001 at 11:51:27AM +0100, A wrote: > >From a web server I receive headers that is an instance of the class > MIMETOOLS.MESSAGE. > How can decode it to get something like this > > Date: Wed, 14 Nov 2001 10:02:17 GMT > Server: Apache/1.3.6 (Unix) PHP/3.0.14 > X-Powered-By: PHP/3.0.14 > Set-Cookie: PHPSESSID=000741aaa06ae3645ff0106145f842b5; path=/ > Expires: Thu, 19 Nov 1981 08:52:00 GMT > Cache-Control: no-store, no-cache, must-revalidate, post-check=0 > Pragma: no-cache > Set-Cookie: c_id=bla; path=/ > Connection: close > Content-Type: text/html msg = mimetools.Message(response) # response must have .read() method cookie_h = msg["Set-Cookie"] cookie = Cookie.Cookie("Set-Cookie: %s" % cookie_h) print cookie["PHPSESSID"].value print cookie["PHPSESSID"]["path"] Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sholden at holdenweb.com Wed Nov 7 08:41:09 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 7 Nov 2001 08:41:09 -0500 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> <8ef9bea6.0111060838.24996280@posting.google.com> <9s9949$hm5$1@news.service.uci.edu> <8ef9bea6.0111061428.28c46fc0@posting.google.com> <8ef9bea6.0111070030.d9c3793@posting.google.com> Message-ID: "Hung Jung Lu" wrote ... > huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) wrote >... > [...] > > You are confused about the cause of this problem. > > I don't think so. > > > It is has nothing to do with namespace. > > Now you are confused. You think you can do Python without namespaces. > I don't believe Huaiyu was suggesting that you could "do Python without namespaces". In so far as names have to live somewhere, clearly they are necessary. Just the same, you should be careful, having found a hammer, not to confuse all problems with a nail. Object mutability is also an important aspect of the problem described. Because the object is referred to by name does not make all problems concerning it "namespace problems". And I am not, by the way, trying to suggest that understanding namespaces isn't essential to a complete understanding of Python. I am simply trying to suggest that, didactically speaking, understanding cannot be complete instantly, and it is therefore necessary to provide a staged set of comprehension levels for beginners. In the early stages, unnecessary complications (those which don't improve understanding) should be omitted. > > Experienced Python programmers always keep the three Python namespaces > in mind. Matter of fact, many good Python programmers, including those > that made Zope and hired Guido [:)], do tweak the built-in namespace > once in a while. I guarantee you, once you have the namespace > dictionaries picture inside your head, you won't need to use terms > like "Python distinguishes between mutation and name-binding" and you > won't run into namespace problems again. Once you understand the > namespace dictionary mechanism, you'll see that all the three examples > ('from xyz import *', 'global', and this one) I have mentioned all > come from the lack of understanding of the namespace mechanism. > Without understanding the namespace mechanism, you think they are > three unrelated problems. (Missing the forest because of the trees, as > they say in English, or, like blindmen touching the elephant, as they > say in Chinese.) Once understood the namespace mechanism, you won't > have any of these problems. Frankly, I don't think a person has > understood Python until they have understood the namespace mechanism. > My advise is: get to see the whole forest, or the whole elephant, or > the whole Python. :) > The different problems have related caused, true. This does not mean that a beginner shouod be confused by having full detail of the namespace mechanisms thrust at them when all they need to do is bind values to a name or two. Your use of the term "understanding" omits any comparative, implying that there is only one level of understanding. We must find out many individual facts about the elephant before we appreciate its true complexity. In the meantime are we not allowed to use it to haul logs? > However, that's not a task for beginners. Me having to spend 4 > postings on this thread should tell you something: many people don't > see the whole Python. > I suspect it is more a measure of your determination to have this matter thoroughly discussed. Would you like to go for 5 :-) ...? > >feeling-exhausted-explaining-this-many-times-ly yr's > > Believe me, I am more exhausted than you are. :) > Newbies are easy. It's the old-timers who are hard to convince! not-that-i-claim-to-be-one-ly y'rs - steve -- http://www.holdenweb.com/ From fgeiger at datec.at Mon Nov 5 15:28:42 2001 From: fgeiger at datec.at (F. GEIGER) Date: Mon, 5 Nov 2001 21:28:42 +0100 Subject: Exception holes, again. References: Message-ID: <9s6spi$ksk$1@newsreaderm1.core.theplanet.net> I had the same problem. This is what Mark Hammond and David Bolen answered to me (cut & pasted from my browser; you can find the whole thread if you search for "Geiger pywintypes" in groups.google.com: http://groups.google.com/groups?q=geiger+pywintypes&hl=de&btnG=Google-Suche) : -------- Von:Mark Hammond (MarkH at ActiveState.com)Betrifft:Re: Want to catch pywintypes.api_error Newsgroups:comp.lang.pythonView this article only Datum:2001-03-13 05:27:15 PST Franz GEIGER wrote: > When I start win32api.FindFiles(filespec) with a non-existing filespec it > throws an exception of class pywintypes.api_error. But a "except > pywintypes.api_error, e:" does not work. Using "except Exception, e:" does > the job, because Exception is the base class. But how can I catch api_error? > What do I miss? > win32api.error Mark.Message 3 in thread Von:Franz GEIGER (fgeiger at datec.at)Betrifft:Re: Want to catch pywintypes.api_error Newsgroups:comp.lang.pythonView this article only Datum:2001-03-13 09:38:19 PST Thank you, Mark! How could I have figured out this by myself? I did a text search for api_error over my ActivePython distribution, w/o success. Is it burrie din those pyd-files? Regards Franz "Mark Hammond" wrote in message news:3AAE208D.4010103 at ActiveState.com... > Franz GEIGER wrote: > > > When I start win32api.FindFiles(filespec) with a non-existing filespec it > > throws an exception of class pywintypes.api_error. But a "except > > pywintypes.api_error, e:" does not work. Using "except Exception, e:" does > > the job, because Exception is the base class. But how can I catch api_error? > > What do I miss? > > > > win32api.error > > Mark. >Message 4 in thread Von:David Bolen (db3l at fitlinxx.com)Betrifft:Re: Want to catch pywintypes.api_error Newsgroups:comp.lang.pythonView this article only Datum:2001-03-13 17:54:06 PST "Franz GEIGER" writes: > How could I have figured out this by myself? I did a text search for > api_error over my ActivePython distribution, w/o success. Is it burrie din > those pyd-files? I'm not sure if it's explicitly documented, but one good way is to do a dir() of the module at hand - you'll find an "error" object in both pywintypes and the individual modules such as win32api. It is a bit confusing that the internal class is called api_error (and that's how the instance objects display themselves) but the actual instance is called error. But having an "error" object in a module for exceptions is reasonably common, so a good thing to check for. -- -- 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 \ \-----------------------------------------------------------------------/ -- ------ "Dale Strickland-Clark" schrieb im Newsbeitrag news:k808uto6v8g6f2ilnfvdv1ondah38lslif at 4ax.com... > On a related subject to the earlier exceptions wart thread. > > I want to trap the specific 'api_error' exception raised by win32api. > > I can't find where that exception is defined so how do I catch it? > > I have searched the whole Python installation for the string > 'api_error' but it isn't there. > -- > Dale Strickland-Clark > Riverhall Systems Ltd -------- From dbelan2 at cs.mcgill.ca Sat Nov 10 14:20:43 2001 From: dbelan2 at cs.mcgill.ca (=?ISO-8859-1?Q?David_B=E9langer?=) Date: 10 Nov 2001 11:20:43 -0800 Subject: doc generator Message-ID: Looking for software to generate doc from source. Tried pythondoc 0.7 but was unable to make it run on freeBSD. Looks that it was more made for Windoz. Thanks, David From garth_grimm at hp.com Thu Nov 29 19:37:41 2001 From: garth_grimm at hp.com (Garth Grimm) Date: Thu, 29 Nov 2001 16:37:41 -0800 Subject: A modest indentation proposal References: Message-ID: <3C06D4D5.7050309@hp.com> I think I'd run into more problems with adding lines to the end of block, but forgetting to delete the ; in what used to be the last line of the block, then I do with 'forgetting' to indent blocks correctly. Garth Erann Gat wrote: > The subject of syntactically-significant indentation seems to dominate a > lot of discussions on Python. Personally I've found it to be less of a > problem than I thought it would be, but annoying nonetheless. It also IMO > makes the language unsuitable for mission-critical applications. It's > just too easy to screw up indentation (particularly when cutting and > pasting large blocks of code) without realizing it. > > I have a suggestion for how to make people like me who are uneasy with > syntactically significant indentation feel more comfortable while at the > same time not alienating those who thing that it's a really cool feature. > The proposal is based on the observation that Python already has the > equivalent of an open-brace for code blocks. It's the colon. To see that > this is so you have only to observe that a good editor can automatically > indent code properly at the beginnings of blocks, but not at the end. The > solution to the problem is to add an optional end-of-block identifier. > > I propose to use a semicolon at the end of a line to denote the end of a > block, e.g.: > > for i in l: # Colon signals beginning of block > foo() > baz(); boff() # Semicolon separating statements works as usual > bar(); # Semicolon at end of line signals end of block > biff() > > > This convention is 100% backwards-compatible with current practice, that > is, code written using this convention runs with no problems in Python as > it currently stands. > > What I would like to see in terms of support for this convention from the > Python community is two things: > > 1) Editor support for this convention so that a semicolon at the end of a > line causes the editor to unindent, and > > 2) Parser support. It would be enough to simply give a warning if there > is a discrepancy between the block structure defined by indentation and > that defined by the semicolon-at-end-of-line convention (i.e. "Warning: > end of block detected without trailing semicolon"). Making this optional > so that die-hard indentation fans could turn it off would also be fine. > > Comments? > > Erann Gat > gat at jpl.nasa.gov > From schaffer at optonline.net Thu Nov 8 08:17:20 2001 From: schaffer at optonline.net (Les Schaffer) Date: 08 Nov 2001 08:17:20 -0500 Subject: mayavi installation problem on Win NT References: <9sdh9v$hgq$01$1@news.t-online.com> Message-ID: <87snbpo10f.fsf@optonline.net> > Error: At least one module has an unresolved import due to a missing > export function in an implicitly dependent module. make sure that there are no _older_ vtkdll.dll files sitting around on your PATH. i think my package puts one right in the python\vtk directory. what unresolved import is dependency walker showing, BTW? les schaffer From pj at sgi.com Wed Nov 14 15:57:42 2001 From: pj at sgi.com (Paul Jackson) Date: 14 Nov 2001 20:57:42 GMT Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) References: <20011112102612.A1723@gerg.ca> <20011112203150.A8294@ibook.distro.conectiva> Message-ID: <9suls6$8b1on$1@fido.engr.sgi.com> Greg wrote: |> [me, on allowing interspersed options and args in Optik] |> ... |> OK, I think I'll add this feature. Still haven't decided to |> enable it by default, but I'm leaning that way right now -- it |> improves usability and shouldn't ruin anyone's day, especially |> since "--" can always be used for "stop processing options now". Well, I for one would not like to see such. It's just a preference issue for me, so feel free to count votes and declare a winner (or just imagine counting them, and cast the final vote yourself ;). But as an old Unix hacker, I'd not expect that arguments past the first non-option arg would be scanned for further options (with a few annoying exceptions ...). Better to solve the problem of inserting an option after you've already typed further in the line by using a shell that allows more flexible command line editing. Better not to encourage yet more gratuitous differences in the non-essential details of how commands parse their command line. Also, adding such a feature will result in the following sequence of events, leading to frustration: 1) Optik parses interspersed options by default 2) Nice New Command is written using Optik 3) User happens to invoke Nice New Command with interspersed options, not even aware that this is "special". 4) Same user can't figure out why some other (not so blessed) command is misbehaving (they interspersed options). And it can lead to yet another frustation: 1) Directory contains (admittedly rare) instance of file whose name matches the pattern '-*'. 2) User invokes Nice New Command using shell wild cards: nicenewfoo -a -b -c * 3) Nice New Command behaves most unexpectedly Like I said - one "no" vote here. -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From loewis at informatik.hu-berlin.de Sat Nov 24 06:20:15 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Nov 2001 12:20:15 +0100 Subject: prep my types for 2.2? References: <3BFEF3DF.5030103@shinners.org> Message-ID: Pete Shinners writes: > i've got several extension types that i'd like to get prepared for > python-2.2. currently i have a function that constructs the object and a > "type" variable available.. > > Myobject() > type(Myobject()) is MyobjectType > > from what i can see in python-2.2, these become the same thing. They need not, but they can - if you want them to. > first, i can't figure out exactly what function slots and TP flags i > need to use to enable this behavior? did i overlook this in the docs > somewhere? (couldn't find) You need to implement a tp_new slot. If somebody writes your_type(arguments) Python will look at the type of your_type (which will be the type type), and then look at its tp_call slot (i.e. typeobject.c:type_call). That, in turn, will use tp_new. > the other question, what is the best way to make this work for both > python-2.2 and earlier releases? You can leave everything as-is if you want. It will continue to work with 2.2 as it did with earlier releases. > it looks like if i hook something nice for 2.2 up in the Type > structure, that won't work for python-2.1. so it 2.1 i'll need to > fallback to the classes function/type like i already have? can i > make it so python-2.1 can construct objects from the Type? No, you can't. In 2.1, the name of your type can be either bound to the type obejct, or to the creator function. In 2.2, you could bind both the name of the type object and the name of the creator function to the type object, so that you would have Myobject is Myobjecttype You could then deprecate one of them, and drop it when everybody has migrated to 2.2. Regards, Martin From tim.one at home.com Sun Nov 4 17:14:54 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 17:14:54 -0500 Subject: Program very slow to finish In-Reply-To: <3BE51CD5.6B8CFC72@chello.nl> Message-ID: [Roeland Rengelink] > I'm pretty sure this is a problem with the garbage collector, I did some > measurements showing bad (O(n**2)) performance when collecting large > numbers of objects at once (as happens when your dicts are deleted at > the end of your program). I filed a bug report (#477963) on it. See: > > > > for more details I expect you're just measuring your platform's cache performance. Here's the output from running on a Win98SE box w/ 256MB RAM (I'll leave out the creation times because they aren't interesting; note too that time.time() on Windows has poor precision, so the numbers are mostly nonsense for the smallest dicts): size: 10000, destruction: 0.00 (usec/elem) size: 20000, destruction: 2.50 (usec/elem) size: 50000, destruction: 1.20 (usec/elem) size: 100000, destruction: 1.10 (usec/elem) size: 200000, destruction: 1.10 (usec/elem) size: 400000, destruction: 1.25 (usec/elem) size: 600000, destruction: 1.37 (usec/elem) size: 800000, destruction: 1.45 (usec/elem) size: 1000000, destruction: 1.54 (usec/elem) So buy more RAM <0.5 wink>. This is the code that deallocates dicts: for (ep = mp->ma_table; fill > 0; ep++) { if (ep->me_key) { --fill; Py_DECREF(ep->me_key); Py_XDECREF(ep->me_value); } } That is, it's a single scan over the key+value pairs, decrementing the refcounts on each. Note that while a left-to-right scan of the container is cache-friendly, dicts work hard to "randomize" the offsets at which keys are stored, so the memory pointed to *by* ep->me_key (containing your string objects) has no useful relation to the order in which you created your string objects: you're going to get mountains of cache misses during deallocation. It's a mystery why deallocation takes so much longer than allocation when things go bad (look at it: the deallocation code is dead simple). I tracked down one of those long ago in hideous detail, and it turned out to be due to the platform free() trashing like mad trying to coalesce adjacent free'd areas. I suspect every platform has its own tale of woe to relate here. From shalehperry at home.com Tue Nov 20 13:07:41 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Tue, 20 Nov 2001 10:07:41 -0800 (PST) Subject: urllib.urlencode has 2 parameters?? In-Reply-To: <32cedc66.0111200950.4f44d898@posting.google.com> Message-ID: On 20-Nov-2001 Matthew D. Wood wrote: > I've been staring at the documentation page for urllib for about 15 > minutes, and experimenting around on the python-command-line trying to > figure out what the second parameter for urllib.urlencode does. > > Does anyone know? I'm very confused. def urlencode(query, doseq=0): If any values in the query arg are sequences and doseq is true, each sequence element is converted to a separate parameter. That is from urllib.urlencode.__doc__. Also, most of python's modules are in python so you can just read the urllib.py file and it is explained there in comments and code. > -- > http://mail.python.org/mailman/listinfo/python-list From skip at pobox.com Sat Nov 3 05:50:38 2001 From: skip at pobox.com (Skip Montanaro) Date: Sat, 3 Nov 2001 04:50:38 -0600 Subject: [ #456742 ] Failing test case for .*? In-Reply-To: References: Message-ID: <15331.52222.372379.155999@beluga.mojam.com> Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> s="""a\nb\n1""" >>> re.findall("[^\n]+?\d", s) ['a\nb\n1'] I don't know if it's a bug, but there are a couple ways to work around it: >>> re.findall("[^\n]+?\d", s) ['a\nb\n1'] >>> re.findall("[^\n]*\d", s) ['1'] >>> re.findall("(?:[^\n]+)?(\d)", s) ['1'] Maybe there's some kind of operator precedence issue (the "?" binds more tightly than the "+") that means you have to wrap the first part of the pattern in a group. Are you just demonstrating the problem or can't you use "*" instead of "+?" for some reason? -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From joost_jacob at hotmail.com Wed Nov 21 14:58:50 2001 From: joost_jacob at hotmail.com (J.Jacob) Date: 21 Nov 2001 11:58:50 -0800 Subject: dictionary-question References: Message-ID: <13285ea2.0111211158.45c04ce8@posting.google.com> Check out the setdefault() dictionary method...from the Library Reference: setdefault() is like get(), except that if k is missing, x is both returned and inserted into the dictionary as the value of k. From lac at strakt.com Fri Nov 9 06:03:09 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 09 Nov 2001 12:03:09 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Paul Rubin of "08 Nov 2001 16:06:22 PST." <7x8zdgx0xt.fsf@ruckus.brouhaha.com> References: <7x8zdgx0xt.fsf@ruckus.brouhaha.com> Message-ID: <200111091103.fA9B3Aua009035@ratthing-b246.strakt.com> Paul Rubin writes: > I think a big goal of the Mindstorms crowd is teaching the concept of > debugging. Most skills are taught with the idea that you master > something by learning it well enough to do it perfectly, so if you > make a mistake at it you haven't learned the skill yet. Teaching > programming to young kids is supposed to develop the cognitive skill > of diagnosing and correcting errors. That's more fundamental than > "applications" like cataloging mp3's or even understanding math > concepts. In the same vein, if any of you out there are writing (or revising) 'how to program in Python' books or papers, could you please put the section on exception handling _early_, say, right after 'what is a loop', rather than in the last chapter? I've decided that what my brother's great insult program needed was: a) 1, possibly 2, dictionaries b) 1 loop c) exception handling for bad data (and, of course, a lot of insults. Data collection is an important part of the scientific process...) One of the nice things about programming is that you _can_ just try it and see. Here's the intepreter. Go play. If it blows up, nothing particularily bad can happen. But a great many new posters here need to be _TOLD_ that. They _ask_ 'What would happen if I typed ...' rather than just typing it. Clearly, they come from a background where making mistakes is a much more serious business than just getting a ValueError. I can't prove it, but I suspect that our societies would be more fun to live in if more people, from an early age, were taught how to clean up after things got unexpectedly messy, and how to predict the sorts of messes that were inherant in any situation. There are days I feel that I am living in the section of code marked /* CAN'T HAPPEN */. Laura Creighton From joonas at olen.to Thu Nov 29 16:19:24 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Thu, 29 Nov 2001 23:19:24 +0200 Subject: __setattr__ recursion problem References: <3C066BF8.8D911FCB@olen.to> <3C0673BC.3C463530@earthlink.net> Message-ID: <3C06A65C.A6C65442@olen.to> Hans Nowak wrote: > > Joonas Paalasmaa wrote: > > > > The code above causes an infinite loop. How can I set an attribute of > > Class > > without overloading the __setattr__ function? Or does someone have some > > other > > solution to make that script work? > > > > class Class2: > > eggs = 1 > > spam = 2 > > > > class Class: > > base = Class2() > > def __setattr__(s,attr, value): > > if hasattr(s.base, attr): > > setattr(s.base, attr, value) > > else: > > setattr(s, attr, value) > > > > Class().foo = "eggs" > > The short answer is that setattr(s, ...) calls s.__setattr__. > Which calls setattr again, and so on. > > This code strikes me as curious though, and I wonder why you > would want to write it like this. The default idiom for a class > and its subclass would be something like Actually I am not trying to subclass the class. I am writing an extension object for VPython and I have to pass all the set/getattrs to an VPython instance. > class Class2: > def __init__(self): > self.eggs = 1 > self.spam = 2 > > class Class(Class2): > pass > > In your approach, > > > class Class: > > base = Class2() > > creates an instance of Class2 *that is shared by all instances > of class*. I'm not sure if this is intentional, but I haven't seen > people use this a lot. Maybe it's possible to rewrite this code > without the setattr and the shared base. That's true. I was just too lazy to write a __init__ in that example. From prabhu at aero.iitm.ernet.in Sun Nov 4 13:15:35 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 4 Nov 2001 23:45:35 +0530 Subject: Python packages - problems, pitfalls. In-Reply-To: <004d01c16540$a6690fa0$0101010a@local> References: <15332.57918.232705.721124@monster.linux.in> <004d01c16540$a6690fa0$0101010a@local> Message-ID: <15333.34247.246968.693702@monster.linux.in> >>>>> "CG" == Chris Gonnerman writes: >> be smart enough to avoid such problems? Why I consider this a >> major problem is that the importing of a sub-package depends on >> where its parent package is!! So if pkg is no longer the root >> of the package and say its put inside another BigPkg then to >> make pkg's sub packages work you'd have to edit *all* the sub >> packages and change every reference to pkg.a to BigPkg.pkg.a. >> This is a huge pain. CG> Hmm. I personally can't say that I've ever renested a package CG> to a deeper level. Has anyone else had a problem with this? CG> The closest I can think of is converting a group of related CG> modules into a package, and that wasn't all that much work. Well, I believe the SciPy project (http://www.scipy.org) had lots of trouble dealing with this -- its a pretty huge project. Also consider the following case: I have an application that is shipped as part of a package. I'd like the application to run right off the main directory or when the package is installed. Also lets add to the problem by saying that the project is under CVS and its a pain putting everything into another directory. Something like this: pkg_root/ __init__.py app.py # app is the application that is not part of the package common_module.py setup.py common/ __init__.py foo.py # more common stuff sub/ __init__.py submodule.py a.py sub1/ __init__.py b.py pkg_root might either be installed as Package (in site-packages) or someone may decide to run app.py from within pkg_root. Also, irrespective of whether people have run into such problems or not, don't you think it makes sense for modules to be searched the way I had suggested earlier?? Or is there some serious issue with this. Thanks. prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net Where there's no emotion, there's no motive for violence. -- Spock, "Dagger of the Mind", stardate 2715.1 From fperez528 at yahoo.com Fri Nov 30 20:30:24 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 02 Dec 2001 00:58:24 +2328 Subject: Whatever happened to String Interpolation? References: <9u6dbn$nsj$1@peabody.colorado.edu> <9uc26v$akh$1@peabody.colorado.edu> <9uckd9$o43$1@peabody.colorado.edu> Message-ID: <9ucn17$pea$1@peabody.colorado.edu> Tim Hammerquist wrote: > >> In fact, things like 'blah %(var)s' to me look a lot less readable >> (and line noise like, perl-like, whatever) than 'blah $var'. Or is >> it that in Python there's such a rabid fear of $ as to not even >> admit a case where something like it may be useful? > > It's possible. Good! Maybe we are getting somewhere after all... :-) I know I can always use itpl, but it's just that it would be so much cleaner to write print $'.....$....' than the current print itpl('......') I hate extra function calls which just clutter things out. I'm a big fan of 'first level' code readability: code which in a first reading, with minimal mental gymnastics, shows its intended purpose. Oh well. We'll see if this gets anywhere. It would be nice to hear from Ping, I wonder if he's around in this group. Cheers, f From stepken at little-idiot.de Mon Nov 12 17:05:48 2001 From: stepken at little-idiot.de (Guido Stepken) Date: Mon, 12 Nov 2001 23:05:48 +0100 Subject: OT: Mobile Internet Toolkit EULA (was: IsPython really O-O?) References: <9snugr$bbc$06$1@news.t-online.com> Message-ID: <9sph0u$gj7$02$1@news.t-online.com> Thanx lots for checking this out ! Hmmm, that means, that it is forbidden to produce (distribute) code, consisting of (L)GPL Software and Microsoft OpenSource. One is not allowed to mix code. BSD License + Microsoft Code, that's OK ! Any ideas, why ? regards, Guido Stepken >Tim Hammerquist wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > ... > http://msdn.microsoft.com/Downloads/eula_mit.htm > > Some interesting excerpts: > > The Restriction: > [ snip ] > : (c) Open Source. Recipient's license rights to the Software are > : conditioned upon Recipient > : (i) not distributing such Software, in whole or in part, in > : conjunction with Potentially Viral Software (as defined > : below); and > : (ii) not using Potentially Viral Software (e.g. tools) to > : develop Recipient software which includes the Software, > : in whole or in part. > [ snip ] > > The Definition: > : Recipient shall not distribute the Software, in whole or in part, > : in conjunction with any Publicly Available Software. > [ snip ] > : Publicly Available Software includes, without limitation, software > : licensed or distributed under any of the following licenses or > : distribution models, or licenses or distribution models similar to > : any of the following: > : (A) GNU's General Public License (GPL) or Lesser/Library GPL (LGPL), > : (B) The Artistic License (e.g., PERL), > : (C) the Mozilla Public License, > : (D) the Netscape Public License, > : (E) the Sun Community Source License (SCSL), and > : (F) the Sun Industry Standards License (SISL). > [ snip ] > > The rest of the EULA adds more legalspeak, but it doesn't get any more > lenient. I believe MS was trying to see how this would go over in the > community and decided to test it with a pre-release version of software > in case users raised too much of a fuss. > > Cheers! > Tim Hammerquist From tim at zope.com Wed Nov 14 11:29:22 2001 From: tim at zope.com (Tim Peters) Date: Wed, 14 Nov 2001 11:29:22 -0500 Subject: Threading In-Reply-To: Message-ID: [Ciobanu Vladimir] > ... > If I'm calling only functions such as __getitem__ ( and maybe > querry which mainly calls .has_key( key)), is it safe not to add locks > to these functions ? > I would ask you not to answer if you're not sure about the answer. > This is quite important, since it would be a major draw-back if two > users couldn't read at the same time. It doesn't make sence, either. In this case, being sure about the answer is much easier than being sure about the question . If you run *any* sequence of dict operations without benefit of locks (get, set, update, clear, whatever), the outcome will be "sequentially consistent", meaning the outcome will be the same as if you had run the dict operations one at a time with benefit of exclusion, for *some* intervleaving of dict operations across threads: each dict operation is atomic (e.g., once a dict.update() starts, it completes before another thread is allowed to run). In particular, if there are no mutations going on, any number of threads can read simultaneously without locks without surprises. However: > I will add a property to DataBase, namely __readonly. If one user > opens it as __readonly, calling function members that change the data > in the DataBase ( such as __setitem__) then an exception is raised. I > will allow one, and only one user to modify the database at a time. > Plus if one is modifyiny, none can read. You can't achieve the last point unless you use *some* synch scheme for reads too, else a mutator would have no way to know that a read may be in progress. A "multiple-reader single-writer" (MRSW) lock is par for that course. From paulp at ActiveState.com Thu Nov 1 00:57:49 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Wed, 31 Oct 2001 21:57:49 -0800 Subject: XML can't read Unicode shock horror. News at 11. References: Message-ID: <3BE0E45C.351DC247@ActiveState.com> Dale Strickland-Clark wrote: > > ... > > Is there any chance that this might be elevated? > > Non-unicode XML is a bit restrictive. :-( I think Martin was trying to make the point that this works okay: dom = xml.dom.minidom.parseString(u''.encode("utf-8")) I agree with you that minidom should probably do this automatically. Paul Prescod From dgrisby at uk.research.att.com Thu Nov 15 09:14:05 2001 From: dgrisby at uk.research.att.com (Duncan Grisby) Date: 15 Nov 2001 14:14:05 GMT Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <9t0du9$f2t$1@pea.uk.research.att.com> <7xbsi4cg6m.fsf@ruckus.brouhaha.com> Message-ID: <9t0ijd$is9$1@pea.uk.research.att.com> In article <7xbsi4cg6m.fsf at ruckus.brouhaha.com>, Paul Rubin wrote: >If it's on the local machine, why mess with TCP at all, instead of using >AF_UNIX? I'm not sure whether the OP intended to run locally tough. Indeed, using Unix sockets makes it 20% to 25% faster than the TCP loopback. Somewhere along the line I got the impression we were talking about TCP, though. Cheers, Duncan. -- -- Duncan Grisby \ Research Engineer -- -- AT&T Laboratories Cambridge -- -- http://www.uk.research.att.com/~dpg1 -- From john.thingstad at chello.no Wed Nov 7 09:24:14 2001 From: john.thingstad at chello.no (John Thingstad) Date: Wed, 07 Nov 2001 15:24:14 +0100 Subject: re OnInteger division Message-ID: <20011107142645.KXFI16219.mta01@mjolner> In iteger arithetric divsion is no the oposite of multiplication. As pointed out (9 / 4) * 4 = 8 Why? 9 / 4 = 2 2 * 4 = 8 To achive a inverse you need to use the modulo as well so: 9/4 = 2 9 %4 = 1 and (9/ 4) *4 + (9%4) = 9 From nas at python.ca Tue Nov 6 12:17:57 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 6 Nov 2001 09:17:57 -0800 Subject: Program very slow to finish In-Reply-To: <3BE737A8.8CF867A5@chello.nl>; from r.b.rigilink@chello.nl on Tue, Nov 06, 2001 at 01:06:41AM +0000 References: <3BE737A8.8CF867A5@chello.nl> Message-ID: <20011106091757.C7312@glacier.arctrix.com> Roeland Rengelink on pymalloc: > Are extension modules in the Python std library affected? I believe all extension modules in the standard distribution work correctly with pymalloc enabled. That are a number of 3rd party extension modules that are known not to work however. Neil From terabaap at yumpee.org Tue Nov 13 20:01:27 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Wed, 14 Nov 2001 01:01:27 GMT Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> <3BF07FA7.10807@yumpee.org> <3BF0BE8C.4010809@yumpee.org> <7x8zdbgogy.fsf@ruckus.brouhaha.com> Message-ID: <3BF1C298.7030106@yumpee.org> Paul Rubin wrote: > Manoj Plakal writes: >> I'm not trying to reinvent a new network >> protocol here. All I'm asking is if there's >> some kind of cross-platform ultra-lightweight >> COM/CORBA-kind of messaging system, built on top >> of some IPC mechanism (UDP or domain sockets or named >> pipes or something not too heavy). >> > > Did Pyro already come up in this discussion? http://pyro.sourceforge.net. Pyro looks nice, but it's Python-only. I'd prefer something that has multiple language bindings. Also, it's in the same domain as CORBA: distributed computing. There must be a stripped-down subset that works better for simple message-passing between apps running the same machine. In a portable manner. Right now, there are some reasonable systems on different platforms: - Win32: COM/OLE/ActiveX - MacOS: AppleScript events - KDE: DCOP, this has a nice feature-set, it's lightweight and I'd really like to see a cross-platform version of this. Right now, it's tied to Qt (notification is done via the Qt event loop). - Gnome: CORBA using ORBit - Generic: XML-RPC, ICE/X-atoms (for X Windows), various CORBA implementations/clones, or cook up your own app/platform-specific protocol on top of sockets or pipes. I might try to spend some time creating an abstract framework for inter-app messaging. Something really dumb and simple, which covers the common cases. And then have multiple instantiations of the framework, perhaps one using simple UDP sockets, or using platform-specific stuff like COM or DCOP. And have multiple language bindings, with the ultimate aim of apps being able to do simple messaging in a portable manner ... Manoj From tim at vegeta.ath.cx Sat Nov 10 09:19:41 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sat, 10 Nov 2001 14:19:41 GMT Subject: Python Vim Module References: Message-ID: Jonathan Gardner graced us by uttering: > I am announcing my intentions to work on a python vim module. > > The first version will be just enough to send messages to a Vim session. I > am aiming for it to work on the Linux platform first. > > If anyone out there is working on something similar or have already done > something like this, let me know. > > Jonathan Well, vim-python comes with a python module, vim.py. It's imported from within a vim session and provides access to vim objects (buffers, lines, settings) with a python interface. I don't know if this will work if imported from outside of a vim session, but it's worth trying. I'll check it out tomorrow. And even if it _can't_ be used from outside vim, you might consider a different name for the module, eg, vim_remote or something. Good night all. Tim Hammerquist -- guru, n: A computer owner who can read the manual. From tjreedy at home.com Fri Nov 2 08:55:16 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 02 Nov 2001 13:55:16 GMT Subject: newbie question References: <20011102004821.02918.00002310@mb-fi.aol.com> Message-ID: <8BxE7.171920$5A3.64506718@news1.rdc2.pa.home.com> > #need to parse text. Would be nice to have \n and other punctuation > removed. I would use maketrans() and translate() functions of string module to change all such to spaces before splitting on whitespace. Terry J. Reedy From Randy.L.Kemp at motorola.com Thu Nov 8 15:18:58 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Thu, 8 Nov 2001 14:18:58 -0600 Subject: I just got in! Message-ID: <81F59ACE9063D511A5BB0002B328D226511625@il93exm20.css.mot.com> Welcome aboard. The folks on his list are great at helping newcomers (a category I'm still in). -----Original Message----- From: Kirk Bailey [mailto:deliberatus at my995internet.com] Sent: Thursday, November 08, 2001 12:51 PM To: Python-list at python.org Subject: I just got in! in the list that is. I want to learn about python, write some things in it, and show that smug bunch ovver in the perl tree that snakes are way cooler than camels. Although these days, EVERYONE wants to smoke a camel... -- Respectfully, -Kirk D Bailey (C)2001 Addme! icq #27840081 end My Sites: http://www.howlermonkey.net/ - free REAL email! list service soon! http://www.sacredelectron.org/ - Rants! Spleenvents! http://www.minorfish.org/ - The list server for some of us! From phd at phd.pp.ru Thu Nov 1 10:00:36 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 18:00:36 +0300 Subject: Monty Python (was: Freeware Python editor) In-Reply-To: ; from mikael@isy.liu.se on Thu, Nov 01, 2001 at 03:57:24PM +0100 References: <20011101154852.B675@phd.pp.ru> Message-ID: <20011101180036.C675@phd.pp.ru> On Thu, Nov 01, 2001 at 03:57:24PM +0100, Mikael Olofsson wrote: > > > [Makes note to remember that Oleg isn't a Monty Python viewer.] > > > > Few years ago I tried to view the scetches - there was Russian > > translation of them on TV - but found them stupid and boring. Well, I was > > in bad mood those days, may be now I'd find it more interesting :) > > You should really watch them in their original language. And I admit, It'd be harder to understand. My english is far from perfect :) > some of them are not that great (those where legs and arms are cut off It is arguable. Different people have different taste and sense of humor :) > and blod everywhere). But then there are the others (for instance the > dead parrot sketch), where the humour is in the language. And they are I already read some of their scripts... > fantastic. "Spam! Spam! Spam!"? :))) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From dsavitsk at e-coli.net Wed Nov 14 11:42:09 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Wed, 14 Nov 2001 16:42:09 GMT Subject: Open a windows database file with a path name? References: <1005317748.433.44382.m12@yahoogroups.com> <5ve4vtgt0o67mtbc0fit6t45svn4esos07@4ax.com> Message-ID: "Nomad" wrote in message news:5ve4vtgt0o67mtbc0fit6t45svn4esos07 at 4ax.com... > On Fri, 9 Nov 2001 16:27:15 -0500, "Bill Bell" > wrote: * * * > > > >There's a good web page offering clues about working with ADODB > >and Python. (If I could remember where it is I'd even tell you!) > > > >Bill > Excellent - exactly what I was looking for. After writing the > origninal post, I realised that as I was using an access database, the > non cross-platform nature of using win32com wouldn't really matter. > However, I haven't even scratched the surface of the win32 extensions, > so thanks for the example to get me started. > > If you do remember the URL please post it up here. > try my page @ http://www.e-coli.net/pyado.html > > PS, what's the "r" for in "( r'ADODB.Recordset' )"? > the r makes the string that follows raw, that is, special characters, escaped characters and the like will be ignored. i don't think it necessary here though it isn't uncommon. -d From mark at knobbits.org Tue Nov 27 05:30:48 2001 From: mark at knobbits.org (Mark Johnathan Greenaway) Date: Tue, 27 Nov 2001 21:30:48 +1100 Subject: pdbtrack in emacs, Great! In-Reply-To: ; from syver-en@online.no on Mon, Nov 26, 2001 at 10:04:49AM +0100 References: Message-ID: <20011127213048.A1677@binks.home> On Mon, Nov 26, 2001 at 10:04:49AM +0100, Syver Enstad wrote: > I'll just have to send a big thank you to the one(s) who made the > pdbtrack feature in the new Emacs python mode. > I can finally debug python code under emacs. Juhuu! > I am currently looking into/fidlling with adding the ability to toggle > breakpoints by a command while browsing the source. It would be really > nice if pdbtrack turned into some sort of minor mode so that it would > be easier to extend without modifying the python-mode.el file, but > then I am a elisp newbie. May I ask what version of emacs and what version of python-mode you're using? Also, how do you start pdb? I've tried to use pdb under emacs and it always seems to stall? -- Mark From colin at programmedintegration.com Thu Nov 22 15:35:27 2001 From: colin at programmedintegration.com (Colin Meeks) Date: Thu, 22 Nov 2001 20:35:27 GMT Subject: Web hosts and Python 2.1 References: <20011122.082840.1253263156.7318@localhost.localdomain> Message-ID: Hi Harold The ISP we use has Python 2.1 installed and also provides us with excellent customer support. Our complete site (http://www.programmedintegration.com) is run on top of Python. The ISP is called GetWebSpace (http://www.getwebspace.com). They are also once of the most reasonable priced ISPs. They also have mySQL installed, so you can migrate your site over time to have full database support. Mention my name if you sign up as I geta free months credit. Let me know how you get on. Regards Colin "Harold Shore" wrote in message news:20011122.082840.1253263156.7318 at localhost.localdomain... > As I progress with using Python naturally I've wanted to convert my web > sites from Perl CGI's to Python. However, my current ISP and most of > the others who have attractive packages for my kind of website , while > they do have Python installed, only have the 1.52 version. with probably got > installed with their latest OS upgrade. > > Asking them to install a 2.1 version of Python hasn't been fruitful so far. > > So my question is: does anyone on this group know of a North American web > host who offers an up-to-date python package? > > Cheers. > Harold --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.286 / Virus Database: 152 - Release Date: 09/10/2001 From mgerrans at ix.netcom.com Tue Nov 13 03:45:56 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Tue, 13 Nov 2001 00:45:56 -0800 Subject: Request for Validation of Python as Development Language References: Message-ID: <9sqmug$efp$1@slb1.atl.mindspring.net> You didn't mention Zope, which is a big Python project, if not commercial. I was using JScript (VBScript actually supported better by MS's Script Host, but I just cannot bring myself to write VB any more) and MSVC to do a lot of Windows platform-specific work. I liked Python, but I thought for the kind of platform-specific work I was doing, it would be inappropriate, so I just used it for my own projects. Then I discovered the PyWin stuff and learned that it was trivial to interact with COM automation servers with Python. I don't think Python is a scripting language any more than Java, C#, managed C++, etc., none of which compile to machine code. You could say that Python compiles to bytecode (pyc files) and needs the Python Virtual Machine to run. The .NET platform is supposed to promote language agnosticism (in a desperate effort to kill Java, I guess) and one of the languages it will ostensibly support is Python. I read this in Microsoft's propaganda. I don't know if they have support for it now, or they were saying "it could be supported" in the same way that the Script Host can support any language you want to implement for it. From what I remember, it was more concrete than that, though. By the way, Python runs on/in Java: Jython (see jython.org). It makes a handy unit testing framework for Java classes. I think in your environment, you have a good argument for Python, but the proof lies in whether you can get the job done with the tool. So, you might want to try the "tracer bullet" concept from The Pragmatic Programmer: think of a task (in your project) that you imagine might impossible or more difficult to do with Python. Spend a little time trying to implement it with Python. If it works, use it. If it turns out to really be more of a problem (than the alternatives, C#, Java, or whatever), then don't use it. - mfg A. Keyton Weissinger wrote in message news:mailman.1005625157.24434.python-list at python.org... > Does anyone have a more recent list of commercial products out there that > use Python? I've heard the usual RedHat, Microsoft (nebulous), and Ultima > Online. I'd like more. > > The information in the books and the python.org site is a bit dated. > > I'm pretty new to the language and I'd like to use it for more stuff at > work. I'm beginning to feel some of the stigma of it being a "scripting > language." This is a bad rap. I'm in a .NET/Java shop (about 90%/10% for > those who care) and I'd like to introduce Python into the mix. But I say > "scripting language" and people head to the hills yelling "PERL!" which is a > bit disconcerting (especially since I like Perl too, though not as much as > Python). They need to hear "object oriented application development > language" or I need to buck up and realize I'm barking up the wrong tree. > > Thank you! > > Keyton > > From shalehperry at home.com Sat Nov 17 17:42:47 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sat, 17 Nov 2001 14:42:47 -0800 (PST) Subject: SGMLParser error on HTML comment In-Reply-To: Message-ID: On 17-Nov-2001 George Thomas wrote: > Hi everyone, > There's the following post dated May 28, 2001 from Marcel van den Dungen. > Didn't see any replies. Has there been a fix ? Does anyone have any ideas > ? > >>> > Hi, > > I'm trying to parse a bunch of HTML files using the SGMLParser class, > which works just fine unless an HTML-file starts with an HTML-comment > marker before the opening-tag. > The following error is emited: > File "c:\python21\lib\sgmllib.py", line 238, in parse_declaration > raise SGMLParseError( > sgmllib.SGMLParseError: unexpected char in declaration: '<' > > Anybody know a fix or workaround for this? > a quick look at sgmllib.py shows that you are falling into the case for ' Message-ID: <3BF4543C.7D323C7A@home.net> Skip Montanaro wrote: > I liked "for i in 10:" at first, however, the more I see of the Haskell > iterator syntax, the more I like it. Given that > > * it should cause no backward compatibility issues (you can't put "..." > in a list now, can you? NumPy?) If this is what you mean, yes, you can: >>> from Numeric import * >>> a = ones((3,3,3),Int) >>> for i in a[1,...,2]: ... print i ... 1 1 1 >>> -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From chrishbarker at home.net Thu Nov 29 14:34:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 11:34:18 -0800 Subject: Copy operator (was list.remove for Noivces) References: <3C054C58.9961A62@home.net> Message-ID: <3C068DBA.F4447D5A@home.net> Michael Hudson wrote: > Has anyone posted this: > > http://effbot.org/guides/python-objects.htm > > into this thread yet? It's about all you need to know. That is a very nice document. It, or something like it, should be in the tutorial. That is being made ubundantly clear by this (and many other) threads. How about it, Fredrik ? (if you are listening) -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From wurmy at earthlink.net Sat Nov 17 10:05:38 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sat, 17 Nov 2001 15:05:38 GMT Subject: identity = lambda x: x -- a Pythonic idiom? References: Message-ID: <3BF67CC9.C877B5C4@earthlink.net> George Demmy wrote: > > I do a bunch of list-oriented programming with a bunch of one-off > programs. For a variety of reasons these lists tend to have a bit > of cruft associated with them (I don't write it -- just process > it!). So stuff like this shows up quite a bit: > > data = filter(lambda x: x, crufty_list) > > I did it so often, that stuff like this shows up: > > identity = lambda x: x # like this in practice (lazy) > > def identity(x): # Pythonic -- shows up in profiler, etc > return x > > data = filter(identity, crufty_list) Note that this can be written as data = filter(None, crufty_list) with the same result. > There are, of course, other nifty things to do with identity, and I > find it used all the time -- far more often than many Python > built-ins. How prevalent is identity usage in the Python community? Is > there anyone that would rather suffer hellfire and damnation that do > something like this? I don't really know what you mean by identity here... lambda x: x, or None, in a filter function filters out everything that evaluates as "false". From prabhu at aero.iitm.ernet.in Wed Nov 7 03:27:28 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 7 Nov 2001 13:57:28 +0530 Subject: A smarter(?) package importer. In-Reply-To: References: Message-ID: <15336.61552.157688.570779@monster.linux.in> hi, >>>>> "RD" == Rainer Deyke writes: RD> Be careful you don't import the same module isn't loaded RD> twice, or bad performance and unreliable behavior will occur. RD> The correct behavior of 'import D' in module 'A.B.C' looks RD> something like this: [snip] RD> Notes: - 'sys.modules' is checked at each step before trying RD> to load the module from a file. This is absolutely essential RD> to prevent multiple copies of a module being loaded. - Each RD> module is stored in 'sys.modules' by its true name. Again, RD> this is essential. Thanks! I think knee.py does this correctly. It does not use None to cache failiure. There is only one place where imp is used to load the module and before that is done it always checks with sys.modules. def import_module(partname, fqname, parent): try: return sys.modules[fqname] except KeyError: pass try: fp, pathname, stuff = imp.find_module(partname, parent and parent.__path__) except (ImportError, AttributeError): # extension modules dont have a __path__ attribute. return None try: m = imp.load_module(fqname, fp, pathname, stuff) finally: if fp: fp.close() if parent: setattr(parent, partname, m) return m Also, I'm assuming that your advice is general and not specifically directed at the code I've put up. RD> - A value of 'None' in 'sys.modules' is RD> used to cache failure. This is not essential, but it matches RD> the current behavior of Python and it can give a significant RD> speed boost. Does the performance boost occur mainly because each subsequent failure would mean that sys.modules would have to scan through all of its keys and then fail? Hmmm, but if you kept caching failure, you'd increase the number of keys. If the package nesting is substantial for every global module this would insert several new item into sys.modules. pkg/ sub/ subsub/ foo.py foo.py: import string This would insert all of the following into sys.modules: subsub.string, sub.string, pkg.string, string so if each and every package did this we'd have way too many 'string's that point to None. This means that len(sys.modules) increases quite significantly. Or can it be proved that caching is better than not caching at all? prabhu -- Prabhu Ramachandran MayaVi Data Visualizer http://www.aero.iitm.ernet.in/~prabhu http://mayavi.sf.net From lucio at movilogic.com Thu Nov 22 15:56:16 2001 From: lucio at movilogic.com (Lucio Torre) Date: Thu, 22 Nov 2001 17:56:16 -0300 Subject: RogueLike Games in Python References: <3BFC9160.24AFA11A@alcyone.com> <20011122125424.A13679@cruciatuz.de> Message-ID: <3BFD6670.2080704@movilogic.com> Stefan Antoni wrote: >On Wed, Nov 21, 2001 at 09:47:12PM -0800, Erik Max Francis wrote: > >>"A. Keyton Weissinger" wrote: >> >>>Anyone know of any written completely (i.e. not just partially) in >>>Python? >>> >>>Thanks in advance... >>> >>I don't believe there are any, although there are a few in progress. >>You can check in rec.games.roguelike.development for more information. >> >>As a side note about the sad level of understanding of Python in the >>world, there was a thread in that newsgroup about how BASIC would be a >>superior choice for creating a Roguelike than Python ... >> >I started to implement something like that in python, but i'm not >skilled enough to code a robust game engine (threading-problems, >server/client problems, KI problems, lack of gameplay etc.). >Anybody who's working at this kind of game in pure python? >I'm highly interested in this, too. > i am trying to do one. i did a first attemp in python games with pysteroids (vampira.dyndns.org), and now im going for an elite multiplayer kind of game. not exaclty rogue, but multiplayer rpg... lucio From kragen at canonical.org Sun Nov 25 22:11:48 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 22:11:48 -0500 Subject: lanching a "*.exe" from Python ? References: <9ts4o1$sd7$1@wanadoo.fr> Message-ID: <838zcutedn.fsf@panacea.canonical.org> "stefff" writes: > I am a new python user and I would like to know if it is possible to launch > an executable in python : ie I have a c compilled program (that I want run > as fast as it possible) and I intend using python for GUI and I/O managing. import os os.system("whatever") That doesn't help with using Python for GUI and I/O, but that may be somewhat separate. From jkn at nicorp.f9.co.uk Fri Nov 16 04:47:56 2001 From: jkn at nicorp.f9.co.uk (Jon Nicoll) Date: 16 Nov 2001 01:47:56 -0800 Subject: what happened to Python Cryptography Toolkit? References: Message-ID: <8351bb33.0111160147.78644a51@posting.google.com> try here: http://www.amk.ca/python/code/crypto.html Peter Wang wrote in message news:... > i find quite a few references to Andrew Kuchling's Python Cryptography > Toolkit on the web, but all the links to actual sources/distributions > are broken. also, there doesn't seem to be any mention of it past > 1995... > > has it been supplanted by something else? all i want is to easily do > RSA, preferrably in a platform-independent manner. (if platform > dependence is unavoidable, unix is preferable.) > > TIA, > peter From radix at twistedmatrix.com Sun Nov 11 04:19:58 2001 From: radix at twistedmatrix.com (radix) Date: Sun, 11 Nov 2001 04:19:58 -0500 Subject: mapping a statement over all list items References: <3BEE4077.8070407@hotmail.com> Message-ID: On Sun, 11 Nov 2001 04:10:15 -0500, Kevin Christie wrote: > Hello all! > > I have list Foo, of strings. Each string has a special character '-' > within the string. What I want is for Python to split each string list > item by '-' and assign the resulting lists to the original list item. > Basically, I want to apply: > > Foo[x] = Foo[x].split('-') > > over all items x in Foo, in one clean statement. > > Thus if Foo was ['abc-xyz', 'black-blue', '123-987'], the result after > mapping to Foo would be: > > Foo = [ ['abc', 'xyz'], ['black','blue'], ['123','987'] ] > Here you go: >>> [string.split(x, '-') for x in l] [['abc', 'xyz'], ['black', 'blue'], ['123', '987']] of course, only in python2.0 or greater. -- that's why I love IRC you can't be late for IRC -- Chris Armstrong <<< radix at twistedmatrix.com >>> http://twistedmatrix.com/users/carmstro.twistd/ From danielk at aracnet.com Sun Nov 18 20:46:12 2001 From: danielk at aracnet.com (Daniel Klein) Date: Sun, 18 Nov 2001 17:46:12 -0800 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> Message-ID: Why not assign the most likely value and then test for the other, ie a = val if idx = 1: b = val Daniel Klein On 18 Nov 2001 20:26:06 GMT, Uwe Schmitt wrote: >Hi, > >i there a nice python shortcut for: > > if idx=0: > a=val > elif idx=1: > b=val > >??? >I tried > (a,b)[idx] = val > >but this does not work, i get an error message. > >Greetings, Uwe. From parz at shaw.SpamBucket.ca Sat Nov 24 21:40:23 2001 From: parz at shaw.SpamBucket.ca (Parzival Herzog) Date: Sun, 25 Nov 2001 02:40:23 GMT Subject: How do use locally compiled debug Python executables? Message-ID: An earlier posting identified a crash in Python21.dll while using an extension module. I was unable to debug into the Python21.dll, so I downloaded the ActiveState 2.1.1 build 212 source tree, and used MSVC 6.0 to build Python_d.exe and Python21_d.dll. I then copied these dlls to my installed python directory, and ran a command line program: -------------------------------- F:\EmsView\New>python_d sample.py Adding parser accelerators ... Done. Traceback (most recent call last): File "sample.py", line 1, in ? import MyWin ImportError: No module named MyWin [2346 refs] F:\EmsView\New>dir *.pyd Volume in drive F has no label. Volume Serial Number is 2C38-2765 Directory of F:\EmsView\New 2001-11-22 18:19 110,641 MyWin.pyd 1 File(s) 110,641 bytes 0 Dir(s) 6,400,483,328 bytes free F:\EmsView\New> --------------------------------- Can anyone explain why the MyWin.pyd extension dll is not found using Python21_d.exe? It continues to be found using the installed Python.exe. Is this the right way to go about debugging problems with extension modules? (Er, obviously not, but what IS the right way?) - Parzival From tim at zope.com Thu Nov 15 11:43:06 2001 From: tim at zope.com (Tim Peters) Date: Thu, 15 Nov 2001 11:43:06 -0500 Subject: Problems compiling python under Win (VS6.0) In-Reply-To: <3bf381b5$1@skynet> Message-ID: [Serg] > When compiling python under Visual Stdio files missing reported: > python src 2.2b1 > files: tcl.h > db.h > expat.h > zlib.h > > Python is taken from python site. > What to do? What is that? Please read PCbuild\readme.txt before building. From syver-en at online.no Fri Nov 23 13:29:19 2001 From: syver-en at online.no (Syver Enstad) Date: 23 Nov 2001 19:29:19 +0100 Subject: Newbie question References: <1puL7.12600$MI2.1847665@typhoon.jacksonville.mediaone.net> Message-ID: flynt writes: > stephen cox wrote: > > > > I just started with Python. Have some basic questions. For work, I wanna > > develop some data entry screens for our sql server - so I assume there's a > > database library out there that gives me functions to connect to a sql > > server? You can use ODBC which, which have several implementations, one is included with win32 extensions as far as I know, and you can also use mxODBC which is more full featured but I think it costs money to use. Also you can use win32com (win32 extensions from active state) to use ADO that interfaces to SQL server and several other products. >Also, for the web, does Python run as a CGI with II5 or is there > > some dll that hooks into IIS5? Last question, does Zope need the zserver? I > > keep reading that it can run on any server but, I haven't found anything > > that tells me how to run it with IIS. Is it just a matter of >running Python? I have not seen any so called Fast CGI's for Python on IIS, I tried to make one and had a proof of concept up and running, but my focus wandered to other things. Maybe I'll get back to it someday. To set up Python for ordinary CGI under IIS you have to flip up the inetmgr applet and configure the site you will be publishing .py files from. Choose the Home Directory sheet, press Configuration button. Choose App Mappings sheet from the new dialog that pops up. Press Add. In the application mappings dialog you fill in the path to the python interpreter and "%s" %s Fill out .py for the extension (you could name it anything, but then you would have to rename your python cgi scripts to that extension too). Check the script engine hook to make python cgi files only need script permissions and you're ready to go. Check out the python documentation for ways to test that cgi is working. You can also use python as the script language in IIS asp pages. This support is bundled with the win32 extensions from Active State. -- Vennlig hilsen Syver Enstad From chrishbarker at home.net Wed Nov 7 16:02:31 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 07 Nov 2001 13:02:31 -0800 Subject: re OnInteger division References: <_LeG7.4769$R43.762969@newsb.telia.net> Message-ID: <3BE9A167.C1FB3E45@home.net> Fredrik Lundh wrote: > > so: > > 9/4 = 2 > > 9 %4 = 1 > > > > and > > (9/ 4) *4 + (9%4) = 9 > > on the other hand, > > >>> from __future__ import division > >>> (9/4)*4 + (9%4) > 10.0 > > oh well. Ah, but >>> (9./ 4) *4 + (9%4) # without future division 10.0 and: >>> (9//4)*4 + (9%4) # with future division should work fine, as should: >>> (9/4)*4 With either floats or integers, which is a whole lot more clear. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From phillip_david at xontech.com Mon Nov 26 18:40:55 2001 From: phillip_david at xontech.com (Phillip David) Date: Mon, 26 Nov 2001 15:40:55 -0800 Subject: Director 8.5 of Macromedia References: <9tiqt2$2td5$1@ulysses.noc.ntua.gr> Message-ID: <3C02D307.E007E729@xontech.com> I believe Director only supports Lingo. Sorry. Phillip mgkiourt wrote: > > Are python or javascript scripting options for Director 8.5? > Thanks.Mike From barry at zope.com Fri Nov 16 15:52:57 2001 From: barry at zope.com (Barry A. Warsaw) Date: Fri, 16 Nov 2001 15:52:57 -0500 Subject: RELEASED: Python 2.2b2 is out! Message-ID: <15349.31913.391080.615780@anthem.wooz.org> Today we release Python 2.2b2, the second -- and probably last -- beta release of Python 2.2, for your enervation, elocution, and effervescence. http://www.python.org/2.2/ Our thanks to everyone who is testing out these beta releases! Please continue to report any bug you find to the bug tracker: http://sourceforge.net/bugs/?group_id=5470 Highlights of what's new for this release are outlined below. For a more complete list, please see: http://sf.net/project/shownotes.php?release_id=61669 Andrew Kuchling is writing a gentle introduction to the most important changes, titled "What's New in Python 2.2": http://www.amk.ca/python/2.2/ Guido's written his own introduction to the type/class unification at: http://www.python.org/2.2/descrintro.html python-is-so-proud-of-little-brother-orlijn-ly y'rs, -Barry -------------------- snip snip -------------------- - Lots of bug fixes! - Multiple inheritance mixing new-style and classic classes in the list of base classes is now allowed. - The new builtin dictionary() constructor, and dictionary type, have been renamed to dict. This reflects a decade of common usage. - dict() now accepts an iterable object producing 2-sequences. For example, dict(d.items()) == d for any dictionary d. The argument, and the elements of the argument, can be any iterable objects. - New-style classes can now have a __del__ method, which is called when the instance is deleted (just like for classic classes). - Assignment to object.__dict__ is now possible, for objects that are instances of new-style classes that have a __dict__ (unless the base class forbids it). - The socket function has been converted to a type; see below. - Assignment to __debug__ raises SyntaxError at compile-time. This was promised when 2.1c1 was released as "What's New in Python 2.1c1". - mmap has a new keyword argument, "access", allowing a uniform way for both Windows and Unix users to create read-only, write-through and copy-on-write memory mappings. - By default, the gc.garbage list now contains only those instances in unreachable cycles that have __del__ methods. - The socket module defines a new method for socket objects, sendall(). - Symbolic group names in regular expressions must be unique. - We've finally confirmed that this release builds on HP-UX 11.00, *with* threads, and passes the test suite. - Thanks to a series of patches from Michael Muller, Python may build again under OS/2 Visual Age C++. - Updated RISCOS port by Dietmar Schwertberger. From bjgough at network-theory.spam.trap.co.uk Wed Nov 21 12:38:42 2001 From: bjgough at network-theory.spam.trap.co.uk (Brian Gough) Date: Wed, 21 Nov 2001 17:38:42 GMT Subject: Scientific Libraries in Python References: <9t1iqq$es0$2@peabody.colorado.edu> <3BF45CAF.9983E26A@home.net> Message-ID: On Thu, 15 Nov 2001 16:24:15 -0800, Chris Barker wrote: > Fernando P?rez wrote: >> GSL -- The GNU Scientific Library at http://sources.redhat.com/gsl >> There may be licensing issues that need to be addressed. > > It is GPL'd, which is a pity, it seems a prime candidate for the LGPL. > Anyway, it would seem to me that linking it with Python would be license > issue, although Python's current license is supposed to be "GPL > Compatible". Does anyone know what that means? Can this be clarified by > someone who knows what they are talking about? I'd love to know whether > this is a project I should delve into. The Python License is GPL-compatible, and the Python-GSL wrappers are under the GPL so there's no problem in using GSL with Python. For example gdbm is under the GPL and the gdbm module is a standard part of python. regards Brian Gough -- remove the spam trap to reply From stephen at theboulets.net Wed Nov 28 08:22:20 2001 From: stephen at theboulets.net (Stephen Boulet) Date: Wed, 28 Nov 2001 07:22:20 -0600 Subject: windows to linux pickled objects? References: Message-ID: Oleg Broytmann wrote: > On Tue, Nov 27, 2001 at 11:05:08PM -0600, Stephen Boulet wrote: >> I pickled a list in windows but couldn't open it in linux without first >> running the handy dos2unix program on it. > > Always write binary data to binary files: > > outfile = open(filename, 'wb') > outfile.write(pickle) > outfile.close() > > Oleg. Thanks to you both for the responses. But is writing in binary mode supported under linux? The tutorial says: << On Windows and the Macintosh, 'b' appended to the mode opens the file in binary mode >> I tried it on linux and the program did run, but the size of the pickled file only went down from 8183905 bytes to 8180057 bytes, and the file wasn't binary at all. Maybe the size difference can be explained by the lack of carriage returns. ;) It would be nice if the binary option worked on linux... -- Stephen From brueckd at tbye.com Fri Nov 2 16:00:24 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Fri, 2 Nov 2001 13:00:24 -0800 (PST) Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) In-Reply-To: Message-ID: On Fri, 2 Nov 2001, Tim Hammerquist wrote: > > the Simpson's > What?! I'll be damned if the Simpson's go down in history as a > representative of American humour. Simpsons isn't funny in and of itself - on the surface it's crass and childish. It *is*, however, a really funny and accurate satire of all-things-USA. It's that aspect of it that earns its spot in history (and damns Tim in the process, I guess). -Dave From kalle at gnupung.net Mon Nov 5 20:50:15 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Tue, 6 Nov 2001 02:50:15 +0100 Subject: Program very slow to finish In-Reply-To: <7xwv1465m7.fsf@ruckus.brouhaha.com> References: <3BE737A8.8CF867A5@chello.nl> <7xwv1465m7.fsf@ruckus.brouhaha.com> Message-ID: <20011106025014.B264@sandra.lysator.liu.se> [Paul Rubin] > Roeland Rengelink writes: > > An optional object allocator has been included. [snip] > > The object allocator can be enabled by providing the "--with-pymalloc" > > option to configure. > > I'm surprised Python doesn't already do something like this. I hope > it can be on the wish list for a future release. But it does, with 2.1. The text you quoted is taken from somewhere in the official Python documentation, perhaps README? Try it. Peace, Kalle -- [ Thought control, brought to you by the WIPO! ] [ http://anti-dmca.org/ http://eurorights.org/ ] From phil at river-bank.demon.co.uk Sun Nov 18 12:16:30 2001 From: phil at river-bank.demon.co.uk (Phil Thompson) Date: Sun, 18 Nov 2001 17:16:30 +0000 Subject: ANN: PyQt v3.0 Released Message-ID: <3BF7ECEE.D1324FED@river-bank.demon.co.uk> PyQt v3.0 has been released and is available for download from http://www.thekompany.com/projects/pykde/. A Windows binary for use with the non-commercial version of Qt is provided. Also released is SIP v3.0, the tool used to generate PyQt. Highlights of this release include... - full support for Qt v3 (including 44 new classes) - support for Python v2.2 - the addition of 7 missing classes and 70 missing methods from Qt v2. Phil From jhauser at ifm.uni-kiel.de Sun Nov 4 18:59:03 2001 From: jhauser at ifm.uni-kiel.de (Janko Hauser) Date: 05 Nov 2001 00:59:03 +0100 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> <3BE5A1A7.75C7EC9C@attglobal.net> <9s4f79$8b3$1@nntp2-cm.news.eni.net> <87ady25fdf.fsf@lisboa.ifm.uni-kiel.de> <3BE5D350.6BD162FB@attglobal.net> Message-ID: <87y9lmnl4o.fsf@lisboa.ifm.uni-kiel.de> I do not know, why the commands module is only specified or Unix. I assume there were problems with the popen function on windows in older releases of Python. As is seems your change makes this working on windows I would submit it as a patch on the sourceforge site. But as noted in this thread, popen also starts a shell for each command, so it doesn't really solve your problem, if this is actually a problem :-). __Janko -- Institut fuer Meereskunde phone: 49-431-597 3989 Dept. Theoretical Oceanography fax : 49-431-565876 Duesternbrooker Weg 20 email: jhauser at ifm.uni-kiel.de 24105 Kiel, Germany From bkhl at anisakis.org Fri Nov 2 08:42:42 2001 From: bkhl at anisakis.org (=?iso-8859-1?Q?Bj=F6rn_Lindstr=F6m?=) Date: Fri, 2 Nov 2001 14:42:42 +0100 Subject: Dockapp in Tkinter Message-ID: <20011102144242.B29933@anisakis.org> Has anyone here tried to write a Window Maker dockapp in Tkinter. In that case, I would be very interested in an example. From lac at strakt.com Fri Nov 9 06:39:42 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 09 Nov 2001 12:39:42 +0100 Subject: newbie tkinter question In-Reply-To: Your message of "08 Nov 2001 11:46:51 PST." <480f610.0111081146.72a92cb0@posting.google.com> References: <480f610.0111081146.72a92cb0@posting.google.com> Message-ID: <200111091139.fA9Bdgua009271@ratthing-b246.strakt.com> Tkinter will not do what you want. But Tinter might. I've never used it myself, though. http://www-106.ibm.com/developerworks/library/l-python6.html has a resources page for curses programming which will probably be of use. But it refers to Tinter as at http://office.iximd.com/~dwalker/ This does not work, as office.iximd now wants password verification before it will let you access web pages. Maybe somebody else on this list will know where it has moved. If so, can you mail the answer to jared at hwai.com in addition to mailing or posting it here? Thanks very much, Laura Creighton From altis at semi-retired.com Wed Nov 21 17:38:35 2001 From: altis at semi-retired.com (Kevin Altis) Date: Wed, 21 Nov 2001 14:38:35 -0800 Subject: using python with MS WSH? .NET? References: Message-ID: <30WK7.458$Q37.361936@news.uswest.net> http://aspn.activestate.com/ASPN/search?query=wsh§ion=PYTHONCKBK&type=Su bsection ka "Peoter Veliki" wrote in message news:mailman.1006366718.31774.python-list at python.org... > > > Can Python be used with MS Windows Script Host (WSH)? What about for use > with .NET? What are the limitations of using Python in windows? I am very > new to the MS world, don't flame if these are silly questions. Thanks. > > > From dsavitsk at e-coli.net Thu Nov 8 22:25:21 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Fri, 09 Nov 2001 03:25:21 GMT Subject: Python, FreeBSD, idle References: <9sd9jv$2e5m$1@mail1.wg.waii.com> <3BEAAC9C.455C7CD8@pinetel.com> Message-ID: thanks, doug "Hal Weaver" wrote in message news:3BEAAC9C.455C7CD8 at pinetel.com... > Martin Franklin wrote: > > > > dsavitsk wrote: > > > > > i installed a new FBSD 4.4 system. i installed Python 2.1.1 from the > > > packages menu. i then installed idle (0.5) from the ports collection. > > > this > > > inturn installed python 1.5.2. from a terminal when i type "python" 1.5.2 > > > is started. is there a trick to linking idle to 2.1.1, and easily > > > resetting it (2.1.1) as the default? > > > > > > or better yet, i notice that idle is up to 0.8 on windows ... has anyone > > > done any work to update the FreeBSD port? > > > > > > doug > > > > > > > > > > > > > Doug, > > > > idle is in the source distribution under the Tools/idle directory. Its > > allways a good idea to have acopy of the python source around, plus it has > > lots of extra goodies..... > > > > ftp://ftp.python.org/pub/python/2.1.1/Python-2.1.1.tgz or > > > > http://www.python.org/ftp/python/2.1.1/Python-2.1.1.tgz > > > > Martin > > I recently installed Python 2.1 on the FreeBSD 4.3 Stable distribution. > In order to use idle I had to install py-tkinter from the X11-toolkits > folder in ports. > > Hal > From virus_catcher at oceanic.com Wed Nov 28 04:40:10 2001 From: virus_catcher at oceanic.com (virus_catcher at oceanic.com) Date: Tue, 27 Nov 2001 23:40:10 -1000 Subject: InterScan NT Alert Message-ID: Receiver, AntiVirus Catcher has detected virus(es) in the e-mail attachment. The Sender has been notified. Date: Tue, 27 Nov 2001 23:40:10 -1000 Method: Mail From: <_Krzysztof.Czarnowski at dgt-lab.com.pl> To: File: SETUP.DOC.scr Action: clean failed - deleted Virus: WORM_BADTRANS.B From m.faassen at vet.uu.nl Fri Nov 23 19:09:22 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 24 Nov 2001 00:09:22 GMT Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <3BFC0365.21FB6AA1@alcyone.com> <9tm7go$atu$1@newshost.accu.uu.nl> <3BFEA602.FEF2FC2C@alcyone.com> Message-ID: <9tmofi$9ke$1@newshost.accu.uu.nl> Erik Max Francis wrote: > Martijn Faassen wrote: >> Cool; I've recently been thinking about that. Any results, info, etc, >> you >> have on your experiments? > They look to be at least as good as using LISP as the genetic language > as in Koza's work. How you repopulate the population each generation > can get tricky, however; a wholesale approach can lead to diversity > problems. A stabilizing approach is during the fitness tests to > randomly select two programs, evaluate their fitness (perhaps by trial > against each other), then perform crossover and mutation and replace the > less fit program with their offspring (and doing this n times in a > population size of n you call a generation). > Even though this seems strange at first, it's really necessary since > diversity problems (where many of the programs start resembling each > other) can lead to a degenerate case where more and more resemble each > other with small defects; after a few generations programs start looking > like stutterers (a bunch of programs that look like A B C D E will > result in programs that might look like A B B B D C C D D C D D E ...). You can probably do something about that making instructions cost something. :) > There's a paper called "Stack-based genetic programming" by Perkis I > could send you (via email) if you're interested. Very interesting. Please do. >> I've worked with a simple virtual machine designed to the same >> constraints too (every sequence of instructions is a legal program), >> but this VM didn't have a stack *or* a set of registers; instead there >> were some instructions to move read/insert/delete heads onto their >> own instruction set. This allowed me to write an ancestor replicator >> would >> copy itself. That's different from genetic programming though, moving >> more towards artificial life. > I also have another artificial life system that involves a virtual > machine language as well, although it has a full instruction set, > registers including some shared registers, the ability for processes to > fork into new ones, always-legal instructions (well, illegal > instructions set an exception register, but they don't halt the > process), indirection, and an assembler with labels support (!). Hm, so what evolves? :) My system has the ability to fork as well (in fact that is a necessity). A replicator exists in space on a grid, can move around and gather resources. Using the resources it can scan itself, copy itself to another area of the instruction string and finally create another processor for it and split off the offspring into another location. What evolves are generally systems to gather more resources and survive crowding conditions. A new 'organ' which consists of a doubly nested loop evolves which does that. > The two systems are called Qu and Jupiter, respectively, by the way; > I've been planning on releasing them publicly for quite some time but > haven't quite had the energy to package them up. Maybe someone with > sufficient interest in playing could light a fire under my butt. I have the interest, but perhaps not the time. My system is called Cielo (as it's in the Tierra/Avida line of experimentation), and is a bunch of rusty C++ code which I'm not sure I want to release. :) I keep thinking about writing a new simulation though adding some of the ideas I've had later. I'm especially interested in adding some concept of genes (as a functional unit) to the simulation. Multiple genes would run in parallel in any individual and contribute to its global behavior. This way, a deletirious mutation in one gene may not necessarily result in a breaking of the individual (if there are other copies of the gene without the mutation still running), hopefully helping to smoothen the fitness landscape and creating more diversity. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From barry at zope.com Fri Nov 2 11:24:09 2001 From: barry at zope.com (Barry A. Warsaw) Date: 02 Nov 2001 11:24:09 -0500 Subject: email module References: Message-ID: >>>>> "DAM" == David A McInnis writes: DAM> I am looking for sample code using the new email module for DAM> Python 2.2. Does anyone have some sample code, I am newish DAM> to the world of Python. Adding some examples to the documentation is on my to-do list for Python 2.2. For now, look at the test suite for examples. In the Python 2.2 cvs, look at Lib/test/test_email.py -Barry From msoulier at nortelnetworks.com Wed Nov 14 17:10:08 2001 From: msoulier at nortelnetworks.com (Michael P. Soulier) Date: 14 Nov 2001 22:10:08 GMT Subject: does \1 in re work? Message-ID: Hello. Looking at the documentation for python 1.5.2, the now aging version that I'm using, in the re module it states that the standard \1, \2 keys that reference that matched value in parenthesis in the pattern do in fact work, as do \g<1>, \g<2>, etc. So, I tried this: new = re.sub("^(-?\d+)(\d{3})", '\1,\2', amount) new always ended up being '\001,\002'. Not what I wanted. So, I used the alternate... new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', amount) Which worked perfectly, giving me, for example, '100000,000' where amount was '100000000'. So, my question is, what was wrong with my first pattern? Thanks very much, Mike -- Michael P. Soulier, TD12, SKY Tel: 613-765-4699 (ESN: 39-54699) Optical Networks, Nortel Networks, SDE Pegasus "...the word HACK is used as a verb to indicate a massive amount of nerd-like effort." -Harley Hahn, A Student's Guide to Unix From ejohnso9 at earthlink.net Mon Nov 19 20:02:00 2001 From: ejohnso9 at earthlink.net (Erik Johnson) Date: Tue, 20 Nov 2001 01:02:00 GMT Subject: Newbie Q: efficiency of list -> string conversion Message-ID: <3BF9A943.F903E057@earthlink.net> I am wondering about the efficiency of converting a list of single characters into the corresponding string. Here is a trivial example: s = "string" l = list(s) l.reverse() rv = "" for i in xrange(len(l)): rv += l[i] print rv This works, but in general, this seems grossly inefficient for large lists. This method involves creating and destroying n = len(l) different strings objects. I am pretty new to Python and not savvy to all the funcitons and libraries yet - does someone know an efficient way to do this? Thanks in advance. :) Sincerely, -ej From fperez528 at yahoo.com Mon Nov 26 06:59:04 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 11:27:04 +2328 Subject: newbie question - object from a string? References: Message-ID: <9u0lv7$447$1@peabody.colorado.edu> Gordon Scott wrote: > Thanks for the reply. Didn't get this until this morning. > > I have a file named MyHandlers.py in which I have the class MyHandler. > > when I use > > __import__('MyHandlers', globals(), locals(), ['MyHandler']) or > . > . > . > eval('MyHandler()', globals(), locals()) or eval('MyHandlers.MyHandler()', > globals(), locals()) > > I get a NameError: name 'MyHandler' is not defined. Python is dynamic. Just generate the code: mod = 'MyHandlers' cls = 'MyHandler' exec 'from '+mod+' import '+cls That should work just fine. Cheers, f From pjotr at poland.com Sat Nov 24 15:26:43 2001 From: pjotr at poland.com (Pjotr) Date: Sat, 24 Nov 2001 21:26:43 +0100 Subject: problem with "elif" Message-ID: Hello! I started learning Python, using Python 2.1.1 and Ivan Laningham's book "Teach yourself Python...". I have a problem with instruction "elif": >>> y = 1900 >>> leap = "no" >>> if y % 400 == 0 : leap = "yes" elif y % 100 == 0 : IndentationError: unindent does not match any outer indentation level (line 3) >>> What's up? This example is from Laningham's book and everything should be OK. Please help me! -- Best regards Pjotr _____________________ &&& pjotr at poland.com &&& From root at [127.0.0.1] Wed Nov 28 10:38:40 2001 From: root at [127.0.0.1] (nobody) Date: Thu, 29 Nov 2001 01:38:40 +1000 Subject: problem popen and 'start' (Win32)? Message-ID: <3c050500$0$13481$afc38c87@news.optusnet.com.au> I'm using popen to trap the output of programs, but if I prefix my command with start it still waits for it to quit. This should only happen if I use 'start /wait' I'm using a loop like: while 1: line = child.readline() if not line: break (do stuff with line) Is that not right, or is popen broken? FWIW, os.system functions correctly.. From fperez528 at yahoo.com Thu Nov 29 20:04:47 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 01 Dec 2001 00:32:47 +2328 Subject: load a class dynamically References: <3C08497D.2C92F2B9@earthlink.net> <7PYN7.24373$S93.953955@e3500-atl2.usenetserver.com> Message-ID: <9ua14i$l9t$1@peabody.colorado.edu> Jeremy Lowery wrote: > Now I'm in search of finding a way to make a dynamic modules, > packages to add the classes to. I'm writing an app that stores all > of this stuff in a ZODB and lets users write code on a server over a > network. And I'm trying to figure out a way to dynamically "pack" > all of the class definitions into modules and packages so that I can > plug the base package into the namespace before the code is run. > > like one user importing Users.JLowery.ACoolModule > in the code that is going to be piped over the network, and then the > module/package structure is dynamically created from the objects in > the ZODB. (Like the User package gets put in the global namespace) > (Of course, not dynamically recreate it on every request but you get > the idea.) > > Jeremy > > > Never mind the funny variable names, but this does exactly (I think) that: for _t.mod in __IP.rc.import_mod: try: exec 'import '+_t.mod in locals() except : __IP.InteractiveTB() import_fail_info(_t.mod) __IP.rc.import_mod is a list of strings with names of modules which get loaded into the user namespace after the program is running. Does this help? f From brueckd at tbye.com Tue Nov 6 09:21:44 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Tue, 6 Nov 2001 06:21:44 -0800 (PST) Subject: Teaching python (programming) to children In-Reply-To: Message-ID: On 6 Nov 2001, Brian Elmegaard wrote: > Paul Rubin writes: > > > Guido Stepken writes: > > > > the Logo language. See the book Mindstorms, by Seymour Papert. He > > > > > > I have had great success in making children (12-15) having fun programming > > > python .... before the were only interested in playing gameboy...with > > > Yes, Python is probably a good choice at ages 12-15. By "children" I > > thought of the kids aged maybe 6-8. Python wouldn't make any sense > > at that age, but Logo apparently worked ok. > > And I thought about the ages inbetween, I guess. At 8 they don't have > the reading and writing skills to program, at 10 I believe they > do. I will look at pygame. Hi Brian, As with reading and writing, the age at which kids can start programming will vary wildly. My 3 year old knows her letters and will probably be reading long before 8. I was much more of a doofus, but still managed to learn BASIC at 8 (it was "neat" enough to overcome lack of intelligence & skills). Also, keep in mind that programming helps develop analytical skills, so you don't necessarily need to wait until the kid can think analytically to turn him or her loose on programming. Woulda been fun to start out with Python... -Dave From ajs at ix.netcom.com Sat Nov 24 19:22:05 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 24 Nov 2001 19:22:05 -0500 Subject: A permutation on permutations Message-ID: <000501c17547$3990c000$a9e1fea9@carol> Was able to find nice stuff on the python-list archives as to list permutations, list reversal, and removing duplicates from lists. My problem is to combine them. I am feeding control points to a curve function, and want all permutations that result in unique curves. For this purpose a sequence is duplicative of its reverse, i.e. [1,2,3,4] == [4,3,2,1], etc. So am a looking for a function to return all permutations, excluding duplicates as defined above. Ideas appreciated. Art From usenet at thinkspot.net Sat Nov 10 22:07:56 2001 From: usenet at thinkspot.net (Sheila King) Date: Sun, 11 Nov 2001 03:07:56 GMT Subject: Teaching python (programming) to children References: Message-ID: <9sjtu5.3vvd2j1.1@kserver.org> On Sat, 10 Nov 2001 21:14:52 -0500, "Arthur Siegel" wrote in comp.lang.python in article : :So my rantings here are not the extent of my involvement, by any :means. Nor did I think this was the case. (I did a web search on your name and found your netcom.com page with your geometry drawing package.) -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From dswegen at allstor-sw.co.uk Wed Nov 14 04:12:56 2001 From: dswegen at allstor-sw.co.uk (Dave Swegen) Date: Wed, 14 Nov 2001 09:12:56 +0000 Subject: os.mkfifo in linux vs freebsd In-Reply-To: References: Message-ID: <20011114091256.A29464@software.plasmon> On Wed, Nov 14, 2001 at 06:08:44AM +0000, Andrei Kulakov wrote: > Hello, > > I noticed mkfifo works differently in linux and freebsd. In linux, I can > do os.mkfifo(file); f = open(file) and then read from f, etc.. Under > freebsd, when I try to open created fifo, it hangs.. > > Anyone know how to deal with this? Is this the right place to ask? > Should I go to some freebsd groups (I hear they don't like to answer > questions, though)? We discovered that creating a fifo on an ext2 fs with FreeBSD 4.1 made the kernel explode. I have no idea if this has been fixed in later versions of Freebsd. As far as I remember though there were no such problems with ufs. If you are using ext2 try switching to ufs and see if it works. Cheers Dave From sholden at holdenweb.com Fri Nov 9 07:58:38 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Nov 2001 07:58:38 -0500 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> <3BEB602C.EFEA8D82@engcorp.com> <7xofmcy0xd.fsf@ruckus.brouhaha.com> Message-ID: "Paul Rubin" wrote in message news:7xofmcy0xd.fsf at ruckus.brouhaha.com... > Peter Hansen writes: > > A necessary step to get the robustness you claim you need is to do > > extensive testing. If one writes an application with Python and it > > breaks a million dollars of merchandise it will not be Python's > > fault, but the programmer's fault for inadequate testing. > > > > The only thing those other languages give you which Python doesn't > > is compiler warnings which lull you into a false sense that your program > > is clean when in fact you were lazy and didn't do proper testing. > > If you do the same amount of testing with Python that you would need > > to do with other languages to be very safe, you would have just as > > robust an end result. > > That makes it sound as if any non-robustness in the application is the > fault of how the application is written. However, the Python > interpreter itself can also have bugs. That affects application > robustness. Bugs in the Python interpreter can make the application > crash even if the application code is itself bug-free. > > Part of the question "can I write robust applications in Python" is > "how reliable is the interpreter, really?". I've seen Python 2.1.1 > inexplicably crash several times. One thing that another language > might give you besides compiler warnings and false senses of security > is implementations that don't crash. > > Overall Python seems pretty reliable but I think its implementation is > not yet as well shaken out as some other languages' implementations. > I'm happy writing web applications in Python. I could not in good > conscience recommend writing life critical apps (medical implant > firmware, avionics, etc.) in Python in its present form. But of course you'd be happy to trust them to IIS-based, NT-based web applications, right? My own opinion, for what it's worth (and I am known to bend ears on this topic): Python's delivered software quality is higher than many commercial language implementations, and the level of support available is an order of magnitude better: with Python you end up communicating with peoiple who actually understand the software. I suspect, without any reasonable data to support it, that most such assertions (but not necessarily yours) boil down to "I'd like to have someone to sue if things come badly unstuck". Have you READ the typical commercial language system license agreement? regards Steve -- http://www.holdenweb.com/ From loewis at informatik.hu-berlin.de Sat Nov 17 06:06:49 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 17 Nov 2001 12:06:49 +0100 Subject: Does smtplib lookup MX records? References: <3BF56916.8834B8D7@letterror.com> <52ac9479.0111170050.f56492a@posting.google.com> <3BF63C49.E0B87A0E@letterror.com> Message-ID: Just van Rossum writes: > But isn't the point that you shouldn't *have to* look up mx records? Indeed. There are many problems with trying to send mail directly to the remote MTA; finding the MX record is just one of them. For example, the remote mail exchanger may be down, or refuse to accept mail unless reverse name lookup succeeds, etc. So as a MUA, you always send mail to your local MTA. Regards, Martin From gh_pythonlist at gmx.de Thu Nov 8 17:14:38 2001 From: gh_pythonlist at gmx.de (Gerhard Haering) Date: Thu, 8 Nov 2001 23:14:38 +0100 Subject: DDE in Windows? In-Reply-To: <20011108215116.41584.qmail@web21107.mail.yahoo.com> References: <20011108215116.41584.qmail@web21107.mail.yahoo.com> Message-ID: <20011108231436.A558@lilith.hqd-internal> On Thu, Nov 08, 2001 at 01:51:16PM -0800, David Brady wrote: > Hello, > > Is it possible to use DDE from within Python on Windows? I'd like to > run a script that can send DDE commands to a server, and possibly to > register a service and listen as well. At least client-side DDE is possible with the win32 extensions from ActiveState. You can get these with their ActivePython Python distribution or seperately with the win32all download from their site (www.activestate.com). Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From Armin_member at newsguy.com Wed Nov 7 14:33:44 2001 From: Armin_member at newsguy.com (Armin Steinhoff) Date: 7 Nov 2001 11:33:44 -0800 Subject: open vs. open References: Message-ID: <9sc2ao011g@drn.newsguy.com> In article , Kirill says... > >On Thu, Nov 01, 2001 at 01:14:23PM -0800, Armin Steinhoff wrote: >> Hi all, >> >> I'm surely not the first one who was trapping into the >> '__builtin__.open vs. os.open' problem. >> >> Question: is it possible to rename the __builtin__.open call to >> __builtin__.fopen because it does really a fopen library call?? >> >> Or does it break something ?? > >$ python2.2 >Python 2.2b1 (#1, Oct 21 2001, 19:50:56) >>>> __builtins__.file is __builtins__.open Many thanks! Good to know ... Armin >1 > > >\Xi > > From wurmy at earthlink.net Tue Nov 27 00:57:12 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Tue, 27 Nov 2001 05:57:12 GMT Subject: Regular expression References: <6039af6a.0111262123.54806bb7@posting.google.com> Message-ID: <3C032B29.A77DE30@earthlink.net> Sang DeSibtis wrote: > > import re,sys,string > for line in open('junk', 'r').readlines () > a = re.compile('AAAA') > b = re.compile('BBBB') > > re.sub(a, 'aaaa', line) > re.sub(b, 'bbbb', line) > > print line # nothing got changed > > print re.sub(a, 'aaaa', line) # works > print re.sub(b, 'bbbb', line) # works, however the line above > doesn't work > > Questions: how do I make a global replacements in the 'line' that > read from the file object (buffer in memory? ).Obviously, this is my > first attemp at Python and I am not sure how things work. I want to > replace all strings (not necessary 'AAAA' or 'BBBB' as illustrated > here) in one pass. Will some one please explain in detail > !!!!!!!!!!!!!!!! re.sub gives you back a new string with the old string (pattern) replaced by the new one. It does not change the original string. To apply the changes, simply do line = re.sub(a, 'aaaa', line) etc... HTH, --Hans From just at letterror.com Sun Nov 11 10:25:37 2001 From: just at letterror.com (Just van Rossum) Date: Sun, 11 Nov 2001 16:25:37 +0100 Subject: Is this considered black magic? References: Message-ID: <3BEE9D79.5844B26@letterror.com> Laura Creighton wrote: > for object in object_list: > try: > object.__class__.__dict__[name_key](object, *args) > except KeyError: > pass Besides the tip to use getattr() as others suggested, it's wise to separate the _getting_ of the method from the _calling_, eg like so: for object in object_list: try: handler = getattr(object, name_key) except AttributeError: pass else: handler(*args) Besides that I find this slightly more readable, there's a very important difference: it won't mask errors in the *method* anymore. Imagine the method raises KeyError in your version of the code: to the client code this looks as if the method didn't exist. This sort of problem can be very awkward to debug... Just From sandysj at juno.com Wed Nov 7 11:51:35 2001 From: sandysj at juno.com (Jeff Sandys) Date: Wed, 7 Nov 2001 16:51:35 GMT Subject: Python VM on Lego Mindstorms References: <3BE7D665.8030904@yumpee.org> Message-ID: <3BE96697.69F0B6B9@juno.com> Manoj Plakal wrote: > > Has there been any work on porting the Python VM to > run on a Lego Mindstorms RCX brick? So that robot > control programs can be written in Python. I think the better solution would be to create a set of classes that represent the RCX primitives. Then each class would send 'compiled' instructions to the RCX. Then the RCX wouldn't the whole of Python. Forth is the only language that fully loads into the RCX. JVM is intended to have a small footprint, the rest of Java is outside of the RCX. I believe that this is the way that MIT's Yellow Brick Logo works. The Logo program is written in LCSI's MicroWorlds. The YBL os replaces the Mindstorms os in the RCX. MicroWorlds sends the instructions to the RCX. Thanks, Jeff Sandys From keyton at weissinger.org Mon Nov 12 22:18:58 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Mon, 12 Nov 2001 22:18:58 -0500 Subject: XML Schema In-Reply-To: Message-ID: Jesper, I too was looking for this. Check out this link for some clues: http://www.xmlhack.com/read.php?item=1392 I am also beginning to look at Python and XML Schema validating. Will post if/when I find something that will meet my needs. Hope this helps. Keyton -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Bill Tate Sent: Monday, November 12, 2001 8:24 PM To: python-list at python.org Subject: Re: XML Schema Jesper Holmberg wrote in message news:<87vggivo5r.fsf at strindberg.maisel.enst-bretagne.fr>... > Hi All, > > I'm trying to get some overview of xml tools in Python, but I'm a little > overwhelmed by the large number of sometimes half-finished, often poorly > documented, libraries and toolkits. I guess this in part is due to XML being a > relatively new technology. > > However, I'm more specifically looking for Python implementations of > XML Schema-validating parser. Does anyone here know of any tool-kit/parser that > supports XML Schema? > > TIA > > Jesper Jesper, I think you will find most support for validation is limited to DTD's - AFAIK, Sean McGrath's book XML processing with Python, provides one utility in particular, XMLV, that will validate an XML document against a DTD but NOT a xml schema. If the parser cannot locate the DTD, it reverts to a non-validating version (essentially the equivalent of his XMLN tool - a non-validating parser). Sean's book does not address validating documents against XML schemas at all - pretty understandable given the state of the schema standard at the time it was published. Sean's book does have a number of very useful tips nevertheless. I presume you've checked out Fourthought's FourSuite product. While it does have tools for XSLT, XPATH, RDF, SAX and DOM - I'm pretty sure it also doesn't provide tools to validate documents against a schema - but I would definitely check that site out first to be certain. You might also want to check out sourceforge - I seem to recall a recent post about a couple projects to build wrappers to make Apache's xerces and xalan tools available to python - I can't speak to that effort or whether it addresses your specific question. -- http://mail.python.org/mailman/listinfo/python-list From paul.pfaff at valorec.com Mon Nov 5 12:24:29 2001 From: paul.pfaff at valorec.com (Paul Pfaff) Date: Mon, 05 Nov 2001 17:24:29 GMT Subject: ping with python Message-ID: <3be6cb4a@guardhouse.chbs> Hello, I'm looking to write a simple Ping tool in Python 2.1.1 to log response time > xx ms. Python is new for me and I find it really interesting. For the moment I have buy following good books : - Programming Python (Mark Lutz, O'Reilly) - Learning Python (Mark Lutz, David Ascher, O'Reilly) But, can you help me please : 1. I need the reference of a beginner book how explain the basic functions, or if possible a URL. 2. Can you tell me if an IP library is available ? (commands : ping, tracert....) Many thanks and best regards, Paul From logiplexsoftware at earthlink.net Fri Nov 9 15:16:43 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 12:16:43 -0800 Subject: Module for reading CSV data In-Reply-To: <01110912111100.01360@logiplex1.logiplex.net> References: <01110912111100.01360@logiplex1.logiplex.net> Message-ID: <01110912164300.01414@logiplex1.logiplex.net> On Friday 09 November 2001 12:11, Cliff Wells wrote: > On Friday 09 November 2001 11:20, David A McInnis wrote: > > Is there a module for reading CSV files into a dictionary? Or is there a > > builtin that is used in conjunction with readlines()? > > > > The first row of my csv file contains field names. > Oops, the code I sent also puts the column name in the data. This is correct: l = [ ['a', 'b', 'c', 'd', 'e'], [1, 2, 3, 4, 5], [6, 7, 8, 9, 10], ] d = {} for h in range(len(l[0])): d[l[0][h]] = [row[h] for row in l[1:]] -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From loewis at informatik.hu-berlin.de Fri Nov 30 07:48:08 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 30 Nov 2001 13:48:08 +0100 Subject: pygettext examples? References: Message-ID: Joseph Santaniello writes: > Does anyone have a link or some info on how in practical terms to use the > pygettext module? I've looked at the online docs, and they do a good job > of explaining in theory how to add multiple languages to an app, but they > haven't got me to where I need to be... I need some examples and recipes > to be able to figure it out. I think mailman uses gettext these days. I'd really recommend that you start using it, and ask any questions that you have in the process. Here are the rough steps: 1. Import or assign _ in your module, e.g. by doing import gettext def _(msg): return gettext.dgettext("demoapp",msg) 2. Mark-up all messages with _ 3. Extract the message catalog 4. Translate it 5. Compile the translations 6. Run the application If any of these steps, if executed in this order, gives problems, don't hesitate to ask for further details. Regards, Martin From skip at pobox.com Fri Nov 16 11:22:16 2001 From: skip at pobox.com (Skip Montanaro) Date: Fri, 16 Nov 2001 17:22:16 +0100 Subject: Are there any list comparison optimizations in Python? In-Reply-To: <0baJ7.43107$vQ1.1408848@atlpnn01.usenetserver.com> References: <3BF0883B.62473129@engcorp.com> <0baJ7.43107$vQ1.1408848@atlpnn01.usenetserver.com> Message-ID: <15349.15672.924103.231065@beluga.mojam.com> Steve> Skip, I think you just turned this discussion on its head. The Steve> question you responded to was not "should equal values compare Steve> true with 'is'", but "is it useful for 'a != b' and 'a is b' to Steve> be true for the same a and b". Have you considered that maybe the discussion was standing on its head before and I simply righted it? ;-) I was trying to answer the quesion "should equal values compare true with 'is'" with "no, and here's why." The expense of keeping immutable objects interned so you can do simple pointer comparisons for them and the mutable object issue both argue that they shouldn't. Skip From tanzer at swing.co.at Fri Nov 30 13:00:25 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Fri, 30 Nov 2001 19:00:25 +0100 Subject: What's the value of "None" between 2.1.1 and 1.5.2 In-Reply-To: Your message of "Fri, 30 Nov 2001 16:25:00 GMT." Message-ID: Michael Abbott wrote: > >> So why don't comparisons of this type generate an exception? > > > > Because comparisons are used in sorts, for example, and it wasn't > > considered helpful for sorts of lists of arbitrary datatypes to raise > > errors. > > Sigh. I understand. > > Of course, if you are sorting a list of arbitrary datatypes using random > datatypes as the key then you're in a state of sin. Well, I often use something like print sorted (dictionary.items ()) at the interactive prompt and I'd sure hate it if I got an exception instead of a nicely sorted output. In such a case, I couldn't care less about the order between keys of different types. -- 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 phd at phd.pp.ru Thu Nov 1 11:07:33 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 19:07:33 +0300 Subject: Monty Python (was: Freeware Python editor) In-Reply-To: ; from mikael@isy.liu.se on Thu, Nov 01, 2001 at 05:07:13PM +0100 References: <20011101180204.D675@phd.pp.ru> Message-ID: <20011101190733.H675@phd.pp.ru> On Thu, Nov 01, 2001 at 05:07:13PM +0100, Mikael Olofsson wrote: > > On Thu, Nov 01, 2001 at 03:59:56PM +0100, Mikael Olofsson wrote: > > > > and blod everywhere). But then there are the others (for instance the > > > ^^^^ > > > Make that "blood". > > > > And now it is time for something completely different - spelling wars :( > > Man, there was no spelling war in c.l.py, never. Why starting it now? > > Well, as long as someone is correcting himself, it's not much of a war, > is it? Oops :) Sure! :))) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From prabhu at aero.iitm.ernet.in Wed Nov 7 14:04:46 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Thu, 8 Nov 2001 00:34:46 +0530 Subject: A smarter(?) package importer. In-Reply-To: References: Message-ID: <15337.34254.81491.925934@monster.linux.in> hi, Thanks to all of you for the tips esp. Bernhard, Gordon, Rainer and Michael. >>>>> "GMcM" == Gordon McMillan writes: >> all of its keys and then fail? Hmmm, but if you kept caching >> failure, you'd increase the number of keys. If the package >> nesting is substantial for every global module this would >> insert several new item into sys.modules. GMcM> But sys.modules is a dictionary. It's hashed, not scanned. GMcM> If you *don't* cache failure, you get 3 (4 on Windows) GMcM> attempted opens per directory that you could have avoided. Well, I'm not sure it does 3/4 opens but yes it does do 3/4 imp.find_modules which will be more expensive than a sys.modules[mod_name]. Anyway, I did the following: (1) added caching to knee.py and fixed a bug in it. (2) I also added caching to my_import.py (what a lousy name! ). (3) cleaned up the pkg stuff so it now tests for caching, tests if importing is ok etc. Its again available here: http://av.stanford.edu/~prabhu/download/ A new test_import.tar.gz package which is far nicer and the modifed knee.py can be found. I'd really appreciate if you folks can check it out. Here are some crude timing estimates while using my_import: # this has been duly done a few times so dont worry this is not first # time import time # normal import >>> import time >>> s = time.time (); import scipy; print time.time()-s 1.38626110554 >>> $ python >>> import my_import >>> import time >>> s = time.time (); import scipy; print time.time()-s 1.48667407036 Which if you ask me is pretty good considering what it can do. Also, this kind of proves that this code works for large projects as well. Here are some crude timings of code with and without cache (its actually just a single line that adds caching). no cache: 1.5991319418, cache: 1.49252903461 which isnt much but is measurable. :) So, I'll ask again, how about making this behaviour standard? :) prabhu From christophertavares at earthlink.net Sun Nov 18 01:54:24 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Sun, 18 Nov 2001 06:54:24 GMT Subject: Instantiating a class from its name References: <9t6m56$n4ld$1@ID-11957.news.dfncis.de> Message-ID: "Emile van Sebille" wrote in message news:9t6m56$n4ld$1 at ID-11957.news.dfncis.de... > > "Daniel Klein" wrote in message > news:sgidvt8e5l5m7jmlk0grkqs9pm66beja8k at 4ax.com... > > I need to create a class factory such that passing the 'name' of the class > to the method will > > produce an instance of that class. In Java, you do this with > > > > Class c = Class.forName("name_of_class"); > > MyClass m = c.newInstance(); > > > > What is the Python equivalent? > > > > >>> class A:pass > ... > >>> a = locals()['A']() > >>> a > <__main__.A instance at 007E5FE4> > >>> class C: > ... def __init__(self, val): > ... self.val = val > ... > >>> c = locals()['C'](123) > >>> c.val > 123 > >>> > > There's probably a better way, so by posting this I expect we'll find out. > ;-) > > > -- Since a class object is a python expression, you can use eval in this case and be a little less confusing: >>> class A: pass ... >>> A >>> eval("A") >>> klass = eval("A") >>> klass() <__main__.A instance at 007E5E0C> >>> -Chris From chrishbarker at home.net Thu Nov 1 14:25:08 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 01 Nov 2001 11:25:08 -0800 Subject: in string References: <3BE17AFD.1655EEF8@juno.com> <9rruun$uuu4u$1@ID-11957.news.dfncis.de> Message-ID: <3BE1A194.9F13689D@home.net> Emile van Sebille wrote: > > I kind of understand why this (below) doesn't work. > > What would you have to do to make it work? > > (to make 'eggs' in 'spam and eggs' return 1) > > Or what does: string member test needs char left operand > > mean? It means that the "in" operator tries to look for an item in a sequence of items. A string is a sequence of single charactors, so to use x in string, x must be a single character. > import string > string.find(a, 'eggs') > > Note: this can return 0 (as in 'eggs and eggs'); > -1 is the not found return value or, in recent pythons: >>> a = 'spam and eggs' >>> a.find('eggs') 9 -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From peterb at cortland.com Wed Nov 14 11:38:37 2001 From: peterb at cortland.com (Peter Bismuti) Date: Wed, 14 Nov 2001 08:38:37 -0800 Subject: anonymous functions,classes? Message-ID: <3bf2a42f$1@207.229.64.20> Anonymous was the word I was looking for in my previous post. I want to pass a function as an argument but don't want to have to define it globally. The way I don't want to do it: def foo(): pass callFunction(foo) The way I want to do it: callFunction(def foo(): pass) I'm guessing this can't be done because of Python's indenting syntax. From prabhu at aero.iitm.ernet.in Thu Nov 8 14:59:49 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Fri, 9 Nov 2001 01:29:49 +0530 Subject: newbie tkinter question In-Reply-To: <480f610.0111081146.72a92cb0@posting.google.com> References: <480f610.0111081146.72a92cb0@posting.google.com> Message-ID: <15338.58421.981723.846115@monster.linux.in> hi, >>>>> "jh" == jared writes: jh> I have read the docs, but cannot glean from them if TKinter jh> works in such an environment. Would it? VT420's are color jh> terminals; what happens if we write for VT420's but someone jh> connects up a VT220 or VT100 emulator? AFAIK, Tkinter needs X to run and VT100's are text only terms. In order to create apps on text terminals you can try to use Python and curses. I think this is a good starting point: http://py-howto.sourceforge.net/curses/curses.html prabhu From fperez528 at yahoo.com Tue Nov 27 16:06:32 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Wed, 28 Nov 2001 20:34:32 +2328 Subject: windows to linux pickled objects? References: Message-ID: <9u4adv$2k9$2@peabody.colorado.edu> brueckd at tbye.com wrote: > Binary usually helps, but it can work against you too: > >>>> import pickle >>>> len(pickle.dumps(5.0)) > 6 >>>> len(pickle.dumps(5.0, 1)) > 10 > > -Dave In very peculiar situations, yes (like if you are storing truncated data). But in the generic case, it will help. As always, use what's generically good, and only if it's not enough look again. Optimize late, later, later... f From gmcm at hypernet.com Tue Nov 6 18:03:36 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 06 Nov 2001 23:03:36 GMT Subject: C callbacks ? Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <9s9eou$214c$1@nntp6.u.washington.edu> Message-ID: Donn Cave wrote: > I had no trouble with Python -> C -> Python, done in the normal > way with PyEval_CallObject() with Stackless 2.0, and even invoked > continuations from previous calls. I don't know if that's inconsistent > with what you're saying, or not - maybe I was just lucky! That *sounds* consistent. It's doing things like creating a continuation in Python(2) that you want used by Python(1) that cause trouble. The only times I've seen anyone bit by this is when they create a continuation in an __init__ method, and then expect to use it from some other method. It's not hard to work around, it's hard to predict when you'll get bit. - Gordon From steve at ferg.org Thu Nov 1 18:11:35 2001 From: steve at ferg.org (Stephen Ferg) Date: 1 Nov 2001 15:11:35 -0800 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> Message-ID: I think That Emile's and Greg's suggestions for a Python version of translate() came close, but didn't quite make it all the way. Emile's code was very close, but didn't allow for the default value of the input character set, which is x'00' thru x'FF'. Greg's routine didn't allow for optional arguments, but his use of maketrans() was nice, so I swiped it. I combined the two solutions and added a bit of code of my own, and here's what I came up with. The code may wrap a bit (does anybody know how to stop long lines of code wrapping in a posting?) ##################################################################################### def translate(s, output=None, input=None, pad=" "): """Function: emulate the REXX translate() built-in function """ # authors: Emile van Sebill, Greg Ewing, Steve Ferg if output == None and input == None: return s.upper() # make sure that pad is exactly one character long if len(pad) == 0: raise "Pad character passed to REXX translate() must not be a null string" if len(pad) > 1: raise "Pad character passed to REXX translate() must not contain more than one character" # the default for output is the null string if output == None: output = "" # the default for input is all characters from hex"00" through hex"FF" if input == None: input = "" for n in xrange(256): # produce numbers 0 through 255 input = input + chr(n) # insure that output is as long as input by adding the pad character, if necessary. if len(output) < len(input): output = output + pad*(len(input)-len(output)) return string.translate(s, string.maketrans(input, output)) ##########################################################################3 And here's some code to test it with... ##################### test it ################################# print "Testing..." assert translate('abc123DEF') == 'ABC123DEF' assert translate('abbc','&','b') == 'a&&c' assert translate('abcdef','12','ec') == 'ab2d1f' assert translate('abcdef','12','abcd','.') == '12..ef' assert translate('4123','abcd','1234') == 'dabc' assert translate('cdefghij', None, 'aeiou', '*') == 'cd*fgh*j' assert translate("ABC", "."*67) == ".. " old_date = "20001122" # change a date from yyyymmdd to mm/dd/yyyy print old_date, "==>", translate('56/78/1234', old_date, '12345678') print "Done!\n" ########################################################################## I'm a REXX programmer that is converting to Python. I've developed a number of REXX work-alikes in Python. Here, for example, is strip(), which you asked about... ############################################################### def strip(s, strip_option=None, strip_char=None): """Function: emulate the REXX strip() built-in function """ if strip_option == None: strip_option = "B" if strip_char == None: strip_char = " " strip_option = strip_option.upper() if strip_option == "L" or strip_option == "T" or strip_option == "B": pass else: raise 'Invalid strip_option passed to REXX strip(): "'+strip_option+'"' if strip_char == "": strip_char = " " if len(strip_char) != 1: raise 'Invalid strip_char passed to REXX strip(): "'+strip_char+'"' if strip_option == "B" or strip_option == "L": # BOTH or LEADING while s[:1] == strip_char : s = s[1:] if strip_option == "B" or strip_option == "T": # BOTH or TRAILING while s.endswith(strip_char): s = s[:-1] return s ############################################################### I'm working on a Python module called rexx.py that implements REXX-like functions in Python. I will post it on my web page this evening, at http://www.ferg.org If you know of anybody that is trying to make the transition from REXX to Python, and trying to do something similar (or already has done it!!) please let me know. -- Steve Ferg (steve at ferg.org) From robin at execulink.com Fri Nov 23 18:44:26 2001 From: robin at execulink.com (robin at execulink.com) Date: Fri, 23 Nov 2001 18:44:26 -0500 Subject: web-based email Message-ID: <13ntvtobo7ure90a0gp8cvnrlr970gcq7t@4ax.com> Are there any standards-based platform-neutral web-hosted email clients that have a clean extensible architecture and interface? Requirements include LDAP support for address books and IMAP for centralised mail message storage. It would also make sense if they used the new email module to incorporate easy handling of attachments, etc. I am aware of two choices, neither one of which meets these requirements. But I'm sure someone has invented this wheel already. GoMail is specific to MS platforms running ODBC and uses lots of Javascripty stuff for the interface. It relies on MySql for the database; address are stored in XML. It does not use the email module but the design is fairly clean and is the best choice for a starting platform. BoboMail requires ZPublisher and ZTemplates and is rather impenetrable (unless you are familiar with those modules, presumably). It does not use either LDAP or IMAP but rather dbm storage. Any other suggestions? ----- robin robin at brainexeculink.com (remove "brain" to reply) From store_li at sina.com Wed Nov 14 01:25:29 2001 From: store_li at sina.com (Kick) Date: Wed, 14 Nov 2001 14:25:29 +0800 Subject: Configure Python CGI failed Message-ID: <9st2pt$158u4s$1@ID-12869.news.dfncis.de> I use the follwing envioment to run pythin CGI: Windows 98 Apache 1.3.22 Active Python 2.11 I change the document root setting to my own directory. And add ExecCGI option to that directory description. finally I changed AddHandle statement to .cgi .py. When I try to execute a program located in my document root, the IE said "Internel Error" What's wrong with my setting? Thanks for any help!! From nt_colonel at hotmail.com Fri Nov 9 15:23:28 2001 From: nt_colonel at hotmail.com (T Malcolm) Date: 9 Nov 2001 12:23:28 -0800 Subject: WSC in python clears method arguments References: Message-ID: "Steve Holden" wrote in message news:... > "T Malcolm" wrote ... > > I'm calling a WSC written in Python from a VBS script that is task > > scheduled. This WSC is a "friendly" interface to the Python ftp > > library. All is well, except for one quirk. When I call methods on > > the WSC, it will clear the variable I pass as an argument. > > > So the scripting component is an object, and you are creating instances... > > > > > Example vbs client script(where objFTP is an instance of the Python > > WSC): > > ---- > > strRemotePath = rs.Fields("RemotePath").Value > > > > 'strRemotePath has a value here > > > > objFTP.cwd(strRemotePath) > > So here you appear to be calling a method of the instance you created... > > > > 'strRemotePath is now a nullstring, the cwd command has succeeded. > > ---- > > > > Python code in WSC (objFTP is an instance of FTP imported from > > ftplib): > > ---- > > def cwd(RemotePath, FTP=objFTP): > > FTP.cwd(RemotePath) > > ---- > > But this appears to be a function definition, not a method. Surely cwd() > shouod be defined inside the definition of the class instantiated as objFTP. > Its first argument should be self -- that's how ytou'd expect to [pick up > the object on which the method is being called. > > > > I had to use the FTP=objFTP as an argument because I couldn't > > reference objFTP in the function from the "global" namespace where it > > resides (another quirk?). > > > Erm, objFTP shouldn't (and probably doesn't) reside in your Python module's > namespace. It should be created dynamically and referred to as self (method > 1st argument) when required. > > > Anyway, does anybody have any idea how I can get this thing to quit > > "eating" my variable values? > > There's probably something I'm missing here. Have you got a copy of Hammond > and Robinson's "Programming Python on Win32"? Great reference to all this > stuff. > > regards > Steve Well, see, the COM Component isn't a pure Python module. All of my Python is in a Windows Script Component(WSC)...an xml file parsed by the ActiveX Scripting engine. Classes are set off with tags, and the COM interface is also described using XML tags. Since this isn't a proper python class there's no "self" first argument on the methods, thus causing half of my problems. Everything calls, and it works just great, but it eats the values stored in my argument variables. From tim at vegeta.ath.cx Wed Nov 28 04:13:58 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 28 Nov 2001 09:13:58 GMT Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: Oleg Broytmann graced us by uttering: Has my killfile score expired already? [ snip ] >> More precisely, it's never been in Bill's pocketbook's best >> interest to be compatible with the rest of the world. >> >> It's _always_ been in MS's best interest to be compatible. There's >> more than enough money in the industry to support Microsoft and >> any other vendors. > > There are other merits, not only money. Corporations want power > even more than money. Down with non-free software. For lack of an explicit smiley, I'll take that as troll bait. (Besides, your sig is bringing back painful memories of my TRS-80.) > -- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. Tim Hammerquist -- In 1968 it took the computing power of 2 C-64's to fly a rocket to the moon. Now, in 1998 it takes the Power of a Pentium 200 to run Microsoft Windows 98. Something must have gone wrong. From phr-n2001d at nightsong.com Wed Nov 7 14:06:57 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 07 Nov 2001 11:06:57 -0800 Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: <7x8zditn72.fsf@ruckus.brouhaha.com> Yes, it's a standard idiom of continuations to implement coroutines with them. One virtue of using kernel threads is in principle the kernel threads can take advantage of multiple hardware CPU's. Python's global interpreter lock stops that from happening, but I thought there was some hope the lock might go away someday. From jeff at ccvcorp.com Thu Nov 15 17:16:03 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 14:16:03 -0800 Subject: PEP 276 Simple Iterator for ints References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> <9t0jko$14b$1@thorium.cix.co.uk> Message-ID: <3BF43EA3.42A5A4B6@ccvcorp.com> Ken Seehof wrote: > Hey, what ever happened to the int[:10] iterator idea? > > >>> for i in int[2:10:2]: print i, > 2 4 6 8 > This doesn't look too bad to me. I'd go for it. > > Hey, you could also do floats! > > >>> for x in float[ :1.0 : 0.2]: print x, > 0.0 0.2 0.4 0.6 0.8 > >>> list(float[3.0:1.0:-0.5]) > [3.0, 2.5, 2.0, 1.5] This *does* change syntax, though--currently only ints are allowed in slices, and I think that's probably a good idea. Besides, this would be just begging for compounded floating-point-precision problems. > > Hmm. Complex numbers? Of course the step would be in radians :-) heh heh. Yikes! Run away!! :) Jeff Shannon Technician/Programmer Credit International From bill-bell at bill-bell.hamilton.on.ca Wed Nov 7 08:10:48 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Wed, 7 Nov 2001 08:10:48 -0500 Subject: New to pyton. Maybe a dumb question? In-Reply-To: <1005115683.728.81806.m3@yahoogroups.com> Message-ID: <3BE8EC88.20493.7A4FDAE@localhost> Cliff Pruitt > Is it possible to create an application with Python that will run > on any machine or doe sthe client machine have to have a python > interperater installed? Each machine that runs Python must have the language interpreter installed--in some form. When you install Python code on any given computer you either (a) install the Python distribution too, or (b) package your Python code in a product such as the one created by MacMillan (sp?). There are at least two such products, so use groups.google.com to find references to them with MacMillan and Python as keys. Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From paul at boddie.net Mon Nov 19 05:10:09 2001 From: paul at boddie.net (Paul Boddie) Date: 19 Nov 2001 02:10:09 -0800 Subject: Xlib bindings for Python? References: Message-ID: <23891c90.0111190210.2986aa4e@posting.google.com> Mike Meyer wrote in message news:... > Yes, I'm really looking for a set of bindings for Xlib, not a Xt or Xm > or some other GUI toolkit. It's probably best not to ask why. > > I found the X-extensions package, but that apparently stopped being > updated about python 1.4. > > Anyone got pointers to something more recent than that? Try Greg Ewing's work, which apparently includes a wrapper around Xlib: http://www.cosc.canterbury.ac.nz/~greg/python_gui/ Paul From shriek at gmx.co.uk Thu Nov 15 03:43:15 2001 From: shriek at gmx.co.uk (Stephen) Date: 15 Nov 2001 00:43:15 -0800 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <3BF2C715.7050400@bigfoot.com> Message-ID: <97ae44ee.0111150043.4382fe2f@posting.google.com> Thanks for the help, Cezary > >>But when NUMTHREADS = 20, half the threads die with this error : > >>Unhandled exception in thread: > >>Traceback (most recent call last): > >> File "", line 6, in send_request > >> File "", line 1, in connect > >>socket.error: (10061, 'Connection refused') > > If you are has clients and a server on the same machine, it is possible, > that server it does not have enough time to accept connections on a > listen socket. If I understand you correctly, then the server receives a request, creates a thread to deal with it. But the server is so busy creating threads to deal with incoming requests, that some other requests are ignored. > By default only 5 connections can wait to be accepted - > if more appears, they are refused by your operating system. You can > raise this number, but there are limits on some OS-es. > > So, for really testing server you should launch clients from another > machine(s). Sorry, you've lost me here. If the server can't generate threads quick enough to deal with the incoming connections, how will moving the clients to another machine give the server more time (except perhaps in introducing a network delay) ? > For building high-performance server check: > http://www.nightmare.com/medusa/ > > Medusa combines asyncore with threads for optimal performance. I had found the asyncore/asynchat method a little strange but just downloaded the medusa package and there's a lot of good documentation in the source. The included chat_server example looks like a good starting point. Will try that. Sam also provides a great page of reference material. Excellent. Stephen. From bobh at hslda.org Mon Nov 5 08:04:11 2001 From: bobh at hslda.org (Robert) Date: 5 Nov 2001 05:04:11 -0800 Subject: BlackAdder Message-ID: <4a249347.0111050504.6f126ae5@posting.google.com> How close is this to being completed? Bob From jeff at ccvcorp.com Thu Nov 15 14:29:20 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 11:29:20 -0800 Subject: anonymous functions,classes? References: <3bf2a42f$1@207.229.64.20> Message-ID: <3BF41790.27070CCA@ccvcorp.com> Peter Bismuti wrote: > Anonymous was the word I was looking for in my previous post. I want to > pass a function as an argument but don't want to have to define it globally. > The way I don't want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) > > I'm guessing this can't be done because of Python's indenting syntax. True, but thanks to nested function defs, you also don't need to define the argument-function globally. (Note--this uses nested scopes, thus requires Python 2.x; in 2.0, from __future__ import nested_scopes is required.) def Outerfunction(foo, bar): def Inner(): return bar * 5 return foo + Inner() You can also use lambdas, as has been pointed out by others. But really, I can't see where there's any harm done by defining a function by name just before you need to use it. (If you're *that* worried about polluting the namespace, you can always del it when you're done...) (Suddenly I find myself missing Alex Martelli and his long discourses... :) ) Jeff Shannon Technician/Programmer Credit International From stuart at bmsi.com Thu Nov 15 19:29:24 2001 From: stuart at bmsi.com (Stuart D. Gathman) Date: Thu, 15 Nov 2001 19:29:24 -0500 Subject: A modest proposal Message-ID: <9t1ml4$vhi$1@nntp1-cm.news.eni.net> I have been putting my thoughts toward the elusive goal of making python as fast as some LISP dialects. As a result, I have a proposal that could drastically speed up the common cases of accessing global variables, while slightly slowing down less common accesses, with some rare pathologies that will eat time and memory. (Such cases would, of course, become even more rare should my proposal ever get implemented :-) Please comment on why this is a terrible/great idea, has already been thought of, etc. etc. The basic idea is to split namespace dictionaries into two parts, a simple C array of PyObject pointers, and a SymbolTable which maps names to indexes into the C array. A SymbolTable can grow, but never shrink. Deleting a name from the namespace is represented by storing a 0 into the C PyObject array. The C array is automatically enlarged as required when adding names to the dictionary (call it a SymbolDictionary). In the general case, access is slightly slower due to the extra index into the C array, and memory could be wasted due to deleted names, which still occupy a (0 value) slot in the array and SymbolTable. However, all python semantics are preserved. What does this gain us? For starters, when compiling a module, references to module globals can be compiled to a prebuilt SymbolTable in the bytecode. Outside of functions, references to module globals can use an indexed bytecode similar to local variables. References to globals in imported modules cannot safely be converted to indexed lookups because the module global might be replaced with some other module or object. Of course, this is not a big win unless functions and methods can use this optimization. The problem is, functions can be called with varying namespaces (because they are assigned to multiple modules, for instance). I propose that functions contain a dictionary or cache of namespaces used to call that function. The first time a function is called for a namespace not in the cache, its bytecodes are optimized for that namespace by converting global references to indexes in that namespaces C array. The optimized code is used and saved. For classes, the SymbolTable for class instances can be stored with the class, and only the C array kept with class instances. It might be helpful to provide an overflow dictionary for class instances to handle the case where instances are used as a container for values with arbitrary identifiers - otherwise the instance C arrays would have lots of 0 entries with that kind of usage. In normal python code, a method is only part of one class, and once it is optimized for that classes namespace, it can access instance variables almost as quickly as local vars. If it is assigned to multiple classes, the caching mechanism takes over. Single inheritance can be optimized by making derived class SymbolTables "extend" the first base class - i.e. keep the same indexes - and make the namespace caching smart enough to recognize this case and not reoptimize base class methods for the derived class. Of course, I can envision programming styles involving using functions with many different namespaces - all needing their own copy of optimized code. This can be mitigated by falling back to the unoptimized code when there are two many namespaces for a given function. If SymbolTables support mapping indexes to names, as well as names to indexes, then a function optimized for one namespace can be easily optimized for another, but looking up the name for each indexed global in the old namespace and looking up the index in the new namespace. (But name errors need to be delayed somehow.) I am late and need to go, but I just realized now to avoid the function namespace caching and still reap the benefits of this scheme! So until next time... -- Stuart D. Gathman Business Management Systems Inc. Phone: 703 591-0911 Fax: 703 591-6154 "Confutatis maledictis, flamis acribus addictis" - Mozart background song for the Microsoft "Where do you want to go from here?" commercial. From buzzard at urubu.freeserve.co.uk Wed Nov 7 21:33:18 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Thu, 8 Nov 2001 02:33:18 -0000 Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) References: <8_dG7.4760$R43.760797@newsb.telia.net> <9sbvsa$925$1@newsg2.svr.pol.co.uk> Message-ID: <9scqu0$s93$1@newsg4.svr.pol.co.uk> "Richard Jones" wrote in message news:mailman.1005177550.9554.python-list at python.org... > On Thursday 08 November 2001 05:51, Duncan Smith wrote: > > "Fredrik Lundh" wrote in message > > news:8_dG7.4760$R43.760797 at newsb.telia.net... > > > > > Gary Stephenson wrote: > > > > Umm, I'm not really sure this is a claim we should be making! Next > > > > thing > > > > > > you'll have us claiming responsibility for making disco popular - and > > > > then > > > > > > they'll just have to shoot us! ;-) > > > > > > but Steve Irwin is your fault, right? > > > > And Rolf Harris. > > Hang on there, we may have spawned that particular evil, but you poms are the > ones encouraging him :) Yes, (but not me). But consider the alternative. He might come home, and if he wasn't making naff British TV programmes he might cut more records, and it would probably just mean more Anthea Turner for us (I can't imagine that name means anything outside the UK). So, on second thoughts, thanks for Rolf. Good on ya. Duncan > > > Richard > From emile at fenx.com Wed Nov 14 10:49:41 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 14 Nov 2001 07:49:41 -0800 Subject: re. module References: <993ae4ca.0111140731.3c11e6d5@posting.google.com> Message-ID: <9su44o$163aq9$1@ID-11957.news.dfncis.de> "Adrian Leu" wrote in message news:993ae4ca.0111140731.3c11e6d5 at posting.google.com... > I am trying to figure out a solution for the following: > > import re > > text = 'name_0 goto place' > string = 'name|name_0|name_1' > > pattern = re.compile(string, re.I) > d = pattern.search(text) > return d.group(0) > > The problem is that my program will return 'name' to this. What I want > is for the search to return a match (if it exists) only after looking > at the whole string (name_0 in this case). I.e. in my example I would > like the program to return 'name_0' not 'name'. > > Any ideas how I could do that? > Also match the space character that follows the identifier? -- Emile van Sebille emile at fenx.com --------- From phr-n2001d at nightsong.com Sun Nov 4 02:56:53 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 03 Nov 2001 23:56:53 -0800 Subject: Python/QT Book no in final edit References: <7xady4cxng.fsf@ruckus.brouhaha.com> <9s1bo2$goc$1@news1.xs4all.nl> <7x3d3v1xvs.fsf@ruckus.brouhaha.com> <9s2rcu$jhe$1@news1.xs4all.nl> Message-ID: <7xr8rfufy2.fsf@ruckus.brouhaha.com> boud at rempt.xs4all.nl (Boudewijn Rempt) writes: > But you really don't want to load 700 a4 pages worth of text with > a few hundred illustrations into you webbrowser in one go :-). I > mean, even the html-one-page version of the Emacs manual takes a serious > time to load, and that doesn't have any images. Hmm, that might be a bit much. 3.5 MB isn't too bad but the uncompressed html might be a lot bigger. > When I was last able to generate a PDF of the book (it's too big > for my system right now), it was 3.5 mb... Can I download the 3.5 mb PDF from somewhere? Thanks. From brueckd at tbye.com Thu Nov 29 18:04:21 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Thu, 29 Nov 2001 15:04:21 -0800 (PST) Subject: A modest indentation proposal In-Reply-To: Message-ID: On Thu, 29 Nov 2001, Erann Gat wrote: > The subject of syntactically-significant indentation seems to dominate a > lot of discussions on Python. Outside of c.l.py it shouldn't, as in nearly every modern progrmaming language indentation is already significant to everyone involved (developer, tester, maintainer) except for the code parser. Python merely lets you omit tokens that are needed because the parser isn't smart enough. > It also IMO makes the language unsuitable for mission-critical > applications. Hee hee. > It's just too easy to screw up indentation (particularly when cutting > and pasting large blocks of code) without realizing it. You often find yourself cutting and pasting large blocks of code in mission-critical apps? Yikes! -Dave From logiplexsoftware at earthlink.net Fri Nov 9 19:49:17 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 9 Nov 2001 16:49:17 -0800 Subject: How much is set in stone? In-Reply-To: References: Message-ID: <0111091649170C.01414@logiplex1.logiplex.net> On Friday 09 November 2001 16:39, Tim Peters wrote: > about 2.1.1 before, and I can assure you we didn't pay everyone on c.l.py Who's "we", Tim? I see you've finally shown yo From fredrik at pythonware.com Wed Nov 7 02:30:16 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 07:30:16 GMT Subject: may be a dumb question,but I can't understand why? References: <9sagj3$a0f$1@mail.cn99.com> Message-ID: "luckey" wrote: > the following function is in bpnn.py > def makeMatrix(I, J, fill=0.0): > m = [] > for i in xrange(I): > m.append([fill]*J) > return m > > I rewrite it to : > def makeMatrix(I, J, fill=0.0): > m=[[fill]*J]*I > return m > the result is defference > Can someone tell me the defference between the two function? the FAQ is your friend: http://www.python.org/doc/FAQ.html#4.50 Q. My multidimensional list (array) is broken! What gives? You probably tried to make a multidimensional array like this. A = [[None] * 2] * 3 This makes a list containing 3 references to the same list of length two /.../ From jdadson at ix.netcom.com Sun Nov 4 01:25:28 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 04 Nov 2001 06:25:28 GMT Subject: How much is set in stone? Message-ID: <3BE4DF39.AE0A8EAA@ix.netcom.com> I'm a newbie at Python, but I've been up to my ears in it for the last couple of days. -- Considering using it for a scripting language for a product at work. I'm very impressed with the system. Of course there are things I would like to change. :-) So the question is, how much is set in stone at this point? Is the definition of 2.x now the law of the land, or can we still make suggestions? Jive From jyrinxatmindspringdotcom Fri Nov 30 01:05:36 2001 From: jyrinxatmindspringdotcom (Jyrinx) Date: Thu, 29 Nov 2001 22:05:36 -0800 Subject: Python evangelists unite! References: Message-ID: <9u77i8$a5j$1@slb0.atl.mindspring.net> I haven't worked much with Ruby, I'll admit, but one of their advertised "features" sounds like something that violates OO far more than Python's dynamic members. I don't like singleton functions at all - they let you cheat by futzing with core implementation details in client code. Yeah, Python probably allows this, too, but it's not common and certainly not advertised. A friend argued that it's a waste of code to declare an entirely new class just to override a method and declare a single instance of it; I'd say that deriving a new class is clearer, and redefining an instance's member functions seems kludgy and prone to hard-to-find bugs. (Besides, I like the Python principle that, while short code is good, clear and succinct code is more important than the absolute minimum of LOC's.) Anyway, the point is, while Python allows extra members to be tacked on for a client's own use, this is not half the violation of OO concepts that a certain other language regards as a neat feature. Jyrinx jyrinx at mindspring.com wrote in message news:baf2f841.0111291428.591f515 at posting.google.com... > Okay, I was extolling the benefits of Python to a friend of mine. He > took strong exception to Python's OO model. > > ME: Python's great--you can add members to instances OR classes > on-the-fly! > FRIEND: Why would you want to do that? > ME: Uh... > FRIEND: Besides, that's awful Object Orientation. If I start adding > attributes to an instance of a class, it ceases to be an instance of > that class. If I create a bunch of instances of the same class, they > should be the same; they should have the same members. > ME: Yeah, but with dynamicism, I can add a new pane to a GUI > while it's running. I just change an instance to include a new pane, > and... > FRIEND: That's pretty cool, but it's not a reason, in and of itself, > to make a language so dynamic. There must be some advantage to being > able to add attributes during runtime. What are they? > ME: Uh... > FRIEND: And another thing! What's with encapsulation? There's no > private!?!?!? > ME: > > So, I need some help. I've checked out c.l.p and some on-line > articles, and I just can't find good practicle examples of a program > that adds members to instances (or classes) at runtime. Anybody got > any? I don't want to have to start avoiding my friend.... > > TIA, > b. From robin at jessikat.fsnet.co.uk Fri Nov 23 20:04:17 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Sat, 24 Nov 2001 01:04:17 +0000 Subject: Who can do genetic programming with Python References: <13285ea2.0111210754.13974f4d@posting.google.com> <3BFC0365.21FB6AA1@alcyone.com> <9tm7go$atu$1@newshost.accu.uu.nl> <3BFEA602.FEF2FC2C@alcyone.com> <9tmofi$9ke$1@newshost.accu.uu.nl> Message-ID: lisp code for another stack based approach is midGP at http://helios.hampshire.edu/~lasCCS/code.html -- Robin Becker From ullrich at math.okstate.edu Fri Nov 2 11:14:55 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Fri, 02 Nov 2001 16:14:55 GMT Subject: Freeware Python editor References: Message-ID: <3be2c653.1205904380@news> On Wed, 31 Oct 2001 08:08:22 -0600, Kemp Randy-W18971 wrote: >Check out the free Python editor at www.crimsoneditor.com. Not that it matters to me, but it seems like someone should ask: What does it do that other free(?????????) Python editors don't do? David C. Ullrich From ws-news at gmx.at Thu Nov 15 12:32:39 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 15 Nov 2001 18:32:39 +0100 Subject: Inter-Thread Communication References: <4go7vtc8dqm8qsfq8ttv95bopidscj56l2@4ax.com> Message-ID: <3bf3fcfa$1@brateggebdc5.br-automation.co.at> Hi, I think you can use the Queue module. You than have a queue for each separate communication path. The locking is built into the queue. hth Werner "Dale Strickland-Clark" wrote in message news:4go7vtc8dqm8qsfq8ttv95bopidscj56l2 at 4ax.com... > I have a master thread and a number of subordinate threads. They all > need to communicate between each other synchronously - in an OS > independent way. > > A typical exchange might be: > > T-A waits for a message from somewhere. > T-B sends T-A a message about an event and waits for a response. > T-A deals with the event and sends a response to T-B. > T-A waits for another message. > > Pretty standard stuff, I would have thought. However, I can't see a > tidy way of doing this in Python that doesn't involve three locks: > > The three locks, all of type threading.Lock, are: > > Message - global > Post - global > Response - local to thread > > 1. T-A acquires Message lock > 2. T-B acquires Response lock. > 3. T-A tries to acquires Message lock - blocking > 4. T-B wants to post a message so acquires Post lock - blocking. > 5. T-B get's Post lock and stores message details. > 6. T-B releases Message lock - waking T-A. > 7. T-B tries to acquire Response lock - blocking > 8. T-A get's Message lock, handles message and stores response. > 9. T-A releases Response lock - waking T-B > 10. T-A releases Post lock ready for another thread > 11. continue from 2 > > This seems awfully fussy to me. Is there an easier way? > -- > Dale Strickland-Clark > Riverhall Systems Ltd From bagattin at altern.org Fri Nov 2 18:48:33 2001 From: bagattin at altern.org (Jerome) Date: 2 Nov 2001 23:48:33 GMT Subject: python-gtk documentation Message-ID: <9rvbch$4l1$1@antares.worldonline.fr> Hello Where can I find a gtk-python documentation ?? I need widget and function descriptions ... Thanks Jerome From kragen at canonical.org Mon Nov 26 15:25:21 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 15:25:21 -0500 Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> Message-ID: <83u1vhs2j2.fsf@panacea.canonical.org> "Bill Melcher" writes: > "Kragen Sitaker" wrote in message > news:83r8qmtgu9.fsf at panacea.canonical.org... > > "Bill Melcher" writes: > Unfortunately, Python seems to mess up the DOS redirection so that in the > command line above, the '>python.txt' fragment creates the .txt file in C:\ > but the output is not redirected to that file. The ability to specify "| > more" is also crippled by python. I caught the console output by using the > Pause key and typing what I saw into an editor. That stuff gets written to stderr for no particularly good reason, so redirecting stdout won't help. I don't think MS-DOS gives you a way to redirect stderr. (You know there's a 'Copy' on the DOS console window's menu, right? Under Edit?) > > Well, running it in a console window will save the last > > scroll-buffer-full. You can set your scrollback buffer size (on > > better versions of Windows) with some Properties dialog --- I can't > > remember where. > > I'll see if I can track this down. I think you might have to create a shortcut and set the shortcut properties, but I'm not sure Win98 supports it at all. > > There's little bits of python you could do to save the messages to a > > file. I think you can say: > > import sys > > sys.stdout = file.open("output", w) > > sys.stderr = sys.stdout > > execfile "Q:\\pysol-4.2\\src\\pysol.py" > > I would presume that I should run this in pythonwin or ppm or idle. I will > give it a shot. In Pythonwin or Idle, you might have a scrollbar on your evaluation window. (I don't know what ppm is, and I don't use Pythonwin or Idle.) In that case, maybe you could just run the execfile line. > > > Another topic is a file called ".gdbinit" which contains: > > > > > > file python > > > set args -u -t pysol.py > > > > > > What the heck is this? > > > > Sounds like an initialization file for the GNU debugger, to set it up > > to run your Python command under the debugger. Dunno why Python > > recorded this. Mine sure doesn't. > > Sorry, I confused you. This is a file in the PySol source. That makes a lot more sense. It's there to make it easier to run PySol under the GNU debugger. > The whole situation is made more confusing because I have very > little Unix understanding while you guys tend to be weak on Win98. Yes, and with good reason. :) > In essense, I need to figure out who's doing what to whom, then burrow down > into which ever product is giving me grief -- PySol, obviously. I just type 'sudo apt-get install pysol', and I have... a pysol command that tells me 'bad .pyc magic number'. So I delete /usr/share/pysol/pysol.pyc, which is the file strace pysol tells me python is accessing right before it dies, and... 'can't open /usr/share/pysol/pysol.pyc'. Well, sure. And there's no apparent way to create it. So I sudo apt-get remove pysol, apt-get source pysol, discover apt-get source is missing 'dpkg-source', figure out that dpkg-source is in the 'dpkg-dev' package, sudo apt-get install dpkg-dev, then apt-get source pysol again. Now Python still complains about a bad magic number in pysol.pyc, but I also have a src directory, and when I cd src and python pysol.py, everything works. (Turns out pysol ships with a .pyc file built for Python 1.5.2, and I have Python 2.1.1 installed.) HTH. From missive at frontiernet.net Thu Nov 29 19:03:11 2001 From: missive at frontiernet.net (Lee Harr) Date: Fri, 30 Nov 2001 00:03:11 -0000 Subject: ZPT and WYSIWYG HTML tools. References: Message-ID: > Does anyone have any details of such ZPT/DreamWeaver problems? > One problem I remember them talking about was trying to load files that do not end in .html or .htm or .gif or .jpg or etc I know there was some hacking done (and some begging of whoever holds the keys to the DreamWeaver code) to fix/work-around the problem. You should really look at the zope mailing list for questions such as these. Those people really know zope. (zope at zope.org) From mwh at python.net Mon Nov 19 06:50:54 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 19 Nov 2001 11:50:54 GMT Subject: How to know when a variable is set References: Message-ID: madsurfer2000 at hotmail.com (-) writes: > Michael Hudson wrote in message news:... > > madsurfer2000 at hotmail.com (-) writes: > > > > > How can I test if a variable has been given a value, or if it's > > > undefined? > > > > Why would you want to do that? Specificaly, in what context do you > > want to know? > > > > I like the idea of structs, and I was planning to use a class the same > way, like > > class info: > pass > ... > info.name = ... Oh. In this case you'd want hasattr(). Or maybe try:/ except AttributeError:. > These would be set in an event driven GUI, and I needed to know if > an attribute had been set before I saved the information. Now that I > have thought more about it, an hash table would be a better choice. Well, the above is only syntax sugar for a hash-table, as it happens. But you're probably right. Cheers, M. -- In many ways, it's a dull language, borrowing solid old concepts from many other languages & styles: boring syntax, unsurprising semantics, few automatic coercions, etc etc. But that's one of the things I like about it. -- Tim Peters, 16 Sep 93 From dalke at dalkescientific.com Sun Nov 11 04:36:54 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sun, 11 Nov 2001 02:36:54 -0700 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> Message-ID: <9slgqh$ffm$1@slb2.atl.mindspring.net> Paul Rubin [on security issues with pickling]: >Basically if you unpickle a string that came from an untrusted source >(say, a browser cookie from the Cookie module), the string can make >pickle load arbitrary modules and call arbitrary object constructors >in your application. The docs for the cookie module mention this and >there's an bug open on sourceforge to fix the pickle docs. I've been trying to figure out what Perl does to prevent this problem in, I assume, Data::Dumper. As usual, I'm confused. It appears that Perl has the same problems Python has, in that arbitrary Thaws methods can be called. (See below for how creating an object, even without calling a constructor or special thawing function, can cause problems because the destructor might have side effects, as with TemporaryFileWrapper.) BTW, the line > the string can make pickle load arbitrary modules and call arbitrary > object constructors in your application. should be replaced with "call arbitrary callables". For example, here's a way to remove a file using pickle.loads: >>> t = "(S'filename.txt'\012p1\012ios\012unlink\012p2\012(dp3\012b." >>> import pickle >>> open("filename.txt", "w").write("Hello\n") >>> ^Z Suspended [dalke at pw600a src]$ cat filename.txt Hello [dalke at pw600a src]$ fg python >>> pickle.loads(t) Traceback (most recent call last): File "", line 1, in ? File "/home/dalke/local/lib/python2.0/pickle.py", line 900, in loads return Unpickler(file).load() File "/home/dalke/local/lib/python2.0/pickle.py", line 516, in load dispatch[key](self) File "/home/dalke/local/lib/python2.0/pickle.py", line 856, in load_build inst.__dict__.update(value) AttributeError: 'None' object has no attribute '__dict__' >>> ^Z Suspended [dalke at pw600a src]$ cat filename.txt cat: filename.txt: No such file or directory [dalke at pw600a src]$ Is the following useful? ============= # safe_pickle.py import pickle class SafeUnpickler(pickle.Unpickler): def __init__(self, file, legit_classes = [], legit_modules = []): pickle.Unpickler.__init__(self, file) self.legit_classes = legit_classes self.legit_modules = legit_modules def find_class(self, module, name): if module in self.legit_modules and \ name in self.legit_classes: return pickle.Unpickler.find_class(self, module, name) else: raise SystemError("Tries to unpickle a soured item (%s, %s)" % \ (module, name)) def load(file, legit_classes = [], legit_modules = []): return SafeUnpickler(file, legit_classes, legit_modules).load() =============== >>> import cStringIO, pickle, safe_pickle >>> >>> class Spam: ... def __init__(sel, x, y): ... print "Called with", x, y ... def __getinitargs__(self): ... return (9, 8) ... >>> spam = Spam(1, 2) Called with 1 2 >>> s = pickle.dumps(spam) >>> pickle.loads(s) Called with 9 8 <__main__.Spam instance at 0x12034a988> >>> safe_pickle.load(cStringIO.StringIO(s)) Traceback (most recent call last): File "", line 1, in ? File "safe_pickle.py", line 18, in load return SafeUnpickler(file, legit_classes, legit_modules).load() File "/home/dalke/local/lib/python2.0/pickle.py", line 516, in load dispatch[key](self) File "/home/dalke/local/lib/python2.0/pickle.py", line 682, in load_inst klass = self.find_class(module, name) File "safe_pickle.py", line 14, in find_class raise SystemError("Tries to unpickle a soured item (%s, %s)" % \ SystemError: Tries to unpickle a soured item (__main__, Spam) >>> safe_pickle.load(cStringIO.StringIO(s), ["Spam"], ["__main__"]) Called with 9 8 <__main__.Spam instance at 0x1202ee1c8> >>> It's also possible to check that find_class really returns a ClassType, and override load_obj (or load_inst or both?) so the constructor is never called. Hmm, and what about returning the Bastionized form of the found class? It's still tricky as things aren't automatically safe -- what if you unpickle a tempfile.TemporaryFileWrapper? It's possible for the destructor there to unlink the named file. So skipping the constructor and any deserialization function still doesn't guarantee the safeness of unpickling. But at least with this 'safe_pickle' you get to determine what you trust. Andrew dalke at dalkescientific.com From phd at phd.pp.ru Sun Nov 4 00:57:39 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sun, 4 Nov 2001 08:57:39 +0300 Subject: Gadfly and regsub with Python 2.1 In-Reply-To: <3BE4A172.1020808@nospam.adelphia.net>; from bobhicks@nospam.adelphia.net on Sun, Nov 04, 2001 at 02:01:22AM +0000 References: <3BE2B29B.1E714B89@noaa.gov> <3BE4A172.1020808@nospam.adelphia.net> Message-ID: <20011104085739.A11999@phd.pp.ru> On Sun, Nov 04, 2001 at 02:01:22AM +0000, Robert Hicks wrote: > What ever happened to Gadfly? Did it ever get updated? The author is very busy working for Reportlabs, and silently dropped kjbuckets, kwprsing nd gadfly projetcs :( I've collected some bits of the dust, but not gadfly. IWBN if someone who uses one of these projects popped up and announced himself as a new maintainer. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From loewis at informatik.hu-berlin.de Fri Nov 23 10:29:10 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 23 Nov 2001 16:29:10 +0100 Subject: Python on AIX References: Message-ID: marco writes: > We haven't tried those, though. Still, we hope this is helpful for > people trying to perform the compilation on their own, and to the > Python developers by letting them know about the glitches we > encountered. Unfortunately, it doesn't help Python developers much. What *would* help is to have an expert on AIX with much time at his hands, who understands all the problems and proposes a fix. That fix, ideally, would work on all versions of AIX or clearly identify the versions it does work for, and not interfere with the build procedure on other systems (or generalize that so that AIX comes out as an instance of the general procedure, instead of being a special case on its own). Regards, Martin From kseehof at neuralintegrator.com Thu Nov 15 13:29:44 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Thu, 15 Nov 2001 10:29:44 -0800 Subject: PEP 276 Simple Iterator for ints References: <7x3d3gc2io.fsf@ruckus.brouhaha.com> <9t0jko$14b$1@thorium.cix.co.uk> Message-ID: <045001c16e04$860fee00$7a93b23f@kens> Hey, what ever happened to the int[:10] iterator idea? >>> for i in int[2:10:2]: print i, 2 4 6 8 Like PEP 276, it doesn't require new syntax (just implement a slice operator for int). int[3:8] should return an iterator equivalent to [3,4,5,6,7] int[-4::2] should return an infinite sequence iterator [-4, -2, 0, 2, ...] I think that this solves all of the problems that PEP 276 solves, without any inconsistent idioms or warts. Here's what http://python.sourceforge.net/peps/pep-0276.html has to say about it: - It would be better to reuse the slicing literal syntax attached to the int class, e.g., int[0:10] Response: Same as previous response. """ Response: Shares disadvantages of other proposals that require changes to the syntax. Needs more design to determine how it would handle the general case of start,stop,step, open/closed/half-closed intervals, etc. Needs a PEP.""" In addition, design consideration needs to be given to what it would mean if one uses slicing syntax after some arbitrary class other than class int. Needs a PEP. What syntax change? There is no syntax change. A slice operator would simply be added to the int class. Slicing syntax applied to some arbitrary class would naturally depend on the slice implementation for that class :-) I agree that it needs a PEP. Hey, you could also do floats! >>> for x in float[ :1.0 : 0.2]: print x, 0.0 0.2 0.4 0.6 0.8 >>> list(float[3.0:1.0:-0.5]) [3.0, 2.5, 2.0, 1.5] Hmm. Complex numbers? Of course the step would be in radians :-) heh heh. - Ken From drs at alex2.labs.agilent.com Fri Nov 30 14:12:10 2001 From: drs at alex2.labs.agilent.com (David R. Smith) Date: Fri, 30 Nov 2001 11:12:10 -0800 Subject: summing NumPy byte arrays Message-ID: <3C07DA0A.2DB4F78C@alex2.labs.agilent.com> I have a big NumPy byte array, and want to sum it. Unfortunately, the add.reduce (alias: sum) method does the sum in the same size receptacle, e.g., >>> from Numeric import * >>> X = arange(255, typecode='b') >>> sum(X) 129 >>> How can I get it to sum the array in a full-width accumulator, without making an up-sized copy of the array? David Smith ps. The array I am working with is a 2-d noncontinguous slice. From philh at comuno.freeserve.co.uk Fri Nov 30 09:37:25 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 30 Nov 2001 14:37:25 +0000 Subject: CryptKit 0.9 released References: Message-ID: On Fri, 30 Nov 2001 02:13:33 -0500, Bryan wrote: >This is a release notification for the CryptKit Project: > >http://eevolved.com/cryptkit/ > >CryptKit is a developer's toolkit implementing several of the most modern and >efficient cryptographic algorithms. The kit is primarily written in ANSI C >for speed and subsequently wrapped with SWIG for ease of use in python. The >goal of this kit is twofold: If i included this kit in my programs, how ease would it be for a user to install it? Would it be more difficult than as pure Python solution? >- Efficiency and size. > > The kit is considerate of developer constraints on size and speed of >applications. That is why CryptKit implements only the most efficient >algorithms ( AES, ECC, DH, NR ) What are ECC and NR? >while maintaining small library size ( around >100KB compared to 2.1 MB for openSSL 0.9.6 ). Sounds good. >CryptKit is small and fast, mainly because it implements excellent >algorithms: Rijndael (AES), SHA 256 bits, Elliptic Curve PKI, Can this be used for digigal sugnatures as well as encryption? >like DES/RC4/RC2 or MD5/SHA ), CryptKit takes the minimalist approach of >implementing only one version of each crypto primitve. Great care went into >selecting the best of what was available. Sounds reasonable. But what about including others, for backward compatibility e.g. with OpenPGP? -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From BPettersen at NAREX.com Mon Nov 26 13:36:07 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Mon, 26 Nov 2001 11:36:07 -0700 Subject: string.join() syntax quirky? Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192215117@admin56.narex.com> > From: Russell E. Owen [mailto:owen at astrono.junkwashington.emu] > > In article <3BFD49D8.F7A4C6CC at earthlink.net>, > Erik Johnson wrote: > > >... I have a list of single character strings. A couple of > people were > >kind enough to clue me in to the best way to turn this back to a > >string: > > > >s = "".join(l) > > > > This works fine, but it seems syntactically backwards to me: > > > ># s = l.join("") > > > >makes much more sense to me. The thingy I want to do > something to is my > >list. I am just trying to learn Python, so no doubt there > will be some > >Python things I will just have to get used to, but is there > a logical > >reason why it was implemented as a string method rather than a list > >method? Does it seem backwards to you or does it make > intuitive sense > >to you? Comments? (other than of the "it's moot" flavor) > > I would also prefer having join be a list method, but there are good > reasons for the current design. > > One way to look at it is that the various collection classes do NOT > inherit from a single base class (which would be a logical place to > define a join method). Hence to have all kinds of collections > learn to > "join" requires a lot of repeat coding. Making join a string method > solves this problem. So instead of doing what's right we're doing what's convenient? Doesn't sound very Pythonic -- bjorn From jdadson at ix.netcom.com Mon Nov 5 18:33:12 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 23:33:12 GMT Subject: Remote debugging? Message-ID: <3BE72194.414BDD9B@ix.netcom.com> Can IDLE be connected via TCP/IP or whatever to a Python program that's running on a different machine? -- one that does not have windowing capability? If not, how much effort would it take to make it so that it could? Jive From huaiyu at laplace.almaden.ibm.com Mon Nov 26 20:27:15 2001 From: huaiyu at laplace.almaden.ibm.com (Huaiyu Zhu) Date: Tue, 27 Nov 2001 01:27:15 +0000 (UTC) Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> Message-ID: On Sat, 24 Nov 2001 21:25:22 -0500, Peter Hansen wrote: >Dave Cinege wrote: >> >> On Saturday 24 November 2001 9:21, Peter Hansen wrote: >> >> > Unfortunately, since the definition of a tab is ambiguous and >> > inconsistent, >> >> # ascii tab >> ASCII 0/9 is decimal 009, hex 09, octal 011, bits 00001001: called ^I, HT, TAB >> Official name: Character Tabulation >> Other names: Horizontal Tab, \t >> >> It's what it's always been for at least 30 years... > >You really don't actually understand the point everyone is >making here, do you? I thought you were just being "in your face" >for effect, but now I see you're lost. I think you are missing one point that half of the people here are saying: - That there is no reason to associate tab with any equivalent in spaces. It should only be used as a distinct character in its own right. - That the problems with different tab-sizes are all caused by people presuming tab can be used as a short hand for spaces. >Yes, the above is what people call a tab. That doesn't say anything >about the uses to which people (and software) put it. It is *that* >which is ambiguous and inconsistent. Didn't that get through >in the dozen other messages on the subject? Or are you currently >in a mode where you jump on perhaps-sloppy use of words instead >of concentrating on the intended meaning? There is no problem in using it the right way - as a place-holder of indentation level. It can be displayed anyway you want, as long as you do not _assume_ the writer and reader will ever display them the same way in terms of spaces. If you get around the notion that tab can ever be translated into spaces in a _universal_ way, you'll find that all the problems dissappear. For example, got a problem with mixing tab and space? Well, just don't do it. They are two different characters. It's the same as mixing w with vv or mixing m with rn. If this is enforced with the same strictness there would be no more problem with mixing tab and space than mixing w and vv. >Tab, tabstop, whatever. There's no "tab" in the binary world either. >Just ones and zeros. Nonesense. There does exist a tab character, which is _defined_ as a combination of zeros and ones. What has that to do with tabstop, which is a horizontal postition? >Once again, the point you missed is that tabs are sometimes >treated (by software) in such a way as to advance the cursor >other than to the next multiple of 8 (which effect I was calling >the tabstop, so I wouldn't get jumped on by people like you for >saying tabs represented a fixed 8 spaces). Why would it matter to you how other people are displaying a particular character on screen? They could just as well display it as red circle inside a blue star followed by a yellow triangle inside a green square. As long as this character is encoded correctly all the programs they sent you will display on your screen the way you want to. Where is the inconsistency you are complaining about? Unless you were sharing code by taking screenshot of editors and sending the graphics around ... :-) [snip] >I strongly suspect, based on your other postings, you are just >trolling here, trying in a really obscure way to say that you >think discussion of tab "sizes" is just a religious discussion. >If that's all you're contributing, consider your point made >and please stop the ranting. I think his point is quite clear. The reason you do not see it that way is because, IMHO, you have not seriously considered the possibility that people might be arguing for the position that tabs can be used consistently without a defined equivalence as spaces. Huaiyu From blagrang at ulb.ac.be Wed Nov 7 06:45:43 2001 From: blagrang at ulb.ac.be (Benoit Lagrange) Date: Wed, 07 Nov 2001 12:45:43 +0100 Subject: Disk explorer from python with COM Message-ID: <3BE91EE7.7050302@ulb.ac.be> Hi all I am wondering wether it is possible to browse the disk from a Python application by using COM. If yes, how to do it? Any help would be great. Thanks Benoit Lagrange From Randy.L.Kemp at motorola.com Fri Nov 2 09:25:04 2001 From: Randy.L.Kemp at motorola.com (Kemp Randy-W18971) Date: Fri, 2 Nov 2001 08:25:04 -0600 Subject: Freeware Python editor Message-ID: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> I think of the whole concept of free having many facets. Imagine a cake was baked and I was free to eat it. Now the cake can be made according to the following methods: 1. The cook makes the cake, gives it to us to eat, and doesn't share the recipe. 2. The cooks makes the cake, gives it to us to eat, and hands out copies of the recipe. 3. Several cooks try a variation of the cake, based on the original recipe, and give it to us to eat. Now there are probably other variations above, but from the philosophy of pragmatism, I can have my cake, and eat it to. -----Original Message----- From: Tim Peters [mailto:tim.one at home.com] Sent: Thursday, November 01, 2001 11:37 PM To: python-list at python.org Subject: RE: Freeware Python editor >> FOR IMMEDIATE DISTRIBUTION TO ALL PSU MEMBERS [Delaney, Timothy] > The PSU failed! A post about the PSU escaped to the world in its > entirety! > > We are fre In case the intended word was "free", I'd like to point out that there are different philosophies about free software, only one is correct, and c.l.py's mission is to educate the world about which one that is. Don't forget that extremism in defense of freedom is no vice. just-following-orders-but-don't-feel-good-about-it-ly y'rs - tim From phd at phd.pp.ru Sat Nov 24 04:36:23 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Sat, 24 Nov 2001 12:36:23 +0300 Subject: HTTPLIB - Problem retrieving a page In-Reply-To: ; from colinmeeks@rogers.com on Fri, Nov 23, 2001 at 07:46:46PM +0000 References: Message-ID: <20011124123623.E11470@phd.pp.ru> On Fri, Nov 23, 2001 at 07:46:46PM +0000, Colin Meeks wrote: > I am running the following code to retrieve pages and strip out some > details, > however I have noticed that some sites do not work, even though the correct > URL is given. I can verify it works by testing it in my browser. The below > code gives a 404 error. > > import urlparse, httplib, urllib > UseURL='http://www.meeks.ca/index.htm' I tested the site a bit and found that it responds Error404 to HTTP/0.9 requests (I tested it with netcat). HTTP/1.0 and HTTP/1.1 requests are ok. So the reason is (or at least may be) that your version of Python library does not send HTTP version with request. Try to verify this (that is, look into headers that httplib sends; use debugging proxy or fake http server for testing - there are a number of pure python tools for this task). Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sasoft at gmx.de Sun Nov 4 17:21:18 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Sun, 4 Nov 2001 17:21:18 -0500 Subject: bg and fg In-Reply-To: <001101c1653f$3f9a33e0$0101010a@local>; from chris.gonnerman@newcenturycomputers.net on Sun, Nov 04, 2001 at 08:44:07AM -0600 References: <20011104112551.A14309@cruciatuz.de> <001101c1653f$3f9a33e0$0101010a@local> Message-ID: <20011104172118.A15499@cruciatuz.de> On Sun, Nov 04, 2001 at 08:44:07AM -0600, Chris Gonnerman wrote: > > - i am using linux > > - i got a script that takes the time.ctime string and > > compares it with a set time. if the time is the same > > as the set time, it will do something. > > - the script is a non-gui application (see bottom of this mail) > > > > question: > > 1. how can i move my process in the background after i > > started it (like: myscript & -> but automatically). > > if os.fork(): > sys.exit(0) > > ... is the basic code (full daemon mode takes a bit more work). Ok, thx. I wrote a little daemon-skelleton with using an example on python.faqts.com : #!/usr/bin/env python import sys, os, time if os.fork() == 0: os.setsid # what does THAT mean? it was in the example. # i looked into "pydoc os" but i didn't understand # find an explantation sys.stdout = open("/dev/null", 'w') sys.stdin = open("/dev/null", 'r') while 1: pass # daemon code: It works :) ... but raises another question: How can i send commands to a daemon to (let's say) get it's status or terminate it without killing it? Do i need a local socket connection for doing something like this? Or is there a more elegant way? > > 2. how do i move it back in the foreground when the > > action for the set time is performed? > > You can't. The shell does it by keeping a "grip" on the process, > and so it can return it to the foreground when told to. AFAIK you > can't tell the shell to do this programmatically. I think this has to do with security(?) -- thx in advance, Stefan Antoni From lac at strakt.com Tue Nov 6 07:34:28 2001 From: lac at strakt.com (Laura Creighton) Date: Tue, 06 Nov 2001 13:34:28 +0100 Subject: importing a tcl/tk widget In-Reply-To: Message from jmsun@bioeng.ucsd.edu (Jeffrey) of "05 Nov 2001 15:55:06 PST." <3daa1aa8.0111051555.125dbd8e@posting.google.com> References: <3daa1aa8.0111051555.125dbd8e@posting.google.com> Message-ID: <200111061234.fA6CYSua004325@ratthing-b246.strakt.com> create_window(x0, y0, window=your_favourite_widget, options ...) doesn't work for you? see: http://www.pythonware.com/library/tkinter/introduction/canvas-window.htm does it work if you embed your widget in a frame, and then embed that frame in the canvas? Or do you want to put arbitrary tcl code in your canvas? Laura Creighton >Hi All, > I wanted to know if anyone knew of a way to import a tcl/tk widget >into a Tkinter canvas widget. I know that you can write a Tkinter >wrapper function but I don't really know how to do this. If anyone >can help, and/or point me to a good website/book that would be great >thanks. From mikael at isy.liu.se Thu Nov 8 04:02:10 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 08 Nov 2001 10:02:10 +0100 (MET) Subject: Australian Disco (was: And Now for Something Completely Diff In-Reply-To: Message-ID: On 08-Nov-2001 Neil Hodgson wrote: > Mikael Olofsson: > > > Talking about the BeeGee's, weren't the HeeBeeGeeBee's from Australia? > > No, they were English too although I saw them perform in a Sydney pub. > That's normally enough to claim them. > "Meaningless songs in very high voices" Boring song. /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 08-Nov-2001 Time: 10:01:23 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From phd at phd.pp.ru Tue Nov 27 12:13:35 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 27 Nov 2001 20:13:35 +0300 Subject: (no subject) In-Reply-To: <9u0hfu+28mg@eGroups.com>; from toffer_ji0@subdimension.com on Tue, Nov 27, 2001 at 05:11:26PM -0000 References: <9u0hfu+28mg@eGroups.com> Message-ID: <20011127201335.V25831@phd.pp.ru> On Tue, Nov 27, 2001 at 05:11:26PM -0000, toffer_ji0 at subdimension.com wrote: > is it possible to call or rather use an instantiated class using, say > a string (assuming unique).. > > i.e. > > anInstance = aClass('uniqueName') > . > . > . > 'uniqueName'.someMethod(someParameter) > > i'm doing this because i need keep a some classes in a list.. i find > it intensive sometimes to use a for loop with if statements > just to check if the class exist then use it... Use dictionary, mapped by uniqueName strings. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From phony_address at yahoo.com Fri Nov 30 21:01:56 2001 From: phony_address at yahoo.com (Phredd Phlintstone) Date: Sat, 01 Dec 2001 02:01:56 GMT Subject: PythonWin DDE Conversion error References: <3c07f946.27546641@news> Message-ID: <3c0839b8.44047280@news> On Fri, 30 Nov 2001 21:45:02 GMT, Mark_Pryor wrote: >Hi, >On Fri, 30 Nov 2001 21:28:47 GMT, phony_address at yahoo.com (Phredd >Phlintstone) wrote: > > >I have the same trouble, but only when running Apache 1.3.20. If I >stop Apache and launch PythonWin, then all goes well. Make sure >that you don't have more than one instance of PythonWin running, too. > >good luck, >Mark Pryor Ah...you were right. I had Python running twice. Butt the problem is ... when I start the program from Start > Programs > PythonWin Environment, it doesn't open, though it appears in my tray as running. Please post any responses to this to this newsgroup. From ChuckEsterbrook at yahoo.com Fri Nov 2 15:47:03 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Fri, 02 Nov 2001 12:47:03 -0800 Subject: delattr()+dir() problem in 2.2b1 In-Reply-To: <15331.240.103695.55897@beluga.mojam.com> References: <5.1.0.14.0.20011102115004.0424b140@mail> <5.1.0.14.0.20011102115004.0424b140@mail> Message-ID: <5.1.0.14.0.20011102124441.0218d610@mail> At 02:24 PM 11/2/2001 -0600, Skip Montanaro wrote: > Chuck> So dir() is now returning attributes that the object doesn't > Chuck> really have, but inherits. Is that intentional? > >Yup. In the common case (executing dir() at the interpreter prompt), this >is more useful than the old behavior. > > Chuck> Is there another function that I should be using to get the data > Chuck> attributes of a particular instance and no more? > >I don't think so. I think you'll either have to catch the exception or >rummage around in the object's __dict__. Duh! (on my part) I just need to replace dir() with self.__dict__.keys() and get on with my life... :-) I was stuck in must-have-a-function mode since I was already using a function. Thanks for jarring me out of that. -Chuck From sholden at holdenweb.com Fri Nov 9 07:47:07 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 9 Nov 2001 07:47:07 -0500 Subject: Example for using MySQL References: <9sg7t8$12a85q$1@ID-69142.news.dfncis.de> Message-ID: One place would be: http://sourceforge.net/docman/?group_id=22307 which is the SourceForge documentation for the MySQLdb module. There are (at least) two (easy) ways to use MySQL in Python: 1) Install the MySQL module and use that; and 2) Install MySQLodbc then treat MySQL just like any other ODBC source. On the Windows platform both these sloutions work well. Don't have any direct Unix experience to quote at you yet. regards Steve -- http://www.holdenweb.com/ "Andreas Penzel" wrote in message news:9sg7t8$12a85q$1 at ID-69142.news.dfncis.de... > Hello NG! > > Where can I find an example for using MySQL in Python (specially how to > connect to the DB)? > > Thanks, Andreas > > From wpmelcher at snet.net Fri Nov 23 16:37:33 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Fri, 23 Nov 2001 21:37:33 GMT Subject: Win98 PySol problem Message-ID: Hi Guys Sorry to bust in here but I have yet to find an appropriate 'place to go'. Perhaps someone can point me to some useful, helpful would be nice, resources or even solve my problem(s). 1) I am very new to Python although not to computer programming (mostly asm on mainframe and IBM clone PC). 2) I attempted to upgrade from PySol 4.20 (with which I have no problems) to PySol 4.72. Since the latter release had no 'W98 install package' available on the author's (Marcus) site. I did the install 'by hand' 3) I have installed ActivePython-2.1.1.msi 4) When I run PySol 4.72: a) An MS DOS window (PyShell ?) opens b) The PySol loading progress bar runs c) The PySol window opens and deals a solitaire hand d) The PySol window and the MS DOS window vanish. 4) After a bit of mucking about, I was able to capture the contents of the DOS window before it evaporated, to wit: Copy of MS DOS (python) window captured at end of pysol_21.pyc execution: Traceback (most recent call last): File "pysol.py", line 19853, in ? File "pysol.py", line 19851, in main File "pysol.py", line 19813, in pysol_main File "pysol.py", line 18904, in mainloop File "pysol.py", line 18984, in runGame File "pysol.py", line 3346, in helpAbout File "pysol.py", line 2365, in __init__ File "pysol.py", line 2287, in __init__ File "pysol.py", line 2024, in makeImage File "O:\PYTHON21\lib\lib-tk\Tkinter.py", line 2972, in __init__ apply(Image.__init__, (self, 'photo', name, cnf, master), kw) File "O:\PYTHON21\lib\lib-tk\Tkinter.py", line 2928, in __init__ self.tk.call(('image', 'create', imgtype, name,) + options) TclError: unknown option"-dither" So here I am, a stranger in a strange land where Python rules and speaks an almost, but not quite, comprehensible language! I have attempted to communicate with Marcus with no success and now his site and the host server are down and have been for a day or two at least. As a result of the site difficulties I have not been able to acquire the sources for PySol 4.72 in which I hoped, perhaps vainly, to find and apply a fix. As a result of my researches, I have (Python documentation to the contrary not withstanding) many questions. I think my central problem is that I do not really 'understand' UNIX since I have never worked with the system or any of it's variations. I, therefore, have more than a little trouble dealing with UNIX concepts and attempting to relate them to Windows, specifically Win98, concept. The secondary problem of the automatic close of the MS DOS window could use a fix also. I am not alone here. See Power-Tech's (Willie's) Re: in the AppBars in Win32... thread earlier today (11/23/2001). In his situation, he doesn't have a prayer of pulling the stunt that I did to capper the trace-back. Any help be it a fix (or two) or a pointer to where I might get some help would be much appreciated. Note that I have (at my age and circumstances) little interest in /programming/ in Python, I just want to get the dang program to run on an alien OS. -- Cheers, Bill TANSTAAFL! From hungjunglu at yahoo.com Thu Nov 22 12:51:30 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 22 Nov 2001 09:51:30 -0800 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> <9t9h3j$7r9$1@tyfon.itea.ntnu.no> Message-ID: <8ef9bea6.0111220951.2db04343@posting.google.com> "Magnus Lie Hetland" wrote in message news:<9t9h3j$7r9$1 at tyfon.itea.ntnu.no>... > Well... If you want an evil solution: > locals()[['a','b'][idx]] = val I can think of: (1) exec ('a=val', 'b=val')[idx] (2) exec 'ab'[idx]+'=val' (3) exec chr(97+idx)+'=val' Hung Jung :) From richard at bizarsoftware.com.au Thu Nov 29 16:51:59 2001 From: richard at bizarsoftware.com.au (Richard Jones) Date: Fri, 30 Nov 2001 08:51:59 +1100 Subject: HOWTO: Programming S/MIME in Python with M2Crypto In-Reply-To: <200111292132.fATLWw368380@bigboy.bizarsoftware.com.au> References: <200111292132.fATLWw368380@bigboy.bizarsoftware.com.au> Message-ID: <200111292151.fATLpk368567@bigboy.bizarsoftware.com.au> On Friday 30 November 2001 08:33, Richard Jones wrote: > On Thursday 29 November 2001 23:11, Graeme Longman wrote: > > Please could you let me know exactly how you got this working. Is the > > sendsmime() method you refer to the same one that is given in the HOWTO ? > > It's equivalent code. > > > Or is there another smime method which is part of the python package ? > > > > I've been trying to get the examples in the HOWTO to work with Netscape > > Messenger and haven't been able to. > > They should work fine - there's nothing at all special about those > examples. Hang on, just had a thought - what _version_ of "Netscape Messenger" are you using? Netscape 6+ aka Mozilla aka "nobody uses S/MIME, it's not important, so we won't bother implementing it" aka *grrr* ... well, it doesn't support S/MIME. You need to revert to a _useful_ email package, like the one with Netscape 4.7 or Outlook (the only two mail packages that I know of that support S/MIME in a graphical environment.) Richard From max at alcyone.com Fri Nov 23 14:22:01 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 23 Nov 2001 11:22:01 -0800 Subject: syntax-error? References: Message-ID: <3BFEA1D9.4AF753E6@alcyone.com> Stefan Antoni wrote: > I got the following script and it produces a syntax error which drives > me crazy. it says: > > File "", line 24 > j = 0 # a counter > ^ > SyntaxError: invalid syntax > > Why? ... > def ExtractData(in_string, start_line, end_line): > lstr = in_string.splitlines() > j = 0 # a counter ... You have an indentation problem. The offending line is on a different indentation level that the line preceding it, but the preceding line doesn't start a new block. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From glennfulford at bigpond.com Thu Nov 22 23:08:26 2001 From: glennfulford at bigpond.com (Glenn R Fulford) Date: Thu, 22 Nov 2001 20:08:26 -0800 Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> <9tdhon$aht52$1@hades.rz.uni-sb.de> Message-ID: "Huaiyu Zhu" wrote in message news:slrn9vntn4.5im.huaiyu at gauss.almadan.ibm.com... > On Wed, 21 Nov 2001 19:25:01 -0800, Glenn R Fulford > wrote: > > > If you have tried to solve differential equations with a difference method > in Fortran you'd have felt the pain of indexing from one. More > specifically, if you divide an interval into n, the nodes would be most > naturally labelled [0, 1, ..., n]. There are many other situations, but I > won't repeat them. > Good example. I have solved DEs with finite difference and found it a bit anoying. That is where Fortran900 is good, where you can declare where you want the arrays so start from. Glenn. > Huaiyu From calves at coelce.com.br Wed Nov 28 15:06:10 2001 From: calves at coelce.com.br (Alves, Carlos Alberto - Coelce) Date: Wed, 28 Nov 2001 17:06:10 -0300 Subject: 1st day newbie question. Message-ID: <29A97D00F387D411AC7900902770E14802BB131F@lcoeexc01.coelce.net> It depends on what OS you are. If you're in Unix world, I think just typing python xxxx.txt or xxxx.py, at command line, will work. On the other hand, if you're on MS Windows world, in DOS prompt, go up to the python directory and type python xxxxx.txt or xxxxx.py ( You also can put all commands in one BAT file to do the whole thing for you. ____ __/____\__ /( ) ( )\ ( /\ ) HA! HA! HA! \|||||||||||||||/ HA! HA! HA! ||||||||||||| |_____| > -----Original Message----- > From: Bupkas [mailto:bupkas at home.com] > Sent: Wednesday, November 28, 2001 2:27 PM > To: python-list at python.org > Subject: 1st day newbie question. > > > Going though the tutorial I am able to use the interactive > environment, but > if I try some of the example programs, how do I run them as a > text file? > > > -- > http://mail.python.org/mailman/listinfo/python-list > -------------- next part -------------- An HTML attachment was scrubbed... URL: From just at letterror.com Sun Nov 11 16:05:21 2001 From: just at letterror.com (Just van Rossum) Date: Sun, 11 Nov 2001 22:05:21 +0100 Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> Message-ID: <3BEEEADE.D539C08C@letterror.com> Laura Creighton wrote: > Okay, new version: > > def foreach(object_list, method_name, *args): > for object in object_list: > try: > method = getattr(object, method_name) > except AttributeError: > pass > else: > if callable(method): > method(*args) > > Did I miss something? One slight improvement that I didn't think of before: def foreach(object_list, method_name, *args): for object in object_list: method = getattr(object, method_name, None) if method is not None and callable(method): method(*args) I think three-arg getattr() is faster than catching an exception. (I would leave out the callable() test, but then again, I don't know your exact needs.) Just From niemeyer at conectiva.com Thu Nov 1 17:51:27 2001 From: niemeyer at conectiva.com (Gustavo Niemeyer) Date: Thu, 1 Nov 2001 20:51:27 -0200 Subject: List transpose method In-Reply-To: ; from TomH@optiscan.com on Fri, Nov 02, 2001 at 08:42:23AM +1100 References: Message-ID: <20011101205127.A4219@ibook.distro.conectiva> > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some functional guru > tell me a one liner to transpose this to the form ((1,3,5),(2,4,6))? I can > only come up with an ugly multiliner. >>> zip((1,2),(3,4),(5,6)) [(1, 3, 5), (2, 4, 6)] Best regards! -- Gustavo Niemeyer [ 2AAC 7928 0FBF 0299 5EB5 60E2 2253 B29A 6664 3A0C ] -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 240 bytes Desc: not available URL: From google at thegoldensun.com Mon Nov 19 19:29:24 2001 From: google at thegoldensun.com (HW) Date: 19 Nov 2001 16:29:24 -0800 Subject: MySQLdb undefined symbol References: <62e69c0c.0111180314.37cc1486@posting.google.com> Message-ID: <62e69c0c.0111191629.18eefe32@posting.google.com> Gerhard =?unknown-8bit?Q?H=E4ring?= wrote in message news:... > On Sun, Nov 18, 2001 at 03:14:46AM -0800, HW wrote: > > Hello, > > > > I get the following error when I try to import MySQLdb: > > > > >>> import MySQLdb > > Traceback (most recent call last): > > File "", line 1, in ? > > File "/home/clairvision/local/lib/python2.1/site-packages/MySQLdb/__init__.py", > > line 27, in ? > > import _mysql > > ImportError: /home/clairvision/local/lib/python2.1/site-packages/_mysql.so: > > undefined symbol: mysql_field_count > > >>> > > > > Red Hat 6.2, python 2.1.1, MySQLdb 0.9.1 > > > > Any ideas? > > Maybe your MySQL is too old. The README says you need MySQL >= 3.22.19. But I'd > use the latest 3.23.x anyway. > > Gerhard Thanks for your response. I am using MySQL 3.23.43... Any other ideas? Cheers, Harlan From loewis at informatik.hu-berlin.de Sat Nov 10 08:08:57 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 10 Nov 2001 14:08:57 +0100 Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> Message-ID: "harry" writes: > > {"key1":[1,2,3,4], "key2": "hello", "key3": [1,2,3]} > > > Notice that dict is now a collection of 11 objects: > > - four strings > > - four integers: 1,2,3,4 > > - two lists: [1,2,3,4] and [1,2,3] > > - one dictionary > > > > I would like to know the size of all objects together (the dictionary and > the contents). I am using Python 2.0 on Windows98 SE. > And I don't think I use any C library. (or you're refering to something that > i'm not aware of using) Ok, let's take it step-by-step. In 2.0, a string is defined as typedef struct { int ob_refcnt; struct _typeobject *ob_type; int ob_size; long ob_shash; PyObject *ob_sinterned; char ob_sval[1]; } PyStringObject; Given that int, long, and pointer types are all 4 bytes on your machine, and given that the strings are null-terminated in memory, the string sizes are 25 bytes each. However, you cannot add them together, because you have to account for the malloc overhead. Assuming you use the Microsoft Visual C Runtime (msvcrt.dll), malloc will add 8 bytes and round-up to a paragraph (16 bytes). This will give 48 bytes per string, or 192 bytes for all strings together. Of course, if the strings appear in your source code, these 192 bytes are consumed only once: the dictionary will share them with the source code. Next, let's look at the integers. They are defined as typedef struct { int ob_refcnt; struct _typeobject *ob_type; long ob_ival; } PyIntObject; giving 12 bytes per int object. In 2.0, ints are allocated in blocks of 1000 bytes, to avoid the malloc overhead. So the four ints together consume 49.15 bytes (assuming that the overhead of 24 bytes per integer block is equally distributed over each of the 83 integers). Of course, if these are the *only* integers, they consume 1024 bytes together, since the entire integer block must be accounted (with 79 wasted integers). Next, the two lists: It is defined as typedef struct { struct _gc_head *gc_next; struct _gc_head *gc_prev; int gc_refs; int ob_refcnt; struct _typeobject *ob_type; int ob_size; PyObject **ob_item; } PyListObject; since lists are garbage-collected. Since a list consumes two memory blocks, the list object itself is 28 bytes. Accounting for the malloc overhead on your system, it is 48 bytes. The lists themselves consume as many pointers as they have elements (atleast initially), so the two lists consume 12 and 16 bytes for the elements. Considering the malloc overhead, each consumes 32 bytes. Together, the to lists consume 180 bytes. Finally, the dictionary. It is struct dictobject { struct _gc_head *gc_next; struct _gc_head *gc_prev; int gc_refs; int ob_refcnt; struct _typeobject *ob_type; int ma_fill; int ma_used; int ma_size; int ma_poly; dictentry *ma_table; dictentry *(*ma_lookup)(dictobject *mp, PyObject *key, long hash); }; So the dictionary itself will consume 44 bytes; considering the malloc overhead, that will be 64 bytes. The ma_table consists of structures typedef struct { long me_hash; PyObject *me_key; PyObject *me_value; } dictentry; i.e. 12 bytes per entry. With three keys, the dictionary will have eight entries in 2.0, giving 96 bytes of entries. With malloc overhead, this comes to 112 bytes. Counting this all together, we get 372 bytes without allocation overhead, 597.15 bytes with malloc overhead, and 1572 bytes with both malloc and integer-preallocation overhead; somebody correct me if I'm wrong. Hope this helps, Martin P.S. Of course, assuming that these are the only allocations done, you have to account the overhead of the Microsoft small block allocator; it obtains, via VirtualAlloc, always a page for small blocks. So these objects together consume 4096 bytes, minimum. That is probably the number you get for any other language, as well, since it is the minimum amount of memory that a Windows process can allocate from the operating system. From eyal at hyperroll.com Thu Nov 8 18:46:17 2001 From: eyal at hyperroll.com (Eyal Lotem) Date: Fri, 09 Nov 2001 01:46:17 +0200 Subject: HOWTO execute an external program? References: Message-ID: <3beb1879@news.bezeqint.net> Patrick Guio wrote: > > Dear all, > I would like to use python as a scripting language to run my simulation > code. I would like to know how do I do that ? > Is there a way to evaluate how long it took to run the command (make a > kind of summary/log of the run)? > Sincerely > Patrick RTFM :) Direction: (The OS module, and the profiler) Should be in the standard documentation package, if I recall correctly. From tim.one at home.com Sun Nov 4 22:15:35 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 22:15:35 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: <3BE5FC3F.56BE1589@ix.netcom.com> Message-ID: [Jive Dadson] > I work in robotics. Our robots have several rotary axes, each of which > can turn considerably more than 360 degrees. The positions 5 degrees > and 365 degress are not equivalent, because the arms can contain wires > and tubes that can only be twisted so many times. I am continually > using the following function, often to "mod out" multiples of 360 > degrees. > > // "Floating point modulus" function > inline double fpMod(double x, double modulus) { > return x-floor(x/modulus)*modulus; > } Why do you use that instead of the platform fmod() function? Is it important that the result be non-negative in this application? From jeff at ccvcorp.com Tue Nov 6 20:52:50 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 06 Nov 2001 17:52:50 -0800 Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> Message-ID: <3BE893F2.2EB42B7A@ccvcorp.com> Edy Lie wrote: > Hi Everyone, > > I am totally a new python wannabe coder. I have been switching between > python and perl last few months. In Perl i could code some small scripts > which does the work i wanted to but somehow in my mind it has been telling > me that python is my choice. > > I have some doubts here > 1. I would really want to learn this lang (What should i do?) i know instead > of asking here i should start coding but i have no idea what should i code. > Is there anyone in here willing to conduct a small class or at least giving > out exercise to newbies to code ? > > 2. Another thing when doing coding if i am facing problem i tend to stop or > rather wanted to learn everything in a day or as fast as i could which i > believe is a wrong approach. Is there anyone kind enough to give me some > direction in order i could code something useful. > > Thanks for all the advices. > > Regards, > Edy Lie. Check out the beginners' guide at http://www.python.org/doc/Newbies.html for some links to check out. Also, you may want to subscribe to the Python Tutor mailing list (http://www.python.org/psa/MailingLists.html#tutor)--there's a number of people there who will gladly help you out with any problems you might have. For lots of suggestions, ideas, sample code, etc, you may also want to look at the Useless Python site (http://www.lowerstandard.com/python), which was made specifically for those of us who are not Python wizards. ;) Hope that this gives you a bit more to go on... Jeff Shannon Technician/Programmer Credit International From zayats at blue.seas.upenn.edu Fri Nov 16 16:54:17 2001 From: zayats at blue.seas.upenn.edu (Salim Zayat) Date: 16 Nov 2001 21:54:17 GMT Subject: Unicode and string conversions References: <9t3ijd$1lr$1@netnews.upenn.edu> <3bf558cb$1@brateggebdc5.br-automation.co.at> Message-ID: <9t41u9$7g6$1@netnews.upenn.edu> This makes a little more sense. But what I don't get is when I am only given a string to begin with, what can I do with it? For example, let's say I have a string >>>s = '\u0162' to begin with. If I run the steps illustrated here and in a few other places I have read, : >>>us = unicode(s, 'utf-8') or even >>>us = unicode('\u0162', 'utf-8') I get back : >>>u'\\u0162' Which is unfortunately not the same thing. I read on the website that the \uXXXX tag in a string means a 32-bit hex value. But I thought utf-8 was an 8-bit character set (if I am not mistaken). I am just a whole lot of confused. Thanks. Salim Werner Schiendl (ws-news at gmx.at) wrote: : Hi, : you can convert (encode) an unicode string to an 8 bit encoding (a string) : with the encode() method of the unicode string object. : The reverse is possible with the builtin function unicode() : e. g. : >>> us=u'\u0621\u0622' : >>> s=us.encode('utf-8') : >>> s : '\xd8\xa1\xd8\xa2' : >>> : >>> nus=unicode(s, 'utf-8') : >>> nus : u'\u0621\u0622' : >>> print unicode.__doc__ : unicode(string [, encoding[, errors]]) -> object : Create a new Unicode object from the given encoded string. : encoding defaults to the current default string encoding and : errors, defining the error handling, to 'strict'. : >>> print us.encode.__doc__ : S.encode([encoding[,errors]]) -> string : Return an encoded string version of S. Default encoding is the current : default string encoding. errors may be given to set a different error : handling scheme. Default is 'strict' meaning that encoding errors raise : a ValueError. Other possible values are 'ignore' and 'replace'. : >>> : You need to specify which encoding should be used. : The available encodings reside in the package 'codecs' of the Python : distribution. : hth : Werner From kragen at canonical.org Sun Nov 25 21:27:18 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 21:27:18 -0500 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> Message-ID: <83n11atgft.fsf@panacea.canonical.org> Martin von Loewis writes: > You don't specify what you mean by "accessing", most likely, you will > need a tree representation of the document, i.e. the DOM. The only > reason *not* to use the DOM would be if the document is too large to > fit into memory. Well, there might be other reasons, too. You might want to use less memory or CPU time than a DOM-based application would, for example, for reasons other than the document not fitting into memory. From mgerrans at ix.netcom.com Tue Nov 13 20:25:54 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Tue, 13 Nov 2001 17:25:54 -0800 Subject: IsPython really O-O? References: <9sl891$eik$1@slb7.atl.mindspring.net> <9sqeq6$qu5$1@slb1.atl.mindspring.net> Message-ID: <9ssh61$4m2$1@slb3.atl.mindspring.net> Tim Hammerquist wrote in message > ... > Touch?. This means I won't be garroted for mentioning Perl elsewhere in > this thread? ;) Don't push your luck! ;-/ - mfg From peter at engcorp.com Mon Nov 19 23:11:44 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 19 Nov 2001 23:11:44 -0500 Subject: REQ: PIL web tutorials References: Message-ID: <3BF9D800.E4A88559@engcorp.com> Tech wrote: > > Are there any good, free PIL web tutorials or any other source I can > find info on the lib? Did http://www.google.com/search?q=Python+Imaging+Library+tutorial not produce the results you needed? -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From phr-n2001d at nightsong.com Tue Nov 6 02:28:14 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 23:28:14 -0800 Subject: Teaching python (programming) to children References: <7xsnbs65ke.fsf@ruckus.brouhaha.com> Message-ID: <7x1yjcs6i9.fsf@ruckus.brouhaha.com> Brian Elmegaard writes: > True, and I find your first answer about logo very interesting. I > think ages 9-12, I guess. After they have learned to read and write > their native language, but they don't necessarily have to have learned > a high level of abstract thinking. > > My idea is that programming your own utilities could be taught at > close to the same age as where you begin to learn word processing, > power point,... IIRC, Papert was a student of Piaget, who was one of the big researchers of child development. Papert's goal in teaching Logo to very young kids was to teach the idea of debugging at a very early age--that they should EXPECT things they do to not work the first time, and to learn how to diagnose and repair the problems, and not get discouraged. From andymac at bullseye.apana.org.au Wed Nov 21 04:50:51 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Wed, 21 Nov 2001 20:50:51 +1100 (EDT) Subject: Steering novices in the right direction In-Reply-To: <20011120143303.E1343@phd.pp.ru> Message-ID: On Tue, 20 Nov 2001, Oleg Broytmann wrote: > On Tue, Nov 20, 2001 at 05:24:06AM -0600, Skip Montanaro wrote: > > I've lately been thinking since the correct response to many "where can I > > find ...?" questions is, "have you tried google?" or at least "have you > > searched yet?" that perhaps the footer added to the end of all > > python-list at python.org mailings should include a line like > > > > Ask here first: http://www.python.org/search/ > > > > or > > > > Before asking where something is, check Google: http://www.google.com/ > > > > Even better would be if Mailman could pick a random line out of a file to > > use as the footer. That way you could have all sorts of interesting > > subliminal messages. > > > > Any thoughts on the general idea of embellishing the footer? > > Good idea. Something like this: > > -- > Python mailing list > (Un)Subscribe: http://mail.python.org/mailman/listinfo/python-list > Other mailing list on python.org: http://www.python.org/psa/MailingLists.html > Search: http://www.python.org/search/ It is a good idea. The sad bit is that such a small percentage of those intended to benefit will respond to such education :-( -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From phr-n2001d at nightsong.com Mon Nov 5 03:18:58 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 00:18:58 -0800 Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> Message-ID: <7xitcp8wb1.fsf@ruckus.brouhaha.com> "Edy Lie" writes: > I have some doubts here > 1. I would really want to learn this lang (What should i do?) Read the tutorial in the documentation directory at www.python.org if you want an intro to the language. > i know instead of asking here i should start coding but i have no > idea what should i code. > Is there anyone in here willing to conduct a small class or at least giving > out exercise to newbies to code ? If there are some things you'd code in perl, write them in python instead. If you want to learn programming in general, the best book is Structure and Interpretation of Computer Programs, by Abelson and Sussman: http://mitpress.mit.edu/sicp/sicp.html however, it's kind of idiosyncratic, and its examples and exercises are in a Lisp dialect called Scheme. Nonetheless you'll learn a lot from it, and Python's approach will seem natural to you. You should be able to do a lot of its exercises in Python instead of Scheme. There are some Python books too, but I haven't looked at them yet. > 2. Another thing when doing coding if i am facing problem i tend to stop or > rather wanted to learn everything in a day or as fast as i could which i > believe is a wrong approach. Is there anyone kind enough to give me some > direction in order i could code something useful. There's nothing wrong with wanting to learn fast. From fredrik at pythonware.com Tue Nov 6 15:49:40 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 06 Nov 2001 20:49:40 GMT Subject: " Message-ID: Amit Weisman wrote: > When parsing an HTML page with SGMLParser ' I get an > error when then parser meets a ! tag (' From mjais at web.de Fri Nov 16 10:26:20 2001 From: mjais at web.de (Markus Jais) Date: Fri, 16 Nov 2001 16:26:20 +0100 Subject: Databases References: <200111161329.fAGDTiv17156@smtp.wineasy.se> Message-ID: On Fri, 16 Nov 2001 15:21:04 +0100, Gustavo Campanelli wrote: > This is a really newbie question, I just started with Python 3 days ago, > and I?m finding it quite fascinating. I don?t know how this works for > you, but I usually learn faster when I?m trying programs, and programs > come out easier when I?m actually doing something and not only trying to > test a comand. So I?m trying to access a database from python. Where > should I look for documentation about using python as interface for > MySQL or PostgreSQL? Of course, that is under Linux. > > Gdc > > hi check out the database sig on www.python.org http://www.python.org/sigs/db-sig/ there you will find lots of useful information on databases and python markus From cliechti at gmx.net Mon Nov 26 13:27:25 2001 From: cliechti at gmx.net (Chris Liechti) Date: 26 Nov 2001 19:27:25 +0100 Subject: application scripting References: Message-ID: Keith Ray wrote in news:k1e2i3t4h5r6a7y-CDB5E9.19575425112001 at news1.rdc1.sfba.home.com: > In article , > Chris Liechti wrote: > [...] >> i assume that the python interpreter is embedded and available for the >> user that wants to write scripts (eg a menu entry to start the >> recorded scripts and maybe an interactive console, could be nice for >> testing). > > Would you know of any examples of this on the internet? not for recording, but there is a embedding demo in the source distribution of python. and i have made a windows screensaver that exposes some drawing commands to python, so that the drawing is controlled by a script. (http://www.geocities.com/chrisliechti/en/python/index.html) > [...] >> maybe you want to have a look at some sample COM scripts. the approch >> is slightly diffrent but its the way msword, excel and may other >> windows software is scriptable (ms uses vbscript but there are python >> bindings too (win32com extension modules from active state)) > > Are there examples of COM-scriptable apps that also support recording? MS Word creates VBScript that uses COM when recording. i used it to find out what Python COM commands have to be used. -- Chris From jorgenhansen at hotmail.com Wed Nov 7 06:19:20 2001 From: jorgenhansen at hotmail.com (=?ISO-8859-1?Q?J=F8rgen_Hansen?=) Date: 7 Nov 2001 03:19:20 -0800 Subject: Avoiding resizing of frames in Tkinter Message-ID: <117880a1.0111070319.36e66c94@posting.google.com> Dear all, I am making a nice array editor dialog in Tkinter. I have modified the Dialog class in the tkSimpleDialog module. My question is, how do I avoid that the buttonbox gets resized or more generally how does one avoid a frame getting resized? I can't seem to find it anywhere in "An Introduction to Tkinter" by Fredrik Lundh. thanks Jorgen From fperez528 at yahoo.com Sun Nov 11 17:10:09 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 12 Nov 2001 21:38:09 +2328 Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> Message-ID: <9sq85f$kdd$1@peabody.colorado.edu> > > The preconditions are that arguments m and n are always positive integers. > She amazingly reduced the above code to the following: > > def count_combos_optimised( m, n ): > numer = 1 > denom = 1 > j = m+n-1 > i = 1 > while i numer = numer * j > denom = denom * i > j = j - 1 > i = i + 1 > return numer/denom > Her 'amazing' reduction is possible simply because it's a very well known formula of combinatoric analysis. By the way, you should use long integers so that the factorials don't blow up in your face for large numbers. You got me thinking. Below is a quick and dirty implementation of the same using Numerical Pyhton and some routines adapted from Numerical Recipes in C (which means they're not the most optimized in the world by any stretch of the imagination). I also added a copy of yours fixed to use longs: #--------------------------------- begin file """Quick and dirty factorials and combinatorics. Some stuff copied from NumRecipes.""" # fix to use longs instead of ints def count_combos_optimised( m, n ): numer = 1L denom = 1L j = m+n-1L i = 1L while i time_test (reps,combi_dist ,m,n) Out[65]= 0.069999999999993179 In[66]:= time_test reps,count_combos_optimised ,m,n -------> time_test (reps,count_combos_optimised ,m,n) Out[66]= 17.5 And for small m: In[67]:= m=30 In[68]:= time_test reps,combi_dist ,m,n -------> time_test (reps,combi_dist ,m,n) Out[68]= 0.07000000000000739 In[69]:= time_test reps,count_combos_optimised ,m,n -------> time_test (reps,count_combos_optimised ,m,n) Out[69]= 0.030000000000001137 So, study your problem domain and decide whether you'll need small or large m. If you'll need both and really need speed, blend the two implementations into one with a branch cutoff (you'll have to play a bit to determine the threshold). One advantage of your colleague's version: b/c it uses longs, it will produce exact results always. Mine is ultimately limited to things that fit into a float, so it will blow up in extreme cases. Hope this helps, F. PS. As for your original question, yes, her solution is correct ;) From phr-n2001d at nightsong.com Sat Nov 17 18:14:41 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 17 Nov 2001 15:14:41 -0800 Subject: Teaching python (programming) to children References: Message-ID: <7xitc9yopq.fsf@ruckus.brouhaha.com> "Arthur Siegel" writes: > The fact is I know little of Piaget's theories. But I do seem to have a > consistent distaste for projects aimed at children with justify themselves > as being based on those theories. I understand what you mean. With me, the fact is I know little about Newton's theories. But I do seem to have a consistent distaste for projects aimed at understanding astronomy which justify themselves as being based on those theories. Knowing tha the earth is flat was good enough for our ancestors and by damn, it's good enough for us. From bill-bell at bill-bell.hamilton.on.ca Mon Nov 12 13:29:06 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 12 Nov 2001 13:29:06 -0500 Subject: Using browser as interface to python app In-Reply-To: <1005502589.987.16793.m12@yahoogroups.com> Message-ID: <3BEFCEA2.8864.50427F@localhost> sandskyfly at hotmail.com (Sandy Norton) > I'm simply trying to use the browser as an interface to a small python > program that retrieves and parses webpages and then publishes the > results in an html page. I would like for example for the user to be > able to configure the app via the browser (by selecting checkboxes and > whatnot) without having to use a command-line menu or a full blown GUI > such as wxPython or Tkinter. Have you considered using Webware (webware.sourceforge.net)? I can't tell you anything about it since I've just started learning about it myself. 400K download. Looks really cool. Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From chrishbarker at home.net Mon Nov 26 16:09:55 2001 From: chrishbarker at home.net (Chris Barker) Date: Mon, 26 Nov 2001 13:09:55 -0800 Subject: IDLE improvement? References: Message-ID: <3C02AFA3.15D439FC@home.net> forgotten gentleman wrote: > - The interactive prompt's memory is cleared and restarted This is very difficult in an IDE that is running in the same interpreter as the code. There is no easy way to "clear and restart" the interactive prompt too bad, it's a feature I'd like to see. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From spendius at MailAndNews.com Sat Nov 17 10:59:06 2001 From: spendius at MailAndNews.com (Spendius) Date: 17 Nov 2001 07:59:06 -0800 Subject: Question to those who know both Java & Python pretty well... Message-ID: <2a6e94ef.0111170759.5fe7027a@posting.google.com> Hi, I'll be quick here: could those amongst you people who know Java AND Python rather well (for having worked using both languages for several months) tell me in which measure these 2 languages differ ? I don't know Python AT ALL, and am a beginner in Java, but I happened to fall on articles and/or web pages that made me considering starting working with Python. Does this language have some specific purposes (like file processing, web etc.) ? Are its graphical capabilities as rich and various as Java's ? What are the advantages and defaults of them ? I'm expecting serious answers, please... Thanks a lot ! Spendius From amyk at foretec.com Mon Nov 12 16:58:28 2001 From: amyk at foretec.com (Amy Katherine) Date: Mon, 12 Nov 2001 16:58:28 -0500 Subject: Python 10 Registration Opens Online Today Message-ID: <5.1.0.14.2.20011112165051.00ac8030@colossus.foretec.com> An HTML attachment was scrubbed... URL: From olli at secnetix.de Tue Nov 13 11:58:06 2001 From: olli at secnetix.de (Oliver Fromme) Date: Tue, 13 Nov 2001 16:58:06 +0000 (UTC) Subject: bool() or similar Message-ID: <9srjeu$ijn$1@isp-m-srv06.izb.net> Hi, I'm still in the process of learning, but I think I have a reasonable overview over the language, built-in functions and libraries. However, I wonder if there is a good way to convert some- thing to a boolean value (0 or 1), given any type of object? Such as a bool() function, which works in the same way as int() or str(). I.e. it would return 0 when given either 0, "", an empty sequence or an empty mapping, and 1 other- wise. The closest thing I could come up with with was: >>> def bool(x): return not not x or >>> def bool(x): return x and 1 or 0 But both of them don't seem to be particularly elegant or clean. Is there something I'm missing? Regards Oliver Fromme -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From ykingma at accessforall.nl Mon Nov 19 14:39:59 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Mon, 19 Nov 2001 20:39:59 +0100 Subject: [IO] Communication between Java and Python References: <3BF91867.3BBDD486@hik.fzk.de> Message-ID: <3BF96008.1E014A97@accessforall.nl> "Christof Hurst (FZK)" wrote: > > i want to send data between a Java-Applet and a python servlet. > how do i get a Connection and how do i send values? > is there a possibility to send binary streams or integer-values? > i want to send in both ways. Use sockets. See the socket howto for the python side: http://py-howto.sourceforge.net/sockets/sockets.html For java use the docs of java.net.socket. Basically your servlet will listen for connections requested from the applet. On this connection you can do a two way communication. You could use netstrings as messages on this connection. Good luck, Ype -- email at xs4all.nl From tim at zope.com Wed Nov 14 13:31:23 2001 From: tim at zope.com (Tim Peters) Date: Wed, 14 Nov 2001 13:31:23 -0500 Subject: Infinite lists and generators In-Reply-To: <5.1.0.14.0.20011114121906.00a695a0@mail.mac.com> Message-ID: [Luigi Ballabio] > ... > My question is: how does one go about pulling such stunts with > generators instead? There are many examples in Lib/test/test_generators.py (from the 2.2b1 release, or browse Python CVS on SourceForge). From hungjunglu at yahoo.com Mon Nov 5 11:32:19 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 5 Nov 2001 08:32:19 -0800 Subject: Teaching python (programming) to children References: Message-ID: <8ef9bea6.0111050832.4474d66a@posting.google.com> Nomad wrote in message news:... > IMHO, python would be one of (if not _the_) best language to teach > beginning programming - not just children, but as you mention, there > is the difficulty with the "englishness" of the language (or almost > any other programming language). I have my doubts about Python being the first programming language to teach. I see all too many newbies running into the problem of namespaces. How do you explain to them that "from xyz import *" is a bad thing, if they don't even understand what's going on behind the scene? Also, how in the world can beginners understand what a hash table mean? Are we going to tell them something like: "oh well, think of Python dictionary as a magic black box, you'll understand it later when you take a course in C/C++"? Python seems very friendly, at first sight. But unless you really understand the dictionary and namespace (and name binding) mechanisms behind it, you'll run into surprises in no time. And at that moment, there is simply no way that it could be explained in easy terms to beginners, when they don't understand things like pointers, references, memory stack and heap, hash tables. I do believe Python should be part of a programmer's school curriculum, but I really doubt it can be a good first language to learn, unless some technicality questions are addressed properly. Or is there a good way of teaching to make it less traumatic for beginners to grasp the concepts of dictionary, name spaces, assignment by reference? It is just really really annoying that every single newbie has to be explained on these issues, and many of them end up without understanding it. I can't imagine teachers having a good time at these issues. I mean, it's OK to make students understand these Python issues, but the time required is not negligible, and the knowledge gained is limited in scope: these peculiarities are very Python specific. And it's doubly frustrating when after spending all the time, the students end up without understanding it. What can you do? It's not the fault of the average students or the average teachers, when the language itself has a non-trivial component that's hard to explain/understand. Hung Jung From lac at strakt.com Fri Nov 9 13:16:48 2001 From: lac at strakt.com (Laura Creighton) Date: Fri, 09 Nov 2001 19:16:48 +0100 Subject: Tkinter scrollbar question In-Reply-To: Your message of "Fri, 09 Nov 2001 17:08:45 +0100." <200111091608.fA9G8ju3009597@ratthing-b246.strakt.com> References: <200111091608.fA9G8ju3009597@ratthing-b246.strakt.com> Message-ID: <200111091816.fA9IGmua009880@ratthing-b246.strakt.com> I now understand more about my scrollbar problem. I said, fine, you got 4 arguments, tell me what they were: def yview(self, x, y, z): print x, y, z And I got this from python: scroll -1 units scroll 1 units Okay. I now have what I want, it's just the second parameter. But then I click on and try to drag the slider part: Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", line 1289, in __call__ return apply(self.func, args) TypeError: yview() takes exactly 4 arguments (3 given) Exception in Tkinter callback Traceback (most recent call last): File "/usr/local/lib/python2.1/lib-tk/Tkinter.py", line 1289, in __call__ return apply(self.func, args) TypeError: yview() takes exactly 4 arguments (3 given) What did you get passed _this_ _time_ oh wretched function? moveto 0.331164133333 moveto 0.328994943333 moveto 0.326825743333 moveto 0.324656543333 ------------------------- Depending on what I did to cause it to be called, I am going to get called with a varying number of very different arguments. Which Fredrik Lundh _did_ tell me, but I didn't understand until I had made the function tell me what was going on. What puzzles me now is why def yview(self, delta): # this works until you do a yscrollbar.set if int(delta) == 1: self.move_everybody_up() if int(delta) == -1: self.move_everybody_down() ever worked at all. Laura From nico.hartmann at daimlerchrysler.com Wed Nov 28 04:48:54 2001 From: nico.hartmann at daimlerchrysler.com (Nico Hartmann) Date: Wed, 28 Nov 2001 10:48:54 +0100 Subject: decoding floats Message-ID: <9u2buq$jo9$1@news.sns-felb.debis.de> Hi there, I look for a way to decode and encode float values into byte arrays. Thanks in advanve, nico From gyekye_7 at yahoo.com Wed Nov 7 05:03:56 2001 From: gyekye_7 at yahoo.com (Kojo Duncan) Date: Wed, 07 Nov 2001 10:03:56 GMT Subject: Help Help Help References: <3be77f95@152.65.161.36> <7x3d3s8jo3.fsf@ruckus.brouhaha.com> Message-ID: <3be90709@152.65.161.36> Okay Paul "Paul Rubin" wrote in message news:7x3d3s8jo3.fsf at ruckus.brouhaha.com... > "Kojo Duncan" writes: > > Write a program that lists all prime numbers less than a prime number a user > > inputs. Post on site for all to see. > > Do your own homework ;-) From jeff at ccvcorp.com Fri Nov 16 12:54:34 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 16 Nov 2001 09:54:34 -0800 Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> <3BF4288A.FC68121F@alcyone.com> Message-ID: <3BF552DA.F9654298@ccvcorp.com> Duncan Booth wrote: > Erik Max Francis wrote in > news:3BF4288A.FC68121F at alcyone.com: > > > Yes. Python has lambda functions for this, although there are some > > restrictions: lambda functions have to take at least one argument > > (otherwise what's the point), and they can only evaluate to expressions, > > rather than whole statements. > > Your second point is correct, but the first one is wrong. You can have a > lambda with no arguments if you wish. The point is the same as any function > with no arguments, if it calls other functions which use globals (or nested > scope variables) or have side effects, then the lamda doesn't access the > globals or produce the side effects until it is invoked. > e.g. > f = open('somefile') > readchop = lambda: f.readline()[:-1] > for i in range(10): print readchop() > > is a not terribly good example. Neither does simply putting the code inline, it seems to me. I realize that this is an extremely simplified example, but I don't see this as being at all preferable to simply using f = open('somefile') for i in range(10): print f.readline()[:-1] This has exactly the same semantics, and unless I'm mistaken, it's impossible for an argument-less lambda to have different semantics than straight substitution, at least in these days of nested scopes (which your example requires). Of course, I've always thought of lambdas as being confusing and less clear than simply defining a (possibly nested) function anyhow, and never understood how being nameless gave it an advantage. Jeff Shannon Technician/Programmer Credit International From chowells at cs.uoregon.edu Wed Nov 21 04:47:36 2001 From: chowells at cs.uoregon.edu (Carl Howells) Date: Wed, 21 Nov 2001 01:47:36 -0800 Subject: how to express the following regular expression? References: Message-ID: <9tft7a$30$1@helix.cs.uoregon.edu> "Stephen" wrote... > I want to search the following formats: > > ([1234567890]*)R > or > P([1234567890]*) > > this means there must be a 'P' before the number or a 'R' after the > number. However, I think I can't use this: > P?([1234567890]*)R? > because the number without P and R is also matched! > > How can I express it? Exactly you you'd expect... One or the other: (P\d*)|(\d*R) You could also use [0-9] in place of \d, if you were really set on using the [] notation. But there's no reason to use [1234567890]. From Michael.L.Schneider at eds.com Tue Nov 27 13:29:10 2001 From: Michael.L.Schneider at eds.com (Michael Schneider) Date: Tue, 27 Nov 2001 13:29:10 -0500 Subject: [help] Driving Visual Studio From Python References: <3C0332D0.8C7BC844@eds.com> Message-ID: <3C03DB76.CBA42A25@eds.com> I have received several requests for more information on what I am trying to do. Here is some info that may help problem: We have a very large CAD/CAM software product ( > 10 Mil lines of code) effect: It is not effective to build a big workspace that contains projects with all of the source necessary to build the entire product Given: All source is managed in clearcase, so you can freeze the code on a base line Given: Full Builds of the product are avail for different baselines Given: database that maps include files to all source files that include them Visual Studio Limitation: A Visual Studio project seems to be able to effectively manage ~2500 files, This requires us to break up our file set over several projects Proposed working model (working sets of files) : Developer has a working set of files that add functionality to the product, or fix a defect. This working set of files can contain: UI files, source files, header files Desired behavior of Python Addin 1) ask clearcase for list of working files (can be done by exec'ing cleartool common) 2) Ask user for baseline environment 3) copy all libraries from nightly build to local workspace area 4) create a Visual Studio Workspace 5) create a Visual Studio Project that contains all of the working set files Note: We now have a workspace, a project with the working set of files. We do not yet have projects to let Visual studio compile the source files that are impacted by the header files in the working set. Example. Point.h contains a class with two data members x, and y. We need to add z to the header file, this will require a recompile of all source files that include point.h 6) For each header file in the working set - query the include->source database to get a list of source files that are dependent on the header file - add these source files to a file list - create a Visual studio project for each library that contains a dependent source file - add the dependent source files for this library to the project 7) create a project to link the exe that is dependent on the working set project and all dependent projects What you have: - Project that contains the working set of files - A dependent project for each library that contains a source file that is dependent on header files in the working set (this allows you to change a header file, and the system will update all source files that include the header file) - workspace that contains a project to link the exe, this project is dependent on working set and all dependent projects - (Optional) a quick-build project that links the exe, but is only dependent on the working set. This allows for a quicker build time for the cycles that you are only modifying source files I have serveral suggestions that I am going to look at this afternoon, any suggestions, or modifications to approach are welcome. I will post what I come up with. Thanks again, Mike Michael Schneider wrote: > Hello All, > > I am an old unix developer finally moving to Windows Visual C++. I have > been using python on Unix since 96, > and have been really happy with python as a scripting/tools language. > > I need to drive visual studio to create projects, add configurations, > and add files to projects. > > The COM extensions make it look like it is possible to do this, but I > am having trouble getting > it going. > > I have ran makepy and added the visual studio type libs. > > I copied the following code from a post > > ----------------------------------------- > import win32com.client > app = win32com.client.Dispatch( 'MSDev.Application') > > wnd = app.ActiveWindow > if wnd.Type == 'Text': > print wnd.Selection > app = None > ------------------------------------------ > > This prints on the selected test. > > I can't seem to get the syntax to obtain and print out project > properties, or to add a project > > Could someone help my out by giving me the python code to try to get > this to go, I am missing something > very basic here. > > Thanks > Mike > > PS. I added the MSDEV links to the visual studio docs > ++++++++++++++++++ > DeveStudio Link to add project > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/vcrefaddprojectmethod.asp > > Link to Visual Studio Application Object > > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_application_object.asp -------------- next part -------------- A non-text attachment was scrubbed... Name: Michael.L.Schneider.vcf Type: text/x-vcard Size: 184 bytes Desc: Card for Michael Schneider URL: From p.vrijlandt at aig.azn.nl Wed Nov 21 06:53:33 2001 From: p.vrijlandt at aig.azn.nl (Patrick Vrijlandt) Date: Wed, 21 Nov 2001 12:53:33 +0100 Subject: DDE Client? References: <9tg4bp$k4k$1@odysseus.uci.kun.nl> Message-ID: <9tg4jt$k6b$1@odysseus.uci.kun.nl> "Patrick Vrijlandt" schreef in bericht news:9tg4bp$k4k$1 at odysseus.uci.kun.nl... > This is all magic: > > import dde > server = dde.CreateServer() > server.Create('') > conversation = dde.CreateConversation(self.server) # correction: conversation = dde.CreateConversation(server) # I have them in a class > conversation.ConnectTo(application, service) > > I'm afraid python dde leaks memory, but I haven't checked the source and > have no confirmation from the author. If your application crashes after a > few thousand dde-calls, think of this. > > -- > Patrick > "David Brady" schreef in bericht > news:mailman.1006302086.2966.python-list at python.org... > > Hi all, > > > > Recently I asked how Python could be used to perform > > DDE, and the answer I got was something like "check > > out win32all", which I have done. I am now at wit's > > end. > > > > I have an application running that has a DDE server in > > it. I know the name of server, the topic, and the > > item I want to retrieve from it. I imagine from > > reading ActiveState's documentation that if I have a > > PyDDEConv object handy, I can call its > > Connect(server,topic) method to get the topic, from > > which I can get an item, from which I can make > > requests. > > > > So, the question of the hour is, how in the heck do I > > get a PyDDEConv object in the first place? > > > > Thanks, > > > > -dB > > > > ===== > > David Brady > > daves_spam_dodging_account at yahoo.com > > I'm feeling very surreal today... or *AM* I? > > > > __________________________________________________ > > Do You Yahoo!? > > Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. > > http://geocities.yahoo.com/ps/info1 > > > > From tjreedy at home.com Sun Nov 11 10:32:24 2001 From: tjreedy at home.com (Terry Reedy) Date: Sun, 11 Nov 2001 15:32:24 GMT Subject: mapping a statement over all list items References: <3BEE4077.8070407@hotmail.com> Message-ID: "Kevin Christie" wrote in message news:3BEE4077.8070407 at hotmail.com... > Hello all! > > I have list Foo, of strings. Each string has a special character '-' > within the string. What I want is for Python to split each string list > item by '-' and assign the resulting lists to the original list item. > Basically, I want to apply: If you are satisfied with a *new* list with corresponding split-up items, then the map or comprehension idioms work great. If you literally mean 'assign the resulting lists to the original list item', then you need a for loop with explicit indexes. >>> import string >>> sl = ['abc-xyz', 'black-blue', '123-987'] >>> for i in range(len(sl)): sl[i] = string.split(sl[i], '-') ... >>> sl [['abc', 'xyz'], ['black', 'blue'], ['123', '987']] From phd at phd.pp.ru Thu Nov 29 04:02:21 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 12:02:21 +0300 Subject: How can i get values from a init - file In-Reply-To: <3c0602a8.2703951@news.tuwien.ac.at>; from u9825527@minteka.dbai.tuwien.ac.at on Thu, Nov 29, 2001 at 09:52:03AM +0000 References: <3c0602a8.2703951@news.tuwien.ac.at> Message-ID: <20011129120221.F16265@phd.pp.ru> On Thu, Nov 29, 2001 at 09:52:03AM +0000, martin z wrote: > I want to make a init - file, where i can set value for variables in > my programm. http://www.python.org/doc/current/lib/module-ConfigParser.html Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From andre.risnes at tenpipes.no Wed Nov 7 04:37:11 2001 From: andre.risnes at tenpipes.no (André Risnes) Date: Wed, 7 Nov 2001 10:37:11 +0100 Subject: VisualPython problem Message-ID: <9saven$r1l$1@lise.netcom.no> Hi. I've installled VisualPython 1.1 on a W2K machine with ActivePython 2.1.1, build 212 (in C:\Python21) and Visual Studio .NET Beta 2. When i try to run the sample project i get a messagebox with the title "ActiveState Visual Perl" and the message "Not ready to run or debug the project". Also, the message "The startup script cannot be found" appears in the Output pane. Any ideas? (I could not find anything like this on google or ActiveStates mailing lists, so i suppose it is not a common error). -- Regards Andr? Risnes From logiplexsoftware at earthlink.net Wed Nov 14 19:37:57 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 14 Nov 2001 16:37:57 -0800 Subject: How to marshal a function? In-Reply-To: References: <01111413063906.04702@logiplex1.logiplex.net> Message-ID: <0111141637570D.04702@logiplex1.logiplex.net> On Wednesday 14 November 2001 15:10, Fran?ois Pinard wrote: > [Cliff Wells] > > > The mechanism you are using (remote execution of python code) introduces > > a big security hole (in your current setup this may not be much of an > > issue for you, but think of the children!). > > Why do you say that? I remotely start the Python server using a shell, > and doing things through that server, rather than using the shell without > the server, is about the same to me, permission-wise. As we do not gain > nor loose any permission, I do not see how we introduce a security hole. > Besides, I feel a bit safe as I channel these Python services through > `ssh', which provides enough user authentication for us, so I presume. Well, that's a different story altogether =) If you weren't using ssh, it would be a huge security hole. > If merely using a shell is a big security hole, I'd rather unplug the > machine from the power outlet! Some practical considerations apply, here! > :-) It wasn't the shell, it was your server that I was questioning. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From daniel.dittmar at sap.com Mon Nov 26 04:41:15 2001 From: daniel.dittmar at sap.com (Daniel Dittmar) Date: Mon, 26 Nov 2001 10:41:15 +0100 Subject: Return value for popen? References: <3c01e2bc$0$13482$afc38c87@news.optusnet.com.au> Message-ID: <9tt2nr$jku$1@news1.wdf.sap-ag.de> > Is it possible to get a process' return (errorlevel) value from popen, as it > is with os.system()? >From the 2.1 documentation of popen (): The exit status of the command (encoded in the format specified for wait()) is available as the return value of the close() method of the file object, except that when the exit status is zero (termination without errors), None is returned. Daniel From tim at zope.com Wed Nov 28 17:51:25 2001 From: tim at zope.com (Tim Peters) Date: Wed, 28 Nov 2001 17:51:25 -0500 Subject: Non-Indented python In-Reply-To: <3C0562F4.7EE7D682@home.net> Message-ID: [Chris Barker] > After reading a whole lot of sometimes ugly bickering, it seems to me > that most of us Python users do agree on one thing: > > Mixing tabs and spaces is a BAD idea. Yup. > If it is true that there is general consensus about this, is there any > movement to disallow it altogether in the Python interpreter? Nope. The "nanny" in "tabnanny" is there for a reason: grownups have no problems here. > Personally, I would prefer that future versions of Python would allow > ONLY tabs or ONLY spaces, but clearly there would be a major > disagreement about which to use. It would be spaces -- "4-space indents, no hard tab characters anywhere" is the coding standard for the Python library. Tools/scripts/reindent.py is routinely run over the Lib directory to ensure it stays that way, too. there-hasn't-been-anything-real-to-argue-about-here-since- 1993-ly y'rs - tim From p.vrijlandt at aig.azn.nl Mon Nov 19 08:09:37 2001 From: p.vrijlandt at aig.azn.nl (Patrick Vrijlandt) Date: Mon, 19 Nov 2001 14:09:37 +0100 Subject: Python kernel32 exception on Win9x while using DDE extensions References: <9s85bf$5qd$1@odysseus.uci.kun.nl> Message-ID: <9tb0aj$lau$1@odysseus.uci.kun.nl> When I asked this question before, MH answered that the dos-window (command-line) has no concept of messages like a normal windows app; so you can't use dde from a dos-window. "Nic" schreef in bericht news:b2b5c45f.0111122345.3f5ed40d at posting.google.com... > "Patrick Vrijlandt" wrote in message news:<9s85bf$5qd$1 at odysseus.uci.kun.nl>... > > > I am running on Win98 SE with the latest DCOM installed. > > > When I try to run the following script fragment from python.exe or > > > pythonw.exe I get a “page fault exception” in > > > kernel32.dll > > > > > > import win32ui > > > import dde > > > import sys > > > > > > def send_string(str): > > > # ….. > > > pass > > > > > > print "Starting DDE v1.02" > > > cESC = chr(27) > > > cF11 = cESC + '[23~' > > > > > > server = dde.CreateServer() > > > > > > # The problem is in the following line > > > server.Create("ERTestClient") > > > > should be: > > server.Create('') > > > > > conv = dde.CreateConversation(server) > > > > then: > > conv.ConnectTo("ERTestClient", service) # service might be "System" > > > > > > > > while 1: > > > str = raw_input("Enter String: ") > > > if str == "EXIT": break > > > str_all = cF11 + str > > > ## send_string(str_all) > > > > > > print "DONE" > > > > > > > > > > > > Thanks > > > Nic > > > > I'm afraid dde leaks memory, but Mark H hasn't confirmed this yet. Think of > > this if your app fails after a few thousand dde calls. > > Thanks for your help. > > I tried the corrections you suggested but I still get an exception > while running the script from python.exe from the command line. > > The same script works fine inside the pythonwin environment. > > The problem only occurred on Win9X, on NT and 2000 it works OK. > > Do anybody know if this a general problem with the windows extensions > or only with the DDE? > > Thanks > > Nic. From Kevin.Smith at themorgue.org Wed Nov 7 21:20:58 2001 From: Kevin.Smith at themorgue.org (Kevin Smith) Date: Thu, 08 Nov 2001 02:20:58 GMT Subject: [ANN] pyLaTeX -LaTeX to HTML, XML, etc. Conversion Framework References: Message-ID: <4RlG7.28298$jP3.1007562@e3500-atl1.usenetserver.com> I'm glad you asked that. :) As a matter of fact, I have the pythondoc macros partially implemented and they are bundled along with the other renderers. They still need some work (this is an alpha release after all). But since the python documentation doesn't use equations or graphical environments the fact that that functionality hasn't been implemented yet isn't a problem. In article , Anthony Baxter wrote: > >So, can it replace the latex2html generated python docs? That would be >the acid test... (and would probably make Fred happy, too...) > >Anthony > >>>> Kevin Smith wrote >> pyLaTeX 1.0 alpha-1.1 >> -------------------------------- >> >> pyLaTeX is a LaTeX document processing framework written entirely in Python. >> It comes bundled with HTML and generic XML renderers, and other renderers can > >> be added as well. >> >> pyLaTeX differs from other tools like LaTeX2HTML, TeX4ht, TtH, etc. in that >> the parsing and rendering of the document are completely separated. This >> separation makes it possible to render the document in multiple output >> formats. It also allows the parser to create a cleaner document object, so >> that the rendering process is easier. >> >> This is the first public release of pyLaTeX and is not yet feature complete. > >> Most notably, there is no functionality for generating images from graphical >> LaTeX environments and equations. >> >> Full documentation and downloads are available at >> http://pylatex.sourceforge.net/. >> >> Kevin Smith >> >> -- >> http://mail.python.org/mailman/listinfo/python-list >> > From terekhov at emc.com Mon Nov 26 17:41:13 2001 From: terekhov at emc.com (Mikhail Terekhov) Date: Mon, 26 Nov 2001 17:41:13 -0500 Subject: postgresql triggers to update GUI? References: <20011126.145234.816620091.2222@localhost.localdomain> Message-ID: <3C02C509.1020608@emc.com> Look for LISTEN/NOTIFY in the Postgres documentation. You need: 1. Create trigger on the tables in question which sends a notify 2. In your application use LISTEN after connecting to the database and then periodically check for notify. Regards Mikhail Robert Nikander wrote: > Hi, > > I am writing a python program that uses a postgresql db backend. I would > like to update the gui whenever a change in certain tables occurs, so it > would be nice to use triggers rather than generating the 'events' when I > update the db. That way I get cascading changes. Does anyone know of a > python module that supports postresql triggers? ie: you can create a > trigger that calls a python function? Is there another solution here > that I am missing? > > Thanks, > Rob > From bt98 at doc.ic.ac.uk Tue Nov 20 13:36:32 2001 From: bt98 at doc.ic.ac.uk (Benjamin Tai) Date: Tue, 20 Nov 2001 18:36:32 +0000 Subject: function return -> input parameter References: <3BF97A1D.C1A165A8@doc.ic.ac.uk> Message-ID: <3BFAA2B0.1C2A8F20@doc.ic.ac.uk> Hi, Sorry for the confusion. I will try to explain it a bit clearer. I am trying to extend the following program, written in C, into Python. Alphabet A, B, C, D; //passing an Alphabet type to the 2nd argument setNext( A, B ); //calling a function, returning Alphabet type to the 2nd argument setNext( A, getPrev(C) ); //doing a recursive function call, returning Alphabet type to the 2nd argument setNext( A, getPrev(getPrev(D)) ); The mian problem is: 1) How can I extend the above C function into Python using Python/C API? These three function calls will achieve the same result, but the control flow behind the Python/C API is very different. Any help or comment would be appreciated Ben From sholden at holdenweb.com Wed Nov 21 10:20:54 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 21 Nov 2001 10:20:54 -0500 Subject: printing without spaces References: <20011119220852.89545.qmail@web21101.mail.yahoo.com> Message-ID: "Lee Harr" wrote in message news:tvlpi01kq1mdb7 at corp.supernews.com... > >> >>> for i in range(3): > >> > >> for j in range(10): > >> print "%d%d" % (i,j), > >> print > >> > >> > >> 00 01 02 03 04 05 06 07 08 09 > >> 10 11 12 13 14 15 16 17 18 19 > >> 20 21 22 23 24 25 26 27 28 29 > >> > > o = '' > for i in range(3): > for j in range(10): > o += "%s%s" % (i,j) > print o > o = '' More simply: for i in range(3): o = '' for j in range(10): o += "%s%s" % (i,j) print o Did somebody already suggest the following? "\n".join(["".join(["%s%s" % (i,j) for j in range(10)]) for i in range(2)]) regards Steve -- http://www.holdenweb.com/ From wtanksle at dolphin.openprojects.net Tue Nov 6 20:14:10 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Wed, 07 Nov 2001 01:14:10 GMT Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> <3BE534B7.F0F56060@chello.nl> <3BE5F306.446480AD@ix.netcom.com> <3BE6D9CD.1D6CF0E1@home.net> <3BE70BB6.A2D0FCEC@ix.netcom.com> <3BE7269A.692326EF@chello.nl> <3BE734BB.51C4488D@ix.netcom.com> Message-ID: On 06 Nov 2001 00:54:55 GMT, Jive Dadson wrote: >Roeland Rengelink wrote: >I'm dumping the rest of your message unread. >Bye now. That's often a good idea, but in this case the rest of his message addresses your proposal very well. I highly recommend that you read it. >Jive -- -William "Billy" Tanksley From simon at callan.demon.co.uk Sun Nov 4 04:24:16 2001 From: simon at callan.demon.co.uk (Simon Callan) Date: Sun, 04 Nov 2001 09:24:16 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> Message-ID: <570711d44a.simon@satin.callan.demon.co.uk> In message <9s2hl0$u6o$1 at bugstomper.ihug.com.au> "Gary Stephenson" wrote: > > Gidday all! > > > You're missing one important link that is well represented in the > > python-list archives: The Goon Show -- with Spike Milligan and > > Peter Sellars. The Goon Show was a BBC radio show that was the > > inspiration for Monty Python. > > > > Spike Milligan beat out John Cleese for 1st place in the BBC's > > millenium poll of the top 10 funniest people: > > > > The patriot (scoundrel??) in me wishes to point out that Spike was / > is an Australian - though I imagine many Brits would be somewhat > upset to learn this . > > He was also I believe the author of the immortal limerick: > > "There was a young man from Wooloomooloo (*) > Whose limericks always finished on line two." > > (* - or somewhere ending in "oo" - can't remember now) Which inevitably has the followup rhyme "There was a young man from Verdun". Simon -- http://www.callan.demon.co.uk/simon/ From tanzer at swing.co.at Mon Nov 12 03:37:14 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 12 Nov 2001 09:37:14 +0100 Subject: Is this considered black magic? In-Reply-To: Your message of "Sun, 11 Nov 2001 21:57:07 +0100." <200111112057.fABKv7ua012761@ratthing-b246.strakt.com> Message-ID: Laura Creighton wrote: > Okay, new version: > > def foreach(object_list, method_name, *args): > for object in object_list: > try: > method = getattr(object, method_name) > except AttributeError: > pass > else: > if callable(method): > method(*args) > > Did I miss something? I'd skip the `callable` test. Otherwise you hide cases, where an object has an attribute `method_name` instead of a method -- but then maybe that's intentional. -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From James_Althoff at i2.com Thu Nov 15 13:01:00 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 15 Nov 2001 10:01:00 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: Graham wrote: >If you're going to define a new function, how about > > for i in indices(sequence): This is proposed in PEP 212 "Loop Counter Iteration". Jim From sholden at holdenweb.com Tue Nov 13 16:01:46 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 16:01:46 -0500 Subject: PEP proposal: enhanced string functions References: Message-ID: "Stephen Ferg" wrote ... > I have been thinking about two proposals for PEPs, and I would like to see what > other folks think of them. They aren't anything major, just small enhancements > that I think would be easy to do and useful. > > -- Steve Ferg (steve at ferg.org) > The changes you propose seem unexceptional and useful, albeit only occasionally. regards Steve -- http://www.holdenweb.com/ From ws-news at gmx.at Fri Nov 23 17:24:49 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 23 Nov 2001 23:24:49 +0100 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> Message-ID: <3bfecd77@brateggebdc5.br-automation.co.at> Hi, "Stephen" wrote in message news:97ae44ee.0111231225.22760e5c at posting.google.com... > Does the Python 'rotor' module conform cross-language algorithm > that is also used in the corresponding C & Java libraries ? > If so, where could I find the algorithm ? Sorry, no idea. > Why isn't rotor.py > in the Python lib directory ? > The rotor modul is built into the python library (at least in my ActivePython 2.1.1 distribution) If it is not builtin, it is still a C extension module (rotor.pyd for Windows, probably rotor.so or rotormodule.so on *nix) You find the C sourcecode in the file Modules/rotormodule.c (if you have source code installed, of course). > Also, is it possible for the output of the rotor to ever > include \r, \n or CRLF ? > see 1st remark :-) hth Werner From aeoo at myspamrealbox.com Fri Nov 2 01:07:19 2001 From: aeoo at myspamrealbox.com (Leo Lipelis) Date: Fri, 02 Nov 2001 01:07:19 -0500 Subject: Exception handling wart in Python References: Message-ID: On Thu, 01 Nov 2001 19:27:47 -0500, Chris Liechti wrote: > "Leo Lipelis" wrote in > news:pan.2001.11.01.19.35.44.23.979 at myrealbox.com: > >> Hi Pythoneers, >> >> I'd like some help with an issue I have with Python. Simply put, I >> think having an exception mechanism is a waste if there is no tool that >> will let you know which unhandled exceptions exist at point foo. I >> have spoken about this issue briefly with Neal, of the PyChecker fame, >> and he seemed to agree with me. >> >> I realize that it's a difficult problem to solve, but I think it would >> be worth solving at the language level, similarly to the way it's done >> in Java. > > on the other hand java has "Errors" which are thrown/raised like > exceptions but those are not enumerated in a "throws" statement. you'll > always find cases where you don't know which exceptions could be thrown > in a method (think of dynamicaly created methods, remote objects,...) > and python is a very dynamic language. But it's important and valuable that Java does let you know about *most* of the exceptions you are likely to encounter. This is not an "all or nothing" thing, is it? I hope not. If some tool can give me any help with exceptions, then I will take it; that's my position. It's infinitely better than reading the docs for a list of exceptions "I might want to handle". As I said before, such a mundane and thankless task needs to be handled by a computer program. > > .. >> I think relying on documentation for this is not an option. First, >> there is never a guarantee of documentation, and I would like this >> feature to be guaranteed. Second, it becomes very problematic with >> deeply nested functions and inheritance. Why should I have to search >> through all those docs for something that compiler should tell me >> anyway? This is just the kind of monotonous task that needs to be done >> by a computer program instead of a human. > > most of the arguments for dynamic typing apply to to the exceptions too. > return types are only in the documentation, parameter types too if you > want to be sure you have to consult the docs anyway (and the sources > aswell, as docs aren't allways up to date). if you don't trust python's > dynamic typing stay to a staticaly typed language like java. I don't have a problem with dynamic typing. Types can be inferred anyway. They don't have to be declared. But this is not the point. The issue is that a good tool can warn you about 99% of all exceptions you are likely to encounter. Is such a tool valuable? It is to me. I would use it all the time. Most of the time you are dealing with exceptions that are *not* dynamically declared. Most of the time, you know well ahead of time that so and so code will throw so and so exception. For example, a piece of networking code can throw "ConnectionException" or some such, because it would be very normal to encounter connectivity problems. Should you dynamically create a random exception and throw it just because the language will let you? I think not. You only throw what makes sense, and in most cases, you will know well ahead of time what exceptions you will be throwing. It's a very *rare* case where you really do *not* know what exception you will throw, but even then, you will at least know what class of exceptions they will belong to. > > .. >> I agree with whoever said that a race horse doesn't belong in the glue >> factory. It seems like Python is being used for serious programming, >> and it seems to me, if it supports exceptions, it should support them >> all the way. It's fairly pointless to provide exceptions if you really >> never know whether you handle all the relevant exceptions or not, >> without the ugly, bad, and stupid except: foo() statements to catch >> *all* exceptions. > > nice and useful "except:", especially if you need a program that runs > unatended for months ;-) A program that runs unattended for months is not necessarily a good or useful program ;). 10 goto 10 > > >> Leo "__who_doesnt_like_underscores_and_many_selves_at_all__" Lipelis >> >> P.S.: The double leading underscore is the ugliest thing I've ever >> seen in language syntax. I've been writing some Python code that uses >> that feature, and man, it looks ugly. For a language that prides >> itself on indentation based code blocks for readability, double >> underscore is an ugly wart that needs to be fixed. That, and having to >> constantly type self.__quax, self.__foo, self.__bar(), >> self.__foobar()... That's *SEVEN* whopping useless characters on every >> line. > > "private" is 7 characters per method decalration too in java (and then Bah, you don't type "private" on every line. On the other hand, I have Python methods where I have "self.__" mentioned 2 or 3 times per line. It's ugly. It's breaks the DRY (don't repeat yourself) concept. Besides, let's not compare to another language with even more problems and say, but they are worse, thus we don't need to improve :). Who cares if Java is too verbose? Point is, Python can be made better by getting rid of the "self.__" in front of every object attribute. For instance, why not assume that ALL variables are instance variables, and have the other ones use some special notation? The absolute majority of attributes you will use are instance attributes. Why penalize the common case? That's bad engineering. You should always penalize the fringe case. Doesn't that make sense to you? If you have 2 class attributes and 20 instance attributes, why would you penalize the 20 instead of 2? That's insane. > the return type, parameter types, throws... ";{}" every now and then, no > thanks, i want to write functionality, code that does something and not > zillions of characters just to get the compiler happy) Same here! I think Python is mostly very good about that. But the double underscore is a bad hack. It's not elegant or brief or intuitive. When you actually *use it a lot* it really grows old fast. It seems like a feature invented by someone who never actually uses it much. > > and python has the advantage that i see that a method is private when i > read the call. in java you have to consult the object documentation or > scroll around just to see if a method is private, (or private, publ.. > etc). a win for python In Java you don't even know anything about private methods. You wouldn't even be SEEING the calls in the first place, because in Java the classes are black boxes. The only thing you will see are calls to protected and public methods. And javadoc or even better ctags+vi will tell you *really fast* and *reliably* what you're calling. So even if it's a win for Python, it's a very mild one and not enough of a win to justify the double leading underscore plus "self." on every single variable and function. > > writing "self" explicitly is important for a distiction for object > attributes and global variables. (ever tried to explain "this" (and > "super") and that its optional sometimes to a java beginner?) Ok, this is a good point. But now Python goes much further than just the teaching language it used to be. Python should serve the professionals too. Isn't there a good solution that works well for both? Why make something that *only* works well for newbies, but becomes a heavy burden for pros? From stephen_purcell at yahoo.com Thu Nov 15 06:40:22 2001 From: stephen_purcell at yahoo.com (Steve Purcell) Date: Thu, 15 Nov 2001 12:40:22 +0100 Subject: [ANN] DBDoc 0.6: Oracle/Postgres DB schema documentation generator Message-ID: <20011115124022.A10613@publishers-market.com> NEW RELEASE The new release of DBDoc features Oracle support in addition to the existing PostgreSQL support. DESCRIPTION If you have ever wanted javadoc-style HTML documentation for your database schemas, or a consistent way of programatically inspecting a database schema, then DBDoc may be of interest to you. This small project defines a simple Python API for inspecting database schemas, and uses it to generate documentation (optionally incorporating descriptive text placed in an auxiliary file). (Implementations of the schema introspection API for other databases would be most welcome.) FURTHER INFORMATION Homepage: http://dbdoc.sourceforge.net/ Download: http://sourceforge.net/project/showfiles.php?group_id=34872 Licence: BSD Best wishes to all, -Steve -- Steve Purcell, Pythangelist Get testing at http://pyunit.sourceforge.net/ From gb at cs.unc.edu Thu Nov 8 08:53:09 2001 From: gb at cs.unc.edu (gb at cs.unc.edu) Date: 08 Nov 2001 08:53:09 -0500 Subject: Fatal Python error: ceval: tstate mix-up References: Message-ID: >This is probably going to be a bug in wxPython, but I'm not sure. >Have you got the latest version of such? Yes, I'm running wxpython 2.3.1. I was thinking that I didn't use any wxpython code in the second thread but now I see that I *do* call wxWakeUpIdle to get my GUI idle loop code to process the notification that the send is complete. Maybe wxWakeUpIdle isn't thread safe? I'll have to try using an event like the theaded example does. From missive at frontiernet.net Tue Nov 20 18:24:48 2001 From: missive at frontiernet.net (Lee Harr) Date: Tue, 20 Nov 2001 23:24:48 -0000 Subject: printing without spaces References: <20011119220852.89545.qmail@web21101.mail.yahoo.com> Message-ID: >> >>> for i in range(3): >> >> for j in range(10): >> print "%d%d" % (i,j), >> print >> >> >> 00 01 02 03 04 05 06 07 08 09 >> 10 11 12 13 14 15 16 17 18 19 >> 20 21 22 23 24 25 26 27 28 29 >> o = '' for i in range(3): for j in range(10): o += "%s%s" % (i,j) print o o = '' From gh_pythonlist at gmx.de Fri Nov 2 14:10:16 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 2 Nov 2001 20:10:16 +0100 Subject: SWIG/Python on Windows In-Reply-To: References: Message-ID: <20011102201016.A77948@lilith.hqd-internal> On Fri, Nov 02, 2001 at 11:47:53AM -0800, DD wrote: > Has anybody used SWIG with Python on Windows without Microsoft Visual > C++? I'm having problems getting the hellolib example in the > Extending Python chapter from "Programming Python" to compile with > gcc. I'm getting undefined reference errors to "Py..." functions, ex: > PyString_FromString. > All the examples I can find on the web use MSVC and I can't find an > example for compiling a DLL using a makefile. Madness lies down that path. I'd recommend you enter the beautiful land of Python distutils instead. Building an extension on Windows is relatively painless then. First, you need to create an import library for gcc. Have a look at the HOWTO I posted here in August on how to do this and other useful tips for developing and debugging on Windows with gcc: http://mail.python.org/pipermail/python-list/2001-August/061125.html - write a setup.py for it - "python setup.py build --compiler=mingw32" (or install, or even bdist_wininst) As for the SWIG part of your problem, I'd just create the .c and .h files for setup.py, then use python setup.py to build. I remember having seen SWIG integration with distutils somewhere, but don't remember where. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From Widgeteye at widgets.com Thu Nov 1 22:26:47 2001 From: Widgeteye at widgets.com (Widgeteye) Date: Fri, 02 Nov 2001 03:26:47 -0000 Subject: python binary search References: Message-ID: On Tue, 30 Oct 2001 10:39:04 +1100, Delaney, Timothy wrote: >> The proof reading and the spell checker can both be done. I will use >> them in the future > >Just a note - glad to see you are taking this in the spirit it was intended >:) > >Now, just watch for those tyops ... > >Tim Delaney > Did anyone ever answer this poor guys question? (: -- "You can always make peace with an F-16 in your pocket" -Yitzhak Rabin From James_Althoff at i2.com Wed Nov 14 20:04:19 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 14 Nov 2001 17:04:19 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: Paul Rubin wrote: >Sometimes you want to use the index in the loop. Maybe the loop syntax >should be extended somehow to easily let you do that. PEP 212 "Loop Counter Iteration" suggests such changes. This doesn't address cases where you are dealing with something that doesn't follow the sequence protocol, e.g., DefaultTableModel -- where cells are accessed via the getValueAt(rowIndex,columnIndex) method. Jim From arona2 at em8s.com Tue Nov 13 08:11:21 2001 From: arona2 at em8s.com (Arona Ndiaye) Date: Tue, 13 Nov 2001 14:11:21 +0100 Subject: Using browser as interface to python app References: Message-ID: <00d201c16c44$b026e700$eb368418@a2000.nl> Greetings, You are certainly most welcome. ----- Original Message ----- From: "s a" To: Sent: Tuesday, November 13, 2001 2:07 PM Subject: Re: Using browser as interface to python app > Many thanks for the response. > > Flash + python is a super cool idea, and it's got me intrigued. I'm checking > out MING and the tutorial you included right now... > > cheers, > > Sandy > > >From: "Arona Ndiaye" > >To: "Sandy Norton" > >CC: > >Subject: Re: Using browser as interface to python app > >Date: Mon, 12 Nov 2001 13:48:31 +0100 > > > >Greetings to each and everyone. > > > >What about... > > > >Flash 5 ---> simple GUI > >Xml ---> data format (flash 5's got Xml support) > > > > > >Flash Kit Tutorial - Flash 5 and XML > >http://www.flashkit.com/tutorials/3rd_Party/Flash_5_-Chris_Sm-213/index.sht m > >l > > > >Doing a google search will give you gazillions of links. > > > >Google results for "Flash 5 Xml tutorial" link follows: > >http://www.google.com/search?hl=en&q=flash+5+xml+tutorial > > > >I'm building a virtual online supermarket with Python and Ming (PHP, C++, > >Java, Python ( pick you favorite one hehehe ) to SWF ( Macromedia Flash > >format or whatever it's called format ) on Debian. I like the mix (python + > >xml + flash) so I guess I'm a little bit biased =) > > > >Most kind regards, > > > >PS: too lazy to run a spell checker, too lazy to check ( lack of sleep ), > >so > >sincere apologies to anyone it might disturbs. > > > >----- Original Message ----- > >From: "Sandy Norton" > >Newsgroups: comp.lang.python > >To: > >Sent: Sunday, November 11, 2001 4:28 PM > >Subject: Re: Using browser as interface to python app > > > > > > > wrote in message > >news:... > > > > Have you considered a GUI built with Flash 5.0? It's very nice for > > > > straightforward business apps, and is pretty much agnostic on the > >browser > > > > and screen-resolution front. As long as you're just using > >Windows-type > > > > widgets, etc., there's really no loading time. You'll probably think > >it's > > > > overkill, but it's really no harder than HTML (and a heck of a lot > >simpler > > > > than Tkinter, etc.) You're likely to spend an awful lot of time > >futzing > > > > with HTML and Javascript in order to serve up those web pages... > > > > > > Cool idea.... but I'm clueless as to how this would be done. How would > > > you get the python interpreter to handle data inputed into the flash > > > interface and then pipe the output back to the browser? Do you have > > > examples for doing this? > > > > > > Sandy > > > -- > > > http://mail.python.org/mailman/listinfo/python-list > > > > > > > > > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > > From mail at cliffpruitt.com Sun Nov 4 05:37:26 2001 From: mail at cliffpruitt.com (Cliff Pruitt) Date: Sun, 04 Nov 2001 02:37:26 -0800 Subject: Considering getting into Python... Any Pros-Cons? Message-ID: Hello, I've just started looking into Python and am considering delving into it a bit. My main reason is that it seems to be pretty portable across platforms. I work on a Mac for the most part but I do work on windows machines durring the day and it would be fun (I think) to develop for both. So far I've downloaded the Python files and flipped through a little bit of the documentation but haven't gone into much detail with it. I'm wondering if anyone could sort of give me a good idea of what Python is really capable of and maybe more importantly what it's NOT capable of. The extent of my programming experience involves VBScript for the web. If i had, say, a microsoft access Database, is python capable of displaying records and doing searches on that database? Maybe more importantly is it capable of adding records? Out of curiousity, what are the nicest or most complex applications you've seen done in Python? A lot of what I've read referrs to Python as being useful as "glue" to hol dother languages like C++ and others together. I dont know any of those so I'm wondering if Puthon will really be somethign useful to learn or not. Your insight is greatly appreciated. Thanks. -- C. Pruitt mail at cliffpruitt.com http://www.cliffpruitt.com From lac at strakt.com Thu Nov 1 03:41:27 2001 From: lac at strakt.com (Laura Creighton) Date: Thu, 01 Nov 2001 09:41:27 +0100 Subject: python development practices? In-Reply-To: Message from "Chris Gonnerman" of "Tue, 30 Oct 2001 23:40:49 CST." Message-ID: <200111010841.fA18fR0W005081@ratthing-b246.strakt.com> Be careful with the leading underscore thingie. I have more trouble with python code written by people (who don't work here) who apparantly as a last step turn _every_ attribute in their class into a _variable. I come along and want to subclass them, or make a helper class .... I'm also tired of finding 3 classes which absolutely, positively, _must_ live in the same file; especially since this is so rarely documented. Laura Creighton From schaffer at optonline.net Sun Nov 11 10:56:51 2001 From: schaffer at optonline.net (Les Schaffer) Date: 11 Nov 2001 10:56:51 -0500 Subject: multipack References: Message-ID: <87itch9u7w.fsf@optonline.net> > Does multipack still exist? check out http://scipy.org as far as i can tell, multipack stuff is included in there now. at least the tar package has multipack.h as well as the the quackpak, odepack, etc stuff. les schaffer From shalehperry at home.com Mon Nov 19 17:00:32 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Mon, 19 Nov 2001 14:00:32 -0800 (PST) Subject: Newbie-ish question In-Reply-To: <_ZeK7.505628$ME2.63350791@typhoon.kc.rr.com> Message-ID: On 19-Nov-2001 Patrick Moorman wrote: > I have a directory containing a large number of files in the format xy.txt > where x is a string of numbers and/or letters and y is a sequential number > with either 2 or 3 digits. Example: 1foo23012.txt or foo12305.txt. How > would I go about identifying all of the files in a sequence and moving them > to their own sub-directory. I am slowly picking up on Python, but there is > a long ways to go. Thanks for any help. > unless you can come up with a way to differentiate 1foo23112 -> (1foo23 112) from (1foo231 12) this will be a hard problem. From the examples you gave I could not tell if y was 012 or 12 in the first one and 305 or 05 in the second one. From jdadson at ix.netcom.com Sun Nov 4 21:41:41 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 02:41:41 GMT Subject: Q: Feature Wish: "%" Extension References: Message-ID: <3BE5FC3F.56BE1589@ix.netcom.com> I work in robotics. Our robots have several rotary axes, each of which can turn considerably more than 360 degrees. The positions 5 degrees and 365 degress are not equivalent, because the arms can contain wires and tubes that can only be twisted so many times. I am continually using the following function, often to "mod out" multiples of 360 degrees. // "Floating point modulus" function inline double fpMod(double x, double modulus) { return x-floor(x/modulus)*modulus; } From kragen at pobox.com Wed Nov 28 03:15:17 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 28 Nov 2001 03:15:17 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: <83u1vf48h6.fsf@panacea.canonical.org> Paul Rubin writes: > CVS is a layer over RCS that lets multiple people work on the same > files at the same time, and automatically merges their changes at > check-in. I don't see any point to it for a one person project. RCS > is a lot simpler. I use RCS for one-person projects and couldn't live > without it. But I haven't found a reason to deal with the increased > complexity of CVS. Is there one? * storing your repository on a remote machine * having multiple copies of the same files in different places at the same time (e.g. my laptop, my desktop) * cvs annotate * triggers (e.g. update-on-commit) * cvs -n -q update, which tells you which files are modified and which aren't under version control * CVS GUIs --- e.g. WinCVS Still, I mostly use RCS for things like .bashrc and .xsession. It's less trouble; I don't have to set up a repository and set up update-on-commit. I just ci -l. From maxm at mxm.dk Wed Nov 21 11:09:18 2001 From: maxm at mxm.dk (maxm) Date: Wed, 21 Nov 2001 17:09:18 +0100 Subject: How can I distribute a python program References: <9tgd5i$2fjm5$1@ID-12869.news.dfncis.de> Message-ID: You could probably find something here: http://www.google.com/search?q=standalone+python+distribution Regards Max M "Kick" wrote in message news:9tgd5i$2fjm5$1 at ID-12869.news.dfncis.de... > I write a python that import TK and some other packages. What shall I do if > I want to distribute this program to my friends who hasn't python > environment? > > Thanks for any help! > > Kick > > From gh_pythonlist at gmx.de Fri Nov 30 14:16:24 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 30 Nov 2001 20:16:24 +0100 Subject: Python 2.2: socket.ssl documentation? In-Reply-To: References: <200111291746.fATHkeY24178@lap1.mtg.at> Message-ID: <20011130191622.GA483@lilith.hqd-internal> On Thu, Nov 29, 2001 at 11:09:08PM -0500, Justin Sheehy wrote: > Andreas Kostyrka writes: > > > Is there any documentation about the ssl support in the socket module? > > Yes. > > > If so where? > > http://python.sourceforge.net/devel-docs/lib/module-socket.html > http://python.sourceforge.net/devel-docs/lib/ssl-objects.html > > > Does it support writing servers? > > Sadly, no. But several third-party libraries can be used to write SSL servers in Python. Links and a short overview of them: htt?://www.cs.fhm.e?u/?ifw00065/??ssl/ M2Crypto is around the longest and I works well from what I've heard. The others dumped core when I did something stupid. That's something I don't like when using a Python library, even if it's a C extension. And I really hate it if I'm in an interactive Python interpreter session and playing with things, then *bam* core dumped :-( > As far as I can tell, none of the proposed patches to > provide useful SSL server support to Python have yet been accepted. > > A standard library module capable of being used to build simple > SSL servers would be an excellent addition, if done well. Indeed. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From jbperez808 at yahoo.com Mon Nov 12 19:36:32 2001 From: jbperez808 at yahoo.com (Jonathan P.) Date: 12 Nov 2001 16:36:32 -0800 Subject: Are there any list comparison optimizations in Python? Message-ID: >>> x=[1,2,3] >>> y=x >>> xlist=[x,1,2,3] >>> ylist=[y,1,2,3] >>> xlist==ylist >>> xlist.remove(x) # these 2 statements not executed one after >>> xlist.remove(y) # the other but representing different cases >>> ylist.remove(x) One of Python's most convenient high-level features is automatic list comparison by value and recursively. Does it know to optimize the compare if it has already been determined that two items share a reference to the same object by not doing a value compare on them anymore? And will this apply to both the comparison and remove() calls above? From icbt at hotmail.com Thu Nov 1 08:27:59 2001 From: icbt at hotmail.com (b t) Date: Thu, 01 Nov 2001 13:27:59 +0000 Subject: boost or object twins Message-ID: Hi, Referring to Donn Cave's email: http://mail.python.org/pipermail/python-list/1999-October/013470.html he has described one of the paper: http://www.python.org/workshops/1995-12/papers/ahlstrom1.html I would like to hear any comments, to find out if object twins is a feasible approach to derive C++ class hierarchy into Python. Especially comparison if anyone has experienced both boost and object twins approachs. Thanks in advance. Ben _________________________________________________________________ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp From tjreedy at home.com Fri Nov 2 10:18:49 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 02 Nov 2001 15:18:49 GMT Subject: extending yield's functionality References: <3be2b616@news.bezeqint.net> Message-ID: "Eyal Lotem" wrote in message news:3be2b616 at news.bezeqint.net... > I was excited to find out about the new yield functionality, of generator > functions, that will be formally in 2.3 > > I wanted to ask if its possible to have yield receive some more information > from the caller, between the yield stages. > > An example syntax to implement this could look like: > > >>> def a(): > ... print "Hello" > ... b=yield 1 > ... yield b*2 > ... yield 3 > > >>> gen = a() > >>> gen.next() > 1 > >>> gen.next(3) > 6 > >>> gen.next() > 3 Yield is a statement. You are trying to use it as an expression. Will not work, ever, as Python is currently designed. I believe you are trying to turn yield into a continuation function. I believe you can do what you want with the Stackless version of Python, which has a continuation module. http://stackless.com/research/stackless/ Terry J. Reedy From maxm at normik.dk Fri Nov 9 08:08:38 2001 From: maxm at normik.dk (Max M) Date: Fri, 9 Nov 2001 14:08:38 +0100 Subject: Trouble with cgi.FieldStorage() on iis/asp Message-ID: <3bebd556$0$25387$edfadb0f@dspool01.news.tele.dk> Hi I am using Pyhon in asp. And I am trying to download a file. I parse my form content with the methods in the cgi module. This sort-of works. Actually the code snippet below works fine. It's just that I cannot find the file name of the opladed file with this example. So I trie to use: form = cgi.FieldStorage(fp, pdict) Instead of: form = cgi.parse_multipart(fp, pdict) And then I tried to get at the data with: form['image'].filename and form['image'].file But apparently my form object is not rigth, as it cannot be indexed. so form['image'] fails. I have tried to read the source of the cgi modul, but I don't see why "FieldStorage()" should have other input parameters than "parse_multipart()" to work. Does anybody have a clue? Regards Max M ###################################### ## form.asp ###############################



## formAction.asp ########################## <%@ LANGUAGE="Python"%> <% import cgi from StringIO import StringIO def getQuery(): # Getting the querystring parsed to 'query' dict qs = str(Request.ServerVariables('QUERY_STRING')) query = cgi.parse_qs(qs) return query def getForm(): # Getting the form type & content content_type = str(Request.ServerVariables('CONTENT_TYPE')) binaryContent = Request.BinaryRead(Request.TotalBytes) # Get the header & create the parameterdict to pass to parse_multipart() header = cgi.parse_header(content_type) pdict = header[1] pdict.update({'content-length':binaryContent[1]}) # Parse and get form as dict fp = StringIO(str(binaryContent[0])) form = cgi.parse_multipart(fp, pdict) fp.close() return form form = getForm() Save the image f = open('c:/temp/image.jpg','w+b') f.write(form['image'][0]) f.close() query = getQuery() %> From jm.vic at freesbee.fr Sun Nov 4 02:18:49 2001 From: jm.vic at freesbee.fr (jm) Date: Sun, 04 Nov 2001 02:18:49 -0500 Subject: gtk, clist & python Message-ID: <3BE4EBD9.1719C3D4@freesbee.fr> hello, how can i do the mapping between rows of a "clist" and a python's vector? how can i know the number of rows in a "clist"? thank you. jmv From decks1998 at aol.com Wed Nov 21 20:49:33 2001 From: decks1998 at aol.com (Decks1998) Date: 22 Nov 2001 01:49:33 GMT Subject: Cross platform catalog Message-ID: <20011121204933.09924.00000994@mb-fg.aol.com> I was wondering if python can be used to create a compact disk catalog for images with some interaction capabilities. I'd like for both mac and window users to be able to use the cd without the need to install additional applications or software. I know little about programing but thinking about taking the plung into python if it's a step in the right direction. Any suggestions would greatly be appreciated. Thanks, Steve decks1998 at aol.com From jtlispl at poczta.NOSPAM.onet.pl Thu Nov 29 10:46:46 2001 From: jtlispl at poczta.NOSPAM.onet.pl (Tomasz Lisowski) Date: Thu, 29 Nov 2001 16:46:46 +0100 Subject: Strange Tkinter behaviour References: <9u4kf5$ran$1@news.onet.pl> Message-ID: <9u5l8i$dh9$1@news.onet.pl> Uzytkownik "Laura Creighton" napisal w wiadomosci news:mailman.1007040459.25437.python-list at python.org... > Try calling update_idletasks(). On occasion I have had that work > when update() didn't. > > Laura Creighton Unfortunately, it did not help in my case. The text is displayed in the drawing only after the button is clicked again, even if update_idletasks() is called. I wonder, whether there is a mechanism suspending the Tkinter event loop, so that other event-based applications (not using Tkinter) could get access, and perform their duties. Tomasz Lisowski From m.faassen at vet.uu.nl Thu Nov 1 18:43:14 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Nov 2001 23:43:14 GMT Subject: python development practices? References: Message-ID: <9rsmmi$cvu$1@newshost.accu.uu.nl> Laura Creighton wrote: > Be careful with the leading underscore thingie. I have more trouble > with python code written by people (who don't work here) who apparantly > as a last step turn _every_ attribute in their class into a _variable. > I come along and want to subclass them, or make a helper class .... > I'm also tired of finding 3 classes which absolutely, positively, > _must_ live in the same file; especially since this is so rarely documented. I don't understand the problem; a single leading underscore for attributes won't give you any such problems. Double underscores are different, but even then I don't see why 3 classes should live in the same module? Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From shriek at gmx.co.uk Sat Nov 24 14:08:48 2001 From: shriek at gmx.co.uk (Stephen) Date: 24 Nov 2001 11:08:48 -0800 Subject: Returning HTTP POST body from CGI module Message-ID: <97ae44ee.0111241108.f40c23a@posting.google.com> I have a Python CGI script receiving XML data via HTTP POST from another company. Unfortunately, that company doesn't seem to have implemented the HTTP protocol correctly. ie. they are currently sending HTTP POST requests of the following format : ----------------->8----------------- POST /script.py HTTP/1.1 HOST: www.fubar.com CONTENT-LENGTH: 66 Toyota Red ----------------->8----------------- If I understand correctly, the body of a HTTP POST should be URL-encoded, right ? Since they are sending XML data in the HTTP body, and it is not URL-encoded, it's not really compatible with the CGI module which will be looking for variable/value pairs. Is it possible to access the raw HTTP header and body from the CGI module instead ? Or will I really have to write a socket handler to deal with this ? Stephen. From DSmithSprint05 at earthlink.net Sat Nov 24 00:57:43 2001 From: DSmithSprint05 at earthlink.net (David R. Smith) Date: Sat, 24 Nov 2001 05:57:43 GMT Subject: Tkinter displaying an image in a button References: <3BFC3295.20FC3F02@alex2.labs.agilent.com> <%Y2L7.14855$QC5.2230883@news20.bellglobal.com> <6qvit9.p68.ln@servant.geotek.co.uk> Message-ID: <3BFF36FB.8609B2FD@earthlink.net> OK, that explains it, and the fix works. Thank you, Sebastien and Richard. David Smith From fperez528 at yahoo.com Fri Nov 30 22:00:21 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 02 Dec 2001 02:28:21 +2328 Subject: Whatever happened to String Interpolation? References: <9u6dbn$nsj$1@peabody.colorado.edu> <9uckd9$o43$1@peabody.colorado.edu> <9ucn17$pea$1@peabody.colorado.edu> Message-ID: <9ucsa0$g$1@peabody.colorado.edu> Tim Hammerquist wrote: [ snip ] >> I hate extra function calls which just clutter things out. I'm a >> big fan of 'first level' code readability: code which in a first >> reading, with minimal mental gymnastics, shows its intended >> purpose. > > Ah, but with training, one can do this with Python, Lisp, and even > Perl! I'm proof! > I know. Even with regexes, the epitome of line-noise-like code. But the point of a clear language is *not* to have to do that all the time (and yes, I know you were half-joking. Just pounding on the nail here). >> Oh well. We'll see if this gets anywhere. > > That _would_ be something. =) Indeed. I have serious doubts at this point. Oh well, from Itpl import Itpl,itpl forever... Cheers, f From george at cc.gatech.edu Sat Nov 17 17:04:24 2001 From: george at cc.gatech.edu (George Thomas) Date: Sat, 17 Nov 2001 17:04:24 -0500 Subject: SGMLParser error on HTML comment Message-ID: Hi everyone, There's the following post dated May 28, 2001 from Marcel van den Dungen. Didn't see any replies. Has there been a fix ? Does anyone have any ideas ? >>> Hi, I'm trying to parse a bunch of HTML files using the SGMLParser class, which works just fine unless an HTML-file starts with an HTML-comment marker before the opening-tag. The following error is emited: File "c:\python21\lib\sgmllib.py", line 238, in parse_declaration raise SGMLParseError( sgmllib.SGMLParseError: unexpected char in declaration: '<' Anybody know a fix or workaround for this? TIA, Marcel >>> rgds -- ------------------------------------------------------------------------- George Thomas Resident,Planet Earth,Third Rock from the Sun ------------------------------------------------------------------------- reduce (lambda c,d:chr(ord(d)-2)+c, 'ofcpqkekhhC"zwpkN"fgtgyqR/pqjv{R') ------------------------------------------------------------------------- From claird at starbase.neosoft.com Thu Nov 1 08:56:52 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 1 Nov 2001 07:56:52 -0600 Subject: MS network provider using Python References: Message-ID: <509A662DDBBEC420.A81865D9751EC8D4.5EE333CD72F3912D@lp.airnews.net> In article , Chris Liechti wrote: >"John S. Yates, Jr." wrote in >news:k7o0ut8u8pm4ueoju5djri48ecabjanver at 4ax.com: >> I am prototyping a network provider (a DLL exporting >> an implementation of the MS defined NP API and invoked >> by MS's MPR (Multiple Provider Router)). Since I >> anticipate a great deal of experimentation I would >> dearly love to do some prototyping in Python. > >so you want a DLL that is used by an other programm but is itself written >in python? > >> Can anyone in this news group offer words of wisdom? >> >> What is the best way in this kind of a rapid prototyping >> environment to expose my python code as a DLL? > >haven't heard of such a tool. py2exe generates standalone python apps, but >thats not what you want. wrapping DLLs so that the functions are available >in python can be done with SWIG, thats the wrong way in this case. > >if you want to expose some (python coded) functions as a DLL, i think you >have to write such a lib yourself. this DLL would then simply call an >embedded python interpreter to achieve the function. > >the DLL init function starts the python interpreter and imports your >script. all calls to the dll are then maped to a coresponding function in >the python script. > >embedding python in C is failrly simple as all what you need to convert >python data to c back and forth is provided by the Python DLL. for a >documentation of this interface, have a look at "Extending & Embedding" in >the Python docs that have come along with your Python distribution. >the source version of python has also some example code on embedding the >interpreter. . . . Another direction one could take this is to write a COM *service* in Python, using Mark's estimable Win- specific extensions. Would that meet the underlying requirement of this project? I presume that it's easy to code a tiny COM-NP gateway. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From joonas at olen.to Wed Nov 7 14:15:30 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Wed, 07 Nov 2001 21:15:30 +0200 Subject: Printing images with Python (win32) Message-ID: <3BE98852.BBA60145@olen.to> How can I print a simple jpeg or gif image with Python? Maybe with win32 extensions? From schaffer at optonline.net Thu Nov 8 17:18:25 2001 From: schaffer at optonline.net (Les Schaffer) Date: 08 Nov 2001 17:18:25 -0500 Subject: mayavi installation problem on Win NT References: <9sdh9v$hgq$01$1@news.t-online.com> <9sevfv$lrn$06$1@news.t-online.com> Message-ID: <87ofmcoqj2.fsf@optonline.net> Prabhu: do you think it would be better if i put my vtkdll.dll in the system32 folder??? les From tim.one at home.com Mon Nov 5 20:20:58 2001 From: tim.one at home.com (Tim Peters) Date: Mon, 5 Nov 2001 20:20:58 -0500 Subject: Underscore data hiding (was python development practices?) In-Reply-To: Message-ID: [Barry A. Warsaw] > FWIW, the double-leading-underscore-no-trailing-double-underscore name > mangling rule wasn't added specifically for data hiding. It was so > that a class that was designed to be subclassed could have a namespace > that subclasses couldn't accidently trample on: [Toby Dickenson] > Interestingly, I often find that that the chosen mangling scheme > doesnt achieve that design goal. The scheme mangles the class name > into the underscore-stripped attribute name, which offers zero > protection if your base classes and subclasses have the same name. > > Does this happen often? A common structure (for me, anyway) is to have > modules BaseWidget, FooWidget, and BarWidget, all of which define a > class Widget. And then what? That is, having a million classes all named Widget isn't a problem, unless you go on to define Yet Another Widget class using one of the existing Widgets as a (direct or indirect) base class. But you didn't say that's what you do, so I'm not sure how your example illustrates your point. Before Guido implemented this, the "what if a subclass and class have the same name?" conflict was discussed on c.l.py: [Guido, long ago] > Actually, I would spell it out in the docs, so whoever writes the base > class that uses private variables can decide whether they will want to > prtoect against this. I showed a simple way to do this already: > > class _RealSpam: > ...long class definition using __spam all over the place... > Spam = _RealSpam Then a Spam derived from this Spam mangles private names in a different way. I can't guess whether I'd be "happy enough" with that in practice, though, as the problem it's trying to address has never bit me. the-class-that-is-named-is-not-the-true-class-ly y'rs - tim From u9825527 at minteka.dbai.tuwien.ac.at Thu Nov 29 04:52:03 2001 From: u9825527 at minteka.dbai.tuwien.ac.at (martin z) Date: Thu, 29 Nov 2001 09:52:03 GMT Subject: How can i get values from a init - file Message-ID: <3c0602a8.2703951@news.tuwien.ac.at> I want to make a init - file, where i can set value for variables in my programm. now i have in my programm a class : class TEST: def __init__(self): self.a = 12 self.b = 13 self.c = 14 self.d = 15 I want to make a init- file like (or a other style. It is free; But i do not want write self.a = 12 because. other peoble should also use) : a 12 b 13 c 14 d 15 I need a init file to save the settings of my programm. How can i read the values of the init file into my programm without asking all cases. ? e.g: If s == a then self.a = s1 I hope you understand my problem. martin From hostmaster at newbrummusic.com Fri Nov 9 14:44:27 2001 From: hostmaster at newbrummusic.com (hostmaster at newbrummusic.com) Date: 9 Nov 2001 19:44:27 GMT Subject: Dont Read - Retaliation for Spamming Message-ID: <9shbmr$avp$4161@plutonium.btinternet.com> hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com hostmaster at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com admin at newbrummusic.com From prabhu at aero.iitm.ernet.in Mon Nov 12 13:20:33 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Mon, 12 Nov 2001 23:50:33 +0530 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <15343.63951.137972.487852@slothrop.digicool.com> References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> Message-ID: <15344.4849.71643.868791@monster.linux.in> >>>>> "JH" == Jeremy Hylton writes: >>>>> "PR" == Prabhu Ramachandran writes: PR> Ummm doing an 'import os' will import the package1/os.py and PR> *not* the standard one. This will happen even though os.py PR> was imported earlier by site.py. This is what Gordon was PR> objecting to in the first place and why he proposes using PR> rimport, rrimport etc. to make things more explicit. JH> Of course, you can use the existing mechanism to do this: JH> 'from package1 import os'. The use of an explicit name seems JH> like the clearest route when you have a package-local module JH> that shadows a top-level module -- no need to understand JH> details of relative imports, no question about what is JH> intended by the code. JH> I haven't followed this thread closely. Is there some reason JH> that explicit names in imports is not sufficient? Yes indeed there is. I've already explained my reasons twice. Eric also explained why this was important for Scipy. Anyway, in short, its a big pain re-nesting packages. Also for any package that has a deep enough structure its a real pain accessing packages. from pkg import subpkg is also not the best way to do imports. I personally prefer import pkg.subpkg and I believe this is the recommended way of doing imports. prabhu From jeff at ccvcorp.com Thu Nov 15 17:30:00 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Thu, 15 Nov 2001 14:30:00 -0800 Subject: Fork a SocketServer on NT References: Message-ID: <3BF441E7.6B905CA9@ccvcorp.com> GT wrote: > Hi, > > I'm trying to fork a SocketServer on NT. But I don't know how to do > this. The os.fork doesn't work on NT. Unless I'm severely mistaken, fork() is a unix-specific function. You can do something similar with threads--read the docs and source for the ThreadingSocketServer. Jeff Shannon Technician/Programmer Credit International From eddie at holyrood.ed.ac.uk Fri Nov 16 14:23:38 2001 From: eddie at holyrood.ed.ac.uk (Eddie Corns) Date: Fri, 16 Nov 2001 19:23:38 +0000 (UTC) Subject: programming logical functions: myand, myor and mynot References: <9sv2c7$6qa$06$1@news.t-online.com> Message-ID: <9t3p3q$rvl$1@scotsman.ed.ac.uk> "Gernot" writes: >Hi, >I want to implement the functions myand, myor and mynot. They should have >the same effect as the known boolean operators and, or and not. >The trick is that I am not allowed to use the boolean operators and, or and >not. >This is what I tried: >----------- >x = raw_input("Type something (x): ") >y = raw_input("Type something (y): ") >def myand(x,y): > if bool(x) == 1: > if bool(y) == 1: > return 1 > return 0 >if und(x,y) ==1: > print "true" >else: > print "false" >-------------- >I think, the idea is not that wrong, but anyway, it doesn't work! It has >something to do with "bool (x)", I think. Maybe this is something like a >module which i have to "activate" first?? >Please give me some hints, I would be very grateful I think you've correctly worked out that AND is equivalent to the nested if statements but it's not clear from the example what you're trying to do. If you are in fact trying to evaluate input from the user you need to choose a representation for true and false (such as 't' and 'f') and make explicit tests for these. If the input is just for testing and you're trying to understand how myand works, then you just need to think of 'x' and 'y' as _expressions_, which will be evaluated to true or false in the right context (I can't think of another way of saying this as a hint rather than giving the answer outright). Eddie From DeepBlue at DeepBlue.org Fri Nov 9 09:31:07 2001 From: DeepBlue at DeepBlue.org (DeepBlue) Date: Fri, 9 Nov 2001 08:31:07 -0600 Subject: Open a windows database file with a path name? References: Message-ID: What is that you are using that is not working? DeepBlue "Nomad" wrote in message news:qnonuto5ao5iu4c0fa1ttletlje3s9sfck at 4ax.com... > Hi, > > Is there anyway that I can open a database (MSAccess in this case) > using the path and file name rather than a DSN? I can't seem to get > it to work. > > TIA > > -- > Nomad > > Wondering of the vast emptyness of the 'net > in search of something cool. From danielk at aracnet.com Fri Nov 16 08:54:53 2001 From: danielk at aracnet.com (Daniel Klein) Date: Fri, 16 Nov 2001 05:54:53 -0800 Subject: List Recursion Message-ID: Now that I've gone thru the exercise to write a whole 6 lines of python code to 'visit' nested list elements, I'm wondering if there is a builtin utility for this, or if someone has come up with a better/faster method. Of course, this will eventually be a class method that 'returns' each object in the list... >>> list1 = ['a', 'b'] >>> list2 = ['1', ['a', 'b'], '2'] >>> import types >>> def visitEachListElementOf(alist): for el in alist: if isinstance(el, types.ListType): visitEachListElementOf(el) else: print el # do whatever is necessary with the list element >>> visitEachElelementOf(list2) 1 a b 2 >>> Daniel Klein "Give a man a computer program and you give him a headache. But teach him to program computers and you give him the power to create headaches for others the rest of his life!" -- Unknown From daves_spam_dodging_account at yahoo.com Tue Nov 13 15:42:00 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Tue, 13 Nov 2001 12:42:00 -0800 (PST) Subject: Stopping exception unwinding at exit Message-ID: <20011113204200.50877.qmail@web21106.mail.yahoo.com> Hello, I'm trying to write a robust script, one that recovers gracefully from just about any condition. Because I'm new to Python, I've wrapped my entire script in a try: block that goes into a friendly exception dumper that lets me know that some unexpected exception was raised, and provides a dump of it as a StringIO, suitable for logging to a file. I have, inside the first try block, an exception handler that catches a specific error, does the dump thing, and then calls sys.exit(-1). The problem I'm seeing is that, because the inner block raised an exception, after the call to sys.exit(-1), the outer block catches it and also dumps the exception. Is there a way to turn that off? Some way to tell Python that the exception has been handled? Here is a dramatically simplified version of the script. Sorry, I don't know how to do this from the interactive prompt since it uses sys.exit(), but here's the script and the output: #------------------------ # SCRIPT import sys def Puke(msg): print "Mr. Creosote: BARF!\n%s" % msg sys.exit(-1) try: try: x = 1 y = 0 z = x/y except: Puke("Can't divide by zero") except: Puke("An unknown exception was raised in the script.") #------------------------ # OUTPUT Mr. Creosote: BARF! Can't divide by zero Mr. Creosote: BARF! An unknown exception was raised in the script. Thank you, -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com From sholden at holdenweb.com Tue Nov 13 07:40:32 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 07:40:32 -0500 Subject: OT: Mobile Internet Toolkit EULA References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> Message-ID: "Tim Hammerquist" wrote ... > > Guido Stepken graced us by uttering: > > [ snipped excerpt from MS MIT EULA ] > > > Thanx lots for checking this out ! Hmmm, that means, that it is forbidden > > to produce (distribute) code, consisting of (L)GPL Software and Microsoft > > OpenSource. One is not allowed to mix code. BSD License + Microsoft Code, > > that's OK ! > > Any ideas, why ? > > The BSD license is unrestrictive. I can take an entire BSD-licensed > file, cut-and-paste it into my own project, sign, seal, and > deliver...and not even have to mention where I got it. > > This is fine by Microsoft because it means if they find anything they > want somewhere inside a Berkeley Quality Software project, they can just > take it. > Yup. But as for giving something back, "Hey, that's ours!" > What I think was even more appalling was the restriction on > > > : (ii) not using Potentially Viral Software (e.g. tools) to > : develop Recipient software which includes the Software, > : in whole or in part. > > > This means I can't > > - test a script using a perl binary that falls under the (default) > Artistic License. > - test a script using a Python binary that falls under the GPL > compatible license. > - _use_ Vim or Emacs to edit _any_ file in the project I'm developing. > - make a tarball of a directory tree using GNU tar or GNU gzip. > - ...and so on > > Limitations on the product distributed is nothing new. OTOH, Microsoft > has just attempted to make it _ILLEGAL_ to use a python binary I've > compiled myself (though ActivePython is probably alright). _This_ is > what a _huge_ number of people are upset about. > > Opinions? Microsoft is a rabidly commercial organisation with little idea of the trouble it is storing up for itself. If I were a stockholder I would be incensed at the behavior of the corporate officers. They still deny any wrongdoing after having been declared a monopolist in the US courts. They still attempt to impose unreasonable terms in licenses. One measure of the success (or otherwise) of the DoJ settlement, should it go through, will be the Samba team's ability to shoehorn a proper protocol description out of MS. Given the current verbiage, the Samba team aren't optimistic. I firmly believe Microsoft will be the first IBM of the 21st century, and some unstoppable market force will unseat them before they realise how wrong they are. Look how nearly they missed the Internet boat, believing they could turn the Internet into a Microsoft network. The really dumb feature is that they don't appear to have learned much from all that. > Rebuttals? > Since the Python license is as liberal as it is, there is no reason why a Python binary has to be GPL, just because (say) you compiled it with gcc. But that apart, your description of the terms and conditions of Microsoft's EULA seems fair, and less biased than, say, my own sclerotic reactions. regards Steve -- http://www.holdenweb.com/ From johnroth at ameritech.net Mon Nov 5 19:13:30 2001 From: johnroth at ameritech.net (John Roth) Date: Mon, 5 Nov 2001 16:13:30 -0800 Subject: Teaching python (programming) to children References: <8ef9bea6.0111050832.4474d66a@posting.google.com> Message-ID: "Hung Jung Lu" wrote in message news:8ef9bea6.0111050832.4474d66a at posting.google.com... > Nomad wrote in message news:... > > IMHO, python would be one of (if not _the_) best language to teach > > beginning programming - not just children, but as you mention, there > > is the difficulty with the "englishness" of the language (or almost > > any other programming language). > > I have my doubts about Python being the first programming language to > teach. I see all too many newbies running into the problem of > namespaces. How do you explain to them that "from xyz import *" is a > bad thing, if they don't even understand what's going on behind the > scene? What happens if you want a particular toy from the box, and you simply empty the entire box on the floor? Then what happens if you want toys from several boxes, and you empty all of them on the floor. There may be a better analogy, but this one should do. > Also, how in the world can beginners understand what a hash > table means? Are we going to tell them something like: "oh well, think > of Python dictionary as a magic black box, you'll understand it later > when you take a course in C/C++"? Any child ready to learn a real programming language is quite capable of understanding a set of keys with tags hanging on a pegboard. It's a very natural analogy. Just look at the pegboard and grab the right key! There are undoubtedly other great analogies, but this one will undoubtedly do. John Roth From gyekye_7 at yahoo.com Wed Nov 7 05:02:49 2001 From: gyekye_7 at yahoo.com (Kojo Duncan) Date: Wed, 07 Nov 2001 10:02:49 GMT Subject: Help Help Help References: <3be77f95@152.65.161.36> Message-ID: <3be906c6@152.65.161.36> Thanks Paul Winker you were most helpful and the site is an amazing resource. And to Paul Rubin I have this to say...........................well maybe I shouldn't. "Paul Winkler" wrote in message news:slrn9uf3gh.2fg.slinkp23 at roaddog.armsnet... > On Tue, 06 Nov 2001 06:13:43 GMT, Kojo Duncan wrote: > >I'm taking a computer science course and I really need help understanding > >python. If you know of any easy to follow tutorials, great emphasis on easy > >to follow, please send me a reply on gyekye_7 at yahoo.com . > > http://www.ibiblio.org/obp/thinkCSpy/ > From roy at panix.com Sat Nov 10 20:41:13 2001 From: roy at panix.com (Roy Smith) Date: Sat, 10 Nov 2001 20:41:13 -0500 Subject: IsPython really O-O? References: Message-ID: wrote: > Is Python not "really" appropriate for true O-O applications, in the > sense that Viz-Age Smalltalk and Eifel and so on are??? I've never been accused of worrying too much about what's appropriate, so maybe this answer isn't going to be either :-) The typical complaint I hear from people when they say Python isn't O-O enough for them, is that it doesn't have private data. The hard-core O-O zealot will insist that the only way to access data inside of an object should be through explicit set/get functions. I'll admit that there is value to the private/set/get way of life, and sometimes I do wish Python worked that way. It certainly does give you some protections that would be nice to have. For example, you wouldn't need warnings such as (from the documentation for string.whitespace): "Do not change its definition -- the effect on the routines strip() and split() is undefined." On the other hand, I'm too busy writing programs in Python that do useful things with a minimum of fuss to worry about whether it's "true O-O" or not. I'll leave that argument to comp.lang.oo.religious-wars. From tim.one at home.com Sun Nov 11 02:35:37 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 11 Nov 2001 02:35:37 -0500 Subject: Bug in list comprehensions in Pyhton 2.1.1? In-Reply-To: <86f75fa2.0111101644.6f9de070@posting.google.com> Message-ID: [Fernando P?rez] > The code below can be copied and run as is. Hopefully it documents > clearly enough what to me seems to be a bug in list comprehensions: > the global namespace is polluted with a local variable which was only > used as the dummy running index of the list comprehension. > ... > def flatten_bug(seq): > # a *global* variable x is left over after calling this function, > # with the value of the last element in the return list > return [x for subseq in seq for x in subseq] See This was a bug, and was fixed last month (for 2.2; perhaps also for 2.1.2). From h.jehadalwan at student.kun.nl Sun Nov 4 09:00:40 2001 From: h.jehadalwan at student.kun.nl (Husam) Date: Sun, 04 Nov 2001 15:00:40 +0100 Subject: How can i retrieve a key from a dictionary? References: <3BE519E0.34312B48@student.kun.nl> <3BE52DBC.724B1C6F@student.kun.nl> Message-ID: <3BE54A08.2AFF9A66@student.kun.nl> Prabhu Ramachandran wrote: > >>>>> "HJ" == Husam writes: > > >> dict.keys()[dict.values().index('one')] > >> > >> prabhu > > HJ> it works, but wat does the -index- means? > > >>> a = [] > >>> print a.index.__doc__ > L.index(value) -> integer -- return index of first occurrence of value > > Also, note the above might give you unexpected results if you have two > different keys that have the same value i.e. if you did: > > dict[3] = 'one' > > You'd have two keys pointing to the same 'one' in this case you are in > for trouble. > > prabhu thanks, now i understand. by the way, if you have time to satisfy my curuosity, what is the solution for the umbiquity in you'r second example? From fperez528 at yahoo.com Mon Nov 19 12:43:22 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 20 Nov 2001 17:11:22 +2328 Subject: Still on python GUI toolkit References: Message-ID: <9terl6$s3m$1@peabody.colorado.edu> Laurent Pointal wrote: > GUI in Java > | > CORBA ORB for Java (OpenORB or other) > | > | > | > CORBA ORB for Python (omniORBpy) > | > scripting and > processing in Python Just curious: why the extra Java layers? Naively I'd have the impression that from within python alone you can easily do the top part of your diagram without needing Java. One more language adds overhead both of execution and development/maintenance. I'm sure you guys have very good reasons for what you're doing but I'm curious. Is it that the currently available gui toolkits are that inferior to swing to justify the extra complexity? Or do you have other reasons? cheers, f. From sheershion at mailexpire.com Fri Nov 9 10:39:12 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Fri, 09 Nov 2001 15:39:12 -0000 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> Message-ID: I wrote: > [something] Ignore previous post: I read 'raw_input' where it actually said 'input'. My mistake. Robert Amesz From gh_pythonlist at gmx.de Wed Nov 28 22:06:33 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Thu, 29 Nov 2001 04:06:33 +0100 Subject: Python, licenses and CVS In-Reply-To: <3C0597E9.4CEB1455@ccvcorp.com> References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> Message-ID: <20011129040631.A1114@lilith.hqd-internal> On Wed, Nov 28, 2001 at 06:05:29PM -0800, Jeff Shannon wrote: > > With all this discussion of CVS, I have a question that I've not been able to > find a satisfactory answer to, myself. > > My current place of employment does not use any significant form of version > control. > Due to the nature of most of our codebase, using CVS for it would be > unrealistic anyhow. If this is because it's a Micro$oft shop, Visual Source"safe" is a reasonable version control software. Btw. CVS also has deficiencies like no history of meta-operations like file moving/renaming, etc. > Despite all of this, I would like to begin using CVS > for those projects that I can, even if I'm the only one using it. The > problem with this, is that I don't have access to a Unix/Linux server to > install CVS on (our one Unix server is host to our virtual-OS (non-SQL) > database, and I don't think I could convince anyone to install anything > unnecessary there ). What I'd really like, is a version (or clone) of > CVS that will allow me to use a local repository under Windows. Does any > such thing exist? Either use Cygwin, which is a pretty complete Unix emulation for Windows. And yes, it has CVS, too. http://www.cygwin.com/ Or use CVSNT (http://www.cvsnt.org/), which is a native win32 CVS server (and client). There are also nice CVS GUIs for Windows: http://www.cvsgui.org/ and my favourite http://www.cvsgui.org/TortoiseCVS/index.shtml which is an Explorer plug-in that let's you use CVS from the standard Windows Explorer. > (I'm very frustrated, trying to teach myself good software > engineering practices in a workplace that doesn't support that at all... ) I'd just try to educate my co-workers. That's what I currently do :) Maybe you could also mention how this or that could have been avoided had there been a version control system/regression tests/any QA at all/proper documentation, etc. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From printers at sendme.cz Fri Nov 16 11:19:41 2001 From: printers at sendme.cz (A) Date: Fri, 16 Nov 2001 17:19:41 +0100 Subject: Is it a job for Thread or Process? Message-ID: <3BF54AAD.14642.10C083@localhost> - Hello, In my Python script I would like to start one function of this script in a different thread or process? That function sends an email. Can you please give me an example how I can start a new thread or process under Win32 systems? Is it better to use a new thread or a new process for this task? Thank you for help. Ladislav From stephane.routelous at sympatico.ca Wed Nov 21 16:06:58 2001 From: stephane.routelous at sympatico.ca (Stephane Routelous) Date: Wed, 21 Nov 2001 16:06:58 -0500 Subject: adding python script into an MFC Application Message-ID: Hello, I'm a beginner with Python. I have an Application done with MFC ( Microsoft Fundation Classes ) under Windows. I would like to integrate a python interpreter in a dialog box. Can you give me some tips, links , etc... ? TIA, Stephane --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.298 / Virus Database: 161 - Release Date: 2001-11-13 From shriek at gmx.co.uk Sun Nov 18 22:04:51 2001 From: shriek at gmx.co.uk (Stephen) Date: 18 Nov 2001 19:04:51 -0800 Subject: MultiThread Socket on NT References: <3bf4f244$1@brateggebdc5.br-automation.co.at> Message-ID: <97ae44ee.0111181904.5ce8e2a3@posting.google.com> > Your problem with performance could come from creating a new thread for > every request. > Depending on the OS, creating threads may be an expensive operation. > > To have a better scalable solution, you could use a thread pool. Is there any boilerplate "thread pool manager" code in Python ? I probably could cook something up but I'd hate to reinvent the wheel (especially when mine would probably be pear or square shaped) and I'm not sure how to do synchronization in Python. Thanks. Stephen. From dalke at dalkescientific.com Sat Nov 17 13:24:55 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Sat, 17 Nov 2001 11:24:55 -0700 Subject: identity = lambda x: x -- a Pythonic idiom? References: <9t64fv$305$1@nntp9.atl.mindspring.net> Message-ID: <9t6aaj$33v$1@slb4.atl.mindspring.net> George Demmy: >operator.truth and the identity function are not exactly the same. >operator.truth returns 1 if true, 0 if false. identity returns its > argument D'oh! And duh! >For filtering purposes, they have the same effect. I was only thinking about its use in this context, forgetting the larger sense. Andrew From bjgough at network-theory.spam.trap.co.uk Thu Nov 22 09:43:15 2001 From: bjgough at network-theory.spam.trap.co.uk (Brian Gough) Date: Thu, 22 Nov 2001 14:43:15 GMT Subject: Scientific Libraries in Python References: <9t1iqq$es0$2@peabody.colorado.edu> <3BF45CAF.9983E26A@home.net> Message-ID: <7a8L7.5503$_J2.576156@news1.cableinet.net> On Thu, 22 Nov 2001 01:08:06 +0530, Prabhu Ramachandran wrote: >>>>>> "BG" == Brian Gough writes: > > [snip] > > BG> The Python License is GPL-compatible, and the Python-GSL > BG> wrappers are under the GPL so there's no problem in using GSL > BG> with Python. > > True but that's not exactly the problem. SciPy is released under a > BSD license, so can SciPy use GSL internally? I guess not. Right. Applications which use GPL-ed libraries need to be under the GPL if they are distributed. -- remove the spam trap to reply From rdsteph at earthlink.net Thu Nov 22 21:28:09 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Fri, 23 Nov 2001 02:28:09 GMT Subject: Indenting with tabs vs spaces References: Message-ID: <3BFDB593.39AFC7FD@earthlink.net> OK, now you all have got me worrying about a new thing. All my code so far is indeented with single tabs (four spaces I think). Since I use IDLE or sometimes PythonWin when I code, will my tabs screw up anyone else trying to run my code? H9ow about if I use Windows Notepad? I hate spaces, like tabs. Peoter Veili wrote: > > >Tabs are wrong, because different editors will treat them differently. > > > > > >Spaces are right, because a space is a space is a space, everywhere you > > >go. > > Indenting with tabs can be done such that it will look the same on every > editor that uses fixed-width fonts, meaning everything will line up > correctly, it least in the sense that really matters. Here's an example of > what I mean: > > function helloThere("hello", > "there"){ > } > > The proper way to do this is the second line needs to be typed with one tab > followed by enough spaces to line up the "hello" and "there". This way the > "hello" and "there" will line up correctly on any editor. If the person was > lazy and tabbed all the way out to right before "there" and then filled in > with a > few spaces, it may not line up depending on what your tabwidth is set to. > > Besides this I know of no problems with using tabs. I find them cleaner and > more efficient. I'd rather tab 10 times than hit the space bar 40 times. I > never have to go through a whole file and manually line things up because at > one place in the file I accidentally didn't indent with the right amount of > spaces and half the file needs fixing. Auto-indent helps, but still.... From altis at semi-retired.com Fri Nov 9 23:05:23 2001 From: altis at semi-retired.com (Kevin Altis) Date: Fri, 9 Nov 2001 20:05:23 -0800 Subject: reusable software components Message-ID: Are there any current efforts to build cross-platform Python components or standardize a Python component model? I've been thinking about creating a component framework for PythonCard, which will use wxPython for its GUI widgets. The component framework is mostly going to be a set of conventions to follow, so that a visual environment can hook together components and make compound components. Since Python itself already provides introspection, what seems to be missing are the hints to use at design time for specifying the properties and events for the component. While Python doesn't use strong typing, components need type info, especially when the component is wrapping a native control written in C/C++. There is no particular reason the conventions need to be limited to wxPython, they could be applied to tkinter components or even non-visual components. Software components are described by the excellent Java Beans intro, which you should take ten minutes to read if you don't know what software components are: http://developer.java.sun.com/developer/onlineTraining/Beans/Beans1/index.ht ml Anyway, I searched the comp.lang.python archive and a few other sources and except for some older messages talking about COM and CORBA and Java Beans, I didn't find any current efforts to make a standard set of conventions for Python components. The PyXPCOM stuff looks like it is stalled out. I would appreciate any feedback, suggestions, or links on software components for Python. Thanks, ka ps. My first post seems to have been eaten by my ISP, but apologies in advance for a double-post if it shows up (I posted the first one over six hours ago). From syver-en at online.no Tue Nov 27 10:08:44 2001 From: syver-en at online.no (Syver Enstad) Date: 27 Nov 2001 16:08:44 +0100 Subject: pdbtrack in emacs, Great! References: Message-ID: Mark Johnathan Greenaway writes: > May I ask what version of emacs and what version of python-mode > you're using? You may :-) It's 21.1 and (defconst py-version "4.6" "`python-mode' version number.") that I've downloaded from www.python.org > Also, how do you start pdb? I've tried to use pdb under emacs and it always > seems to stall? > Yes on my machine it's terrible, never gotten it to work. But pdbtrack is great, start up a python interpreter with C-c! and import pdb (put it in your pythonstartup file) put a pdb.set_trace() statement in the sourcefile you wish to debug. Call a function that will bring the execution to the set_trace call. When pdb.set_trace is called the pdbtrack feature breaks in and shows the overlay arrow in the fringe, and you can write pdb commands in your *Python* buffer. Of course, you could have done that anyway, the difference being that the sourcefile being debugged is displayed together with the arrow showing the location of the instruction pointer). I've made some extensions to the py-shell-keymap together with some simple lisp functions that enables me to control the most common functionality with the function keys that I am used to from VC++ Devstudio which is the debugger I like the most. I am currently working on enabling and disabling breakpoints directly from the sourcecode, enabling is ok, but disabling it needs a little more attention. -- Vennlig hilsen Syver Enstad From garth_grimm at hp.com Thu Nov 29 16:35:34 2001 From: garth_grimm at hp.com (Garth Grimm) Date: Thu, 29 Nov 2001 13:35:34 -0800 Subject: finding a value in a tuple References: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Message-ID: <3C06AA26.6020906@hp.com> Dan Allen wrote: > Say I have > > mylist = ['one','two','three'] > > which I presume is a "tuple" as I have been scanning the manual. That's a list, not a tuple. A tuple would be like myTuple = { 'one', 'two', 'three' ) > Now, > is there a way to run the php-like function in_array() on this. > Consider this, I want to know if one of the values in that tuple is > exactly equal to "four". The answer of course is no, but how would I > find it. Here is what I have so far, which works, but it is ugly.. This should work... if value in mylist: doStuffHere else: doOtherStuff or if value not in mylist: doStuffHere else: doOtherStuff They should work for both tuples, and lists, (and strings too, I think) Or, you could do list specific things, like: if mylist.count(value) > 0 : or just call mylist.index(value) and catch the exception that's raised if the value isn't in the list, or there is probably some other ways, but one of the ones above should be adequat. Garth > > d = {} > for value in mylist > d[value] = 1 > try: > if d['four']: > print "your value was found" > except: > print "your value was not found" > Okay, d = {} is a dictionary, not a list nor a tuple. In this case, use something like if d.has_key(value): doStuffHere else: doOtherStuff what you're trying to do above is access a key-value pair, and then handling the exception raised if the key doesn't exist. That also works, but don't use a dictionary unless you actually have key-value pairs. Garth > Two question here, is that a bad use of try/except? Second is, is > there an array_flip, or do you just have to do what I did above? I > would imagine there is a way to search down the tuple. > > Thanks! > > Dan > From fredrik at pythonware.com Wed Nov 7 12:14:44 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 17:14:44 GMT Subject: Australian Disco (was: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor))) References: <9sacsk$r82$1@bugstomper.ihug.com.au> Message-ID: <8_dG7.4760$R43.760797@newsb.telia.net> Gary Stephenson wrote: > Umm, I'm not really sure this is a claim we should be making! Next thing > you'll have us claiming responsibility for making disco popular - and then > they'll just have to shoot us! ;-) but Steve Irwin is your fault, right? From jeff at ccvcorp.com Wed Nov 21 14:33:22 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 21 Nov 2001 11:33:22 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFB34A9.565BBF2E@engcorp.com> <20011121000734.48b85dde.sthiyaga@operamail.com> Message-ID: <3BFC0182.7DDF6B4E@ccvcorp.com> Dave Cinege wrote: > Rule of God: > The punishment for non-tab based indentation is death. This is exactly backwards. Tabs are wrong, because different editors will treat them differently. Spaces are right, because a space is a space is a space, everywhere you go. Jeff Shannon Technician/Programmer Credit International From pinard at iro.umontreal.ca Thu Nov 15 08:00:06 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 15 Nov 2001 08:00:06 -0500 Subject: How to marshal a function? In-Reply-To: References: Message-ID: [Michael Hudson] > pinard at iro.umontreal.ca (Fran?ois Pinard) writes: > > Earlier today, I wondered how to marshal a function, in view of > > transmitting it to a remote machine and executing it there. > Well, the bytecode has changed between every released version of > Python, AFAIK. Certainly 1.5.2->2.0, 2.0->2.1 and 2.1->2.2, and not > usually backward compatibly. > So you can forget that idea. Simple enough! Thanks! :-) -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From TomH at optiscan.com Sun Nov 25 17:17:47 2001 From: TomH at optiscan.com (Tom Harris) Date: Mon, 26 Nov 2001 09:17:47 +1100 Subject: win32process question Message-ID: Greetings, I have been playing with starting up processes in Win32, but I also need to be able to kill them if they hang. I have been using win32process.TerminateProcess() to do this, but this is not the best method as it does not allow the killed process to do any cleanup, unload DLLs, kill child processes, etc. The way Windows would *like* you to do it is to persuade the process-to-be-killed to call the (Win32 API call) ExitProcess(), I think that the default ctrl-C and ctrl-break handlers make a thread that does just this, has anyone made a module to deliver signals to arbitrary processes for Win32? Tom Harris, Software Engineer Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, Australia email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 This email may contain confidential information. If you have received this email in error, please delete it immediately,and inform us of the mistake by return email. Any form of reproduction, or further dissemination of this email is strictly prohibited. Also, please note that opinions expressed in this email are those of the author, and are not necessarily those of Optiscan Pty Ltd. From peter at engcorp.com Thu Nov 29 19:24:28 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 29 Nov 2001 19:24:28 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> <8ef9bea6.0111291148.1c5d4fa@posting.google.com> Message-ID: <3C06D1BC.F8B46749@engcorp.com> Hung Jung Lu wrote: > > I'll speak for one here, on my own experience. I honestly tried very > hard to switch from SourceSafe to CVS. But the CVS world just seemed > kind of immature for Windows platform, and the disdain attitude of > some CVS developers towards the Windows platform did not help. After > wasting some time on various Windows adaptations of CVS, I gave up. Our experience was the opposite. I had used Starteam in the past and found it very effective, but they changed their licensing and for my new group it would have been prohibitively expensive. We evaluated SourceSafe extensively, but after fighting it (crashes, lost data, and missing features) for months, I finally gave in to the advice of a co-op student who insisted that CVS was quite up to the task. I'm very glad to see him proven right. Our conclusion was that while SourceSafe *might* be suitable for a one-person situation, it was absolutely unsuited, and downright *dangerous*, for a team environment. I feel that with CVS our data is *much* more secure, and we've had effectively no issues such as crashing. (As I mentioned elsewhere, we are now running pserver on Linux and using WinCVS for Windows clients, plus some shell Linux clients. Perhaps Hung's experience with CVS on Windows was several years ago, and things might have changed.) But of course YMMV. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From soren at pobox.com Thu Nov 15 13:28:43 2001 From: soren at pobox.com (Soren Ragsdale) Date: 15 Nov 2001 10:28:43 -0800 Subject: What is "marshal data"? Message-ID: <859c71be.0111151028.63227109@posting.google.com> I'm testing some scripts with Python 2.1.1: we're upgrading from 1.5.2. I've been noticing this error, and the REAL problem is that I've never heard of "marshal data" before. This error is not reproducible: this script is part of a distributed program which runs on about 200 machines, and four of the scripts produced this error. The problem isn't isolated to individual machines: > /tip/td/python2-irix64/bin/python -u ren_blade.py 44 Traceback (most recent call last): File "ren_blade.py", line 4, in ? import uh,gh ValueError: bad marshal data Possible sources of the problem: "uh.py" is imported from MANY programs on our network. It's being imported by Linux and Irix machines running 1.5.2 and 2.1.1 versions of Python. Could this be some sort of race condition, where one platform or version produces a .pyc file while the other platform or version is also writing the same .pyc file? From eldiener at earthlink.net Mon Nov 12 00:20:57 2001 From: eldiener at earthlink.net (Edward Diener) Date: Mon, 12 Nov 2001 05:20:57 GMT Subject: IsPython really O-O? References: Message-ID: <3BEF5D31.1090900@earthlink.net> "Object-oriented" is like the caterpillar in Alice saying, effectively, that when he says a word it means what he wants it to mean. No doubt your Smalltalk guru has his own definition of OOP so even if you ask him you will just be arguing against someone whose idea of OOP is Smalltalk, or some such similar nonsense. A more effective response would have been to ask him what he didn't like about Python. Maybe then you could have had an intelligent conversation with him. OOP is so personal that arguing about it is a huge waste of time. kentsmith at dxsys.com wrote: > A Smalltalk guru in our organization looked at Python last weekend (after I > had made a big scene saying that it may be a solution to some of our > cross-platform issues) and came away saying that it was no more > object-oriented than Java. I sputtered around a bit but could hardly make a > decent argument, as I'm a mere designer. We do very large-scale industrial > work here, all O-O, with object databases (I thought the ZODB business > looked great). Is my friend right? Is Python not "really" appropriate for > true O-O applications, in the sense that Viz-Age Smalltalk and Eifel and so > on are??? > > Kent Smith > > > > > From crispiewm at hotmail.com Sun Nov 11 04:33:24 2001 From: crispiewm at hotmail.com (Kevin Christie) Date: Sun, 11 Nov 2001 03:33:24 -0600 Subject: mapping a statement over all list items References: <3BEE4077.8070407@hotmail.com> <9slfje$p9c$2@peabody.colorado.edu> Message-ID: <3BEE45E4.5080407@hotmail.com> Fernando P?rez wrote: >> Thus if Foo was ['abc-xyz', 'black-blue', '123-987'], the result after >> mapping to Foo would be: >> >> Foo = [ ['abc', 'xyz'], ['black','blue'], ['123','987'] ] >> > > Is this good enough for you (never mind the bizarre prompts, I have my own > interpreter)? > > In[1]:= foo=['abc-xyz', 'black-blue', '123-987'] > > In[1]:= [x.split('-') for x in foo] > > Out[1]= [['abc', 'xyz'], ['black', 'blue'], ['123', '987']] > > > Cheers, > > f Thanks, that worked great :) I'm still a bit new to Python, but love it so far! Sincerely, Kevin Christie Neuroscience Program University of Illinois at Urbana-Champaign crispiewm at hotmail.com From jeff at ccvcorp.com Tue Nov 13 19:22:30 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 13 Nov 2001 16:22:30 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear References: <7396d2b2.0111112010.7649efa1@posting.google.com> <3BEF67B0.31ED5766@engcorp.com> <7396d2b2.0111122102.2058f188@posting.google.com> <7396d2b2.0111131345.22483e62@posting.google.com> Message-ID: <3BF1B946.35E697B1@ccvcorp.com> Lemniscate wrote: > Actually, here is the code I am working on now. ..... Whew. I'm not very familiar with Tkinter, and as you warned, the code *is* messy :) You might find things easier if you separated this into several functions/classes--one to set up the GUI, one to parse your input files, one to drive Excel, etc. That would make it a bit easier to keep track of what's going on here. However, as for the hyperlink problem... > > Pstr = GenericLinkGen.FindTheURL(HLLstr, > r"http://www.proteome.com/databases/HumanPD/reports/") > #Pout.write(Pstr) > XL.SetCell(xRow,xCol, Pstr) I *think* that this is the part that you're trying to create as a hyperlink. Presuming that Pstr contains the URL that you want to link to, and that xRow and xCol are the row/column of the cell you want the hyperlink to appear in... Try extending the easyExcel class (from the Python on Win32 book) like this (I haven't tested it, I'm just going from the docs): class ExtendedExcel(easyExcel): def setHyperlink(self, sheet, row, col, url): sht = self.xlBook.Worksheets(sheet) sht.Hyperlinks.Add(sht.Cells(row, col),url) Then, in the above code fragment, replace the setcell call with: XL.setHyperlink(1, xRow, xCol, Pstr) (I notice that your XL method calls don't include the sheet parameter, unlike the book's version, so you may wish to modify this to treat the sheet in the same way that you do for setCell(), etc...) Jeff Shannon Technician/Programmer Credit International From maxm at normik.dk Thu Nov 29 08:06:59 2001 From: maxm at normik.dk (Max M) Date: Thu, 29 Nov 2001 14:06:59 +0100 Subject: Mass mailing module for Python Message-ID: <3c0632ee$0$25408$edfadb0f@dspool01.news.tele.dk> I have been whip up a mass mailing system for one of our customers, that needs to adress about 25-40.000 of their cosumers by email regularly. The mails will all be different with personalized content. So i guess that a regular list manager like mailman is out of the question. Without having tried it I guess that using a regular mailserver and then just sending tons of mails from that, one at a time, wont work either. Though it would be very easy. Here I am thinking about bouncing mail and unavailable mailservers, but I could be wrong. Doest anybody have an idea as to how I should approach this in Python? Has anybody tried it? I know that I could write a test, but the problem is that it's pretty hard to realistically test sending 25000 emails out in the wild. So in this case my hope is that somebody else has made the mistakes before me. regards Max M From sholden at holdenweb.com Tue Nov 13 08:17:02 2001 From: sholden at holdenweb.com (Steve Holden) Date: Tue, 13 Nov 2001 08:17:02 -0500 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> <15344.43730.821724.769885@monster.linux.in> <5q52vtgjkn38etn7tpu8eji4r9k0oaguk9@4ax.com> Message-ID: <_%8I7.9688$vQ1.368397@atlpnn01.usenetserver.com> "Toby Dickenson" wrote in message news:5q52vtgjkn38etn7tpu8eji4r9k0oaguk9 at 4ax.com... > barry at zope.com (Barry A. Warsaw) wrote: > > >Why does B have to add packages to A's namespace? Why can't the B > >author simply use distutils to ensure that vanilla A is installed, > >import the bits and pieces of A that you want to expose, overriding > >what you want to change, and export an interface through B that > >clients can use instead of A? > > Two reasons have ocurred in my projects over the last year: > > 1. A and B have the same author, and he want to > *permanently* repackage B inside A. Maybe he > developed A independantly without considering > where it would be finally packaged > In which case the re-packaging work is one-off (US: one-time-only) and should not be seen as an unbearable load. > 2. Maybe A needs to use an old version of B, or > a version of B that has been hacked for an > A-specific reason. > In which case it would seem more sensible to rename it as hacked_B, since surely madness otherwise lies down the road. regards Steve -- http://www.holdenweb.com/ From zooko at zooko.com Mon Nov 26 11:02:23 2001 From: zooko at zooko.com (Zooko) Date: Mon, 26 Nov 2001 08:02:23 -0800 Subject: bugs in `gc.get_referents()' Message-ID: [Would this be more appropriate for the Python developers' list?] Hello Pythonistas, Pythonics and Pythonifiers! I'm using Python 2.2b2 as compiled and packaged by debian. I've been using `gc.get_objects()' and `gc.get_referents()' (since renamed `gc.get_referrers()') to find out how my app Mojo Nation[1] uses memory. (Thank you to the implementors of those functions! It has been a great help!) There are two apparent bugs: first, the return value from get_referents() *always* contains a number of entries that do not refer to the object in question, and it is always the same entries. For example: >>> t = (0,1,2,3,) >>> l = [t,] >>> refs = gc.get_referents(t) >>> len(refs) 9 >>> hr(refs[0]) '[(0, 1, 2, 3)]' >>> hr(refs[1]) "{'__builtins__': {'ArithmeticError': , 'AssertionError': , 'AttributeError': , 'DeprecationWarning': , 'EOFError': , 'Ellipsis': Ellipsis, ...}, 'broker': <__main__.Broker instance at 0x856820c>, 'gc': , 'hr': , 'human_readable': , 'l': [(0, 1, 2, 3)], ...}" >>> hr(refs[2]) "{'Additional_DTML_Paths': [], 'DocumentTemplate': , 'DuplicateChecker': , 'PresentationError': , 'PseudoModule': , 'VariableManager': , ...}" >>> hr(refs[3]) '[, ]' >>> hr(refs[4]) "{'_cid_to_cs': {}, '_mesgen': , '_tcpch': , '_upward_inmsg_handler': }" >>> hr(refs[5]) "{'_DELAY': 600, '_attrs': {'_commstratseqno': 0, '_lastannouncedcommstratdict': None}, '_commstratseqno': 0, '_cryptol': , '_dirty': None, '_fname': '/home/zooko/playground/.mojonation//broker/mtmdb/P0e0Is12KvUN6HI4aAvwyjJgiVA/TCPListener.pickle', ...}" >>> hr(refs[6]) '' >>> hr(refs[7]) '' >>> hr(refs[8]) '' The first response is the answer I expected. The second and third might be some local or global scope dict or some other Python guts that I don't understand. But the remaining six entries are data structures from my code which do *not* refer to the object in question, and curiously those six data structures (or ones like them -- I'm not sure) are *always* returned from any call to gc.get_referents()! The second bug is that about once every few hours of use, get_referents() seg faults. I think it might be more likely to do that when I have a larger collection of objects in memory -- maybe the time to traverse the larger set of objects reveals a race condition? I'm running gc.get_referents() in an interactive interpreter while several threads are simultaneously working and mutating the data! Also some of those threads are using native code which might be failing to DECREF properly. I would be rather interested in digging into the implementation of get_referents() myself, but first I'd like to hear from the Pythonistas whether these bugs are surprising or unsurprising, whether the code has been changed since 2.2b2, if there is any sort of "starting point" for digging into it that they recommend, etc. Thanks! Zooko http://zooko.com/ [1] http://mojonation.net/ From gmcm at hypernet.com Sat Nov 10 16:50:32 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Sat, 10 Nov 2001 16:50:32 -0500 Subject: [Import-sig] Re: Proposal for a modified import mechanism. In-Reply-To: <033301c16a1a$59c1c690$c300a8c0@ericlaptop> Message-ID: <3BED5AD8.24350.78407262@localhost> eric wrote: [Frederic Giacometti] > > because the obvious reason of increased name space collision, > > increased run-time overhead etc... > > I'm missing something here because I don't understand why this > increases name space collision. Currently, os.py in a package masks the real one from anywhere inside the package. This would extend that to anywhere inside any nested subpackage. Whether that's a "neat" or a "dirty" trick is pretty subjective. The wider the namespace you can trample on, the more it tends to be "dirty". > If the objection is to the fact > that SciPy can have a version of Numeric in it that masks a > Numeric installed in site-packages, I guess I consider this a > feature, not a bug. Afterall, this is already the behavior for > single level packages, extending it to multi-level packages seems > natural. If this isn't your objection, please explain. Well, it's a feature that can crash Python. If the package (which the user has, and you have a hijacked, incompatible copy of) contains an extension module, all kinds of nasty things can happen when both are loaded. Submit patches to the package authors, or require a specific version, or write a wrapper that adapts to different versions or fork or do without. This is definitely a dirty trick. > The current runtime overhead isn't so bad. Under anything near normal usage, no - packages structures are nearly always shallow. It wouldn't be much work to construct a case where time spent in import doubled, however. When the "try relative, then try absolute" strategy was introduced with packages, it added insignificant overhead. It's not so insignificant now. When (and if) the standard library moves to a package structure, it's possilbe it will be seen as a burden. - Gordon From michael at rcp.co.uk Fri Nov 2 07:29:52 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 2 Nov 2001 12:29:52 +0000 (UTC) Subject: MemoryError under 2.2b1 References: <1004688073.78898@lix-049dz-008.inside.impress.com> Message-ID: "wtr" wrote in news:1004688073.78898 at lix-049dz- 008.inside.impress.com: > The following little script ends in a MemoryError > > hello world! > Traceback (most recent call last): > File "C:/Python22/HelloWorld.py", line 4, in ? > for j in range(99999999,1000000001): > MemoryError > > There seems to be a strange dependancy between the two range parameters; > ranges (99999999,100000000) and (999999999,1000000099) work. Well, 1000000001 - 99999999 = 900000002 100000000 - 99999999 = 1 1000000099 - 999999999 = 100 Another clue: range() allocates the entire list before returning (you might prefer to use xrange() if appropriate). Allocating a list containing 900000002 entries uses at least 3.6GB. If your machine could handle this I'd be mightily impressed! From jeff at ccvcorp.com Fri Nov 30 13:57:00 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 30 Nov 2001 10:57:00 -0800 Subject: Copy operator (was list.remove for Noivces) References: Message-ID: <3C07D67C.EAF16E64@ccvcorp.com> "Delaney, Timothy" wrote: > > From: Jeff Shannon [mailto:jeff at ccvcorp.com] > > > > Just as a minor point, the quoted section above was written > > by Art Siegel, not > > by me. I don't think any confusion has resulted, and I'm not > > really worried > > about being misattributed, just wanted to clarify this for > > the record. :) > > It's not misattributed! Look at the indentation! What it says is that Art > says that Jeff wrote nothing, and then Art said something else. Ah, well, that makes perfect sense then, since whatever I say (or type), it's usually equivalent to nothing in the end. ;) Jeff Shannon Technician/Programmer Credit International From luruguaya at yahoo.com Tue Nov 13 12:25:24 2001 From: luruguaya at yahoo.com (Lu Ruguaya) Date: 13 Nov 2001 09:25:24 -0800 Subject: COM server created with py2exe fails if CLSCTX_INPROC_SERVER Message-ID: <30f17542.0111130925.713c2aa5@posting.google.com> I tried Thomas Heller's example changing _reg_clsctx_ to pythoncom.CLSCTX_INPROC_SERVER (his example uses CLSCTX_LOCAL_SERVER) It registers OK, but when I tried to use it from a VB client I get the following error: "Unexpected Python Error: exceptions.AttributeError: '__main__' module has no attribute 'HelloWorld' If I use LOCAL_SERVER, then it works like a champ. It obviously relates to the code: if hasattr(sys, 'importers'): # In the py2exe-packed version, specify the module.class # to use. In the python script version, python is able # to figure it out itself. _reg_class_spec_ = "__main__.HelloWorld" Any suggestions? Lu Ruguaya (Thomas code can be found in: http://groups.google.com/groups?hl=en&rnum=3&selm=9eag5l%241muh3%241%40ID-59885.news.dfncis.de) From rnd at onego.ru Mon Nov 5 03:40:15 2001 From: rnd at onego.ru (Roman Suzi) Date: Mon, 5 Nov 2001 11:40:15 +0300 (MSK) Subject: python-mode for Emacs 21.1? Message-ID: Is there python-mode for Emacs 21.1? (My old one for 20.5 doesn't compile correctly, it seems) I wonder why python-mode not in standard Emacs distro... Sincerely yours, Roman A.Suzi -- - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru - From weismana at cs.bgu.ac.il Sun Nov 11 09:04:10 2001 From: weismana at cs.bgu.ac.il (amit weisman) Date: Sun, 11 Nov 2001 16:04:10 +0200 Subject: HTTP proxy variable Message-ID: <000801c16ab9$bd5f2db0$e62a4884@mas1115b> Hi How does one change the http proxy and ftp proxy of a user ? Thanks Amit -------------- next part -------------- An HTML attachment was scrubbed... URL: From mikael at isy.liu.se Wed Nov 7 09:05:01 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 07 Nov 2001 15:05:01 +0100 (MET) Subject: And Now for Something Completely Different! (was: Monty Pyth In-Reply-To: <%oaG7.3490$U07.169147@atlpnn01.usenetserver.com> Message-ID: On 07-Nov-2001 Steve Holden wrote: > "Fredrik Lundh" wrote in message > news:F1YF7.5270$Z_1.857034 at newsc.telia.net... > > Gary Stephenson wrote: > > > We here downunder have just always claimed him as one of our own > > > > like ABBA? > > > Does this mean alt.bonzer.bozos.australia? Rather -What was before A-teens? /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 07-Nov-2001 Time: 15:04:02 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From mwh at python.net Fri Nov 16 06:39:30 2001 From: mwh at python.net (Michael Hudson) Date: Fri, 16 Nov 2001 11:39:30 GMT Subject: [Q] Printing color strings on stdout without using escape sequences ? References: <3BF4F588.9010500@edf.fr> Message-ID: Ivan DUTKA-MALEN writes: > Hello, > > for my application to be a bit more friendly, I want to show some > colored strings on the standard output but I don't want to use ugly > escape sequence like '\033[1m;' or so... > > I'd prefer use a module (if one exists) that encapsulate all those > things and that allows me to be portable on various Unix-like systems > (especialy Linux, Solaris, HP-UX, IRIX). > Does anyone know such a module ? > > For information, I tried to use curses but I think it doesn't make > what I want in the sense that it uses the full screen and I just want > to use the standard output stream. I may be wrong and I surely misuse > it. Some help will be much appreciated :-)). You can use bits of the curses module -- setupterm, tigetstr, tparm, putp, specifically. Try this: >>> import curses >>> curses.setupterm() >>> curses.putp(curses.tparm(curses.tigetstr("setaf"), 1)); \ ... print "this is in red" this is in red You'll need Python 2.1 or newer, and you'll probably be wanting to wrap this up in something nicer. HTH, M. -- The meaning of "brunch" is as yet undefined. -- Simon Booth, ucam.chat From James_Althoff at i2.com Thu Nov 8 16:58:17 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 8 Nov 2001 13:58:17 -0800 Subject: iters on ints? (reducing the need for range/xrange) Message-ID: Now that the issue of transfinite cardinals has been fully resolved, isn't it time for yet another unpopular-and-non-pythonic suggestion? I believe it is. What if (in post-2.2) Python the tp_iter slot in the int type was defined to return an xrange-like iterator such that one could do the following: for i in 10: doSomething(i) or, more realistically, for rowIndex in table.getRowCount(): doSomething(rowIndex) instead of having to do the range(table.getRowCount()) thingie (or xrange, if one prefers)? (Following, here, the lead of the 2.2 mechanism for handling sequences in for loops, etc.) Fancy stuff could still be done with "range", of course. (I never do fancy stuff), Jim ps. Or we could have another long thread about possible new syntax for "1..10". Or, explore ideas on the connection between Python and the continuum hypothesis. From dalke at dalkescientific.com Tue Nov 13 14:10:10 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 12:10:10 -0700 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> <9srbs8$pur$1@slb2.atl.mindspring.net> Message-ID: <9srr3l$3v7$1@slb6.atl.mindspring.net> Marco Antoniotti: >Historical cruft? The evolution of the languages have been different. >The presence of strong vendors in the CL camp does (IMHO) work as a >disincentive to community wide standardization. Interesting. So by *not* having a strong advocacy for Python, there isn't the urge to have multiple competing implementations, so Python can keep developing new 'standard' libraries? I like that approach -- less arguments and more code :) [Seeing that you didn't cross-post to c.l.lisp ..] I always seemed to me too easy to make new Lisps, and many of the people doing Lisp argue for esthetic purity, which leads to the large number of variations in the language. Python has always felt more pragmatic, and pragmatically speaking it's easier to have one standard, reference platform from which other implementations derive, rather than through a language spec. >As for "widely used though non-standard libraries for CL for "doing >stuff like internet programming", you can check the CLOCC >(http://sourceforge.net/projects/clocc). Not much, but it is there. I know little about CL systems, which is why I quoted the original statement from someone else. Andrew dalke at dalkescientific.com From rjroy at takingcontrol.com Mon Nov 12 13:48:34 2001 From: rjroy at takingcontrol.com (Robert Roy) Date: Mon, 12 Nov 2001 18:48:34 GMT Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: <3bf01850.1296461609@news1.on.sympatico.ca> PythonWin and Tkinter do not play nicely together. See: http://www.python.org/topics/tkinter/trouble.html under windows gotchas Bob On Mon, 12 Nov 2001 17:38:08 GMT, "Dave Butler" wrote: >I recently began exploring Tkinter programming. I built the following >program based on similar code in a book: > >from Tkinter import * > >top = Tk() > >quit = Button(top, text='Quit', command=top.quit) >quit.pack() > >mainloop() > > >This simple "app" opens fine and closes when run from a command prompt >(under Win2000). However, when run from PythonWin (win32all build 140) the >app does not close and a few clicks later PythonWin crashes with a MS Visual >C++ runtime error ("abnormal program termination"). > >Any explanations? Is PythonWin a stable platform for using Tkinter? > >Thanks, > >Dave > > From jdavis at empires.org Mon Nov 19 23:51:53 2001 From: jdavis at empires.org (Jeff Davis) Date: Mon, 19 Nov 2001 20:51:53 -0800 Subject: Try block problem Message-ID: <9tcnls$42k$1@news1.ucsd.edu> It seems like the following makes sense to me: try: ... except: ... finally: ... I know it doesn't work, my question is: why? Is it difficult to implement in python? Does it promote some kind of "bad coding"? Is there a logical flaw (i.e. maybe it doesn't make sense in all contexts)? I know that Ruby has it implemented similarly with begin...rescue...ensure, which brings another question: does every language make new keywords for the same concept of exceptions, or are they different somehow? Regards, Jeff From tjreedy at home.com Thu Nov 22 10:30:46 2001 From: tjreedy at home.com (Terry Reedy) Date: Thu, 22 Nov 2001 15:30:46 GMT Subject: question on __dict__ References: Message-ID: "Markus Jais" wrote in message news:pan.2001.11.22.12.52.34.97867.2869 at web.de... > can somebody tell me, what the difference is between > > self.__dict__('foo') = 'bar' > and > self.foo = 'bar' The second translates to the first *UNLESS* there is a .__setattr__() method. This is what you should usually use. Within a __setattr__() method, you *SHOULD* use the first form -- unless you want your program to get caugth in an infinite loop. (Not sure of impact of 2.2 changes on above statements.) Terry J. Reedy From db3l at fitlinxx.com Thu Nov 15 19:03:30 2001 From: db3l at fitlinxx.com (David Bolen) Date: 15 Nov 2001 19:03:30 -0500 Subject: Threading References: Message-ID: Thomas Jensen writes: > Thank you for the detailed explanation, I guess the reason I asked was > that I didn't quite know how the GIL worked. > I thought that perhaps the for loop would lock the specific list for > modification. The more I think about it, the more unreasonable it > seems. Especially since the lock is global, it would not only block > access to the list. > > I'll keep up the paranoia :-) You might also want to do some google searching since there have been some discussions recently that cover this in more detail. In particular, the "Critical sections and mutexes" thread, which discusses this and includes some opposing viewpoints in terms of being able to be more trusting of the thread-safety of the interpreter. I think this URL will get you to the thread (not sure if it can be simplified) - it's all one line: http://groups.google.com/groups?hl=en&threadm=mailman.1003864103.32304.python-list%40python.org&rnum=1&prev=/groups%3Fq%3Dg:thl4080539814d%26hl%3Den%26selm%3Dmailman.1003864103.32304.python-list%2540python.org Worse case searching for the subject should do it. Looking for GIL or global interpreter lock will probably turn up other references as well. -- -- David -- /-----------------------------------------------------------------------\ \ David Bolen \ E-mail: db3l at fitlinxx.com / | FitLinxx, Inc. \ Phone: (203) 708-5192 | / 860 Canal Street, Stamford, CT 06902 \ Fax: (203) 316-5150 \ \-----------------------------------------------------------------------/ From konkurs at pexim.net Thu Nov 1 18:05:59 2001 From: konkurs at pexim.net (PEXIM) Date: Thu, 1 Nov 2001 15:05:59 -0800 Subject: POTREBNI PROGRAMERI Message-ID: <9rs6r5$lne$46@cer.yubc.net> TRAZIMO WEB PROGRAMERE Neophodno je: Iskustvo u radu sa HTML (notepad) Iskustvo u radu sa Javascript jezikom Pozeljno je: Iskustvo u radu sa ASP (PHP) Poznavanje XML I XSLT Poznavanje jezika C Poznavanje ASP.NET Vozacka dozvola WINDOWS PROGRAMERE Neophodno je: Iskustvo u radu sa Borland Delphi alatom Iskustvo u radu sa SQL bazama Znanje engleskog jezika Pozeljno je: Iskustvo u radu sa jezicima Pascal i C Poznavanje PC hardvera Vozacka dozvola Konkurs je stalno otvoren. U CV navedite formalno obrazovanje, kurseve, samostalne i timske projekte, reference i kontakt telefon za zakazivanje razgovora. Kontakt: Mail: konkurs at pexim.net Tel: 011/3015131, 3015132 Informacije: http://www.pexim.net From nico.hartmann at daimlerchrysler.com Thu Nov 29 01:53:44 2001 From: nico.hartmann at daimlerchrysler.com (Nico Hartmann) Date: Thu, 29 Nov 2001 07:53:44 +0100 Subject: decoding floats References: <9u2buq$jo9$1@news.sns-felb.debis.de> Message-ID: <9u4lqh$gc7$1@news.sns-felb.debis.de> > > Hi there, > > > > I look for a way to decode and encode float values into byte arrays. > > >>> import array > >>> a = array.array('f') > >>> a.append(42.42) > >>> a.tostring() > '\x14\xae)B' > > Something like this? Yes, that would do. I figured out using the stuct.pack from struct package also works fine: import struct bytes = struct.pack("d", 34.34) Regards, nico From emile at fenx.com Mon Nov 5 09:12:33 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 5 Nov 2001 06:12:33 -0800 Subject: Sequenced dictionaries References: Message-ID: <9s670v$11gimb$1@ID-11957.news.dfncis.de> "Morten W. Petersen" wrote in message news:Pine.LNX.4.21.0111051436400.21948-100000 at bcryachts.atsat.com... > Hi, > > I'm wondering if there exists any C-based implementations of sequenced > dictionaries, i.e. dictionaries that will remember the order of the > objects 'added' on it. > > I have a pure python implementation [1] but suspect that it will be > too slow.. Note that in 2.2 you'll be able to do the following: Python 2.2a2+ (#22, Sep 5 2001, 14:10:41) [MSC 32 bit (Intel)] on win32 Type "copyright", "credits" or "license" for more information. >>> class seqdict(dictionary): def __init__(self): self.seq = [] dictionary.__init__(self) def __setitem__(self, ky, val): self.seq.append((ky, val)) dictionary.__setitem__(self, ky, val) >>> d = seqdict() >>> d[3] = 3 >>> d[2] = 2 >>> d[1] = 1 >>> d['c'] = 1 >>> d['b']=2 >>> d['a']=1 >>> d.seq [(3, 3), (2, 2), (1, 1), ('c', 1), ('b', 2), ('a', 1)] >>> d {'a': 1, 1: 1, 2: 2, 3: 3, 'b': 2, 'c': 1} >>> Although dictionary wil be renamed dict for the final release. -- Emile van Sebille emile at fenx.com --------- From husalwan at sci.kun.nl Sat Nov 10 09:06:03 2001 From: husalwan at sci.kun.nl (husam) Date: Sat, 10 Nov 2001 15:06:03 +0100 Subject: data structures versus data bases??? Message-ID: <3BED344B.5050703@sci.kun.nl> hi, im trying to learn programming with python. one of the things confusing me is the difference between data structures and data bases. so, can you tell me what the difference is between them? thanks in advance. From klaus_momberger at yahoo.com Sat Nov 17 05:13:54 2001 From: klaus_momberger at yahoo.com (Klaus Momberger) Date: 17 Nov 2001 02:13:54 -0800 Subject: Databases References: <200111161329.fAGDTiv17156@smtp.wineasy.se> Message-ID: <5fa34dc2.0111170213.98d577c@posting.google.com> "Gustavo Campanelli" wrote in message news:... > I?m trying to access a database from python. Where should I look for > documentation about using python as interface for MySQL or PostgreSQL? Of > course, that is under Linux. > > Gdc > You can compile Postgresql with Python support (configure --with-python) which builds a module that is loadable from Python. -klaus. From benoitcerrina at hotmail.com Mon Nov 12 21:49:46 2001 From: benoitcerrina at hotmail.com (Benoit Cerrina) Date: Tue, 13 Nov 2001 03:49:46 +0100 Subject: client server, c files References: <01111302002607.00632@linux> <01111309323600.00630@linux> Message-ID: Looking at Jonathan Gardner python module I wondered: This may be a good time to ask why is there a if_xcmdsrv.c and no if_w32cmdsrv.c with all the client server code fow windows folded in os_mswin.c? Benoit From geert at cs.uu.nl Tue Nov 13 04:49:32 2001 From: geert at cs.uu.nl (Geert-Jan Giezeman) Date: 13 Nov 2001 09:49:32 GMT Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> <9sl98i$bjs$1@nntp9.atl.mindspring.net> Message-ID: <9sqqbc$dp4$1@samos.cs.uu.nl> In <9sl98i$bjs$1 at nntp9.atl.mindspring.net> "Matt Gerrans" writes: >> I have an idea, but considering the fact that I just learned python >> yesterday, it probably won't help... > >That comment made me chuckle. (actually, it is pretty impressive that you >learned Python yesterday and are already answering questions -- you must be a >quick learner!) Well, this is my first serious python program, so all help is appreciated. >As for the original post, my personal opinion is that with this much data, it >is time to consider using a database. Or at the very least, you should come >up with a scheme to manage and partition in to multiple smaller chunks. Even >if it worked with shelve module, wouldn't the performance be pretty awful? > >The PyWin database modules are pretty handy and the dbm module can be used on >Unix platforms. I don't know about other platforms, though. There might be >even better database access available... > >Even if you don't use a database, if all you are storing is a bunch of floats, >you don't even need shelve. It is easy enough to write them to (and read >from) a file on your own with a loop, isn't it? The performance of shelves was pretty good. In fact, that was a reason why I used them. I use the shelve in a cgi script in which I need just one of the 1100 lists, depending on a parameter. I would rather not read all data in. Of course, I could have solved this by having 1100 files, one for each list, but I did not take that road initially (and it worked for smaller values). What does also work, I discovered, is using a btree (bsddb.btopen) instead of a shelve (a hash table). I used marshal (instead of pickle) to get smaller strings. This leads to a file of only 47 MB (even containing two extra strings with every float). Thanks everyone who provided answers. From skip at pobox.com Thu Nov 1 12:29:33 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 11:29:33 -0600 Subject: map, filter, reduce, zip, range, and.. slice? In-Reply-To: References: <3bdf39a6@news.bezeqint.net> <9rrp5f$37r$1@scotsman.ed.ac.uk> Message-ID: <15329.34429.690016.203225@beluga.mojam.com> George> Eddie's solution in the lambda notation... George> divide = lambda x,s=1: [ x[i:i+s] for i in range(0,len(x),s) ] ... George> Love them lambdas... Just out of curiosity, what's the advantage you perceive of lambda over def divide(x, s=1): return [ x[i:i+s] for i in range(0,len(x),s) ] in this situation? -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From dhaaron at hotpop.com Wed Nov 14 01:32:51 2001 From: dhaaron at hotpop.com (Aaron Sterling) Date: Wed, 14 Nov 2001 06:32:51 GMT Subject: may be a dumb question,but I can't understand why? Message-ID: <1103_1005719571@t4q4p0> > the following function is in bpnn.py > def makeMatrix(I, J, fill=0.0): > m = [] > for i in xrange(I): > m.append([fill]*J) > return m > > I rewrite it to : > def makeMatrix(I, J, fill=0.0): > m=[[fill]*J]*I > return m > the result is defference > Can someone tell me the defference between the two function? it seems to work alright on my machine. I defined a function to test it to arbitrary parameters without a proplem. def test(max): i = j = 0 for i in xrange(max): for j in xrange(max): if makeMatrix(i, j) != makeMatrix2(i, j): print i, j Aaron, dhaaron at hotpop.com From phr-n2001d at nightsong.com Sun Nov 4 16:30:19 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 04 Nov 2001 13:30:19 -0800 Subject: Q: Feature Wish: "%" Extension References: Message-ID: <7xsnbu9qc4.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > > Knuth says to use floor_mod? Where? > > Knuth *defines* x mod y as being x - y * floor(x/y), way back in volume 1. > It simply has the nicest properties when x and y are ints and y > 0. Yes, x mod y is usually defined that way. However, "x remainder y" doesn't necessarily mean the same thing. The question then is whether % in a programming language should denote "mod" or "remainder". > > Every CPU that I know of uses trunc_mod (your 1st variant). > > A great many CPUs have no "mod" instruction at all; most with an integer > division instruction truncate, possibly due to an unfortunate feedback loop > involving early Fortran <0.7 wink>. All integer division instructions I've seen give separate quotient and remainder results, with remainder==trunc_mod. > > Floor_mod makes more sense for a lot of things. I can't help > > thinking there must be a reason for all the implementations > > using trunc_mod, but I don't know what it might be. > > Why do almost all PC keyboards have a giant CAP LOCKS key where the CTRL key > ought to be? It's not really because they wanted to trick Sun keyboard > users (or, at least, I hope not ). > > traditionally y'rs - tim From johnroth at ameritech.net Fri Nov 16 00:41:03 2001 From: johnroth at ameritech.net (John Roth) Date: Thu, 15 Nov 2001 21:41:03 -0800 Subject: PEP proposal: enhanced string functions References: Message-ID: "Dale Strickland-Clark" wrote in message news:kks7vtois5dp8a5gs2rspn9ge3qqof27k4 at 4ax.com... > I don't think you can have too much string processing help. > > Without it you are frequently left with character-level manipulation > and code that starts to resemble assembler in detail. > > That said, you can achieve an awful lot with cunning use of re and %. Yea, right. Some of us have other things to do than become experts in obscure things you can do with regular expressions. John Roth From fog at debian.org Tue Nov 13 20:22:53 2001 From: fog at debian.org (Federico Di Gregorio) Date: Wed, 14 Nov 2001 02:22:53 +0100 Subject: psycopg 1.0 released Message-ID: hi everybody and welcome to psycopg 1.0, after eight months of work Michele and Federico are pleased to release the 1.0 version of the psycopg Python/PostgreSQL/Zope database driver. previous releases (especially the 0.99.x series) were already stable for a lot of people but only now, after plugging every memleak, after fixing every segfault, after scratching every itch, psycopg is absolutely ready for the one-dot-oh release. applause, please... :) psycopg can be downloaded from: http://initd.org/Software/psycopg/ have fun, federico what you get with psycopg 1.0 ----------------------------- * very fast python/posgresql database driver, optimized for heavy multithreaded applications (very fast means that several people have reported many-fold speedups when switching to psycopg, and in real world situations, not benchmarks); * stability. a lot of people have run with it for weeks without a single problem. unplug the database or kill the connection, psycopg will just raise an exception, rollback and go back to work. * complete (and we mean 100% complete) DBAPI 2.0 compliance; * DBAPI extensions: per-cursor commits, isolated cursors, user-defined typecast objects (postgresql->python), lastoid() function and other goodies; * complete translation of postgresql date, time, timestamp and interval types to eGenix (http://www.egenix.com/) mx DateTime and DateTimeDelta objects. * Zope database adapter (ZpsycopgDA); * stability (have I already said that?) what is missing from 1.0 ------------------------ * documentation: we are working on two guides, one about DBAPI 2.0 programming and one about psycopg itself. both will be released in a future psycopg release. * regression test: much needed to be sure the development branch does not remove features or introduce new bugs. * how zpsycopgda should treat intervals is still dubious. until we make a decision you'll get strings if using Zope's DatTime or DateTimeDelta objects if using mx's. From qrczak at knm.org.pl Sun Nov 4 14:06:44 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Sun, 4 Nov 2001 19:06:44 +0000 (UTC) Subject: Q: Feature Wish: "%" Extension References: <7xy9lmmmx7.fsf@ruckus.brouhaha.com> Message-ID: 04 Nov 2001 10:05:40 -0800, Paul Rubin pisze: > Knuth says to use floor_mod? Where? Concrete Mathematics, and AFAIR not only there. > I can't help thinking there must be a reason for all the > implementations using trunc_mod, but I don't know what it might be. I don't understand the reason. Floor_mod was always the more natural version for me. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From ens_z at yahoo.com Sat Nov 24 07:04:19 2001 From: ens_z at yahoo.com (Ens) Date: 24 Nov 2001 04:04:19 -0800 Subject: getting string parameterz in pyd Message-ID: <39ce62b8.0111240404.1a952eeb@posting.google.com> i have a problem in getting a string parameter with PyArg_ParseTuple(args, "s", &s) // s is (char*) length of string is unknown and i want to get strings of any length. From tim at vegeta.ath.cx Tue Nov 13 21:50:33 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 14 Nov 2001 02:50:33 GMT Subject: Python Vim Module - works References: Message-ID: Andrei Kulakov graced us by uttering: [ snip ] >> $ gvim --servername TEST >> $ python >>>>> import vim >>>>> vim.list() >> ['TEST'] >>>>> vim.send('TEST', 'iHello World!') >> >> You should see the string "Hello World!" neatly typed into the newly opened >> vim window!!! > > I'm sorry if this is a dumb question, but what's the purpose of this? Jonathan wrote an extension module for Python that can access each instance of gvim on an X display from _outside_ of vim. Vim can also be compiled to use Python and/or Perl as an internal scripting language, and the Python engine has a builtin module called 'vim' that grants access to vim internals (buffer lists, lines of buffers, etc.) As this module is useful but unavailable outside of vim, Jonathan wrote his own. Or did I misunderstand your question? Tim Hammerquist -- No violence, gentlemen -- no violence, I beg of you! Consider the furniture! -- Sherlock Holmes From dcinege at psychosis.com Wed Nov 21 02:42:28 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Wed, 21 Nov 2001 02:42:28 -0500 Subject: Non-Indented python In-Reply-To: <20011121000734.48b85dde.sthiyaga@operamail.com> References: <9sbd8i$680$1@wanadoo.fr> <3BFB34A9.565BBF2E@engcorp.com> <20011121000734.48b85dde.sthiyaga@operamail.com> Message-ID: On Wednesday 21 November 2001 0:56, you wrote: > On Tue, 20 Nov 2001 23:59:21 -0500 > On UNIX, > > col -x < infile > outfile > > will replace all tabs with spaces. using -b will do the reverse. Rule of God: The punishment for non-tab based indentation is death. Everyone is hereby commanded to use '-b'...however what you probably really want to do is regex 's/ /\t/' a file. (4 spaces -> tab) This seems to be the most common evil. Dave -- The time is now 22:37 (Totalitarian) - http://www.ccops.org/ From bmstroh at cavtel.net Thu Nov 29 19:25:30 2001 From: bmstroh at cavtel.net (Brent Stroh) Date: Thu, 29 Nov 2001 19:25:30 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> Message-ID: Roy Smith wrote: >Although we do not enforce it with locked checkouts, we really prefer to >work in the "one person editing a file at a time" mode. If we ever go to >check a file back in and discover it's got changes to merge from somebody >else's work, we generally consider that a problem, and at the very least, >manually verify that the merged changes make sense. As you should. CVS doesn't know anything about C++, Java, whatever. It merges text files, regardless of the contents. A tool is not a substitute for a development process, or for understanding of what a piece of code should be doing. From wesc at yahoo.com Fri Nov 9 14:50:49 2001 From: wesc at yahoo.com (Wesley J. Chun) Date: 9 Nov 2001 11:50:49 -0800 Subject: Teaching python (programming) to children References: Message-ID: Renaming this fork off the thread to: "Teaching Python (programming) to Teachers" Kids are young, flexible, and easily impressioned, so teaching kids isn't the only topic involved with this subject. In order to make kids' learning effective, it must also come with the supporting infrastructure, meaning teachers and courseroom materials. We must first teach the teachers! They will be the ones who are passing on this knowledge to our children, and so that should be the first step. We cannot take it for granted that all teachers are like Jeff E., Sheila K., or Tim W. :-) If we can achieve this, that will facilitate learning on a more effective level. I wonder if there are any such technology training requirements for those going after teaching credentials in a math/science discipline. Anyone know? Anyway, I have proposed a continuing education course for teachers which has a goal of teaching teachers the basics of programming (using Python of course) to those who have little or no background in programming at all. I made this pitch to UC Santa Cruz out on the California central coast and at this time, is currently under review. I have not made this proposal elsewhere yet, as i also have a full-time job! :-) Finally, there has to be effective teaching materials for the classroom, both for teachers and for students. Concepts must be taught at the same time as "language syntax." The more effective programming languages are those, of course, whose syntax does NOT get in the way of learning the concepts. Python, Scheme, and BASIC are some of the better choices in that area. And like some of the other postings i've seen, you DON'T have to reveal *everything* that Python has to offer. just start with a small subset and move from there. anyway, those are my $0.02 for now. -wesley - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "A computer never does what you want... only what you tell it." "Core Python Programming", Prentice Hall PTR, December 2000 http://starship.python.net/crew/wesc/cpp/ wesley.j.chun :: wesc at yahoo.com cyberweb.consulting :: silicon.valley, ca http://www.roadkill.com/~wesc/cyberweb/ From mmillikan at vfa.com Fri Nov 2 15:34:50 2001 From: mmillikan at vfa.com (mmillikan at vfa.com) Date: 02 Nov 2001 15:34:50 -0500 Subject: Underscore data hiding (was python development practices?) References: Message-ID: Your cat is not fixed? From horatio at qpsf.edu.au Mon Nov 12 18:13:48 2001 From: horatio at qpsf.edu.au (Horatio Davis) Date: Tue, 13 Nov 2001 09:13:48 +1000 (EST) Subject: Scientific Libraries in Python In-Reply-To: <9sp7mv$pje$1@peabody.colorado.edu> Message-ID: On Mon, 12 Nov 2001, Fernando [ISO-8859-1] P?rez wrote: > To avoid unnecessary duplication, it might be worth considering a > SciPy/Scientific/whatever system to be based on something like the GSL. GSL seems impressively rich in functionality, and would certainly fill gaps that need filling. Now, how to match impedance between GSL blocks and Numeric arrays? > - The GSL guys specifically mention a wrapper-friendly design of their > project. So maintaining the python interface shouldn't be all that hard > (famous last words...) This would be PyGSL at pygsl.sourceforge.net? Cheers, AHD From sandskyfly at hotmail.com Sat Nov 10 07:15:56 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 10 Nov 2001 04:15:56 -0800 Subject: Using browser as interface to python app Message-ID: Hi Pythonistas, I've just been prototyping a simple multi-threaded internet news monitor and have gotten to the point where I need to make a decision about the direction(s) the user interface might take: I've ruled using wxPython and Tkinter as I think a GUI is overkill, however I'm intrigued by the possibility of running a simple local webserver which would serve a set of webpages (with checkboxes, text fields, etc..) directly to a browser which would then allow the user to interact with the running python app. I thought about using CGIHTTPServer in the Standard Lib but its use of forking doesn't make sense for Windows. OTOH, I'm also sure that there's a COM way to do this somehow, but I'd really like to try to make the end app as portable as possible. Another consideration is distribution footprint...(we wouldn't want the user to have to download and set up apache :-) Any tips, pointers, advice whatsoever on this topic would be greatly appreciated. Thanks in advance, Sandy Norton FYI: I'm using Internet Explorer 5.0 and python 2.1.1 on win2K From mikael at isy.liu.se Wed Nov 21 10:10:27 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Wed, 21 Nov 2001 16:10:27 +0100 (MET) Subject: dictionary-question In-Reply-To: <20011121151855.B24412@kub.nl> Message-ID: On 21-Nov-2001 Bas van Gils wrote: > Hi, > > I just found some dictionary-behavior that I don't quite understand: > > Python 2.1.1 (#1, Nov 3 2001, 19:19:22) > [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> foo = {} > >>> type(foo.get("bar",0)) > > >>> foo.get("bar",0) += 1 > SyntaxError: can't assign to function call > > My current "workaround" is this: > > >>> if foo.has_key("bar"): > ... foo["bar"] += 1 > ... else: > ... foo["bar"] = 1 > ... > >>> foo > {'bar': 1} > > Now, can someone please explain why the > > foo.get("bar",0) += 1 > > won't work ... and what might be a better sollution then my current > workaround? I will not try to explain why. I guess it has to do with the fact that the result of foo.get("bar",0) is never bound to any name. However, if it was legal, it still would not do what you want it to do. In case it was legal, I suppose it would be equivalent to temporaryVar = foo.get("bar",0) temporaryVar += 1 del temporaryVar and the entries of foo would not be affected, regardless of if foo['bar'] was defined before or not. Greetings /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 21-Nov-2001 Time: 16:01:55 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From emile at fenx.com Thu Nov 1 10:29:45 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 1 Nov 2001 07:29:45 -0800 Subject: question regarding dictionaries References: <9rrp75$qai@r02n01.cac.psu.edu> Message-ID: <9rrq3g$vg494$1@ID-11957.news.dfncis.de> "Rajarshi Guha" wrote in message news:9rrp75$qai at r02n01.cac.psu.edu... > Hi, > I have a question regarding dictionaries. When I compare them as > > if (dict1 == dict2): > print 'ok' > > Where dict1 and dict2 shoudl have the same key and corresponding key values. > It seems to work. Is it meant to work, or am I just being lucky. > Yes. (...it's meant to work ;-) > And secondly why won't thjis work: > > for i,j in list1,list2: > #do something with i and j > try: for i,j in zip(list1, list2): -- Emile van Sebille emile at fenx.com --------- From sheila at spamcop.net Sat Nov 10 01:38:33 2001 From: sheila at spamcop.net (Sheila King) Date: Sat, 10 Nov 2001 06:38:33 GMT Subject: Teaching python (programming) to children References: Message-ID: <9shleq.3vv84ln.1@kserver.org> On Sat, 10 Nov 2001 00:42:57 -0500, "Arthur Siegel" wrote in comp.lang.python in article : :My deepest objection - and why I'm consistently nasty when :getting near this subject - is that it always seems to be the tool in play :< LOGO/MindStorm/Alice, etc and etc> and its creators/advocates :that are hogging center stage. And off in the corner somewhere is :the happy student, and somewhere backstage, a subject matter. : :God, I'm tired of going around in this circle. If you were in the classroom working with students, this wouldn't be important at all. At least, for me, it never was. In a way, it is nice for people to be out there expounding on their pet theories and pet methods. At least if they are vocal enough about it, the educator may become aware of them, and hopefully several alternatives. Then it is up to the educator to decide what to implement in the classroom. For years I taught AP Calculus, and the "reform" and "graphing calculators" are all the rage, and proofs are down, and algebraic manipulation is down. But I listened to all of this. I got copies of the reform textbooks. I participated in the mailing lists on this topic. I went to the workshops and conferences. And then I went off, alone, to my own corner, and decided what, if any, of this stuff I wanted to incorporate into my course, and how I wanted to present the material in my classroom. I don't see why this "circle" would bother any classroom practitioner at all. Because teachers really do get to decide what they want to do, to a large extent, when they go into their classroom with their students and close the door. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From mlh at idi.ntnu.no Fri Nov 2 12:42:33 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Fri, 2 Nov 2001 18:42:33 +0100 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> Message-ID: <9rulu9$n2m$1@tyfon.itea.ntnu.no> "Oleg Broytmann" wrote in message news:mailman.1004711703.24605.python-list at python.org... [snip] > And after you've modified it - do you have > rights to distribute it to your friends? I hope you are not claiming that what you said above is something peculiar to Free (as in Gnu/FSF) Software? It would also apply to Open Source software. (And, yes, people would be allowed to make non-open-source software based on it, and _that_ software might not be free in any sense.) > Information have to be free. Without it we are all but slaves of our > governments and megacorporations. Information have to be available, > modifiable and redistributable. Especially source code of programs, because > programs and microchips are now everywhere. > > Oleg. It seems you are working well with the PSU here. I must really From mkelly2002 at earthlink.net Tue Nov 20 22:59:59 2001 From: mkelly2002 at earthlink.net (Michael Kelly) Date: Tue, 20 Nov 2001 22:59:59 -0500 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <9sp8ht$obt$1@tyfon.itea.ntnu.no> <3BF3378B.8030205@altavista.com> Message-ID: On Thu, 15 Nov 2001 03:38:59 GMT, modman wrote: >apparently this script relys on the programer of the other language to >write good readable code so that it looks a bit like python indentation >in the first place. I've been checking out Python and already there are many things I like about it, but I'm starting to get paranoid about indentation issues with code pasted out of other scripts. Seems when the parser takes it into its head that "expecting indented block at line #" when it sure as hell looks indented, it gets into a thing where there's no way other than retyping lots of stuff and praying to get it to parse the code. Is there a utility to "clean" foreign scripts so that tabs/spaces issues and other stuff invisible to the programmer can be weeded out? I mean, it would save a lot of time if I could stick some Begin .. Ends or {} delimiters in the script and move on to what I'm trying to do or at lease mark a block and "clean" it so I'd know there'd be and end point to messing with lines that have no apparent syntactic errors(and are aligned, at least to the naked eye.) I guess I'm bumming out 'cause there's so many things I like about Python, esp how easy it is to use home grown ActiveX .ocx with events and stuff, that I'm thinking there's gotta' be a "gotcha" and so far indentation looks like it in this case. :) What do you guys use esp. when cutting and pasting snippets from other files etc.?? Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From loewis at informatik.hu-berlin.de Wed Nov 14 08:16:01 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 14 Nov 2001 14:16:01 +0100 Subject: Python .elc and /etc/magic References: Message-ID: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) writes: > Here is the Python relevant code in the copy from Linux SuSE 7.2. We found that adding # MAGIC as specified in Python/import.c # 60717 ( YEAR - 1995 ) + MONTH + DAY (little endian followed by "\r\n" 0 belong 0x2ded0d0a python (2.2) compiled # 60202 ( YEAR - 1995 ) + MONTH + DAY (little endian followed by "\r\n" 0 belong 0x2aeb0d0a python (2.1) compiled # 50823 ( YEAR - 1995 ) + MONTH + DAY (little endian followed by "\r\n" 0 belong 0x87c60d0a python (2.0) compiled will help. > And even, if one knows the proper incantations, how do we proceed then > for having that `/etc/magic' file more universally modified? We'll make a Debian bug shortly, and make sure it is propagated upstream. Regards, Martin From michael at rcp.co.uk Fri Nov 30 07:25:31 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 30 Nov 2001 12:25:31 +0000 (UTC) Subject: Non-Indented python References: Message-ID: Nicholas FitzRoy-Dale wrote in news:mailman.1007091520.21435.python-list at python.org: > On 29 Nov, Tim Peters wrote: > >>> get some wierd error, eventually think to check for tabs. >> >> Don't you run Python with -tt? > > This at least solves my problem. I had never noticed -tt. > Is there a global option (I'm on WinNT) to make -tt the default? P.S. Where is this documented? I can't see any documentation of command line parameters in any of the standard documentation (ref.ps, lib.ps, etc) I have, so I presume that Python -h is all I've got to go on. There doesn't seem to be an environment variable which can pre-set command line options, so I'll have to do something more tricksy to get -tt set by default. Finally, when -t refers to "inconsistent tab usage", what exactly does this mean? I would really like something like to treat tabs (and indeed all non-printing characters except for space and newline) as syntax errors wherever they appear in the source. From usenet at jeffjohnson.net Fri Nov 16 10:15:39 2001 From: usenet at jeffjohnson.net (Jeff Johnson) Date: 16 Nov 2001 07:15:39 -0800 Subject: Python seg faults with M2Crypto Message-ID: The following script causes "Segmentation fault (core dumped)" on FreeBSD 4.3, Python 2.1.1, M2Crypto all from the ports tree. Can anyone else reproduce this? -Jeff class X: def _submit(self, dict, headers=[]): """ Given a dict of form variables, make the HTTPS POST. """ import urllib from M2Crypto import httpslib, SSL ## only until python 2 comes out data = urllib.urlencode(dict) h = httpslib.HTTPS(self._secureServer) h.putrequest('POST', "/" + self._securePage) h.putheader('Content-type', 'application/x-www-form-urlencoded') h.putheader('Content-length', '%d' % len(data)) for head in headers: h.putheader(*head) h.endheaders() h.send(data) errcode, errmsg, headers = h.getreply() assert errcode==200, \ "problem reading from %s: %s, %s" \ % (self._secureServer, errcode, errmsg) fp = h.getfile() content = "" chunk = "start" while len(chunk) != 0: chunk = fp.read() content += chunk fp.close() return content x = X() x._secureServer = "secure.authorize.net" x._securePage = "gateway/transact.dll" d={"x_Test_Request": "TRUE"} h=[] #for i in range(20): print x._submit(d, h) From jdadson at ix.netcom.com Fri Nov 2 19:54:06 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 03 Nov 2001 00:54:06 GMT Subject: search path Message-ID: <3BE33EB9.F7A9F629@ix.netcom.com> I R'd the FM, but I can't figure it out: How do I set the search path Python uses to find modules? The documentation that came with Python says it uses an enviornment variable named PYTHONPATH. What kind of environment variable? I'm running this under Windows (spit!). I looked under Settings/Control Panel/System/Environment, but I found no variable named PYTHONPATH in either the user variables or system variables. Yet, Python is finding a path somewhere, because I can view it by typing sys.path in the Python console window. It contains stuff it could not have known about before I installed Python on my machine. I tried adding a Windows (spit!) system variable called PYTHONPATH, but it had no effect. Jive From daves_spam_dodging_account at yahoo.com Mon Nov 19 17:08:52 2001 From: daves_spam_dodging_account at yahoo.com (David Brady) Date: Mon, 19 Nov 2001 14:08:52 -0800 (PST) Subject: printing without spaces Message-ID: <20011119220852.89545.qmail@web21101.mail.yahoo.com> Hello, I'm trying to print a list of information programmatically. Using 'print i,' doesn't quite work the way I'd like because the , seems to inject a space between arguments. Is there a way to do this with print? Thanks Here's a sample of what I'm talking about: >>> for i in range(3): for j in range(10): print "%d%d" % (i,j), print 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 I'd like the output to be 00010203040506070809 10111213141516171819 20212223242526272829 Thank you, -dB ===== David Brady daves_spam_dodging_account at yahoo.com I'm feeling very surreal today... or *AM* I? __________________________________________________ Do You Yahoo!? Find the one for you at Yahoo! Personals http://personals.yahoo.com From prabhu at aero.iitm.ernet.in Tue Nov 13 04:11:11 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 13 Nov 2001 14:41:11 +0530 Subject: Scientific Libraries in Python In-Reply-To: <9sp7mv$pje$1@peabody.colorado.edu> References: <9sp7mv$pje$1@peabody.colorado.edu> Message-ID: <15344.58287.155971.156169@monster.linux.in> hi, >>>>> "FP" == fperez528 writes: FP> The first major release of the GNU Scientific Library is now FP> available for general use. FP> The GNU Scientific Library (GSL) is a free numerical library FP> for C programmers. The routines have been written from FP> scratch by the GSL team in ANSI C. They present a modern API, FP> allowing wrappers to be written for very high level languages. FP> The library includes a 450-page reference manual and is FP> distributed under the GNU General Public License. Yes, the GSL sounds terrific and has a very detailed manual, but its license might be a problem. SciPy is distributed under a BSD like license so i dont think it would be possible to use a GPL'd library and extend it to be used in a non-GPL framework. However, IANAL, and am pretty ignorant of all the ramifications of all these licenses. :( prabhu From timr at probo.com Sat Nov 24 00:56:45 2001 From: timr at probo.com (Tim Roberts) Date: Fri, 23 Nov 2001 21:56:45 -0800 Subject: Simple (I think) regex question References: Message-ID: Michael Kelly wrote: > >I've used Perl quite a bit, but am very new to Python, and am still getting >used to things. I'm not sure if I'm explaining this correctly or clearly, >but here goes: > >My question is this: In a sub(), how do set the replacement string to be as >long as the first matched substring? (i.e., the len() of \1). You'll have to do this in two steps. Do the match; it will return the start and length of the match. You can use that information to do the replacement. Many "magic" perl constructs take longer to spell in Python. Plus, you'll find that the perl habit of thinking about every problem in terms of regular expressions often produces sub-optimal results in Python. However, there is usually a way to look at the problem in terms of lists that produces a more Python-like solution. -- - Tim Roberts, timr at probo.com Providenza & Boekelheide, Inc. From aeoo at myspamrealbox.com Fri Nov 2 18:13:21 2001 From: aeoo at myspamrealbox.com (Leo Lipelis) Date: Fri, 02 Nov 2001 18:13:21 -0500 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> <3mxE7.5808$gl5.151284@atlpnn01.usenetserver.com> Message-ID: On Fri, 02 Nov 2001 08:42:42 -0500, Steve Holden wrote: > "Leo Lipelis" wrote ... [...] [plenty of horseshit snipped] > because open can raise several exceptions which this statement fails to > handle. Yup, that's horseshit all right. Just as a matter of interest, > what would be your "approved" alternative for the above one-liner? Sorry > if my response comes off as aggressive, which isn't in the spirit of > this newsgroup. I'm actually trying to teach you something here! > > didn't-realise-i-cared-so-much-ly y'rs - steve -- > http://www.holdenweb.com/ > After whittling down my reply to bare essentials, all I am left with is: You're an ass. There. I've tought you more and in fewer words. ;) From rxg218 at psu.edu Thu Nov 22 11:38:30 2001 From: rxg218 at psu.edu (Rajarshi Guha) Date: Thu, 22 Nov 2001 11:38:30 -0500 Subject: Using Numeric arrays to store different datatypes Message-ID: <9tj9jq$sm4@r02n01.cac.psu.edu> Hi, Is it possible to store say a list variable in a Numeric array? Or even a class in a Numeric arry? -- ------------------------------------------------------------------- Rajarshi Guha | email: rajarshi at presidency.com 152 Davey Laboratory | web : www.rajarshi.outputto.com Department of Chemistry | ICQ : 123242928 Pennsylvania State University | AIM : LoverOfPanda ------------------------------------------------------------------- GPG Fingerprint: DCCB 4D1A 5A8B 2F5A B5F6 1F9E CDC4 5574 9017 AF2A Public Key : http://pgp.mit.edu/ ------------------------------------------------------------------- Heisenberg may have been here. From husalwan at sci.kun.nl Mon Nov 12 08:58:51 2001 From: husalwan at sci.kun.nl (husam) Date: Mon, 12 Nov 2001 14:58:51 +0100 Subject: data structures versus data bases??? References: <3BED344B.5050703@sci.kun.nl> <3BED54C2.1010608@sci.kun.nl> Message-ID: <3BEFD59B.9000709@sci.kun.nl> John Roth wrote: > "husam" wrote in message > news:3BED54C2.1010608 at sci.kun.nl... > > >>yes, i understand the general defenition of data bases and of data >>structures. i should in fact put the question like this: >>is a given dictionary or list of a set of data, a data base? >> >> > > In some respect, it depends on your point of view. All of the > data structures quoted in the previous articles in the thread > are in fact collections with different access policies. Data bases > are also collections with different access policies (SQL being > by far the most popular one). > > I normally think of a data structure as an abstract description > of a way to organize a collection, a collection as a concrete > example of a data structure with specific data that is in > memory, and a data base as something that is managed > by an external piece of software, called a 'data base > manager.' > > John Roth > > > ok, the thing that i can make up from this discussion is that the difference between data base and data structures (list, dicts and tuples) lies in the usage policy. i mean data access and data manipulation methods differe, but they might resemble each other by the way data is organized. to be more specific, i have builed a small application to manage my audio cds. i made two programs in the first one i stored the cds and programs in lists. the length of main_list represent cd numbers, and each cd number is a list of the names of the audio tracks in that cd. in this program i can manipulate the items in any way i desire. in the second program i organized the cds and the audio tracks in dictionaries. to go back to the subject and according to what i understood i can now call my application is a data base program, or my cds are organized in a data base! right? From db3l at fitlinxx.com Fri Nov 30 18:26:58 2001 From: db3l at fitlinxx.com (David Bolen) Date: 30 Nov 2001 18:26:58 -0500 Subject: popen with separete stdout/stderr deadlock. References: <3c069454@news.bezeqint.net> <831yifvqy8.fsf@panacea.canonical.org> Message-ID: Kragen Sitaker writes: > Eyal Lotem writes: > > When running popen with a separate stdout/stderr, can I use read() on the > > resulting stdout file? it seems to 'hang', and I'm assuming stderr's buffer > > is stuck on write (as it is all filled up), and my stdout read() is stuck > > on waiting for EOF, which will never come. Deadlock. > > > > Is this really what's happening and how can it be avoided? > > Could be. import select and use select.select to avoid it. Or if you're under Windows (where you can't select on a file handle), one classic solution is to multi-thread so you can drain (or feed) all the handles simultaneously. You can still create a deadlock if you incorrectly synchronize your threads and re-create dependencies but in general it's fairly easy to work around. -- -- 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 jicondon at us.ibm.com Tue Nov 13 14:35:38 2001 From: jicondon at us.ibm.com (dW) Date: 13 Nov 2001 11:35:38 -0800 Subject: Web Services and Python articles Message-ID: Below are some IBM developerWorks article on Web Services developement with Python. The Python Web services developer: Part 1: The world of Python Web services This article presents an overview and survey of tools and facilities available for Web services development in Python. This includes built-in Python features and third-party open-source tools. http://www-106.ibm.com/developerworks/library/ws-pyth1?open&l=968,t=grws,p=pws1 The Python Web services developer, Part 2: Web services software repository, Part 1 Creating a software repository system built on Web services and developed in the Python programming language. Mike Olson shows you the details of using the 4Suite open-source XML server with Python to create Web service-based applications. http://www-106.ibm.com/developerworks/library/ws-pyth2?open&l=968,t=grws,p=pws2 The Python Web services developer, Part 3: Web services software repository, Part 2 Example of a Web service for storing and managing software. http://www-106.ibm.com/developerworks/library/ws-pyth3?open&l=968,t=grws,p=pws3 The Python Web services developer, Part 4: Web services software repository, Part 3 Building a software repository implemented as a Web service. http://www-106.ibm.com/developerworks/library/ws-pyth4?open&l=968,t=grws,p=pws4 The Python Web services developer, Part 5: Python SOAP libraries Discussion the various SOAP implementations available for Python, giving detailed code examples. http://www-106.ibm.com/developerworks/library/ws-pyth5?open&l=968,t=grws,p=pws5 From claird at starbase.neosoft.com Wed Nov 28 09:35:20 2001 From: claird at starbase.neosoft.com (Cameron Laird) Date: 28 Nov 2001 08:35:20 -0600 Subject: Two questions about Python.. References: <3BF99E55.2C300858@hotmail.com> <83r8qj6gi8.fsf@panacea.canonical.org> <124312AFE15AC2A7.3108D1F50CF59A6C.A4102B9233F78776@lp.airnews.net> <3C045ACA.C336DEFA@engcorp.com> Message-ID: <2A896DD3A63C8A6D.D3436B3D2D396F10.8DA95B74A64C0556@lp.airnews.net> In article <3C045ACA.C336DEFA at engcorp.com>, Peter Hansen wrote: >Cameron Laird wrote: >> >> Kragen Sitaker wrote: >> >Ville Vainio writes: >> > >> >> Ken writes: >> >> > I'm looking into using Python for a project, and was wondering how does >> >> > Python rank up against other scripting languages for speed? >> > >> >It's about as fast as Perl, much faster than Tcl or sh, and much >> >slower than Lua, a good Scheme, FORTH, or GhostScript, in my >> >experience. HTH. >> >> And it depends, of course, on the kind of project of interest. >> Numeric makes Python a world-beater for many problems, for >> example. > >Cameron, can you confirm that by this you mean that for >intensively numeric-processing-bound programs, the Numeric >package effectively makes Python a *higher* performance >solution than most/all other solutions? Or were you talking >more about features and ease-of-use, for example? . . . Thank you, Peter, for this opportunity to clarify. "Both" is my answer to your nicely-leading question, although I had the former in mind when I first posted: old-line "scientific" programs, which are bound by speed of numeric processing, are certainly not "much slower" in Numeric Python than even "a good Scheme" or Lua, and are frequently faster. I write this as a fan of Scheme and Lua. I also recognize that I don't have as much recent experience with scientific programming as some readers; I'm reasonably confident that I'm working from trustworthy data, though. -- Cameron Laird Business: http://www.Phaseit.net Personal: http://starbase.neosoft.com/~claird/home.html From pieroul at attglobal.net Sun Nov 4 15:14:31 2001 From: pieroul at attglobal.net (Pierre Rouleau) Date: Sun, 04 Nov 2001 15:14:31 -0500 Subject: Command shell access within Python References: <3BE582C6.7D8C450B@attglobal.net> Message-ID: <3BE5A1A7.75C7EC9C@attglobal.net> Thanks for taking the time to answer Stefan. > > I also need to get the return code (c exit()) of the program that ran. > os.system() gives you the return code of your command. > try interactively: > > import os > > print os.system('ls') > > ... listing ... > 0 <-- return code Actually, i knew that i can execute a single program inside a command shell and get the return code. What i want is to execute a large set of commands inside the same shell process and being able to get the return code for exach one of the calls. For example, i would like to be able to do someting like: myShell = Process('cmd') error = myShell.execute('make myproject') if (error == 0) : myShell.execute('ls') myShell.execute('pj ci makefile') I want to be able to issue a whole list of line commands whithout having to create a new process on every one of them. Pierre From s713221 at student.gu.edu.au Fri Nov 9 17:16:00 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Sat, 10 Nov 2001 08:16:00 +1000 Subject: Matrix in Python . References: <9sglpt$a3r$1@news.tpi.pl> <3BEC22AE.AAA58F3@ccvcorp.com> Message-ID: <3BEC55A0.440CEE05@student.gu.edu.au> Jeff Shannon wrote: > > Nomad wrote: > > > You mean Python is going to take over the world and keep living people > > in vats of goo? > > What do you think the PSU has been doin Naaah. The PSU has a more secret agenda. They're secretly using their time machine to go back into the past, and using a python-brain interface, uploading everyone's minds into bot analo Traceback (most recent call last): File "FreeWill.py", line 10001, in 100023404050 RealityError: Attempt to reference PSU-bound data in a reality-distorting manner. Software agent being reset to default. -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From peoter_veliki at hotmail.com Thu Nov 22 06:58:08 2001 From: peoter_veliki at hotmail.com (Peoter Veili) Date: Thu, 22 Nov 2001 03:58:08 -0800 Subject: Indenting with tabs vs spaces Message-ID: > >Tabs are wrong, because different editors will treat them differently. > > > >Spaces are right, because a space is a space is a space, everywhere you > >go. Indenting with tabs can be done such that it will look the same on every editor that uses fixed-width fonts, meaning everything will line up correctly, it least in the sense that really matters. Here's an example of what I mean: function helloThere("hello", "there"){ } The proper way to do this is the second line needs to be typed with one tab followed by enough spaces to line up the "hello" and "there". This way the "hello" and "there" will line up correctly on any editor. If the person was lazy and tabbed all the way out to right before "there" and then filled in with a few spaces, it may not line up depending on what your tabwidth is set to. Besides this I know of no problems with using tabs. I find them cleaner and more efficient. I'd rather tab 10 times than hit the space bar 40 times. I never have to go through a whole file and manually line things up because at one place in the file I accidentally didn't indent with the right amount of spaces and half the file needs fixing. Auto-indent helps, but still.... From peter at engcorp.com Thu Nov 1 00:59:44 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 01 Nov 2001 00:59:44 -0500 Subject: Why 'self' ? References: Message-ID: <3BE0E4D0.23179E68@engcorp.com> Tim Peters wrote: > > Depending on who you ask, Python 1.6 was the fabled incompatible Python > 3000. Some "hard" incompatibilities are scheduled for version 3, including > a change in the meaning of integer division (to be optional in 2.2), and > likely a facelift for some of the monsters lurking in the dark corners of > types and classes. > > plus-llambda-will-be-spelled-with-two-els-ly y'rs - tim Hmm... do we have to pronounce it as in Spanish? Sounds like a sweet potato to me... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From dlakelan at sil-no.spam-con.com Thu Nov 15 20:47:06 2001 From: dlakelan at sil-no.spam-con.com (Daniel Lakeland) Date: Thu, 15 Nov 2001 17:47:06 -0800 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> <7xhervy3v9.fsf@ruckus.brouhaha.com> Message-ID: In article <7xhervy3v9.fsf at ruckus.brouhaha.com>, "Paul Rubin" wrote: > "Daniel Lakeland" writes: >> On a similar type of program I worked on in CMUCL it would run plenty >> fast at home on my 233 MHz PII and then when I took it to work and ran >> it on a 400 Mhz Sparq or something like that, it would be a dog. >> >> Turned out that consing was a big problem, and the x86 had a >> generational collector, whereas the Sparq had a mark-sweep. > > CMUCL uses different GC's on different platforms? Or do you mean you > were using CMUCL on one box and a different CL on the other? Yes CMUCL uses (or used in Feb 2000) different GC's on different platforms. -- Daniel Lakeland dlakelan at endpointcomputing.com http://www.endpointcomputing.com From qrczak at knm.org.pl Fri Nov 9 18:51:58 2001 From: qrczak at knm.org.pl (Marcin 'Qrczak' Kowalczyk) Date: Fri, 9 Nov 2001 23:51:58 +0000 (UTC) Subject: iters on ints? (reducing the need for range/xrange) References: <7xzo5v34pt.fsf@ruckus.brouhaha.com> Message-ID: 09 Nov 2001 15:27:26 -0800, Paul Rubin pisze: > The trouble is as someone else noted, "for i in 10" replaces "for i in > range(10)". But how do you handle range(1,10)? By writing 'range(1,10)'. Similarly as 'for x in dict' is a shortcut for 'for x in dict.iterkeys()' and 'for x in dict.iteritems()' must be written explicitly. -- __("< Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/ \__/ ^^ QRCZAK From michael.g.abbott at ntlworld.com Mon Nov 5 13:42:45 2001 From: michael.g.abbott at ntlworld.com (Michael Abbott) Date: Mon, 05 Nov 2001 18:42:45 GMT Subject: Problem formatting Python docs with MikTeX References: <66e0420f.0111051008.11b30844@posting.google.com> Message-ID: luecking at uark.edu (Dan Luecking) wrote in news:66e0420f.0111051008.11b30844 at posting.google.com: > > It would seem you have two choices: > ... > 2. Use a command line option. Quoting from the MiKTeX 2.1 manual: > The command-line option --include-directory=folder allows > you to extend the input search path for one invocation of TeX. Aha! I should have spotted that (I can't find *anything* in Windows help file format documents...) > I can't immediately check if this option was available before version > 2.1. Well, 2.1 will do just fine for me, thanks very much! From sholden at holdenweb.com Mon Nov 19 14:30:44 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 19 Nov 2001 14:30:44 -0500 Subject: Cookies References: Message-ID: "David A McInnis" wrote ... > I want to read the values of a cookie that was placed on my computer by a > web site. I opened it up and it appears to be encoded. Is there anyway to > decode the values? > A "good" cookie will simply be a random value used as a key to access information stored on the server. There is no general scheme to find out what information a cookie represents, though a poor use of cookies might make information visible on the client side. Where are the cookies coming from? regards Steve -- http://www.holdenweb.com/ From nospam at bigfoot.com Tue Nov 27 07:11:21 2001 From: nospam at bigfoot.com (Gillou) Date: Tue, 27 Nov 2001 13:11:21 +0100 Subject: Perl to Python References: Message-ID: <9tvvgu$1vmn$1@norfair.nerim.net> You should consider to use a python DB API 2.0 compliant service to handle your OpenLink connection. I'm sure that a package like mxODBC (said to support any OpenLink driver) will shorten your code significantly... http://www.lemburg.com/files/python/ It's a commercial package but you can use it for free in a non commercial environment. Querying your database is just easy as... import ... mycnx = mxODBC.connect(host='myhost', database='mydb', user='me', password='xxx') crs = mycnx.cursor() crs.execute('select id from mytable where name='bob') bobid = crs.fetchone()[0][0] This is a more "pythonic" way to do the job an changing your database to something else (say MySQL on your local host) will require few change. HTH --Gillou From phr-n2001d at nightsong.com Fri Nov 2 15:24:48 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 12:24:48 -0800 Subject: Underscore data hiding (was python development practices?) References: Message-ID: <7x4rocj4z3.fsf@ruckus.brouhaha.com> "Tim Peters" writes: > > However, I would definitely be wary of making my code depend upon > > something like the name-mangling scheme, > > I don't expect it will change (although new gimmicks may be added). > > > which is clearly a hack > > Guido didn't think so (and every complaint ever made about it was made at at > least once before it was implemented, so the odds of a compelling new > argument are approximately nil). > > > and actually seems a likely place to see a future change. > > That's only because you think it's a hack . Python *used* to have an > "access" keyword, implementing an elaborate name-visibility scheme of the > kind some people favor. Guido dislike it so much he never documented it, > and eventually ripped out all the code in support of it (making "access" the > only keyword ever removed). I'd like to make the argument for removing the name mangling scheme from the language specification document. It's fine to leave it in the implementation and it can be described in an implementation note. But if someone writes a new Python implementation they shouldn't be required to do it the same way, if they can find some alternative way to resolve collisions. "Portable" (across Python implementations) applications shouldn't depend on name mangling working the way it does. From keyton at weissinger.org Sat Nov 17 23:26:00 2001 From: keyton at weissinger.org (A. Keyton Weissinger) Date: Sat, 17 Nov 2001 23:26:00 -0500 Subject: Speed Comparisons: Python vs Java In-Reply-To: <2a6e94ef.0111170759.5fe7027a@posting.google.com> Message-ID: I've seen some Java/Python comparisons, but none that show side by side performance tests of any real depth. Has anyone seen any? If so, where? Thank you. Keyton From jeff at ccvcorp.com Wed Nov 7 17:15:03 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 07 Nov 2001 14:15:03 -0800 Subject: Teaching python (programming) to children References: <9s9qie$rer$1@news.lth.se> <9savp2$5t1$1@news.lth.se> <9sbui9$d7k$1@news.lth.se> Message-ID: <3BE9B267.77BCDF7A@ccvcorp.com> David Andreas Alderud wrote: > Yes, but then, aren't we supposed to teach programmers how the computers > work? Or am I just a relic of the ancient world of bits, shifts and > rotations. Except that, the whole idea of CP4E and teaching programming languages to all (or most) schoolchildren, is that most of these students will *never* become programmers. They will do other things, but will benefit from having some idea of how to program a computer. Programmers will still need to know the details of how a computer works, but they'll pick that up later on (as they learn other languages, and advanced data structures, and so on). But to the person who's just trying to write a script to, say, generate a catalog of all the mp3 files on his computer, it really doesn't *matter* how many bits a given integer requires, or the difference between a simple linked list and a red/black tree, or... To use an automotive analogy, we're teaching kids to be able to change the oil on their computers, not how to rebuild the transmission. :) And even if they later go on to learn how to rebuild that transmission... they'll still benefit from already knowing how to change the oil. Jeff Shannon Technician/Programmer Credit International From carole_valentin at yahoo.fr Fri Nov 2 03:58:37 2001 From: carole_valentin at yahoo.fr (=?iso-8859-1?q?carole=20valentin?=) Date: Fri, 2 Nov 2001 09:58:37 +0100 (CET) Subject: Problem with imported variable Message-ID: <20011102085837.63194.qmail@web14105.mail.yahoo.com> Christopher Barker wrote: >carole valentin wrote: >> I have a little question: >> I have 2 classes "Class1" and "Class2" and several >> functions in each class. The Class1 is in the file >> "File1" and the Class2 is in another file "File2". >> At the beginning of the File1, I import the File2: >> from File2 import * >> >> In the Class2, I create a variable with a specific >> value. When the program is running, I modify the >> value of this variable in the other class (Class1) >> and then I want to read the new value of the >> variable farther in the code of the Class2. >> The problem is that the value does not change in the >> File2 (Class2). Moreover, as the 2 classes are not >> in the same files, the global statement does not >> change the problem. >> Does someone have an idea? >> Thanks for your help! > > Someone else may be able to figure out what you want > to do, but I'm lost. Try posting a very small > version of your attempt to do what you > want, and we'll probably be able to help you. Here is a very small version of the program: # ------- File1.py ------- global var var = 2 print "var1 = ", var # => var1 = 2 from File2 import * class Class1: def function1(self): global var var = 3 print "var3 = ", var # => var3 = 3 first_class = Class1() first_class.function1() second_class = Class2() second_class.function2() print "var6 = ", var # => var6 = 3 , But I would like that var6 = 4 !!! # ------- File2.py ------- from File1 import var # if I don't put this line, it says that the variable var does not exist print "var2 = ", var # => var2 = 2 class Class2: def function2(self): global var print "var4 = ", var # => var4 = 2 , But I would like that var4 = 3 !!! var = 4 print "var5 = ", var # => var5 = 4 # ----------------------- Shankar wrote: >Actually, I too faced the same problem today. >I struggled for nearly an hour. >If I all code in the same file, >everything seems to work. But, in the >name of modularity, when I tried to split my code >neatly into 2 different classes, variables of class2 >set by methods of class2, but accessed from methods >of class1 seem not to get updated. That is exactly my problem !!! Carole. ___________________________________________________________ Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en fran?ais ! Yahoo! Courrier : http://courrier.yahoo.fr From fperez528 at yahoo.com Sun Nov 18 10:53:32 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 19 Nov 2001 15:21:32 +2328 Subject: Numercial Reduction question References: Message-ID: <9tc0q7$lih$1@peabody.colorado.edu> > For example, I might have a 31 by 12 array (days by months) of > data. Some cells have a special value in them to denote that there is > no data for that day (either it's an invalid date, or there was no data > for that day). I want to be able to collapse along the day axis (31) to > create monthly data, say summing the values, or averaging the > values. I just mentioned masked arrays. But if you don't have fancy requirements, just using where might do: In[1]:= x=array([1,2,3,-99,4]) In[2]:= sum(x) Out[2]= -89 In[3]:= sum(where(x==-99,0,x)) Out[3]= 10 cheers, f From syver-en at online.no Mon Nov 26 03:04:15 2001 From: syver-en at online.no (Syver Enstad) Date: 26 Nov 2001 09:04:15 +0100 Subject: Return value for popen? References: <3c01e2bc$0$13482$afc38c87@news.optusnet.com.au> Message-ID: "nobody" writes: > Is it possible to get a process' return (errorlevel) value from popen, as it > is with os.system()? Yes, it returns None when everythings ok, errorlevel in other cases, see the python docs -- Vennlig hilsen Syver Enstad From kseehof at neuralintegrator.com Sat Nov 10 06:50:13 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Sat, 10 Nov 2001 03:50:13 -0800 Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> <8ZXG7.5723$Yh.305712@atlpnn01.usenetserver.com> Message-ID: <01a501c169df$346bfb80$4b4bb43f@kens> > > He is probably asking you which C library your version of Python was > > compiled with. But you don't need to know that, either. > > > > All Python dictionaries are a standard 2.5 cm by 3.6cm. Integers have no > > width and are all 1.2 cm in length. Strings are all 2 mm times the number > of > > characters, except Unicode strings, which are 4 mm times the number of > > characters. > > could you explain further about the metric standard you're using. this is > the first time a size of data structure is measured using meters instead of > byte/bit. > i need the information for my post-mortem of my assignment to explain why > using python data structure would be efficient. yes, i'm only a studemt who > is still need to learn lots of stuffs. > thanks. Okay, so everyone's explained why you don't care what the answer to your question is :-). Actually, the size of a data structure does sometimes matter, specifically when you are dealing with particularly huge quantities of data. For example, python genetic molecular simulators usually store the entire human genome in a dictionary in memory. Don't they? :-) It is generally more difficult to analytically figure out memory usage in python than in c, so what I do in this kind of situation is do the empirical thing. >>> def makedict(x): ... d = {} ... for i in xrange(x): ... d[random.randint(100,1000000000)] = random.randint(100,1000000000) ... return d >>> a = makedict(1024*1024) >>> b = makedict(1024*1024) >>> del a >>> del b >>> ... etc.... By watching my memory monitor, I determined that the dictionary costs about 32 bytes per entry (give or take a byte). It doesn't really matter much what the bytes are used for, but if you are in the mood to get analitical... #define PyObject_HEAD \ int ob_refcnt; \ struct _typeobject *ob_type; A python object is 8 bytes plus data. That's 12 bytes per integer (note that integers are 0 bytes for -3 < n < 100). I'd expect the hash table to cost about 3 pointers per entry for a well-balanced hash table. That's 12 bytes. So an entry in our dictionary (2 integers and a hash index entry) should be 36 bytes. So, I'm wondering, where'd the extra four bytes go? (well maybe I'm just being sloppy...) Remember to multiply all of your results by 2.7 mg/farad. - Ken Seehof kseehof at neuralintegrator.com From mail at andreas-penzel.de Tue Nov 13 13:04:14 2001 From: mail at andreas-penzel.de (Andreas Penzel) Date: Tue, 13 Nov 2001 19:04:14 +0100 Subject: input Message-ID: <9srncp$15ljf7$1@ID-69142.news.dfncis.de> Hello NG! I am new in the world of python. First I made some Tuturials, but what I could not find: How to get an input from the console? for example: the program starts, givs some prints on the screen and now I want an input from the user like this: print "please type your name:" the input should get into to a variable like user_input = ??? I hope I could explain the problem, that everyone can follow my minds. - Andreas From phd at phd.pp.ru Thu Nov 1 07:48:52 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 15:48:52 +0300 Subject: Monty Python (was: Freeware Python editor) In-Reply-To: ; from sholden@holdenweb.com on Thu, Nov 01, 2001 at 07:39:31AM -0500 References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> Message-ID: <20011101154852.B675@phd.pp.ru> On Thu, Nov 01, 2001 at 07:39:31AM -0500, Steve Holden wrote: > [Makes note to remember that Oleg isn't a Monty Python viewer.] Few years ago I tried to view the scetches - there was Russian translation of them on TV - but found them stupid and boring. Well, I was in bad mood those days, may be now I'd find it more interesting :) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From peter at engcorp.com Mon Nov 26 19:06:18 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 26 Nov 2001 19:06:18 -0500 Subject: smtplib help References: Message-ID: <3C02D8FA.CC569C3D@engcorp.com> David A McInnis wrote: > > Actually, I am using imail from IPSWITCH. Anyway, it was a speed issue. > When I called time.sleep(2) from the time module giving me a 2 second sleep, > I was able to process the messages. > > I don't like being able to send only one msg every 2 seconds. Any help > would be appreciated. Very likely you are misinterpreting the situation. time.sleep() is a wonderful "solution" if you want to work around a problem, but it rarely really addresses the root cause. There are many types of problem which you might think are time-related because adding delays makes the problem go away (or hide, or move), but this is often misleading. (Threading issues are a great example.) In this case, the underlying operating system (Windows) is eventually releasing the unused sockets to you can use them again. This takes some time, but it is probably shorter than 150 times 2 seconds (5 minutes), or it would not have "solved" the problem by doing this. Take the time.sleep() back out and find a real solution, or live with it for a while as you get other things working to your satisfaction, then come back later. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From guuge at localhost.localhost Mon Nov 19 10:23:17 2001 From: guuge at localhost.localhost (guuge) Date: 19 Nov 2001 15:23:17 GMT Subject: something Evil happens when large hashes destroyed References: <9t8m1c019qd@enews1.newsguy.com> <3BF7F1CB.AD30E469@earthlink.net> Message-ID: <9tb8550vqq@enews1.newsguy.com> On Sun, 18 Nov 2001 17:37:03 GMT, Hans Nowak wrote: > guuge wrote: >> >> I was trying to sort about 100,000 items by splitting them into >> groups (using a python dictionary type) and then successively splitting >> these groups until they were small enough to use a brute force method. >> >> My test program, which used only two or three keys to create the first >> split, worked fine. When I tried the real thing, using 256 keys, the >> program slowed to a crawl. The python interpreter took forever to >> destroy the dictionaries. >> >> Here's a little program that will place X number of elements into >> Y number of bins and gives the time used to do the placement and >> the time used to destroy the dictionary. >> > [snip snip] > > Interesting... on my box, a P3/900 with 128 Mb, the dicts are destroyed > faster when I use more keys. Low numbers of keys result in long > destruction times. > > For 100,000 elements, I always get a creation time of 2 seconds, and > the following destruction times: > 20 keys: 61 seconds > 34 keys: 24 seconds > 60 keys: 8 seconds > 256 keys: 3 seconds > > Of course, this could have been timed better, by using a larger set than > 100,000. Maybe some other time... > > It seems, the larger the dicts, the more time it takes to destroy it. > In other words, if N elements are distributed over a lot of small > dict, the total destroy time is a lot lower than when they are > distributed over a few large dicts. Maybe this makes sense for people > who know the C implementation of the dict... (I don't. :-) > > Anyway, my guess is that if you use a lot of keys, the total destroy > time should be lower... correct? I suppose more keys would make destroy time take a bit longer, but it would seem natural that an increase in destroy time would be gradual. The wierd thing is that as you slowly increase keys (1 -> 2 -> etc..) at some point the destroy time makes a huge jump from a few seconds to a few minutes. btw, compiling the python interpreter with pymalloc solved the problem. I guess it's a linux libc issue. From mlh at idi.ntnu.no Sun Nov 4 08:28:18 2001 From: mlh at idi.ntnu.no (Magnus Lie Hetland) Date: Sun, 4 Nov 2001 14:28:18 +0100 Subject: Freeware Python editor References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9rulu9$n2m$1@tyfon.itea.ntnu.no> Message-ID: <9s3fpj$978$1@tyfon.itea.ntnu.no> "DeepBlue" wrote in message news:tu5nijl8b4kr25 at corp.supernews.com... > > "Magnus Lie Hetland" wrote in message > news:9rulu9$n2m$1 at tyfon.itea.ntnu.no... > > "Oleg Broytmann" wrote in message > > news:mailman.1004711703.24605.python-list at python.org... > > [snip] > > > And after you've modified it - do you have > > > rights to distribute it to your friends? > > > > I hope you are not claiming that what you said above is something peculiar > > to Free (as in Gnu/FSF) Software? It would also apply to Open Source > > software. (And, yes, people would be allowed to make non-open-source > > software based on it, and _that_ software might not be free in any > > sense.) > > > This is contested. check the issue with Virtual Dub. An open source > project. > Someone used the code to produce an **unopen application. Virtual Dub guy > does not like and he is threatening to sue. > What you describe is called theft. No, it's called OpenSource. (Take Python as an example.) Virtual Dub is Free Software in the GNU sense -- it's governed by the GPL, which is exactly the issue. That's _not_ what I was talking about. > DeepBlue -- Magnus Lie Hetland The Anygui Project http://hetland.org http://anygui.sf.net From sill at sill.silmarill.org Mon Nov 26 01:19:48 2001 From: sill at sill.silmarill.org (Andrei Kulakov) Date: Mon, 26 Nov 2001 06:19:48 GMT Subject: A newbie that needs some HELP References: Message-ID: In article , The News wrote: > First background on me. Since you'll probably be seeing me here alot. :) > > Ok. I bought a new computer this week and found..... (lo and behold while I > was erasing the useless gunk manufacturers load 'for' you) it was > pre-installed with Python v2.1.1. > > So I think to myself, "Cool! I've been wanting to get back into > programming." Now, I do a little research on the web and find out what this > "Python" is. I see that I like it alot as far as languages go (and I dig > the Monty association ), so I D/L a web tutorial and get busy trying to > self-teach. > > Languages I know: BASIC, Pascal, HTML, english, and some spanish (muy > pequito) > > Now on to the problem. > I'm working on lists. Trying to figure them out. So I decide to write this > little algorithim for user inserted lists. My proto goes as follows: > > monty = [] > number = input("How many Monty's are there?") > for x in range(1,number): > mln = input("Name a Monty?") > monty.append(aln) what's aln? > print monty > > It gets through it but prints out some wierd stuff along with each listed > monty. Can someone tell me what I'm doing wrong? Also, when I try to get > it to repeat x at the end of "Name a Monty #", x it gives me an error. How > could I get around that? > > Also, while learning HTML I found a program called Homesite (by Allaire) it > was very helpful. Is there something like it for Python? The two most popular programming editors are vim and emacs. I prefer vim. Unlike emacs, it can also be scripted in python. (Actually, I read on this newsgroup that python embedding in emacs is being worked on, but it just appeared and is in alpha or beta, iirc, while vim's python scripting is comprehensive, stable, and it's been there for years). > > Thanks in advance. > > Mish > lbaker at hot.rr.com > "No one expects the Spanish Inquisition!" > > > > -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From micoud78 at hotmail.com Fri Nov 23 06:33:10 2001 From: micoud78 at hotmail.com (micoud78 at hotmail.com) Date: Fri, 23 Nov 2001 11:33:10 -0000 Subject: binding event on tkinter? Message-ID: <9tlc5m+10at6@eGroups.com> hi, can anyone tell me how to bind the ctlr-> and ctlr-< event on a text widget? it seems that : mywidget.bind('', mywidget.mymethod) or mywidget.bind('', mywidget.mymethod) (my keyboard is a qwerty one) does not work. And the tkinter does not tells about those kind of special binds thanks for help newbie in the fog.... From jdadson at ix.netcom.com Mon Nov 5 18:22:04 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 05 Nov 2001 23:22:04 GMT Subject: Solving Partial Differential equation in Python References: <3BE51085.90702@stu.ust.hk> Message-ID: <3BE71EF8.2956E561@ix.netcom.com> Calvin wrote: > > Greetings, > Did anyone have the experience in solving a PDE numerically in Python. > The PDE is a Euler-Lagrange equation. In fact it is a simulation of LCD > modeling. I search the web and find many libraries like Numeric Python. > But I cannot find any library aim at solving PDE. So I think I have to > design my own Algorithm. Could anyone help me. > > -Calvin As a last resort, you might look into _Numerical Recipes in C_ by Press et al. If you find something there that appears to do what you want, you could write a Python extension module for it. There are many pitfalls to working with the NRC code. It subscripts arrays and variables from 1, not 0. (Many functions are more or less direct translations from Fortran.) It uses floats rather than doubles too much. Termination criteria for iterative procedures are often seriously botched. Sometimes the codes are not anywhere close to state-of-the-art. But it is available, and more or less free. See http://lib-www.lanl.gov/numerical/bookc.html, chapter 19. Jive From gmcm at hypernet.com Mon Nov 12 17:17:19 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: Mon, 12 Nov 2001 17:17:19 -0500 Subject: Proposal for a modified import mechanism. In-Reply-To: <15344.5763.557118.787529@walden.zope.com> References: <15344.4849.71643.868791@monster.linux.in> Message-ID: <3BF0041F.517.82A5AD5B@localhost> Jeremy wrote: [relative and recursively-relative imports] > I'd rather see the imports be explicit "import root.a.b.c" than > "import b.c". Then re-nesting requires all the import statements > to be edited. It's more typing and might even require a simple > script to do search-and-replace, but it doesn't sound like a > prohibitive burden. As a (minor) data point, if "b.c" is resolved as a relative import, it will be faster than the absolute form ("import a.b.c"). Having re-arranged a number of packages, I have some sympathy for Prabhu's complaint. OTOH, this is a feature which only helps package authors (not package users, who are likely to have a somewhat harder time finding their way around the package). [Prabhu] > PR> from pkg import subpkg is also not the best way to do > imports. I PR> personally prefer import pkg.subpkg and I > believe this is the PR> recommended way of doing imports. [Jeremy] > Why do you think this is the recommended way of doing imports? I > use both in my code and haven't been able to come up with a clear > rationale for doing one or the other. The from ... import form > seems useful when the name of the package/module is long or when > it's only one or two names I'm using. When you have circular imports, someone must use the "import a.b.c" form. This can show up in some surprising ways, especially when the package in question desparately needs re-arranging . - Gordon From aaldv97 at student.remove-this-part.vxu.se Tue Nov 13 08:25:12 2001 From: aaldv97 at student.remove-this-part.vxu.se (David Andreas Alderud) Date: Tue, 13 Nov 2001 14:25:12 +0100 Subject: Teaching python (programming) to children References: <9s6ecs$1u7$1@news.lth.se> <3BEC91CD.2D54508D@engcorp.com> <9sp073$k6d$1@news.lth.se> <3BF06DA8.19F3E284@engcorp.com> Message-ID: <9sr72d$6p9$1@news.lth.se> > I think we were talking about *children*, who are definitely not interested > in writing efficient programs... Don't mix first-year students who might > want to learn about the guts of a PC with the audience which was targetted > by this discussion. You're underestimating children, don't do that, please. I've been teaching everything from 7 year olds to university students, the 7 to 9 year olds are by far the most powerful students, they are like vacuum cleaners, absorbing every piece of knowledge presented to them. > Uh, yeah, so teachers are just there to serve cookies? And would > you seriously prefer Ada over Python for teaching *children*? You can't force someone to learn somthing, but by providing them with an environment that provides them with sound rules they absorb those rules too, good or bad. Ada had great rules, declarations are an important rule. And yes I would, but as I've said in previous posts, it's my preference and there is no absolute truth. > Neither do I; that was my point. But likely we are talking apples > and oranges... I've been using Python to talk to instruments like > oscilloscopes via a GPIB interface, to talk to various devices > through serial or parallel ports, and to talk to a 16-bit processor > through a dual-port RAM, and to twiddle the bits in a watchdog timer > device on an embedded PC104 module. The results have been > uniformly superior to those I seen with other languages, thus > my claim that Python would be quite effective at teaching "hardware > programming" to first-year university students (allowing them > to focus on the task at hand, not the language). > > So what do *you* mean by "hardware programming"? Writing devicedrivers and accompanying APIs, for example. Ada is great for hardware programming, one major reason is because PGAs and FPGAs are, normally, coded in VHDL, which is a subset of Ada. So with Ada knowledge one can with little extra knowledge design both hardware and software for embedded devices; not for children, but it really shows how powerful Ada really is. From drs at labs.agilent.com Thu Nov 15 17:59:41 2001 From: drs at labs.agilent.com (David R. Smith) Date: Thu, 15 Nov 2001 14:59:41 -0800 Subject: Tkinter: cleaning up when a toplevel is destroyed Message-ID: <3BF448DD.90195EA2@labs.agilent.com> I want to create multiple gizmos and views of them, letting the views overlap on the screen. In my searching, I came across references to an MS-Win-style multiple document interface widget set, but the links were all stale. P.32 of Grayson shows the creation of multiple toplevel windows, and I figured that would be the ticket. So I coded that up, but I have a problem with how to delete a data structure when the user deletes the associated toplevel window by clicking on its X-button in the upper right corner. What I have right now is: class BlockView: def __init__(self, block, # Display is of a block title, # for title bar root, # ur-toplevel interface destroyCB): # callback for when the window is destroyed self.tl = Pmw.MegaToplevel(root) self.tl.bind('', lambda event, self=self, destroyCB=destroyCB: destroyCB(event,self)) ... The idea is that when the MegaToplevel is destroyed, BlockView sends a 'delete me' message to its creator via destroyCB. The creator then deletes the BlockView from its lists. However, Destroy events get sent for all the children of the new MegaToplevel. I need to strain out all but one callback. I thought I could do it by rewriting the lambda expression as lambda event, self=self, destroyCB=destroyCB: event.widget is self.tl and destroyCB(event,self)) but this never calls destroyCB. I tried rewriting the new test as event.widget is self.tl.interior() but that didn't activate, either. Obviously, I don't understand what event.widget is, and Grayson's explanation of events isn't very thorough. Can someone give me some hints here? TIA David Smith From chrishbarker at home.net Tue Nov 6 19:19:06 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 06 Nov 2001 16:19:06 -0800 Subject: How much is set in stone? References: <3BE8724E.7482C881@ix.netcom.com> Message-ID: <3BE87DFA.A83884E0@home.net> Jive Dadson wrote: > I expected better from this group. That last message was a littel snide, but what exactly di you expect. As someone new to Python, you have proposed something that you think is absolutely indespensible, and despite a number of people politely explaining why they don't think your suggestion is likely to to be incorporated into Python, you continue to imply that the language is practically unusable because of this one missing feature. People are only going to listen to that for so long before they get snide. By the way, every single one of the modifications listed as being part of "C-mode" have been suggested by people new to Python, who insisted that Python would be much better if that feature were incorporated! (except maybe removing class, but I wouldn't be too surprised!) -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From phd at phd.pp.ru Mon Nov 26 09:29:48 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Mon, 26 Nov 2001 17:29:48 +0300 Subject: HTTPLIB - Problem retrieving a page In-Reply-To: <37sM7.7568$2Fd.3180@news1.bloor.is>; from colinmeeks@rogers.com on Mon, Nov 26, 2001 at 02:14:23PM +0000 References: <37sM7.7568$2Fd.3180@news1.bloor.is> Message-ID: <20011126172948.H13216@phd.pp.ru> On Mon, Nov 26, 2001 at 02:14:23PM +0000, Colin Meeks wrote: > connect: (www.meeks.ca, 80) > send: 'GET /index.htm HTTP/1.0\r\n' > send: 'Accept: text/html\r\n' > send: 'Accept: text/plain\r\n' > send: '\r\n' > reply: 'HTTP/1.1 404 Not Found\r\n' You need Host: header: Host: www.meeks.ca:80 Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From opengeometry at yahoo.ca Sun Nov 11 23:09:56 2001 From: opengeometry at yahoo.ca (William Park) Date: Sun, 11 Nov 2001 23:09:56 -0500 Subject: Scientific Libraries in Python In-Reply-To: ; from horatio@qpsf.edu.au on Mon, Nov 12, 2001 at 11:32:34AM +1000 References: Message-ID: <20011111230956.A1281@node0.opengeometry.ca> On Mon, Nov 12, 2001 at 11:32:34AM +1000, Horatio Davis wrote: > > G'day, > > I've been looking at SciPy and ScientificPython, and a question occurs: > > Would it be possible for one to absorb the other so we have a single > standard scientific library for Python? > > There's good stuff in both of them that would be nice to have in _one_ > place, and it just seems more Pythonic. Comments about redundant > functionality, conflicting philosophies, license incompatibility, and > other potential victims^H^H^H^H^H^H^H scientific libraries to be > assimilated are welcome. > > Cheers, > > AHD Simply including the Fortran/C libraries (and their wrappers) as part of Python distribution wouldn't be a problem, other than licenses. But, so far, nobody made that decision or see the need for it. -- William Park, Open Geometry Consulting, . 8 CPU cluster, NAS, (Slackware) Linux, Python, LaTeX, Vim, Mutt, Tin From ws-news at gmx.at Fri Nov 16 08:25:45 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 14:25:45 +0100 Subject: [Q] Printing color strings on stdout without using escape sequences ? References: <3BF4F588.9010500@edf.fr> Message-ID: <3bf5149d$1@brateggebdc5.br-automation.co.at> Hi, when looking for something similar a couple of days ago, I found that there are some such modules in The Vaults of Parnassus. Look into User Interfaces - Text Based UI http://www.vex.net/parnassus/apyllo.py/808292924.243256747 However, I did not dive into any of those products. hth Werner "Ivan DUTKA-MALEN" wrote in message news:3BF4F588.9010500 at edf.fr... > Hello, > > for my application to be a bit more friendly, I want to show some > colored strings on the standard output but I don't want to use ugly > escape sequence like '\033[1m;' or so... > > I'd prefer use a module (if one exists) that encapsulate all those > things and that allows me to be portable on various Unix-like systems > (especialy Linux, Solaris, HP-UX, IRIX). > Does anyone know such a module ? > > For information, I tried to use curses but I think it doesn't make what > I want in the sense that it uses the full screen and I just want to use > the standard output stream. I may be wrong and I surely misuse it. Some > help will be much appreciated :-)). > > Thanks > Ivan > > -- > Ivan DUTKA-MALEN > EDF R&D > mailto: dutka at cli76al.der.edf.fr > mailto: ivan.dutka-malen at edf.fr > From etoffi at bigfoot.com Thu Nov 29 07:25:13 2001 From: etoffi at bigfoot.com (e toffi) Date: 29 Nov 2001 04:25:13 -0800 Subject: pypan Message-ID: <655abd4a.0111290425.5cbfa108@posting.google.com> i put this in a separate posting in anticipation (or rather in case) of a long thread. i wish to start a pypan -- something similar to cpan, but for python, obviously. for example: pypan install RandomGreatPackage would download, compile and install RandomGreatPackage on a users system. how bout it? if you are interested in contributing software, i'm not taking it ;P but i will accept descriptions: please include url, author name and email, req. packages, purpose, category and any other pertinent information. ps: the more traffic this generates the quicker we can shove it down peoples throats. -- etoffi From dalke at dalkescientific.com Mon Nov 12 12:31:16 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Mon, 12 Nov 2001 10:31:16 -0700 Subject: Is this considered black magic? References: <3BEE9D79.5844B26@letterror.com> <3BEEEADE.D539C08C@letterror.com> Message-ID: <9sp10u$h36$1@slb0.atl.mindspring.net> Laura Creighton: >What is the collective noun for 'attributes that aren't >methods (you can't call them)'? Python calls them "members". http://www.python.org/doc/current/lib/specialattrs.html#l2h-113 Andrew dalke at dalkescientific.com From era_akost at yahoo.de Tue Nov 27 11:41:03 2001 From: era_akost at yahoo.de (Era Akost) Date: 27 Nov 2001 08:41:03 -0800 Subject: Redirect output from os.system() Message-ID: <6749bb94.0111270841.c808c39@posting.google.com> Hi all, Searching through the group emails, I've found out how to redirect output from python functions. Now I would like to redirect the output from a os.system() process to a Text widget. How can I do it? Python Reference Library says the following on stdout, stdin of sys module: "(Changing these objects doesn't affect the standard I/O streams of processes executed by os.popen(), os.system() or the exec*() family of functions in the os module.)" So, what should be done?? Thanks, Era From alanmk at hotmail.com Thu Nov 29 14:23:56 2001 From: alanmk at hotmail.com (Alan Kennedy) Date: 29 Nov 2001 11:23:56 -0800 Subject: ZPT and WYSIWYG HTML tools. Message-ID: Hi All, I've been looking at ZPT, and it's very good. I've been looking for something like it for a while, and was toying with the idea of coding something similar myself. For those who don't know what ZPT is, check out http://www.zope.org/Wikis/DevSite/Projects/ZPT/VisionStatement The most important thing about ZPT for me is that it will (hopefully) survive the trip in and out of WYSIWYG HTML editing tools like DreamWeaver. This is really important for me because the guy who does our HTML page design is great with such tools, but he couldn't write a line of code if his life depended on it. Therefore, asking him to get his head around things likle *SP, Cheetah, etc, is just out of the question. It's almost guaranteed that between him and the WYSIWYG tool, any logic embedded in the HTML would get fouled up. We've been using DreamWeaver up to now for HTML editing. But I've just read a UseNet message which stated that there were problems with ZPT and Dreamweaver, but didn't actually give any details. Does anyone have any details of such ZPT/DreamWeaver problems? Does anyone know of any GUI editing tools that DO work seamlessly with ZPT? TIA, Alan. From tim.one at home.com Fri Nov 9 17:35:39 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 9 Nov 2001 17:35:39 -0500 Subject: Strange __str__ behavior In-Reply-To: Message-ID: > I am defining a class w/ method __str__. If I put a print statement > inside __str__, and if I then use the print statement to display an > instance of the class, I get an extra space in the output. Please see: From rdsteph at earthlink.net Mon Nov 26 21:38:14 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Tue, 27 Nov 2001 02:38:14 GMT Subject: 11-15 new Python Books on the way! (fwd) References: Message-ID: <3C02FDE5.8EECF2FE@earthlink.net> Excellent! Excellent! and thanks. I have added prominent links to both your Charming Python: Updating Your Python Reading List and also Part 2, Charming Python Updating Your Python Reading list. Now I feel its complete! Thx ron stephens (yeah, I never could bring myself to step on those cracks in the sidewalk, when I was a kid. remember those?) "Dr. David Mertz" wrote: > Ron Stephens wrote: > |Truly a surfeit of books. But, for what it is worth, I have listed all I > |could find out about them all at http://www.awaretek.com/plf.html > > Ron seems to have done a more complete job than I have (or than I have > really tried). But Pythonistas might enjoy looking at my reviews of > many Python books for IBM developerWorks (quite a few overlaps with > those Ron looked at): > > http://www-106.ibm.com/developerworks/linux/library/l-pbook2.html > > http://www-106.ibm.com/developerworks/linux/library/l-cp12.html > > Yours, David... From peter at engcorp.com Wed Nov 28 19:00:15 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 19:00:15 -0500 Subject: sourcecode scrambler References: <55881dd4.0111280851.682ac024@posting.google.com> <9u3n1o$778$1@slb7.atl.mindspring.net> Message-ID: <3C057A8F.9F61CF5E@engcorp.com> Matt Gerrans wrote: > > Markus wrote: > > does anyone know how to scramble my > > python source-code? > > I want to assign random names to all > > variables and modules, > > You could alternatively deliver the pyc files instead of py files, if you are > trying to keep your code semi-secret. I suspect that would be far less useful. .pyc files are quite easy to decompile back to source, while randomizing the module and variable names (provided the source didn't depend on certain forms of introspection) would go farther to ensure a reader couldn't understand the source. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From buzzard at urubu.freeserve.co.uk Mon Nov 26 14:50:52 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Mon, 26 Nov 2001 19:50:52 -0000 Subject: XML help needed References: <9tplso$jea$1@newsg1.svr.pol.co.uk> <9tsfls$7q2$1@news8.svr.pol.co.uk> Message-ID: <9tu6fv$ec0$1@newsg2.svr.pol.co.uk> "Martin von Loewis" wrote in message news:j4d725n9ua.fsf at informatik.hu-berlin.de... > "Duncan Smith" writes: > > > Thanks for the reply. Basically I have an XML file containing data > > that I need as various Python objects (strings, lists, arrays etc.). > > I don't need to make changes to XML files, although I might want to > > write data to new XML files of the same type (same DTD). > > I see. In that case, I recommend to use plain print statements to > generate the XML (or other means of string processing, like collecting > pieces of the document in a list). This is easier than generating a > DOM or SAX in-memory representation, and then serializing it. > > > (I don't really want to have to learn about XSL, XSLT, X-path, SAX, > > DOM, Pyxie etc. unless I know it's going to be useful.) > > Depending on the exact processing job, XSLT may be indeed useful. If > you know that the output only depends on the input, then writing a > style sheet that does the transformation, without writing a line of > Python, might be possible. > > > Learning all that lot would be a lot of effort to achieve what I > > need. So if you (or anyone) could give me advice along the lines of > > "DOM would be appropriate but you'll have to know... as well", then > > I'd be grateful. > > DOM alone will allow you to get all information from the document, in > a moderatly convenient way. If you find to that you write algorithms > of the kind > > Starting from the root, go to the first child element "foo", then to > the last child element "bar", and take its "foobar" attribute value > > than XPath would help to tighten your code. > > > Martin, you were bang on with the 'invalid XML' thing. Cheers. > > That's a phrase (to be bang on) that is beyond my English > understanding. I take it to mean something good, in absence of a clear > understanding :-) > Spot on, exactly right. My application's based on graphical models, so DOM kind of appeals to me. Thanks for your reply, and thanks to Paul for his. Duncan > Regards, > Martin From db3l at fitlinxx.com Wed Nov 28 17:36:29 2001 From: db3l at fitlinxx.com (David Bolen) Date: 28 Nov 2001 17:36:29 -0500 Subject: sys.prefix in COM References: Message-ID: "Bill Bell" writes: > David Bolen wrote, in part: > > sag at hydrosphere.com (Sue Giller) writes, in part: > > > I hate the registry - hassles abound. I would rather do anything > > > else including hard coding the path and forcing other users to use > > > my paths :) > > > > There's not much different from adding such a key to the registry > > (just publish a .reg file for your users to use) and hardcoding a > > path. > > Sue and David, > > I haven't been following this thread. However, I wonder what would > make you use a .reg rather than just doing the registry > manipulations in the Python? This was in the context of providing an application to some other user on a different machine. Providing a .reg file seems easiest to me since the end user can just double click on that and import it directly to make the necessary tweaks to their registry. But sure, any approach that updates the registry entries (including doing it as part of a full installation) would be fine too. -- -- 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 d_blade8 at hotmail.com Mon Nov 5 20:18:45 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 5 Nov 2001 17:18:45 -0800 Subject: Considering getting into Python... Any Pros-Cons? References: Message-ID: <7396d2b2.0111051718.34610f8e@posting.google.com> I agree with everything said here (for the most part), but I think it is all a bit biased (most readers of this newsgroup are python progs) so check this out: http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf From phr-n2001d at nightsong.com Thu Nov 15 20:12:03 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 17:12:03 -0800 Subject: Python & cgi on win98--tinyweb problems, etc References: Message-ID: <7x8zd7zfh8.fsf@ruckus.brouhaha.com> Chris Stromberger writes: > Any other recommendations for small simple web servers for this > project? How about the HttpServer class that's already in the Python library? From bac at OCF.Berkeley.EDU Thu Nov 22 02:42:51 2001 From: bac at OCF.Berkeley.EDU (Brett Cannon) Date: Wed, 21 Nov 2001 23:42:51 -0800 Subject: Pulling out In-Reply-To: <3bfb6c61.6364882@wa.news.verio.net> References: <3bfb6c61.6364882@wa.news.verio.net> Message-ID: Could use negative lookahead and lookbehinds. Another solution is to just strip out all comments from the HTML. Probably wouldn't hurt, anyway, since it will probably increase performance slightly be cutting down on the amount of tags to deal with. But it is also illegal syntax, I believe, to embed tags within a comment. -Brett C. On Wed, 21 Nov 2001, Bengt Richter wrote: > On Sun, 18 Nov 2001 20:45:44 -0800, Brett Cannon wrote: > > >You could just read each page and use a regex to fetch it: > > > >title_value=re.search(r'(?P<title>.*?)',re.I) > >title_value.group('title') > > > Hm. What happens with the following page? > > > > Official new title > ...whatever... > > >On Sun, 18 Nov 2001, David A McInnis wrote: > > > >> I am writing a script to catalog about 30,000 html pages on my site and need > >> to pull out the value of . > >> > >> I guess this is possible with htmllib, but I cannot figure it out. > >> > >> Thanks, > >> David > >> > >> > >> > > > > From lfini at arcetri.astro.it Mon Nov 5 11:00:25 2001 From: lfini at arcetri.astro.it (Luca Fini) Date: Mon, 5 Nov 2001 17:00:25 +0100 Subject: Problems compiling PyQt In-Reply-To: <3be698b3$0$203$e4fe514c@newszilla.xs4all.nl> References: <3be698b3$0$203$e4fe514c@newszilla.xs4all.nl> Message-ID: Thak you very much for your reply. On Mon, 5 Nov 2001, Boudewijn Rempt wrote: > Luca Fini wrote: > > > > > I'm trying to compile PyQt on RedHat Linux 7.1 (gcc version 2.96 20000731) > > > > Is this the infamous incompatible gcc? (I always forget the version > numbers.) > > > as usually I do: > > > > ./configure > > make > > > > And I always get the following errors: > > > > qtcmodule.cpp: In function `PyObject *registerClasses (PyObject *, > > PyObject *)': qtcmodule.cpp:9159: `Rounded' is not a member of type > > `QTabWidget' qtcmodule.cpp:9160: `Triangular' is not a member of type > > `QTabWidget' qtcmodule.cpp:10361: `TSCII' is not a member of type `QFont' > > qtcmodule.cpp:10625: `AccelOverride' is not a member of type `QEvent' > > qtcmodule.cpp:11251: `WGroupLeader' is not a member of type `Qt' > > > > > > This happens for various versions pf PyQt(2.3,2.4,2.5). > > Are sip and PyQt finding the same version of Qt? Aren't you trying to > compile PyQt against Qt 3.0? (You need one of the recent 3.0 preleases > for that.) Well, I've the Qt which comes with RedHat: qt-2.2.0 and I believe is the only available on my PC. Moreover those seems compilation problems: I didn't get to linking yet. The line giving the error is the following: it seems that includes thre right stuff: c++ -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python2.1 -I/usr/local/include/sip -I/usr/lib/qt-2.2.0/include -I/usr/X11R6/include -fno-exceptions -O2 -Wp,-MD,.deps/qtcmodule.pp -c -fPIC -DPIC qtcmodule.cpp -o qtcmodule.lo -- -------------------------------------------------------------------------- -- ) Luca Fini Tel: +39 055 2752 307 ___ |\ Osservatorio Astrofisico di Arcetri Fax: +39 055 2752 292 / | | |-_ L.go E.Fermi, 5 +----------------------------------------- (___|___//___) 50125 Firenze / WWW: http://www.arcetri.astro.it/~lfini (_) (_) Italia / e-mail: lfini at arcetri.astro.it -----------------------------+-------------------------------------------- From olli at secnetix.de Tue Nov 6 08:33:08 2001 From: olli at secnetix.de (Oliver Fromme) Date: Tue, 6 Nov 2001 13:33:08 +0000 (UTC) Subject: Finding name for a signal number Message-ID: <9s8oqk$a38$1@isp-m-srv06.izb.net> Hi, I've just begun learning Python, so please don't eat me for lunch if my question is too stupid. In a small script I'd like to print the name of a signal number: In the event that an os.system() call is aborted by a signal, the signal number is returned in the lower 7 bits of the return value. I'd like to print a meaningful message which includes the signal name (like "SIGQUIT"), not just the number. I've searched the library reference for a signal name dictionary (just like the errno.errorcode dictionary in the errno module), but haven't found one. The next thing I came up with is extracting the signal names from the namespace dictionary of the signal module itself, like this: import signal def get_signame (n): "Return the signal name for a signal number." for sig in dir(signal): if sig.startswith("SIG"): value = eval("signal." + sig) if type(value) is IntType and value == n: return sig return "SIG#" + str(n) This works. However, the above code seems awkward and inefficient, in particular the eval() part. Is there a better way? Did I miss something? Thanks in advance! Regards Oliver -- Oliver Fromme, secnetix GmbH & Co KG, Oettingenstr. 2, 80538 M?nchen Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "All that we see or seem is just a dream within a dream" (E. A. Poe) From lucio at movilogic.com Mon Nov 5 15:24:04 2001 From: lucio at movilogic.com (Lucio Torre) Date: Mon, 05 Nov 2001 17:24:04 -0300 Subject: IDLE breakpoints on Windows? References: <3BE6F149.BD4CBD32@tds.net> Message-ID: <3BE6F564.80402@movilogic.com> Edward K. Ream wrote: >Hi, > >Do breakpoints work with any version of IDLE on Windows? If so, how >does one set them? If not, what needs to be done to make them work? >No one on idle-dev seems to know. > >BTW, various Python documents offer different opinions about whether >breakpoints work on Windows. > >Edward >-------------------------------------------------------------------- >Edward K. Ream email: edream at tds.net >Leo: Literate Editor with Outlines >Leo: http://personalpages.tds.net/~edream/front.html >-------------------------------------------------------------------- > i tried them on windows 98 (or 200, dont remember). you have to rememeber to open the debugging console to make them work. hope it helps. lucio From loewis at informatik.hu-berlin.de Tue Nov 27 05:36:06 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: Tue, 27 Nov 2001 11:36:06 +0100 (MET) Subject: bugs in `gc.get_referents()' In-Reply-To: (message from Michael Hudson on Tue, 27 Nov 2001 05:15:48 -0500 (EST)) References: Message-ID: <200111271036.fARAa6415091@paros.informatik.hu-berlin.de> > > Again, this might go away with the patch. get_referents isn't supposed > > to trigger a garbage collection. > > All those PyList_Appends might, though. How could that happen? PyList_Append calls ins1, which calls (through NRESIZE) PyMem_RESIZE, which is realloc. Apart from that, and apart from the error cases (which lead to immediate abortion of get_referrers), it only does INCREFs. Regards, Martin From Administrator Tue Nov 27 11:11:12 2001 From: Administrator (Administrator) Date: Tue, 27 Nov 2001 09:11:12 -0700 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <02f901c1775e$21c62730$0e0fbb82@corp.es.com> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = rwerwe Recipient(s) = python-list at python.org Subject = Re: Scanning Time = 11/27/2001 09:11:11 Engine/Pattern = 5.600-1011/171 Action on virus found: The attachment news_doc.DOC.scr contains WORM_BADTRANS.B virus. ScanMail has Deleted it. Warning to administrator. ScanMail has detected a virus. 11/27/2001 09:11 AM TORINO news_doc.DOC.scr/Deleted python-list at python.org rwerwe Re: From logiplexsoftware at earthlink.net Mon Nov 19 21:18:25 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 19 Nov 2001 18:18:25 -0800 Subject: MultiThread Socket on NT In-Reply-To: References: Message-ID: <01111918182500.11646@logiplex1.logiplex.net> On Friday 16 November 2001 22:02, Neil Beattie wrote: > The ms documentation says this about sockets > "Windows NT Server version 4.0 allows a backlog maximum of 200. Windows > NT Workstation version 4.0 supports only a maximum allowable value of > 5." Does this not affect the situation? > Neil. It seems like it should. I don't usually read the MS documentation =) However, I can say that using NT Porkstation 4 the problem went away when I applied SP5. > > -----Original Message----- > > From: python-list-admin at python.org > > [mailto:python-list-admin at python.org]On Behalf Of Cliff Wells > > Sent: Saturday, November 17, 2001 2:09 AM > > To: python-list at python.org > > Subject: Re: MultiThread Socket on NT > > > > On Friday 16 November 2001 14:26, David Bolen wrote: > > > Cliff Wells writes: > > > > Be sure you are using at least SP5. NT 4 had serious threading > > > > issues prior to that. > > > > > > Do you have any pointers or references to what the problem was? > > > I've been using multi-threaded applications (although not a high > > > density connection server) under NT4 SP4 without any observable > > > problems. > > > > It's been around three or four years since I encountered that, so the > > details are pretty vague now.... I was writing an instant > > messaging server > > that spawned a thread for every incoming connection (not the best > > way, but > > it was my first attempt at network programming, multithreading and my > > first Python program to boot =). I was stress-testing my server > > and I had > > an adjustable parameter limiting the number of threads allowed at any > > one time. If I set this higher than, say 20 (highly questionable if > > that's the number), NT would flake out (I think to the point of BSOD, > > but I can't > > recall). Anyway, without changing any code, applying SP5 fixed it, > > and I seem to recall that threading was one of the issues addressed in > > SP5. > > > > -- > > Cliff Wells > > Software Engineer > > Logiplex Corporation (www.logiplex.net) > > (503) 978-6726 x308 > > (800) 735-0555 x308 > > > > -- > > http://mail.python.org/mailman/listinfo/python-list -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From ws-news at gmx.at Mon Nov 26 06:10:27 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 26 Nov 2001 12:10:27 +0100 Subject: (newbie) A very weird Python CGI problem, possibly related to os.system References: Message-ID: <3c0223e9$1@brateggebdc5.br-automation.co.at> Hi, I'm sorry I have no more concrete suggestion, but I would really start adding some debugging output. There are a couple things in your gameservers function which could possibly fail (creating the temporary file, os.system(),...) I'd try to print some lines as the script processes to see what goes wrong exactly. Maybe it's easier for us then to help. good luck Werner From dalke at dalkescientific.com Tue Nov 13 09:47:37 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Tue, 13 Nov 2001 07:47:37 -0700 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> Message-ID: <9srbs8$pur$1@slb2.atl.mindspring.net> Michael Hudson: >But they very much take their lead from CPython, so Tim's points all >remain valid. Well, except for vyper, but that doesn't have enough >influence to count (perhaps unfortunately). I recall some of the conversation when (then) JPython was being developed, on making sure the documentation didn't require implementation-specific functionality. So there is *some* standard-like documentation. What's needed to call something a standard? I don't know of a C++ compiler which fully meets the C++ standard. (They all seem to have bits of 'oh, we don't do that yet'.) So I figured three different implementations (C, Java and OCaml) with no shared run-time environment was enough to disprove Tim's statement: ] there is only one implementation, and the language ] is defined implicitly by that implementation For Python, would it be better to say there are several implementations, and the language is mostly defined by the documentation, but the other implementations defer to the C implementation, distribution, and developers in matters of interpretation. ? Tim's point was that standardizing a library is a complicated and expensive process. My point is that the Python library (standardized or not) works with quite different runtimes. Why aren't there similarly widely used though non-standard libraries for CL for "doing stuff like internet programming"? [Paul Rubin] For example, back in the Perl4 days when CGI programming first became hot, just about everyone used cgi-lib.pl even though it wasn't part of the standard Perl library, and this was pre-CPAN. Andrew dalke at dalkescientific.com From maxm at mxm.dk Fri Nov 9 09:27:17 2001 From: maxm at mxm.dk (maxm) Date: Fri, 9 Nov 2001 15:27:17 +0100 Subject: New to pyton. Maybe a dumb question? References: <3beb180c@news.bezeqint.net> Message-ID: "Eyal Lotem" wrote in message news:3beb180c at news.bezeqint.net... > Cliff Pruitt wrote: > Python must be interpreted, unless a native-code compiler is used. The only > one I know of is the .NET ActiveState Python compiler (and I'm not even > sure it is one). > > This means that you have to have an interpreter running where you want to > run Python code. There are two approaches: > A) Require the interpreter to be installed, as you said. > B) Use a tool like py2exe and stick the Python code and its dependencies in > the Python file, and hand over an interpreter DLL with the package. In fact this is muche easier than it sounds, and to the end user it will work exactly as a normal program. At least under windows there is an .exe file and everything. You will have to create a different distribution for every platform you want it to be run on, but This can be automated so it will not be a pain to do. regards Max M From go at prepaidonline.com Fri Nov 30 22:53:05 2001 From: go at prepaidonline.com (go at prepaidonline.com) Date: Sat, 01 Dec 2001 03:53:05 GMT Subject: The Best Prepaid Phone Card Yet Message-ID: UNLIMITED domestic calling to ANYWHERE in the U.S. NO Taxes, NO Junk, Just Unlimited Talk for 30 days! Service can be used 24 hours a day, 7 days a week, from the same phone! $89.95 DOUBLE TALK - Two phone cards in one - a connection fee card, great for longer calls, or a no-connection fee card, better for shorter calls. From $.02 to $.10 per min. WorldWide! Features low rates to the U.S., Europe and Mexico! $10.00 The CLEAN CARD - Talk for a minute - pay for a minute. No hidden fees or connection fees. Great rates to many international destinations, as well as a .065 rate for the U.S.! $10.00 GO TO: http://go.prepaidonline.com/ Lowest Prepaid Phone Cards, Inc. is a recognized leader in guaranteed prepaid long distance phone service. We are a leading world-wide supplier of prepaid telecommunication services and by working in partnership with the largest telecommunication and network services companies, PrepaidOnline is able to consistently offer the lowest cost and highest quality cards available. GO TO: http://go.prepaidonline.com/ From philh at comuno.freeserve.co.uk Sun Nov 25 19:14:37 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Mon, 26 Nov 2001 00:14:37 +0000 Subject: list.remove for Novices References: Message-ID: On Sun, 25 Nov 2001 16:02:52 -0500, Tim Peters wrote: >[Arthur Siegel] >> I see that my - >> >> >>>foo = [1, 2, 3, 4, 5] >> >>>for bar in foo: >> ... foo.remove(bar) >> >> issue which I ran into trying to follow suggestions for >> my permutations problem was addressed beginning at: >> >> > >That looks like an email address; it's unclear what it refers to. > >> But damn it to hell. Even when I try to be a normal Python >> guy, and just post up "technical" problems, I get into- >> or raise - issues/controversary. >> >> Because I am being asked to accept that the list.remove >> behavior is somehow apparent - rather than a true >> trap for the novice. > >I expect every newbie gets bit by this at least once. I've not been bitten by it up to now. (Or maybe I was, such a long time ago when I was learning programming, and I've since internalised the idea that it is undefined if you adjust the parameters of a for-loop inside the loop) -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From phd at phd.pp.ru Thu Nov 1 04:28:15 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 1 Nov 2001 12:28:15 +0300 Subject: Freeware Python editor In-Reply-To: <3BE11391.BF044772@alcyone.com>; from max@alcyone.com on Thu, Nov 01, 2001 at 01:19:13AM -0800 References: <81F59ACE9063D511A5BB0002B328D2265115F4@il93exm20.css.mot.com> <3BE01E8F.3A384D4C@alcyone.com> <3BE038B5.6AFA6BFB@alcyone.com> <3BE11391.BF044772@alcyone.com> Message-ID: <20011101122815.H30403@phd.pp.ru> On Thu, Nov 01, 2001 at 01:19:13AM -0800, Erik Max Francis wrote: > Oh, please. You don't have the "freedom" to dictate to other people > what license to put on software that _they_ write. When and where was I dictating this? Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From christophertavares at earthlink.net Sun Nov 18 23:08:55 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Mon, 19 Nov 2001 04:08:55 GMT Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> Message-ID: "Daniel Klein" wrote in message news:eoigvt0jf0jqgt15et5o61nomh27f0mp7j at 4ax.com... > Why not assign the most likely value and then test for the other, ie > > a = val > if idx = 1: > b = val > > Daniel Klein Actually, that has different semantics. What you'd need is: a = val if idx == 1: # Note the typo - should be ==, not = b = val del a # <--- need this to match original version To be honest, I'd prefer the original - it's easier to read and more straightforward. I'm a bit curious what the original poster wanted to do - these kind of constructions are almost always done better some other way. -Chris From prabhu at aero.iitm.ernet.in Sun Nov 4 07:13:24 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 4 Nov 2001 17:43:24 +0530 Subject: How can i retrieve a key from a dictionary? In-Reply-To: <3BE52DBC.724B1C6F@student.kun.nl> References: <3BE519E0.34312B48@student.kun.nl> <3BE52DBC.724B1C6F@student.kun.nl> Message-ID: <15333.12516.662608.163084@monster.linux.in> >>>>> "HJ" == Husam writes: >> dict.keys()[dict.values().index('one')] >> >> prabhu HJ> it works, but wat does the -index- means? >>> a = [] >>> print a.index.__doc__ L.index(value) -> integer -- return index of first occurrence of value Also, note the above might give you unexpected results if you have two different keys that have the same value i.e. if you did: dict[3] = 'one' You'd have two keys pointing to the same 'one' in this case you are in for trouble. prabhu From paulp at ActiveState.com Thu Nov 1 16:21:35 2001 From: paulp at ActiveState.com (Paul Prescod) Date: Thu, 01 Nov 2001 13:21:35 -0800 Subject: XML can't read Unicode shock horror. News at 11. References: Message-ID: <3BE1BCDF.5C4B2A09@ActiveState.com> Dale Strickland-Clark wrote: > > ... > > That's not much good if my XML document happens to start with: > > > > To quote from the O'Reilly book, "XML In A Nutshell" p71: "An XML > parser is required to handle the UTF-16 and UTF-8 encodings or > Unicode." And I expect similar is stated in the XML DOM spec if I had > time to look for it. As Martin says, you won't find anything like that in the DOM spec. And the XML-spec is not going to provide much support for your position either, because it discusses the parsing of *byte sequences*. I showed you how to construct a UTF-8 byte sequence. You can also construct a UTF-16 byte sequence using the same technique (change the string "UTF-8" to "UTF-16"). If you want to write a function that creates the right byte sequence no matter what the encoding declaration, you'd have to sniff the encoding declaration. Paul Prescod From thomas.heller at ion-tof.com Fri Nov 23 09:32:56 2001 From: thomas.heller at ion-tof.com (Thomas Heller) Date: Fri, 23 Nov 2001 15:32:56 +0100 Subject: AppBars in Win32 -- SUCCESS References: Message-ID: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> "Keith Farmer" wrote in message news:RPpL7.916$1W5.155013214 at newssvr14.news.prodigy.com... > After beating my head against various things, I have successfully created an > AppBar under Win32. What's an AppBar, you ask? > > An AppBar is a window docked at the edge of the screen, such that Windows > knows about it, and adjusts the desktop boundaries accordingly. The taskbar > is one such example. > > Currently, I've managed to get it to dock and undock on various sides of the > screen. I haven't done anything fancy, like dragging it to dock/undock, nor > has the window been more complex than a blank frame under wxPython. The > extension I wrote interfaces to the SHAppBarMessage function, and uses part > of the win32 extensions to determine screen size. I've borrowed some > constants from an attempt by Bill Bell to perform the same task. If I'm > correct, this extension should work with both PythonWin and wxPython. > > I'll next be trying to put widgets in the frame. > Sounds interesting. Will you publish the code? Thomas From gward at python.net Wed Nov 14 08:48:43 2001 From: gward at python.net (Greg Ward) Date: Wed, 14 Nov 2001 08:48:43 -0500 Subject: ANNOUNCE: Optik 1.0 (new command-line parsing library) In-Reply-To: <20011112203150.A8294@ibook.distro.conectiva> References: <20011112175357.F26476@phd.pp.ru> <20011112102612.A1723@gerg.ca> <20011112203150.A8294@ibook.distro.conectiva> Message-ID: <20011114084843.C22086@gerg.ca> [me, on allowing interspersed options and args in Optik] > Not yet; I deliberately punted on this because most other Unix > command-line parsing libraries are lazy and don't bother to scan all > arguments for options. (I think scanning all arguments is the preferred > behaviour, but for historical reasons it should probably be optional > behaviour. I could be wrong...) On 12 November 2001, Gustavo Niemeyer said: > This seems desirable. It's usual for people (at least I have seen many > doing this, including myself) to type a whole line, and then remember about > a command line option and include it at the end. OK, I think I'll add this feature. Still haven't decided to enable it by default, but I'm leaning that way right now -- it improves usability and shouldn't ruin anyone's day, especially since "--" can always be used for "stop processing options now". I'll also see about adding "store_many" as a standard action. Sounds like it would be useful. Those two features should be enough to justify Optik 1.1. > Btw, congratulations. I haven't used the library so far, but seems very > flexible, and a nice option to include in standard library. Maybe someday! It should certainly get some exercise out in the field, first. But I would love to have something better than getopt in the standard library. > Meanwhile, > you could want to pack the library in a single file, to be easier to > include in other projects. Anyway, this should be easy to achieve by > someone wanting to do so. Nah, that's for others to do. I'm concerned with keeping the code clear and maintainable for now. If you want to cat lib/[a-z]*.py > optik.py then be my guest. It would only be 725 lines, counting comments and docs. Just keep the name and the copyright message intact, please! Greg -- Greg Ward - programmer-at-large gward at python.net http://starship.python.net/~gward/ If you can read this, thank a programmer. From kalle at gnupung.net Tue Nov 6 22:02:29 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Wed, 7 Nov 2001 04:02:29 +0100 Subject: Yahoo Groups archive of python-list wiped - what happened? In-Reply-To: <9sa4hk$11vhaf$1@ID-11957.news.dfncis.de> References: <3BE878FA.103DA334@letterror.com> <9sa4hk$11vhaf$1@ID-11957.news.dfncis.de> Message-ID: <20011107040229.A13526@sandra.lysator.liu.se> [Emile van Sebille] > "Fredrik Lundh" wrote in message > news:nJ%F7.4684$R43.746961 at newsb.telia.net... > > Just van Rossum wrote: > > > I hope it's a temporary glitch, and not that they've simply > > > wiped their archives... > > > > note that the first post in their new archive is timestamped > > "Nov 5, 2001 7:29 pm". > > > > before and after Orlijn? > > > > OK... what's that? The closest hit I get is spoorlijn. Has somebody pulled > a fast one? http://www.python.org/~guido/orlijn/ Peace, Kalle -- [ Thought control, brought to you by the WIPO! ] [ http://anti-dmca.org/ http://eurorights.org/ ] From christophertavares at earthlink.net Mon Nov 12 21:54:30 2001 From: christophertavares at earthlink.net (Chris Tavares) Date: Tue, 13 Nov 2001 02:54:30 GMT Subject: OT: Mobile Internet Toolkit EULA (was: IsPython really O-O?) References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> Message-ID: "Guido Stepken" wrote in message news:9sph0u$gj7$02$1 at news.t-online.com... > Thanx lots for checking this out ! Hmmm, that means, that it is forbidden > to produce (distribute) code, consisting of (L)GPL Software and Microsoft > OpenSource. One is not allowed to mix code. BSD License + Microsoft Code, > that's OK ! > Any ideas, why ? > > regards, Guido Stepken > Simple - the Microsoft code in question is NOT open source in any way, shape or form. It does include some source code and program samples, but it's not open source, and the end user does not have redistribution rights. The phrases in the EULA doesn't really add anything - actually, the GPL includes the same clause (If you link GPL code with non-GPL code, you can't release the program unless you change the license of the non-GPL code). It's just Microsoft's lawyers & marketing dept. getting together and rattling their sabers. The reason that the BSD license works with MS code is that the BSD license says, basically "use this, but you can't sue us." No requirements to change licensing on any other code. -Chris From jdadson at ix.netcom.com Sun Nov 4 01:50:07 2001 From: jdadson at ix.netcom.com (Jive Dadson) Date: 04 Nov 2001 06:50:07 GMT Subject: Q: Feature Wish: "%" Extension References: <3BE34077.8EA553CB@spam.net> <9s16fj$l7i$1@usenet.Stanford.EDU> Message-ID: <3BE4E4FF.BD553892@ix.netcom.com> Amit Patel wrote: > > anonymous wrote: > | > | PS: I'm still dumbfounded why Python's division operator must behave > | differently than that in php, js, java, perl, awk, and C/C++ -- I'm dumbfounded that it works correctly! Back when dinasaurs walked the earth, I had a long argument with the Pascal standards committe about the correct definition of the modulus operator. Believe it or not, they had it so that (-3)%2 was a negative number! After much going back and forth, I convinced them otherwise. To my astonishment, they then proceded to get integer division wrong -- incompatible with the definition of mod that they finally agreed to! C and C++ have it wrong also. The following relation should hold for any integer x and any positive integer M: (x/M)*M + (x%M) == x That makes "slicing and dicing" work easy to do. Change it, and you start needing tests for negative in your code. Jive From sasoft at gmx.de Sun Nov 4 20:20:10 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Sun, 4 Nov 2001 20:20:10 -0500 Subject: Command shell access within Python In-Reply-To: <3BE582C6.7D8C450B@attglobal.net>; from pieroul@attglobal.net on Sun, Nov 04, 2001 at 01:02:46PM -0500 References: <3BE582C6.7D8C450B@attglobal.net> Message-ID: <20011104202010.A15720@cruciatuz.de> On Sun, Nov 04, 2001 at 01:02:46PM -0500, pieroul at attglobal.net wrote: > I also need to get the return code (c exit()) of the program that ran. os.system() gives you the return code of your command. try interactively: import os print os.system('ls') ... listing ... 0 <-- return code -- Stefan Antoni From skip at pobox.com Fri Nov 9 12:21:19 2001 From: skip at pobox.com (Skip Montanaro) Date: 9 Nov 2001 11:21:19 -0600 Subject: Dr. Dobb's Python-URL! - weekly Python news and links (Nov 9) Message-ID: My oh my! Do we ever have ideas about teaching Python to kids! http://groups.google.com/groups?th=b78ddb54d75bd5ad Jive Dadson wonders about how "set in stone" Python's features are, which eventually gives Barry Warsaw a reason to show how the new __slots__ feature can be used to avoid some common typos: http://groups.google.com/groups?selm=3BE4DF39.AE0A8EAA%40ix.netcom.com http://groups.google.com/groups?selm=ba3d3s305x.fsf%40anthem.wooz.org Is Stackless Python DEAD? Should it be added to the core? This thread is surely to be continued: http://groups.google.com/groups?th=597402650b88d48a Achim Domma wants to have his indexing cake and to eat it too. Several people show how: http://groups.google.com/groups?th=f949f9a6bf120a24 Nospam Fred wonders why it takes his program so long to exit. This, naturally, leads to a discussion of malloc/free performance and to the use of PyMalloc as an alternate allocator for Python objects: http://groups.google.com/groups?th=89782a3d14447d9f Dave Cole has a new version of his fast CSV file reader: http://groups.google.com/groups?selm=m37kt4cv8z.fsf%40ferret.object-craft.com.au This will bulk you up. No, wait, watch out for that rock! A new version of PySteroids has been released. (And you wondered if games could be written in Python!) http://groups.google.com/groups?th=7ad5efc98af53c24 ======================================================================== 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 continued Andrew Kuchling's marvelous tradition of summarizing action on the python-dev mailing list once every other week, into July 2001. Any volunteers to re-start this valuable series? 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/ The old Python "To-Do List" now lives principally in a SourceForge reincarnation. http://sourceforge.net/tracker/?atid=355470&group_id=5470&func=browse http://python.sourceforge.net/peps/pep-0042.html 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://www.ddj.com/topics/pythonurl/ http://purl.org/thecliff/python/url.html (dormant) 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 tdickenson at devmail.geminidataloggers.co.uk Mon Nov 5 07:35:58 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Mon, 05 Nov 2001 12:35:58 +0000 Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> Message-ID: barry at zope.com (Barry A. Warsaw) wrote: >FWIW, the double-leading-underscore-no-trailing-double-underscore name >mangling rule wasn't added specifically for data hiding. It was so >that a class that was designed to be subclassed could have a namespace >that subclasses couldn't accidently trample on: Interestingly, I often find that that the chosen mangling scheme doesnt achieve that design goal. The scheme mangles the class name into the underscore-stripped attribute name, which offers zero protection if your base classes and subclasses have the same name. Does this happen often? A common structure (for me, anyway) is to have modules BaseWidget, FooWidget, and BarWidget, all of which define a class Widget. Toby Dickenson tdickenson at geminidataloggers.com From chrishbarker at home.net Thu Nov 29 14:23:46 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 11:23:46 -0800 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> Message-ID: <3C068B42.8C2F42D8@home.net> Jeff Shannon wrote: > I would like to begin using CVS > for those projects that I can, even if I'm the only one using it. The > problem with this, is that I don't have access to a Unix/Linux server to > install CVS on It would be pretty easy to use any old Intel box, put Linux on it, and run it as your CVS server. If that's all it was doing, you could run it on a old 386! Then you might be able to convince your collegues of the glory of Linux, along with the glory of CVS and version control! Personally, I work in a mostly Mac, some Windows shop. I am the only one running Linux, but I manage a project with CVS, and just run it on my desktop box. It works just great. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From cliechti at gmx.net Thu Nov 22 13:54:38 2001 From: cliechti at gmx.net (Chris Liechti) Date: 22 Nov 2001 19:54:38 +0100 Subject: redirecting sys.stdout and threads References: <3BFC9620.EF571437@engcorp.com> Message-ID: Peter Hansen wrote in news:3BFC9620.EF571437 at engcorp.com: > Chris Liechti wrote: >> >> the standard way to redirect outputs of print statements is to assign >> an other file to sys.stdout and/or sys.stderr. the editors (idle, >> pythonwin, wxWindows pyshell, etc.) are an example for this. >> >> but what can you do if more than one thread wants to use redirection? > > The way I handled this was to write a redirector object > (I called it the Doppleganger class) which can be installed > in place of sys.stdout. When the write() method of the > Doppleganger was called, it would check to see if the current > thread object had a predefined name which referenced a > Redirector object with another write() method. If it did, it > would pass the data on to that object's write() method. > Otherwise it would just print to the original stdout. > > This allowed creation of, among other things, a redirector > which wrote to a socket, and one which wrote to a log file, > depending on what object a particular had installed as > its redirector. > > There might be easier methods, but after I noted that the > interpreter (apparently) records sys.stdout *on startup* and > uses that one reference for all subsequent print statements > (effectively "fixing" destination of printed output), > I saw no other choice. > I realized that my example script modified the one and only sys instance that is common for all threads, hence its logic that all threads print to the same stream. I'm mainly interested in redirecting output of an exec statement and you can specify a global dict for exec: "exec string in myglobals" so i could make a copy of the original globals and then modify the dict to use a copy of the sys module with redirected outputs. i'll have to play around with this... chris -- Chris From matt at mondoinfo.com Sat Nov 24 15:21:54 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sat, 24 Nov 2001 20:21:54 GMT Subject: Win98 PySol problem References: Message-ID: On Fri, 23 Nov 2001 21:37:33 GMT, Bill Melcher wrote: Dear Bill, >Hi Guys Hi! >Sorry to bust in here but I have yet to find an appropriate 'place to go'. >Perhaps someone can point me to some useful, helpful would be nice, >resources or even solve my problem(s). >1) I am very new to Python although not to computer programming >(mostly asm on mainframe and IBM clone PC). > File "pysol.py", line 2024, in makeImage > File "O:\PYTHON21\lib\lib-tk\Tkinter.py", line 2972, in __init__ >apply(Image.__init__, (self, 'photo', name, cnf, master), kw) > File "O:\PYTHON21\lib\lib-tk\Tkinter.py", line 2928, in __init__ >self.tk.call(('image', 'create', imgtype, name,) + options) >TclError: unknown option"-dither" You'll need to get the source distribution and hack it very slightly. I think that the relevant code is: if os.name == "nt": if dither is not None: kw["dither"] = dither And I think you'll be fine if you just comment it out. The code assumes that Tk supports a dither option under some versions of Windows when at least sometimes it doesn't. >Note that I have (at my age and circumstances) little interest in >/programming/ in Python, I just want to get the dang program to run >on an alien OS. Have fun with PySol and you may want to take a look at Python: programming in Python is fun! Regards, Matt From grzegorz at ugrad.cs.ualberta.ca Sun Nov 4 06:23:28 2001 From: grzegorz at ugrad.cs.ualberta.ca (Grzegorz Dostatni) Date: Sun, 4 Nov 2001 04:23:28 -0700 Subject: Tkinter, pickle (or shelve) and marshal Message-ID: Cheers! How do I detect when an object is being Pickled (or just before?). Read below for an explanation (WHY ???) In short. I want to take a current graphical state of an application (or perhaps only a part of it) and pickle it (usually to database, but just plain pickle will suffice). I may also need to pickle code objects - hence marshal. I know that normally that will not work. Widgets are part of the TkApp object that cannot be pickled. However if I can detect that an object is being pickled I can save complete widget information, dynamically delete all references to runtime tkApp object (or create a new class that will do so) and save that "cut down" version of my widgets. That should work. I can write a module that will modify Tkinter in memory to smoothly add that functionality (I've done similar things before ;-) - to make it easier on the less experienced Python programmers). I need to be able to detect when an object is being pickled. I could hack it as well by binding myself to the pickle module in memory as well. (what I mean is that I import pickle module, import picklewrap module that renames all the functions in pickle and adds my own wrappers to the pickle module - all that is done in memory, and If I do it right - the program knows no difference ). As an added incentive my project is going to end up under GPL. The real project is not going to be all that usefull to most people, but some parts of it are going to be quite interesting. The ability to create a graphical application from a definition in a database will be another. As well as a Tree widget that displays Database info and allows to edit Python code within, etc, etc. I am looking for a beautifull, Pythonic way to solve this ;-) Grzegorz _-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_-=-_ Some family trees bear an enormous crop of nuts. Wayne H. Drawing on my fine command of language, I said nothing. *Anonymous From ws-news at gmx.at Mon Nov 26 05:40:13 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Mon, 26 Nov 2001 11:40:13 +0100 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <83bshqtek2.fsf@panacea.canonical.org> Message-ID: <3c021cd7@brateggebdc5.br-automation.co.at> Hi, ... > > > Then there's a second point: I see that many projects use version > > control (usually CVS). I tried using DJGPP's cvs, but it > > (unsurprisingly) doesn't work well on WinXP. There's such a thing > > as WinCVS, but the whole process strikes me as clumsy... checking > > in and out and committing every time something changes... what is > > the point of this? What happens if you forget a step? Does it have > > substantial benefits over versioning your files by hand, aside from > > having a repository through which you can undo changes? > > Cygwin cvs works well on pre-XP versions of NT. I haven't tried XP. > > CVS doesn't require you to check out repeatedly, and you only check in > when there are changes. > > Version control is a huge benefit when you're trying to work on > something with other people; it keeps you from accidentally destroying > their work. It's not as big a win with individual projects, but it > still has some advantages: > - I can type 'cvs annotate' to see when each line of code in my work > area was added --- what date, what time. (And by whom.) > - I can type 'cvs diff -D 2001-10-25' and see the changes since > October 25th. > - I can type 'cvs diff' and see what changes I haven't committed, > which often keeps me from committing typos in comments (where I typed > some character in the wrong window) > - saving my current work state is quicker than with a copy-tree, and > it takes less disk space, which makes it easier to back up my entire > work history. > > That said, I still mostly use it when I'm working with somene else, or > when I have multiple copies of files on different machines that I > might edit independently. (I keep my PIM stuff --- calendar, > addresses --- this way.) > There are some more things I really like about version control. + You need only backup your CVS repository and are relatively safe against big data loss in case some part of the hardware decides to break down. (I know that one should always have a good backup anyway, but I tend to be realistic too). E. g. in our office we keep virtually everything in our source control system (even documentation, specification files, etc.). When my box is suddenly dead, the worst that is lost are my bookmarks, the rest is backed up (at least the last working version) in source control. + I speeds up development a lot, at least for me. Before having source control, I spent a lot of time to backup things before trying a new way to do something. By now, you just get a fresh working copy of what you intend to change, try your stuff as desired. If you find out that it's not worth the change, you do not need to manually restore any changes (which offers great opportunity to forget some 'minor' changes) but simple discard your changes and let source control care for the rest. That said, I use source control for virtually anything. One gets used to the process very quickly, and when you come to the point where an automated rollback does a good job, you'll safe more than you've invested (in terms of time and hassles). just my 0.02 ? Werner From toffer_ji0 at subdimension.com Tue Nov 27 12:11:26 2001 From: toffer_ji0 at subdimension.com (toffer_ji0 at subdimension.com) Date: Tue, 27 Nov 2001 17:11:26 -0000 Subject: (no subject) Message-ID: <9u0hfu+28mg@eGroups.com> is it possible to call or rather use an instantiated class using, say a string (assuming unique).. i.e. anInstance = aClass('uniqueName') . . . 'uniqueName'.someMethod(someParameter) i'm doing this because i need keep a some classes in a list.. i find it intensive sometimes to use a for loop with if statements just to check if the class exist then use it... From hahaha at sexyfun.net Tue Nov 13 22:19:58 2001 From: hahaha at sexyfun.net (Hahaha) Date: Tue, 13 Nov 2001 21:19:58 -0600 (CST) Subject: Enanito si, pero con que pedazo! Message-ID: <0GMR006NJT62I7@SMTP.Prodigy.Net.mx> Faltaba apenas un dia para su aniversario de de 18 a?os. Blanca de Nieve fuera siempre muy bien cuidada por los enanitos. Ellos le prometieron una *grande* sorpresa para su fiesta de complea?os. Al entardecer, llegaron. Tenian un brillo incomun en los ojos... -------------- next part -------------- A non-text attachment was scrubbed... Name: enano porno.exe Type: application/octet-stream Size: 23040 bytes Desc: not available URL: From emile at fenx.com Fri Nov 30 12:30:04 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 30 Nov 2001 09:30:04 -0800 Subject: Non-Indented python References: Message-ID: <9u8g1o$6v9i3$1@ID-11957.news.dfncis.de> "Michael Abbott" wrote in message news:Xns9169A839E1656michaelrcpcouk at 194.238.50.13... > I'm sure you're right, and if I'm fanning an unwanted fire, I'll stop. > > However, until you ask me to stop (or we get bored), I want to continue to > say: > > Hard tabs in source files serve no useful purpose and cause trouble. > Please don't use them! > > This is a self evident +holy truth+ :^) I prefer hard tabs. I use 4 spaces for consistency with Python Labs' declared standard, but the useful purpose hard tabs served for me was that my preferred editor displays hard tabs with a character that is easy to follow up and down the display. I find that my eye wanders following visible spaces when confirming indentation, and thus annoy me more when coding. Colons at the end of lines, on the other hand, serve no useful purpose and cause trouble. ;-) ban-colons-not-tabs-ly y'rs, -- Emile van Sebille emile at fenx.com --------- From maxm at mxm.dk Fri Nov 16 13:26:21 2001 From: maxm at mxm.dk (maxm) Date: Fri, 16 Nov 2001 19:26:21 +0100 Subject: OT:This group archived? References: <9t367u$kg6$1@neptunium.btinternet.com> Message-ID: There's allways google groups: http://groups.google.com/groups?hl=en&lr=lang_da|lang_en&group=comp.lang.pyt hon "DL" wrote in message news:9t367u$kg6$1 at neptunium.btinternet.com... > Hi all, > > just a quick question from someone new to Python. Is this group archived > anywhere to save me > bothering everyone with questions which have been asked hundreds of times. > > Cheers, > Derek. > > From fperez528 at yahoo.com Fri Nov 30 19:45:40 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 02 Dec 2001 00:13:40 +2328 Subject: Whatever happened to String Interpolation? References: <9u6dbn$nsj$1@peabody.colorado.edu> <837ks6se4c.fsf@panacea.canonical.org> <9uc26v$akh$1@peabody.colorado.edu> Message-ID: <9uckd9$o43$1@peabody.colorado.edu> Tim Hammerquist wrote: > Fernando P?rez graced us by uttering: > [ snip ] >> "x is $x, f(x) is $f(x)" >> >> This to me is readable, unambiguous and very useful. > > Ambiguity: > > Is that "the result of function f on variable x" or "the value > of variable f, with the literal '(x)' after it"? I don't see the ambiguity. Here's a transcript of what Itpl (Ping's 'reference' implementation): In [1]: from Itpl import itpl In [2]: x=5 In [3]: itpl('x is $x, f(x) is $f(x)') # this fails, f is undefined: --------------------------------------------------------------------------- NameError Traceback (most recent call last) ? in itpl(text='x is $x, f(x) is $f(x)') ? in __str__(self=) NameError: name 'f' is not defined In [4]: f='NAME F' # this fails, you want to call a string: In [5]: itpl('x is $x, f(x) is $f(x)') --------------------------------------------------------------------------- TypeError Traceback (most recent call last) ? in itpl(text='x is $x, f(x) is $f(x)') ? in __str__(self=) TypeError: object of type 'string' is not callable In [6]: def f(x): return x**2 ...: # now f is a function, all is well: In [7]: itpl('x is $x, f(x) is $f(x)') Out[7]= 'x is 5, f(x) is 25' # if you want f to be something else, you protect the name just like # in a normal shell. No need to go as crazy as you said in @{[&f(x)]}: In [8]: f='NAME F' In [9]: itpl('x is $x, f(x) is ${f}(x)') Out[9]= 'x is 5, f(x) is NAME F(x)' > This slippery slope is one of many reasons many Pythonistas don't > want creeping featurism to infect their language. I honestly don't see it as a slippery slope. Ping's implementation seems to 'do the right thing' in all cases, produces no surprises and doesn't at all require the kind of grossness you quoted. > (Perl has ways of disambiguating(?) the above expression, but it > leads to ugly code Pythonistas love to make fun of. eg: > > "x is $x, f(x) is @{[&f(x)]}" > > That's the perl equivalent. ) I'm not trying to be stubborn, I'd just like to see if this topic can be discussed a bit more. For regexps the \\\\\\ plague was deemed bad enough that the best solution was to introduce a special type of string, r''. Unicode strings also are special. I don't see interpolated strings as being a 'slippery slope', the concept of special strings is *already* in the language. I certainly *don't* want to see Python go the perl route (and I've written a lot of perl, so I know exactly what it's like). But that doesn't mean that there aren't things where python's current syntax can actually end up leading to unnecessary ugliness. In fact, things like 'blah %(var)s' to me look a lot less readable (and line noise like, perl-like, whatever) than 'blah $var'. Or is it that in Python there's such a rabid fear of $ as to not even admit a case where something like it may be useful? Regards, F. From mgerrans at ix.netcom.com Wed Nov 28 04:22:40 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Wed, 28 Nov 2001 01:22:40 -0800 Subject: Keeping Python loaded References: <9tndpi$qbe$1@slb0.atl.mindspring.net> <9tvlns$ca4$1@slb1.atl.mindspring.net> <83ofln6g1o.fsf@panacea.canonical.org> Message-ID: <9u2aei$jdh$1@slb2.atl.mindspring.net> Thanks, Kragen! I made a mini-command interpreter to keep the engine going and run scripts on the "command line." It works great! It is super fast (compared to the normal start-up time for an individual script) and doesn't eat any CPU while waiting for the next script to run. I've included the script below, for those who are interested. - mfg #!/usr/bin/python import sys def runScript(filename): namespace = { '__name__' : '__main__' } execfile(filename, namespace) return namespace def readCommands( verbose = 0 ): while 1: cmd = raw_input('--> ') args = cmd.split() if len(args) > 0: if args[0].lower() in ('exit','quit','bye','adios'): print 'Bye!' return else: if (len(args[0]) < 3) or (args[0][-3:].lower() != 'py'): args[0] = args[0] + '.py' try: sys.argv = args if verbose: print 'Running ' + args[0] + ' with args = ' + `sys.argv` runScript( args[0] ) except: print '*'*20,'Bronk!','*'*20 print 'Exception: ', sys.exc_type print 'Extra clues:', sys.exc_value def main(): if '-v' in sys.argv: print 'Running in verbose mode!' readCommands(1) else: readCommands() if __name__ == '__main__': main() From sheershion at mailexpire.com Tue Nov 13 17:17:32 2001 From: sheershion at mailexpire.com (Robert Amesz) Date: Tue, 13 Nov 2001 22:17:32 -0000 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> <2b326e2e.0111130531.7a85a0b8@posting.google.com> Message-ID: Steven Rumbalski wrote: > Michael 'Mickey' Lauer > wrote in message news:<3beedf26 at nntp.server.uni-frankfurt.de>... > >> What do you think would be a good application to show the basics >> and a few more sophisticated topics in programming GUI >> applications with Python? > > My $.02: > > How about a simple text editor? Whatever application you present > you should probably have either an appendix or an early chapter > explaining the code that will stay the same across each > implementation. That's trivial if you use a standard display component (e.g. the wxTextCtrl or wxStyledTextCtrl for wxPython) or very hard if you're starting from scratch. Hmmm, how about an .INI/.CFG file editor? You could start by using a standard text control, and then move on to different and more sophisticated ways (perhaps using tree controls and different panes). As a piece de resistance you could us a thread to monitor if the .ini/.cfg file has changed by another program and merge it with your copy if it has, updating the display. This would be a good demonstration of how a GUI can react to things from the outside (a point which was raised by Laura Creighton). Robert Amesz From nospam!jklassen at biblesociety.ca Wed Nov 7 12:47:39 2001 From: nospam!jklassen at biblesociety.ca (Jeff Klassen) Date: Wed, 7 Nov 2001 12:47:39 -0500 Subject: Creating a list of files in a directory Message-ID: Hello, I am new to Python. As a non-programmer I am encouraged by the level of 'success' I feel I have had, relative to similar learning attempts in other languages. I would like to simply do the following: - read all of files of a particular form (e.g. *.cev) from a particular directory - manipulate them with a series of re.sub expressions - write each file to its own output file with a certain form (e.g. *.out). I have been able to create the re stuff, and process individual files. However, I cannot get a for loop to do everything in a directory. Here is the code I came up with. (I am wanting to create a list of all files that conform to *.cev) ---------------------------- import dircache import re workingdir=dircache.listdir('/jobs/python/learning/') filespec = re.compile(r'.*?\.cev') filestoprocess = [] for allfiles in workingdir: matchedfile=filespec.match(allfiles) filestoprocess.append(matchedfile.group()) print filestoprocess ---------------------------- When I run this script I am returned: AttributeError: 'None' object has no attribute 'group' When I issue these commands in the Python Shell, substituting an actual value for allfiles such as 'mat.cev', everything works OK. I can execute filestoprocess.append(matchedfile.group()) and then print filestoprocess, and I am returned ['mat.cev']. Why does this fail to work inside of the loop? Thanks very much for any help. Jeff From DTSRV10-SA at dutchtone.nl Tue Nov 13 22:32:51 2001 From: DTSRV10-SA at dutchtone.nl (DTSRV10-SA at dutchtone.nl) Date: Wed, 14 Nov 2001 04:32:51 +0100 Subject: ScanMail Message: To Recipient virus found and action taken. Message-ID: <234008652B43D41188200008C71E750C02C715BA@dtsrv10.dutchtone.nl> ScanMail for Microsoft Exchange has detected virus-infected attachment(s). Sender = hahaha at sexyfun.net Recipient(s) = python-list at python.org;python-announce at python.org Subject = Enanito si, pero con que pedazo! Scanning Time = 11/14/2001 04:32:51 Action on virus found: The attachment enanito fisgon.exe matched file blocking settings. ScanMail has Deleted it. Warning to recipient. ScanMail detected a virus in an email attachment.=========================================================== De verzonden informatie is uitsluitend bestemd voor de geadresseerde natuurlijke persoon of rechtspersoon en bevat mogelijk vertrouwelijke en/of geprivilegeerde gegevens. Met uitzondering van de geadresseerde persoon is het niet toegestaan de informatie openbaar te maken, te kopi?ren, te verspreiden of anderszins actie te ondernemen op basis van de informatie. Indien u de informatie abusievelijk heeft ontvangen, neem dan contact op met de afzender en verwijder de informatie uit alle computers. Dutchtone staat niet in voor de juiste en complete verzending van de informatie, noch is zij aansprakelijk voor de vertraagde ontvangst hiervan. The information transmitted is intended exclusively for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any disclosure, copying, distribution or other action based upon the information by persons or entities other than the intended recipient is prohibited. If you receive this information in error, please contact the sender and delete the material from any and all computers. Dutchtone does not warrant a proper and complete transmission of this information, nor does it accept liability for any delays. =========================================================== From john.thingstad at chello.no Thu Nov 22 13:17:50 2001 From: john.thingstad at chello.no (John Thingstad) Date: Thu, 22 Nov 2001 19:17:50 +0100 Subject: assigning to nested variables Message-ID: <20011122183013.HPIK20719.mta01@mjolner> I tried to create the followin callback function in Python 2.1 from __future__ import nested_scopes def ask(self, pattern): """Ask Ask if query sentence is true; return 0 otherwise 1.""" cPattern = self.convertClause(pattern) found = 0 def match(bindings): global found; found = 1; return 1 self.backChainEach(cPattern, match) return found The ide was to assign 1 to found if the match callback function was called. However, found = 1 creates a new local variable found and ask's found variable remains zero. Is there a way to assign 1 to ask's found? I read the documantation but found no refrerence to this. From skip at pobox.com Mon Nov 26 14:03:09 2001 From: skip at pobox.com (Skip Montanaro) Date: Mon, 26 Nov 2001 13:03:09 -0600 Subject: Become In-Reply-To: <3c028dfc$0$26362$7a628cd7@news.club-internet.fr> References: <3c028dfc$0$26362$7a628cd7@news.club-internet.fr> Message-ID: <15362.37357.61087.768052@beluga.mojam.com> Jiba> Here is a module that reproduce the Smalltalk "become" capability. Jiba> Become can replace (quite) all references to an object by a Jiba> reference to another object. It relies on gc.get_referents(). Can you motivate this with an example that shows where it would be useful? -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From sandskyfly at hotmail.com Mon Nov 19 13:44:16 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: Mon, 19 Nov 2001 18:44:16 -0000 Subject: object identity and equivalence References: Message-ID: <3bf9532b_1@mk-nntp-1.news.uk.worldonline.com> Erno Kuusela wrote: >> as a rule, a is b implies a == b (except for odd things like floating >> point NaNs that compare inequal to themselves). >> a == b does not imply a is b. You are correct of course : >>> x = 10.0 >>> y = 10.0 >>> x is y 0 >>> x == y 1 Two different objects, same value, different identity. Makes sense... must have been a momentary lapse: I think I better change my coffee... (-: Almost immediately after I posted my question, I ran another search and found this link to be helpful: http://groups.google.com/groups?hl=en&th=7fe7cbcb5f2d40b5&seekm=1002344191.5 78675%40cswreg.cos.agilent.com&frame=off > There! I've announced my ignorance to the world. Feel better already! >> congratulations :) Thanks! Sandy From jason at jvoegele.com Fri Nov 30 13:17:27 2001 From: jason at jvoegele.com (Jason Voegele) Date: 30 Nov 2001 10:17:27 -0800 Subject: Python evangelists unite! References: <9u77i8$a5j$1@slb0.atl.mindspring.net> Message-ID: <91acf731.0111301017.31cd71a5@posting.google.com> "Jyrinx" wrote in message news:<9u77i8$a5j$1 at slb0.atl.mindspring.net>... > I haven't worked much with Ruby, I'll admit, but one of their advertised > "features" sounds like something that violates OO far more than Python's > dynamic members. I don't like singleton functions at all - they let you > cheat by futzing with core implementation details in client code. Yeah, > Python probably allows this, too, but it's not common and certainly not > advertised. A friend argued that it's a waste of code to declare an entirely > new class just to override a method and declare a single instance of it; I'd > say that deriving a new class is clearer, and redefining an instance's > member functions seems kludgy and prone to hard-to-find bugs. (Besides, I > like the Python principle that, while short code is good, clear and succinct > code is more important than the absolute minimum of LOC's.) > > Anyway, the point is, while Python allows extra members to be tacked on for > a client's own use, this is not half the violation of OO concepts that a > certain other language regards as a neat feature. Neither singleton methods, nor dynamic members are a violation of OO principles in the least. They are both, on the other hand, violations of a static typing principles. Neither Ruby or Python offer static typing, so why is this a big deal? Ruby offers this flexibility because it's a dynamic language, and it comes in very handy. For example, I'm writing a Ruby binding to the Object-Oriented database GOODS. Some objects are persistent, some are transient. You don't know at "compile time" which are which, so it's very nice for my binding to be able to add persistence support methods at run-time only to those objects that will be stored in the database. Without Ruby's support for adding these methods to individual objects, I'd have to modify the class, which would mean adding all this persistence-related stuff to transient objects. Ruby allows a much cleaner solution: add the persistence support methods only to those objects that need them. The point is: don't listen to this kind of argument from someone who has little or no experience with dynamic languages. Singleton methods and dynamic members are not cheating, they're incredibly useful features that some C++ programmers are averse to because it doesn't "feel right", because it doesn't follow the "strict interface" semantics required by a statically typed language. If you're using a dynamically typed language, you've already given up the static-typing safety net, so why bother to live with the restrictions that are necessary for a static type system? Remember, in a dynamic language, class does not equal type. Jason Voegele From James_Althoff at i2.com Wed Nov 28 18:36:20 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 28 Nov 2001 15:36:20 -0800 Subject: PEP 276 Simple Iterator for ints Message-ID: Jeff Shannon wrote: >Better still, and already valid: > >if index >= len(mylist): > print 'index out of range' ... although you would probably want to add the other condition as well: if index >= len(mylist) or index < 0: Jim From etoffi at bigfoot.com Fri Nov 30 01:46:39 2001 From: etoffi at bigfoot.com (e toffi) Date: 29 Nov 2001 22:46:39 -0800 Subject: pyplets References: <655abd4a.0111290417.4b28a0f2@posting.google.com> <9u5k47$e7p$0@216.39.145.92> Message-ID: <655abd4a.0111292246.36de44a1@posting.google.com> rossini at blindglobe.net (A.J. Rossini) wrote in message news:<9u5k47$e7p$0 at 216.39.145.92>... > >>>>> "et" == e toffi writes: > > et> i was thinking (which i dont do often), and came up with an > et> idea (which i *do* do often -- dont ask me how). the idea is > et> pyplets -- the analogue to java applets with a fittingly silly > et> name. anyway the premise is to define an api that lets > et> programmers write small programs that execute in a browser. > > et> whatdyathink? > > I thought they had support for them in Grail eons ago. how many people use grail? how many have even heard of it? and does it still actually work? ---- Vincent A. Primavera. >> jythonc hello.jy ---- Andreas Ulbrich >> is there really a point to that? i mean we can do that now, but it's still just java. ---- Cameron Laird >> hi ;) ---- Oleg Broytmann >> activex and netscape plugins! ---- Jiba >> not exxactly what i was talking about, but interesting nonetheless. -- etoffi From not.this at seebelow.org Mon Nov 5 00:14:06 2001 From: not.this at seebelow.org (Grant Griffin) Date: Sun, 04 Nov 2001 23:14:06 -0600 Subject: How much is set in stone? References: <3BE4DF39.AE0A8EAA@ix.netcom.com> Message-ID: <3BE6201E.6638CCCA@seebelow.org> Jive Dadson wrote: > > I'm a newbie at Python, but I've been up to my ears in it for the last > couple of days. -- Considering using it for a scripting language for a > product at work. I'm very impressed with the system. Of course there > are things I would like to change. :-) So the question is, how much is > set in stone at this point? Is the definition of 2.x now the law of the > land, or can we still make suggestions? Sure, you're free to make suggestions. (We tried to stop folks in the past, but it didn't work .) However, bear in mind that nearly anything any newbie might suggest has very likely already been suggested and debated *many* times in Python's 10-year history, so if it isn't already in Python, it has probably been rejected, and you are very likely wasting your breath. (The Python FAQ at http://www.python.org/doc/FAQ.html addresses some of these things in its "Python's Design" section.) That being said, in observing Python's change over the last two years, I have been unable to discern any overall direction to them. Python embodies several different design ethics, some of which are contradicatory, so its designer, Guido van Rossum, has had to make choices. For example, one ethic is to minimize the number of features; even so, features get added on a regular basis. Another ethic is to make Python run faster; however, one new feature, "rich comparisons", has actually slowed it. Another ethic is to make only backwards-compatible changes; however, a new feature, the "__future__" statement, was added to allow backwards-incompatible changes to be phased in; fortunately, though, the __future__ statement is itself backwards-compatible. (Who but Picasso could know exactly which noses to paint sideways? ) Version 1.5.2 was current when I started, and several new features have been added since then. I suppose every thinks the "true" version of Python is the one in use when they started. But in all honesty, I haven't found the newer features to be very useful (to me, at least) except for string methods (you used to have to import the string library to do basic string manipulations) and "augmented assignments" (things like "+=", "*=", etc.). I also use "list comprehensions" (which are too incomprehinsible to summarize here ) on rare occasions--though I'm usually ashamed of myself later. Overall, if you find a simple feature to be "missing" (e.g. C's increment and decrement operators: "++", "--") it probably has been intentionally omitted (or at least "steadfastly not added"). As you become experienced in Python, you will eventually discover the reasons for the choices Guido has made, and you will most likely agree with them (though I never *did* figure out why Python 1.5.2 didn't have augmented assignments .) If not, you can always demand your money back. What I'm getting at, of course, is that most things that newbies suggest (including myself) result from a lack of understanding of The Big Picture, which you might eventually discover--heck, I'm still hoping to . Or, maybe it just hasn't happened yet. In any case, be assured that somebody has thought of it, somebody has suggested it, and somebody has debated it--probably many times. if-Python-doesn't-already-have-it,-you-probably-don't-need-it-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 skip at pobox.com Thu Nov 1 18:24:35 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 17:24:35 -0600 Subject: Learning Python In-Reply-To: <20011101180300.21692.00000997@mb-mr.aol.com> References: <20011101180300.21692.00000997@mb-mr.aol.com> Message-ID: <15329.55731.851644.10895@beluga.mojam.com> >> What is a good tutorial for learning Python? If you're completely new to programming, check out the links available at http://www.python.org/doc/Newbies.html If you're already comfortable with another programming language, I think the best place to start is the Python tutorial at http://www.python.org/doc/current/tut/tut.html In general, there are tons of interesting links (take your pick) reachable from http://www.python.org/doc/ -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From kalle at gnupung.net Tue Nov 6 18:58:00 2001 From: kalle at gnupung.net (Kalle Svensson) Date: Wed, 7 Nov 2001 00:58:00 +0100 Subject: How much is set in stone? In-Reply-To: <3BE8724E.7482C881@ix.netcom.com> References: <3BE8724E.7482C881@ix.netcom.com> Message-ID: <20011107005759.D23894@sandra.lysator.liu.se> [Jive Dadson, regarding responses to his "option explicit" proposal] > I expected better from this group. You did? What would be better in this case? That anyone who doesn't like your proposal (most of the c.l.py subscribers, I would guess) stay quiet? Peace, Kalle -- [ Thought control, brought to you by the WIPO! ] [ http://anti-dmca.org/ http://eurorights.org/ ] From skip at pobox.com Thu Nov 29 22:23:42 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 29 Nov 2001 21:23:42 -0600 Subject: What's the value of "None" between 2.1.1 and 1.5.2 In-Reply-To: References: Message-ID: <15366.64446.319118.148410@beluga.mojam.com> Ozone> I have written a simulation in python 1.5.2.... It used to work Ozone> fine. Ozone> When I logged on a new machine which has Python 2.1.1 installed, Ozone> my simulation has gone wild. Later on, I figured that out one Ozone> weird thing about the value of "None": You were relying on undocumented behavior. There is no obvious ordering between integers and None. Ozone> I don't really want to fix this type of bug again whenever Python Ozone> upgrades.... Then fix your program so it doesn't rely on this. You'll only have to fix it once. ;-) -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From wzdd at lardcave.net Thu Nov 1 00:02:14 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Thu, 1 Nov 2001 16:02:14 +1100 (EST) Subject: python development practices? In-Reply-To: <200110310458.f9V4wJ018969@mbuna.arbhome.com.au> Message-ID: On 31 Oct, Anthony Baxter wrote: > >>>> pzw1 at cornell.edu wrote >> > [unit tests, XP, blah blah blah] > >> hmm.. this seems to be the uniform response to my questions, and it was >> what i had surmised before even posting. is there really no middle >> ground? are there no real development groups using python with high >> time-to-market pressures and imperfect process? i find it hard to >> believe that someone or some group hasn't evolved a way of dealing with >> this... > > If you play with them for real a bit, you'll find that unit tests actually > _improve_ your time to market - the time you need to spend writing them and > keeping them up to date is more than outweighed by the savings in debugging > and bughunting. As someone who has worked in an almost exclusively-Python company for close to a year, I have to agree that unit (and more importantly functional) tests vastly speed up development, for exactly the reasons outlined above. Perhaps Python needs them more than many languages because of its lack of strong types, but I'm so enamoured with them that I'm going to try to use them with everything I do. We also use various other Extreme Programming-related things, such as pair programming and code reviews, but nothing is quite so company-wide and (to my mind) useful as the test suites. -- - Nicholas FitzRoy-Dale http://www.lardcave.net I'm thinking of getting a pet cheese. I already have the cheese food. - http://www.enweirdenment.org/cgi-bin/cube-hof.html From pehr at alum.mit.edu Sun Nov 4 09:57:17 2001 From: pehr at alum.mit.edu (pehr) Date: Sun, 04 Nov 2001 14:57:17 GMT Subject: ANNOUNCE: PySteroids 2.0 References: Message-ID: <3BE557DD.7030001@alum.mit.edu> Oops, this version has a bug! Two files are missing: fire.bmp and ship.bmp that can be copied in from the previous pysteroids-1.1 release to make it work. When these files were not found, pysteroids failed rather ingracefully, leaving me trapped with a blank screen in one case and killing my X session in another. In all pysteroids is lots of fun! I like the feel of it and it seems like a base that can be exteneded nicely. If you are looking for feature ideas, I'd order it like this: 1. Antialiased fonts on introduction / instructions 2. Antialiased graphics for ship, asteroid images would give the game a really professional look 3. Use of alpha blending on explosion graphics so they don't look quite so chunky. The current explosion effect is quite nice but edges do show. 4. Better collision detection for missles & ship. I seem to be able to shoot throught the edge of a ship and graze asteroids with imputnity. Maybe you could split some objects into more rectangles for the purpose of collision detection or else use a separate collision verification algorithm on objects after being detected as being "near" eachother with overlapping major rectangles. Good work! I think this is a fun game and look forward to testing out new versions as you release them! Please add me to your mailing list if you have one. Thanks for adding some fun to my day. -pehr -pehr Lucio Torre wrote: > Im happy! this is public release of pysteroids 2.0. my asteroids game > done with pygame. > > Nothing near paradigm shifting in games, but its my baby. > > check it out at: > > http://vampira.dyndns.org/zope/software/ > > lucio. > > From tim at vegeta.ath.cx Sun Nov 25 07:19:27 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Sun, 25 Nov 2001 12:19:27 GMT Subject: How To Kill a Python References: Message-ID: Ben Ocean graced us by uttering: > Hi; I continually run into problems adding new software to my server > that is dependent on Python because I have 2 versions, one of which > is completely unnecessary; namely, 1.5.2. I want to kill it, or at > least make it so that when Python is called it automatically calls 2.1 > instead of 1.5.2, but I don't want to screw anything else up on the > server. How should I go about this? > > TIA, BenO In addition to explicitly specifying which python binary to call in the #! line of the script as mentioned elsewhere in the thread... If you want to automatically call the new python binary when casually working in the shell, alter your $PATH so it'll find your binary before the others. In your .profile or .bash_profile (the file your shell uses to initialize itself) add: PATH="/path/to/your/bin_dir:$PATH" Tim Hammerquist -- /earth is 98% full ... please delete anyone you can. From rpm1deletethis at frontiernet.net Thu Nov 15 22:28:58 2001 From: rpm1deletethis at frontiernet.net (RPM1) Date: Thu, 15 Nov 2001 22:28:58 -0500 Subject: popen on Win 9x? Message-ID: Goal: Write a python program that can call two other C programs and interact with the stdin and stdout of the C programs on Win 98. The two C programs are chess programs that I won't have source to. I want the two programs to play against each other. I have been successful at using popen2 to act as stdin and stdout for either chess program separately but when I try to communicate with both I have problems when I close the second program's pipes. It leaves the process running and leaves a W9xpopen process going and at least one Winoldap process. I open the pipes to each program and then write and read the pipes, (using fstat and stat to determine how much data is in the pipes coming from the chess programs so I don't block). My program works on Windows NT but not on 98. Any thoughts? Thanks, Patrick From jim at interet.com Mon Nov 12 09:52:57 2001 From: jim at interet.com (James C. Ahlstrom) Date: Mon, 12 Nov 2001 09:52:57 -0500 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> Message-ID: <3BEFE249.371EA5FD@interet.com> Gordon McMillan wrote: > Currently, os.py in a package masks the real one from > anywhere inside the package. This would extend that to What??? When Python starts, it imports site.py which imports os.py. So os.py gets loaded, and won't normally get re-loaded. The os.py that gets loaded depends on sys.path. So if os.py is in package1, it won't get loaded for "import os", but it would get loaded for "import package1.os". Are you saying that "import package1.package2.os" will load package1/os.py? I hope that "import os" will not load package1/os.py, will it? Or am I totally confused. Jim Ahlstrom From martin.franklin at westgeo.com Tue Nov 20 11:48:27 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Tue, 20 Nov 2001 16:48:27 +0000 Subject: problem with a python script References: <9tdvv4$1ugdj$1@ID-79019.news.dfncis.de> <9te14d$gm8$1@thorium.cix.co.uk> Message-ID: <9te1fh$16og$1@mail1.wg.waii.com> gbreed at cix.compulink.co.uk wrote: > Felix Seeger wrote: > >> Here is the part of the code: >> >> >> class Mail: >> def __init__(self,outserver="localhost"): >> import smtplib >> self.outserver=outserver >> >> def sendmail(self,from,to,msg,mopts="",rcptopts=""): >> s=smtplib.SMTP(outserver) >> s.sendmail(from,to,msg,mopts,recptopts) >> s.quit() > > It must have been written for an old interpreter where "from" wasn't a > keyword. Try changing the sendmail method to > > def sendmail(self,fromadddr,to,msg,mopts="",rcptopts=""): > s=smtplib.SMTP(outserver) > s.sendmail(fromaddr,to,msg,mopts,recptopts) > s.quit() > > You may also want to change other things # do the import at top of module so smtplib 'global' import smtplib class Mail: def __init__(self, outserver="localhost"): self.outserver=outserver # from is keyword so using fromaddr instead def sendmail(self, fromaddr, to, msg, mopts="", rcptopts=""): # outserver would be local to this function/method # if it existed, so need to use self.outserver s=smtplib.SMTP(self.outserver) # again from is keyword so remember from addr here too. s.sendmail(fromaddr, to, msg, mopts, recptopts) s.quit() Martin From jeff at ccvcorp.com Tue Nov 27 13:52:06 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 27 Nov 2001 10:52:06 -0800 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> Message-ID: <3C03E0D5.BDBEC7A9@ccvcorp.com> Yong Lu wrote: > David Bolen writes: > > > > > One other useful mention is that the "%s" formatter is Python string > > formatting operations will automatically apply str() to any non-string > > object that it is handed. So another approach could be: > > > > print "integer i = %s" % i > > > > A newbie question. Where can I find documentation of this usage? > I've searched a bit in the Python manual, but the only section > on print doesn't mention this. This is, of course, because it has nothing to do with print. ;) String formatting is its own thing (though this is not terribly obvious), and can take place without any usage of the print command, i.e., def format(number, string1, string2): return " %2d: (%s, %s)" % (number, string1, string2) It *is* a bit difficult to find, perhaps, but usage of string formatting is spelled out in the tutorial... Actually, my biggest problem with the documentation for it, is that it assumes familiarity with C printf()-style format specifiers. Jeff Shannon Technician/Programmer Credit International From pj at sgi.com Fri Nov 9 13:04:28 2001 From: pj at sgi.com (Paul Jackson) Date: 9 Nov 2001 18:04:28 GMT Subject: iters on ints? (reducing the need for range/xrange) References: <3BEB4F6E.A173C05D@cosc.canterbury.ac.nz> Message-ID: <9sh5rc$70i4i$1@fido.engr.sgi.com> Michael wrote: |> Horrific idea, BTW. Perhaps. But as someone who specialized in set theory for a brief time long ago, I like it. For me, ten _is_ the set of numbers zero through nine. I trust Guido has the good sense to ignore my preference here. -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From grante at visi.com Tue Nov 27 13:03:10 2001 From: grante at visi.com (Grant Edwards) Date: Tue, 27 Nov 2001 18:03:10 GMT Subject: smtplib help References: <83wv0ds4pk.fsf@panacea.canonical.org> Message-ID: In article , Oleg Broytmann wrote: > On Mon, Nov 26, 2001 at 02:38:15PM -0500, Kragen Sitaker wrote: >> Have you tried running the code on an operating system that doesn't suck? > > Have you ever saw a piece of software that does not suck? :( Paraphrasing Michael Elkins: "All software sucks. Some software just sucks less." -- Grant Edwards grante Yow! .. Should I get at locked in the PRINCIPAL'S visi.com OFFICE today -- or have a VASECTOMY?? From ens_z at yahoo.com Sat Nov 24 03:34:32 2001 From: ens_z at yahoo.com (Ens) Date: 24 Nov 2001 00:34:32 -0800 Subject: unicode fonts in wxPython Message-ID: <39ce62b8.0111240034.27fd22f3@posting.google.com> How can i use unicode fonts in wxPython? From brueckd at tbye.com Wed Nov 28 15:54:21 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Wed, 28 Nov 2001 12:54:21 -0800 (PST) Subject: windows to linux pickled objects? In-Reply-To: <86f75fa2.0111281255.713bdbb5@posting.google.com> Message-ID: On 28 Nov 2001, Fernando P?rez wrote: > Stephen Boulet wrote in message news:... > > > I tried it on linux and the program did run, but the size of the pickled > > file only went down from 8183905 bytes to 8180057 bytes, and the file > > wasn't binary at all. Maybe the size difference can be explained by the > > lack of carriage returns. ;) > > > > It would be nice if the binary option worked on linux... > > > > Just to clarify, what I meant was binary *pickle*, not binary file > write. Pickling in binary should decrease file size by quite a bit > (think of it: a float is 8 bytes long, but can take about 16-18 > characters to print as text). Binary usually helps, but it can work against you too: >>> import pickle >>> len(pickle.dumps(5.0)) 6 >>> len(pickle.dumps(5.0, 1)) 10 -Dave From marcoxa at cs.nyu.edu Tue Nov 13 10:16:30 2001 From: marcoxa at cs.nyu.edu (Marco Antoniotti) Date: 13 Nov 2001 10:16:30 -0500 Subject: Benefits of moving from Python to Common Lisp? References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> <9srbs8$pur$1@slb2.atl.mindspring.net> Message-ID: "Andrew Dalke" writes: > Michael Hudson: > >But they very much take their lead from CPython, so Tim's points all > >remain valid. Well, except for vyper, but that doesn't have enough > >influence to count (perhaps unfortunately). > > I recall some of the conversation when (then) JPython was being > developed, on making sure the documentation didn't require > implementation-specific functionality. So there is *some* > standard-like documentation. > > What's needed to call something a standard? > > I don't know of a C++ compiler which fully meets the C++ standard. > (They all seem to have bits of 'oh, we don't do that yet'.) > > So I figured three different implementations (C, Java and OCaml) > with no shared run-time environment was enough to disprove Tim's > statement: > > ] there is only one implementation, and the language > ] is defined implicitly by that implementation > > For Python, would it be better to say > > there are several implementations, and the language is mostly > defined by the documentation, but the other implementations > defer to the C implementation, distribution, and developers in > matters of interpretation. > ? > > Tim's point was that standardizing a library is a complicated and > expensive process. My point is that the Python library > (standardized or not) works with quite different runtimes. Why > aren't there similarly widely used though non-standard libraries > for CL for "doing stuff like internet programming"? [Paul Rubin] > > For example, back in the Perl4 days when CGI programming first > became hot, just about everyone used cgi-lib.pl even though it > wasn't part of the standard Perl library, and this was pre-CPAN. Historical cruft? The evolution of the languages have been different. The presence of strong vendors in the CL camp does (IMHO) work as a disincentive to community wide standardization. On top of that add the dwindling support for CL as a whole, irrespective of the technical merits of the language itself. Things are changing, yet slowly. This is just the way things are. As for "widely used though non-standard libraries for CL for "doing stuff like internet programming", you can check the CLOCC (http://sourceforge.net/projects/clocc). Not much, but it is there. Cheers -- Marco Antoniotti ======================================================== NYU Courant Bioinformatics Group tel. +1 - 212 - 998 3488 719 Broadway 12th Floor fax +1 - 212 - 995 4122 New York, NY 10003, USA http://bioinformatics.cat.nyu.edu "Hello New York! We'll do what we can!" Bill Murray in `Ghostbusters'. From teg at redhat.com Fri Nov 30 12:32:53 2001 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 30 Nov 2001 12:32:53 -0500 Subject: pygettext examples? References: Message-ID: Joseph Santaniello writes: > Hi Martin, > > I've gotten my code marked up: (test.py) > > #!/usr/bin/python2 > import gettext > > def _(msg): > return gettext.dgettext("test", msg) > > def do_stuff() > print _("I don't know.") > > if __name__ == '__main__': > do_stuff() import gettext ## ## I18N ## gettext.bindtextdomain(PROGNAME, "/usr/share/locale") gettext.textdomain(PROGNAME) _=gettext.gettext print _("Hello, world!") -- Trond Eivind Glomsr?d Red Hat, Inc. From barry at zope.com Thu Nov 1 02:17:07 2001 From: barry at zope.com (Barry A. Warsaw) Date: 01 Nov 2001 02:17:07 -0500 Subject: Send an email . References: <007901c16133$0835e260$a197003e@rashome> Message-ID: >>>>> "OB" == Oleg Broytmann writes: OB> mimetools and MimeWriter for generating mail. Or the new email package. Available in Python 2.2, or with a distutils-based compatibility package for earlier versions (requires at least Python 2.0). http://sourceforge.net/project/showfiles.php?group_id=25568&release_id=58732 -Barry From eppstein at ics.uci.edu Tue Nov 27 19:36:51 2001 From: eppstein at ics.uci.edu (David Eppstein) Date: Tue, 27 Nov 2001 16:36:51 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> Message-ID: In article , Gareth.McCaughan at pobox.com (Gareth McCaughan) wrote: > Greg Ewing wrote: > > > While trying to think of a range syntax that looks > > unambiguously half-open without clashing with list > > or tuple constructors, the following blindingly > > obvious solution occurred to me: > > > > for 0 <= i < 5: > > ... > > +1 if it also groks "for 0 < i <= 5" and so on. Also +1 if it gives the reversed sequence for "for 5 > i >= 0". I don't much care about nice syntax for increments other than 1 and -1. -- David Eppstein UC Irvine Dept. of Information & Computer Science eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/ From dalke at dalkescientific.com Wed Nov 14 18:05:21 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Wed, 14 Nov 2001 16:05:21 -0700 Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> <9srqem$vt2$1@slb0.atl.mindspring.net> <9nj5vto66nk83romuu3f40qrd72lmrjpui@4ax.com> Message-ID: <9sut89$b7v$1@slb7.atl.mindspring.net> Me: >>I wanted to add a new method, so I did >> >>class Spam: >> def double(self): >> self.x = self.x * 2 Daniel Klein: >Just curious to know how it is that you expected this to work Because I didn't think that 'class Spam' always created a new class. I thought it would reuse a definition of one already exists. I believe this is similar to what Smalltalk does. > why you were 'annoyed'? Because it didn't fit my model of how the language worked, so was more effort to learn. >I can't >see what the problem is with the double() method. The problem was I wanted to add a method to an existing class. The method definition was fine. Andrew dalke at dalkescientific.com From recip at a1-online-marketing-advertising.com Sun Nov 25 19:23:07 2001 From: recip at a1-online-marketing-advertising.com (Gloria) Date: Sun, 25 Nov 2001 19:23:07 -0500 Subject: Reciprocal Links Message-ID: <200111251920.23w9r9A@192.168.0.2> An HTML attachment was scrubbed... URL: From gat at jpl.nasa.gov Thu Nov 8 14:33:41 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Thu, 08 Nov 2001 11:33:41 -0800 Subject: What does *x mean? Message-ID: I've heard people mention "the new *x syntax". Does Python have a prefix * operator now? What does it do? (It's not mentioned in the online language reference at python.org.) Email replies preferred. Thanks! Erann gat gat at jpl.nasa.gov From LLewin at oreilly.com Mon Nov 26 08:14:05 2001 From: LLewin at oreilly.com (Laura Lewin) Date: 26 Nov 2001 05:14:05 -0800 Subject: 11-15 new Python Books on the way! (fwd) References: Message-ID: This is a great list! You can also add Jython Essentials, O'Reilly, Samuele Pedroni and Noel Rappin. The book is due out in March. Laura LLewin at oreilly.com > Ron Stephens wrote: > |Truly a surfeit of books. But, for what it is worth, I have listed all I > |could find out about them all at http://www.awaretek.com/plf.html > From killspam at darwinwars.com Wed Nov 28 03:49:38 2001 From: killspam at darwinwars.com (Andrew Brown) Date: Wed, 28 Nov 2001 08:49:38 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> <83u1vhs2j2.fsf@panacea.canonical.org> Message-ID: "Bill Melcher" wrote in : > >"Bill Melcher" wrote in message >news:uaCM7.538$yq7.150911048 at newssvr10.news.prodigy.com... >> [...] > >I have discovered that pysol.py in .../src is supposed to create the >'bundle' so all I have to do is discover where the output module >(pysol.pyc) has gone or why it did not get created. > I have been following this thread, having come across the same problem when I downloaded pysol 4.72 for Windows. It wouldn't run becasue of the "dither" error. This was on Windows 2k I left that installation where it was -- when I ran the windows installer, I got all the card sets and everything; and simply unpacked the source into a fresh subdirectory under that tree (C:\program files\games\pysol-4.72\src) and comented out the "dither" lines as suggested in this thread. I then run "python src\pysol.py" from the directory above, and it finds the cards and runs perfectly -- until I move the mouse when clicking on a card. this makes the game crash with an error about an unrecognised cursor, which I must find and fix. From dsavitsk at e-coli.net Mon Nov 12 23:16:01 2001 From: dsavitsk at e-coli.net (dsavitsk) Date: Tue, 13 Nov 2001 04:16:01 GMT Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <581I7.3817$Rw2.2586663@newssrv26.news.prodigy.com> to add to some of the other suggestions, how about using java swing with jython. or, similarly, sam rushing's DynWin (http://www.nightmare.com/~rushing/dynwin/index.html) -d "Michael 'Mickey' Lauer" wrote in message news:3beedf26 at nntp.server.uni-frankfurt.de... > Hi group, > > I'm currently writing a Python GUI book, where several toolkits > (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... > of course... Tkinter) are presented and explained. > My idea is that besides going into some detail of every Toolkit I > construct _one_ application scenario with a skeleton, which I > later complete with each of the toolkits. > This should give the reader the means to choose the toolkit > which matches their personal taste & programming philosophy. > > Given this approach, the main question I'm currently trying to > figure out is: What application shall I present? It must be complicated > enough to show some advanced topics (not only presenting a tour of > the widgets and voila...) but at the same time small enough to cover > it within 50 pages or so (remember: for each toolkit!). > > I first thought of some contact application - in outlook style - or > some kind of presentation program - powerpoint style - ... here's a plea > for your input. > > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? > > Apart from this concrete question do you have some topics which you > think should be a _must_ in such a book? Imagine you're a not a total newbie > in python GUI programming... what did you want to read in such a book? > > thanks for your input! > > Yours, > > Mickey. > From mwh at python.net Thu Nov 15 14:24:28 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 15 Nov 2001 19:24:28 GMT Subject: What is "marshal data"? References: <859c71be.0111151028.63227109@posting.google.com> Message-ID: Cliff Wells writes: > On Thursday 15 November 2001 10:28, Soren Ragsdale wrote: > > > Possible sources of the problem: "uh.py" is imported from MANY > > programs on our network. It's being imported by Linux and Irix > > machines running 1.5.2 and 2.1.1 versions of Python. Could this be > > As mentioned in another thread, the bytecode between python versions is not > backward compatible, so you may be trying to execute 2.1.1 bytecode on a > 1.5.2 interpreter and that may be causing the problem. Shouldn't be. The first four bytes of a .pyc file are a version-specific magic number, meant to stop this happening. Executing the wrong bytecode would cause SystemErrors or core dumps, not ValueErrors complaining about marshal data -- the marshal module does little checking of its input, as it's only there to speed things up... Cheers, M. -- First of all, email me your AOL password as a security measure. You may find that won't be able to connect to the 'net for a while. This is normal. The next thing to do is turn your computer upside down and shake it to reboot it. -- Darren Tucker, asr From phr-n2001d at nightsong.com Thu Nov 15 01:37:48 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 14 Nov 2001 22:37:48 -0800 Subject: who called a function? References: Message-ID: <7xeln0wncz.fsf@ruckus.brouhaha.com> writes: > How can I find out what object called a function and essentially step back > through that? At most I need to step back about 4 to 5 levels but it would > be very useful for me to find a particular object back up the list and > change behavior based on that. Mostly I just wants the self var as I step > back until I find the one I want. Raise and catch an exception and examine the stack trace object. From patrick at palacecomputers.com Mon Nov 19 16:39:06 2001 From: patrick at palacecomputers.com (Patrick Moorman) Date: Mon, 19 Nov 2001 21:39:06 GMT Subject: Newbie-ish question Message-ID: <_ZeK7.505628$ME2.63350791@typhoon.kc.rr.com> I have a directory containing a large number of files in the format xy.txt where x is a string of numbers and/or letters and y is a sequential number with either 2 or 3 digits. Example: 1foo23012.txt or foo12305.txt. How would I go about identifying all of the files in a sequence and moving them to their own sub-directory. I am slowly picking up on Python, but there is a long ways to go. Thanks for any help. PKM From phd at phd.pp.ru Thu Nov 29 07:38:29 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 15:38:29 +0300 Subject: pypan In-Reply-To: <655abd4a.0111290425.5cbfa108@posting.google.com>; from etoffi@bigfoot.com on Thu, Nov 29, 2001 at 04:25:13AM -0800 References: <655abd4a.0111290425.5cbfa108@posting.google.com> Message-ID: <20011129153828.R16265@phd.pp.ru> On Thu, Nov 29, 2001 at 04:25:13AM -0800, e toffi wrote: > i wish to start a pypan -- something similar to cpan, but for python, > obviously. Catalog-SIG (Special Interest Group) http://www.python.org/sigs/catalog-sig/ is supposed to do this. Subscribe to their mailing list and go! Good luck! Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From mikael at isy.liu.se Thu Nov 1 11:07:13 2001 From: mikael at isy.liu.se (Mikael Olofsson) Date: Thu, 01 Nov 2001 17:07:13 +0100 (MET) Subject: Monty Python (was: Freeware Python editor) In-Reply-To: <20011101180204.D675@phd.pp.ru> Message-ID: On 01-Nov-2001 Oleg Broytmann wrote: > On Thu, Nov 01, 2001 at 03:59:56PM +0100, Mikael Olofsson wrote: > > > and blod everywhere). But then there are the others (for instance the > > ^^^^ > > Make that "blood". > > And now it is time for something completely different - spelling wars :( > Man, there was no spelling war in c.l.py, never. Why starting it now? Well, as long as someone is correcting himself, it's not much of a war, is it? /Mikael ----------------------------------------------------------------------- E-Mail: Mikael Olofsson WWW: http://www.dtr.isy.liu.se/dtr/staff/mikael Phone: +46 - (0)13 - 28 1343 Telefax: +46 - (0)13 - 28 1339 Date: 01-Nov-2001 Time: 17:06:17 /"\ \ / ASCII Ribbon Campaign X Against HTML Mail / \ This message was sent by XF-Mail. ----------------------------------------------------------------------- Link?pings kammark?r: www.kammarkoren.com From maxm at normik.dk Fri Nov 30 04:18:05 2001 From: maxm at normik.dk (Max M) Date: Fri, 30 Nov 2001 10:18:05 +0100 Subject: Design tips requested for OOP forum system (using pickle) References: Message-ID: <3c074ec6$0$25369$edfadb0f@dspool01.news.tele.dk> "Simon Willison" wrote in message news:eb8b2b6e.0111291359.64a1ee62 at posting.google.com... Here's an example that isn't persistent. I cannot remember if this one was the absolute last version i made, but it should give the general idea. Also the message class ony contains id and title, yu would probably want to add a few more parameters than that ;-) It was a quick prototype, done in an hour or two, for a discussionboard I have later done in Zope. I changed quite a few things in the final version but anyhoo .... Regards Max M ##################################################### class message: def __init__(self, id, title, _parent=None): self.id = id self.title = title self._parent = _parent self._children = [] self.hidden = 0 self.indent = 0 class msgList: def __init__(self): self.msgDict = {} self._newId = 0 def _getNewId(self): # generates a new unique id for a message # get new id and make a zero-padded string idString = str(self._newId) newID = (4*'0')[:-len(idString)] + idString self._newId += 1 return '%s' % newID def addMessage(self, title, _parentId=None): id = self._getNewId() if _parentId != None: parent = self.getMessageById(_parentId) msg = message(id, title, parent) # add as child to parent parent._children.append(msg) else: msg = message(id, title, None) # indent doesn't change so set it here once and for all if _parentId != None: msg.indent = len(self.parents(msg)) else: msg.indent = 0 # add to messages self.msgDict[id] = msg def delMessage(self, id): # let parent take over this the messages children self.msgDict[id].parent._children += self.msgDict[id]._children # let children have this messages parent as their parents for child in self.msgDict[id]._children: child._parent = self.msgDict[id].parent.id # delete the bugger del(self.msgDict[id]) def hideMessage(self, id): self.msgDict[id].hidden = 1 def getMessageById(self, id): return self.msgDict[id] def getChildren(self, msg): # evil recursive function to get all children of a message # (recursion is evil by default!) grandChildren = [] for child in msg._children: grandChildren += self.getChildren(child) return msg._children + grandChildren def parents(self, msg): # another evil recursive function to get all parents of a message # mostly used for calculating the indent level if msg._parent: return [msg._parent] + self.parents(msg._parent) else: return [] def msgSort(self, msgs, sortAttrib='id', forward=1): # Sorts a list of objects in accordance to an attribute of choice # I assume that Pythons built in sort() is blistering fast # So I run around hoops to use that. sortValues = [(getattr(msg, sortAttrib), msg.id) for msg in msgs] sortValues.sort() if not forward: sortValues.reverse() return [self.msgDict[sortVal[1]] for sortVal in sortValues] def messages(self, threaded=1, sortAttrib='id', forward=1): """ Returns a list with all the messages sorted and/or grouped. This is the most important method here. If threaded == 1 the messages are grouped by threads, else they are just sorted by the value of 'sortAttrib' If forward = 1 the value of sortAttrib is ascending If forward = 0 the value of sortAttrib is descending """ if threaded: result = [] threads = [ msg for msg in self.msgDict.values() if msg._parent==None ] threads = self.msgSort(threads, sortAttrib, forward) for thread in threads: # REMEMBER!!!! still needs to sort in self.getChildren() result += [thread] + self.getChildren(thread) return result else: return self.msgSort(self.msgDict.values(), sortAttrib, forward) msgs = msgList() msgs.addMessage('msg10') msgs.addMessage('msg02') msgs.addMessage('msg13', '0000') msgs.addMessage('msg4', '0001') msgs.addMessage('msg5', '0001') msgs.addMessage('msg6', '0002') msgs.addMessage('msg7', '0005') msgs.addMessage('msg8', '0005') #print msgs.parents(msgs.getMessageById(7))[-1].title print '-------------' for msg in msgs.messages(threaded=1, sortAttrib='title', forward=1): print msg.id, msg.indent*' '+msg.title From mwh at python.net Wed Nov 28 07:08:47 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 28 Nov 2001 12:08:47 GMT Subject: Installing Python > 2.1: make fails in posixmodule.c References: <9u2g7u$5i5al$1@ID-113469.news.dfncis.de> Message-ID: Elmar H?fner writes: > Hi all, > > When I try to compile Python, version 2.1.1 and up, 'make' stops in > posixmodule.c with following message: [schnipp] > Rerunning make after 'make clean' didn't help. > I also couldn't find a bug report on sourceforge concerning this. Didn't look hard enough: http://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=440522 I'm pretty that fix went into 2.1.1 though. Which version are you compiling? 2.1.1 and current CVS don't have PRIO_PROCESS at line 1145. > Has anybody any hint or tip on how to get around this? Try current CVS? Tell us which version you're compiling? Cheers, M. -- That being done, all you have to do next is call free() slightly less often than malloc(). You may want to examine the Solaris system libraries for a particularly ambitious implementation of this technique. -- Eric O'Dell, comp.lang.dylan (& x-posts) From sdm7g at minsky.med.virginia.edu Thu Nov 8 18:03:45 2001 From: sdm7g at minsky.med.virginia.edu (Steven D. Majewski) Date: Thu, 8 Nov 2001 18:03:45 -0500 (EST) Subject: iters on ints? (reducing the need for range/xrange) In-Reply-To: Message-ID: On Thu, 8 Nov 2001, Rainer Deyke wrote: > wrote in message > news:mailman.1005256814.9657.python-list at python.org... > > > > Now that the issue of transfinite cardinals has been fully resolved, isn't > > it time for yet another unpopular-and-non-pythonic suggestion? I believe > > it is. > > > > What if (in post-2.2) Python the tp_iter slot in the int type was defined > > to return an xrange-like iterator such that one could do the following: > > > > for i in 10: > > doSomething(i) > > I like it. I guess that just goes to show how non-Pythonic I am. > > Seriously, I don't see how this is worse or less Pythonic than, say, 'for > line in file'. > If "for i in 10:" was legal, I'ld guess it meant the same thing as "for i in [10]:" or "for i in (10,):" A file *IS* a sequence -- although you could just as easily slice it by characters as lines -- or by any arbitrary object for binary files, as Pascal does. If the integer 10 suggests any sort of sequence, it's the singleton sequence containing: 10. -- Steve From nas at python.ca Tue Nov 13 15:52:14 2001 From: nas at python.ca (Neil Schemenauer) Date: Tue, 13 Nov 2001 12:52:14 -0800 Subject: Tracking memory leaks In-Reply-To: <9srvk5$e8o$1@news.vanderbilt.edu>; from jonathan.gilligan@vanderbilt.edu on Tue, Nov 13, 2001 at 02:25:41PM -0600 References: <9srvk5$e8o$1@news.vanderbilt.edu> Message-ID: <20011113125213.A27571@glacier.arctrix.com> Jonathan M. Gilligan wrote: > I have problems with an application that makes heavy use of Numeric and > calldll. The problem is that it leaks memory like a seive (at each iteration > of a loop in which large Numeric arrays are created and (I hope) destroyed, > python's memory use skyrockets. I have invoked gc.set_debug and there are no > unreachable objects, but the third-generation object store gets bigger and > bigger each time through the loop. Make sure there are no objects in the gc.garbage list. If there are then you have objects with __del__ methods that are involved in a reference cycle. If there are not, then you've most likely got a reference counting bug somewhere. > I am sure that the problem is with my code, not with the core of Python or > Numpy, but I would really like to get to the bottom of this. Is there any > good way for me to get python to dump a list of all the Python objects in > existence? The gc module in Python 2.2 has a get_objects() method that would be useful in debugging this problem. It returns all of the objects tracked by the GC. Neil From sholden at holdenweb.com Fri Nov 2 08:18:27 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 2 Nov 2001 08:18:27 -0500 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> <3BE20B6E.F9275CD0@cosc.canterbury.ac.nz> <9rt3co$rid$1@slb2.atl.mindspring.net> Message-ID: "Andrew Dalke" wrote in message news:9rt3co$rid$1 at slb2.atl.mindspring.net... > Greg Ewing: > > input = ''.join(range(256)) > > input = "".join(map(chr, range(256))) > input = "".join([chr(x) for x in range(256)]) -- http://www.holdenweb.com/ From buzzard at urubu.freeserve.co.uk Mon Nov 5 16:30:20 2001 From: buzzard at urubu.freeserve.co.uk (Duncan Smith) Date: Mon, 5 Nov 2001 21:30:20 -0000 Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s43jo$bku$1@news8.svr.pol.co.uk> <9s538j$qo1$1@bugstomper.ihug.com.au> Message-ID: <9s70e2$5gh$1@newsg2.svr.pol.co.uk> "Gary Stephenson" wrote in message news:9s538j$qo1$1 at bugstomper.ihug.com.au... > > > The patriot (scoundrel??) in me wishes to point out that Spike was / is > an > > > Australian - though I imagine many Brits would be somewhat upset to > learn > > > this . > > > > Yet he was born in India and (now) holds an Irish passport (as a result of > > having an Irish father (English mother? not sure)). Has he ever held an > > Australian passport? > > Umm, errr, you've got me there! I'd forgotten that he was born in India. > We here downunder have just always claimed him as one of our own - and will > continue to do so, you festering putrid pile of maggot infested batsh*t, I > blow my nose at you, I fart in your general direction ... and if you want > to argue any further about it I suggest you need the room down the hall! > This is abuse! ) > I can't think of a good Pythonesque response, so here's a Groucho quote that's a bit Milliganesque. Outside of a dog, a book is a man's best friend. Inside a dog, it's too dark to read. Groucho Marx (1895-1977) And a little tale about the late great Peter Cook: At the start of his career, Peter applied to the actor's union for membership. They wrote back telling him he would have to change his name as there was a Peter Coke and this might cause some confusion. The regulations were very strict in this regard. Peter wrote to them saying that in future he would be known as Xavier Blancmange to which the union replied that this was a silly name. He then suggested Wardrobe Gruber and Sting Thundercock. He never heard from the union on the subject again. Duncan > gary > > From gh_pythonlist at gmx.de Sun Nov 11 04:29:02 2001 From: gh_pythonlist at gmx.de (Gerhard =?unknown-8bit?Q?H=E4ring?=) Date: Sun, 11 Nov 2001 10:29:02 +0100 Subject: mapping a statement over all list items In-Reply-To: <3BEE4077.8070407@hotmail.com> References: <3BEE4077.8070407@hotmail.com> Message-ID: <20011111102900.A1148@lilith.hqd-internal> On Sun, Nov 11, 2001 at 03:10:15AM -0600, Kevin Christie wrote: > Hello all! > > I have list Foo, of strings. Each string has a special character '-' > within the string. What I want is for Python to split each string list > item by '-' and assign the resulting lists to the original list item. > Basically, I want to apply: > > Foo[x] = Foo[x].split('-') > > over all items x in Foo, in one clean statement. > > Thus if Foo was ['abc-xyz', 'black-blue', '123-987'], the result after > mapping to Foo would be: > > Foo = [ ['abc', 'xyz'], ['black','blue'], ['123','987'] ] > > It seems as if there should be a way to map the function over all items [...] ^^^ :-) Check out the map builtin in the documentation. Basically, the form is map(function, sequence), like in: import string input = ['abc-xyz', 'black-blue'] result = map(lambda x, string.split(x, '-'), input) Other tools for functional programming are lambda, apply, reduce and zip. Very often, list comprehensions are easier to use and more readable than using map and friends. For your example: import string input = ['abc-xyz', 'black-blue'] result = [string.split(x, '-') for x in input] Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From sasoft at gmx.de Mon Nov 19 18:52:16 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Mon, 19 Nov 2001 18:52:16 -0500 Subject: python and applets In-Reply-To: <9tbff1$sjg$1@planja.arnes.si>; from anton.vahcic@kiss.uni-lj.si on Mon, Nov 19, 2001 at 06:27:15PM +0100 References: <9tbff1$sjg$1@planja.arnes.si> Message-ID: <20011119185216.B11363@cruciatuz.de> On Mon, Nov 19, 2001 at 06:27:15PM +0100, Anton ml. Vah?i? wrote: > I know it might sound silly question, but can be python run in the same mode as Java applets - you > something like Python applets? 1. I think you can do something like that with Jython (Python in Java - CPython would be Python in ANSI C) Here's a link: http://www.jython.org/applets/ 2. Grail is a webbrowser in python which supports a thing like that, but i think this isn't what you're searching for ... http://grail.sourceforge.net/ -- Stefan Antoni ---------------------------- Mon Nov 19 18:44:43 EST 2001 _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \ From wurmy at earthlink.net Wed Nov 14 12:59:32 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 14 Nov 2001 17:59:32 GMT Subject: memory leak in python script References: <1005749457.219815@newsmaster-04.atnet.at> Message-ID: <3BF2B102.D0592169@earthlink.net> Philipp Schmid wrote: > > hi, > > my python2.0.1 script allocates slowly the whole system memory, how can i > find out if it's a python bug or if my script is buggy? > if its my script, how can i find the cause of the leak? There are a few modules out there that check for cyclic references, cyclops.py and plumbo.py (I think). I don't use these modules myself, so I don't really know where to find them, but I'm sure a search on www.python.org or google can tell you more. --Hans From jerk at 163.net Wed Nov 7 01:34:16 2001 From: jerk at 163.net (jerk at 163.net) Date: Wed, 7 Nov 2001 14:34:16 +0800 Subject: how to find out all valid ip in a machine with multiple nic Message-ID: <62434813558.20011107143416@163.net> Hello python list, I have a machine that have two nic,how can I use python to get the binding ip on these two nic? -- Best regards, jerk mailto:jerk at 163.net From martin.franklin at westgeo.com Tue Nov 20 12:05:51 2001 From: martin.franklin at westgeo.com (Martin Franklin) Date: Tue, 20 Nov 2001 17:05:51 +0000 Subject: os.kill........ Message-ID: <9te2g4$sma$1@mail1.wg.waii.com> Hi, I'm looking for a way of determining if a process is still running (having spawned it from a python app), I have come up with os.kill(PID, 0) this will raise an exception if the process does not exist, and do nothing if the process does exist. The sig of zero does not _seem_ to affect it (at least not on my linux box) My question is..... is this an OK way of doing this? do I have any other _pure_ python options..... Regards Martin From fdrake at acm.org Mon Nov 26 16:38:59 2001 From: fdrake at acm.org (Fred L. Drake) Date: Mon, 26 Nov 2001 16:38:59 -0500 (EST) Subject: [development doc updates] Message-ID: <20011126213859.1A7AE28696@cj42289-a.reston1.va.home.com> The development version of the documentation has been updated: http://python.sourceforge.net/devel-docs/ Various small corrections and additions. From fperez528 at yahoo.com Sun Nov 11 07:56:23 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Mon, 12 Nov 2001 12:24:23 +2328 Subject: Scientific Libraries in Python References: Message-ID: <9sp7mv$pje$1@peabody.colorado.edu> > > Would it be possible for one to absorb the other so we have a single > standard scientific library for Python? I think the following I saw today on sci.math.num-analysis is worth mentioning in the context of this discussion: ------------------copy The first major release of the GNU Scientific Library is now available for general use. The GNU Scientific Library (GSL) is a free numerical library for C programmers. The routines have been written from scratch by the GSL team in ANSI C. They present a modern API, allowing wrappers to be written for very high level languages. The library includes a 450-page reference manual and is distributed under the GNU General Public License. The source code can be downloaded from ftp.gnu.org in the directory /gnu/gsl/ or from any mirror site (see http://www.gnu.org/order/ftp.html) The project home page is at http://sources.redhat.com/gsl/ ------------------/copy To avoid unnecessary duplication, it might be worth considering a SciPy/Scientific/whatever system to be based on something like the GSL. This has some important advantages, IMHO: - Because the base code is not python-specific, many more people will contribute to it/debug/enhance it. - The GSL guys specifically mention a wrapper-friendly design of their project. So maintaining the python interface shouldn't be all that hard (famous last words...) I'm not saying that a Science Python environment should be *only* a wrapper around GSL, but that the GSL should be one core component of such a project. Other things can then be added to from the full environment (like visualization and the ultra-cool scipy.compiler system). Cheers, f. From ajs at ix.netcom.com Sun Nov 25 12:06:28 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sun, 25 Nov 2001 12:06:28 -0500 Subject: A permutation on permutations Message-ID: <002301c175d3$86e9c0e0$a9e1fea9@carol> Simon writes - >well, i'd like to see this list comprehension >implemented properly ; it doesn't >compute as it stands (on 2.1.1)...? Lots of typos in my previous perms function. This does work - as per Rainer Deyke's post. def perms(L): if L == [] : return [[]] return [[L[i]] + p for i in range(len(L)) \ for p in perms(L[:i] + L[i+1:])] >To choose, eg. pick only perms >whos first entry is less than the last Good sugestion. But now it gets real strange - at least to me. The following little func does not work as I would expect!!! Something about the iteration of p in t with the list.remove(). Is the func as written certifiably bad Python , or a bug/trap I fell into? M=[1,2,3,4] def removedups(t): for p in t: if p[-1]>p[0]: t.remove(p) print t removedups(perms(M)) Note that p in t does not iterate over all items of the original list, so sublists where p[-1] > p[0] survive!!! Art From sasoft at gmx.de Thu Nov 22 20:38:57 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Thu, 22 Nov 2001 20:38:57 -0500 Subject: RogueLike Games in Python In-Reply-To: <3BFD4A6B.900782F4@alcyone.com>; from max@alcyone.com on Thu, Nov 22, 2001 at 10:56:43AM -0800 References: <3BFC9160.24AFA11A@alcyone.com> <3BFD4A6B.900782F4@alcyone.com> Message-ID: <20011122203857.A17128@cruciatuz.de> On Thu, Nov 22, 2001 at 10:56:43AM -0800, Erik Max Francis wrote: > Here's the one I've heard of most recently: > > http://kuoi.asui.uidaho.edu/~kamikaze/Umbra/ > > It looks to be sort of a Roguelike/Wizardy hybrid. i know, i had email contact with Mark Hughes (because the sourcecode is not distributed, there are just binary files which make this game uninteresting for me): Stefan Antoni spake: >... umbra, but i am using python2.2 . i didn't find any sourcecode of >this project, where can i get it? >(python2.2 and 2.1 are binary incompatible) Yeah, I haven't got 'round to recompiling the binaries for 2.2 yet. I'll do that this weekend, I think. Mark Hughes -- Stefan Antoni ---------------------------- Don Nov 22 20:35:22 EST 2001 _ ASCII ribbon campaign ( ) - against HTML email X & vCards / \ From dpetrac at yahoo.com Wed Nov 7 10:20:56 2001 From: dpetrac at yahoo.com (Danijel) Date: Wed, 7 Nov 2001 16:20:56 +0100 Subject: Focus problem References: Message-ID: <9sbjbd$79v$1@sunce.iskon.hr> Sorry, I did'n thing about that. OS is Win2000, ActivePython 2.1.1, build 2.1.2 and wxPython 2.3 (This information I send thru mail, because I don't have access to news right now) Danijel "Bill Bell" wrote in message news:mailman.1005141909.14130.python-list at python.org... > > "Danijel" > > I need that for validation check, when user enter some value into > > TextControl, and go FROM THAT FIELD. > > Danijel, we'd need more information in order to answer your > question: what OS? what software is involved? - Bill > "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery > From keiichi at yggdrasil.maisel.enst-bretagne.fr Sat Nov 3 13:36:36 2001 From: keiichi at yggdrasil.maisel.enst-bretagne.fr (Defresne Sylvain) Date: 3 Nov 2001 18:36:36 GMT Subject: [BUG ?] Slicing a 'struct_time' can crash Python interpreter Message-ID: Hello I'm trying to take a slice of a 'struct_time' returned by time.gmtime() with version 2.2b1 of Python. This is what I'm getting : Python 2.2b1 (#1, Oct 24 2001, 23:50:39) [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import time >>> x = time.gmtime() >>> x (2001, 11, 3, 18, 25, 35, 5, 307, 0) >>> type(x) >>> x[:3] (2001, 11, 3) >>> x[3:] (, , , 18, 25, 35) >>> x[:3] + x[3:] Segmentation fault This used to work with Python 2.0 and 2.1 where time.gmtime() returned a simple tuple. As a workaround I can always do : x = tuple(x), but this look ugly ... I wanted to know if this is a bug in my version of python (provided by debian), or a bug in Python 2.2 itself. Bye PS : I posted this on this newsgroup because I'm unable to report the bug on sourceforge ... From tony at lsl.co.uk Fri Nov 2 10:47:13 2001 From: tony at lsl.co.uk (Tony J Ibbs (Tibs)) Date: Fri, 2 Nov 2001 15:47:13 -0000 Subject: Exception handling wart in Python (or, pehaps, underscores) In-Reply-To: Message-ID: <008801c163b5$a42f05a0$545aa8c0@lslp862.int.lsl.co.uk> Leo Lipelis demonstrated in earlier messages his dislike of "magic underscores" (gosh, I remember *discussion* about whether using "__" at the beginning of a name to indicate mangling was a good or bad thing - how time flies) and then wrote: > Point is, Python can be made better by getting rid of the > "self.__" in front of every object attribute. ... > But the double underscore is a bad hack. It's not elegant > or brief or intuitive. When you actually *use it a lot* it > really grows old fast. It seems like a feature invented by > someone who never actually uses it much. Aha, I go, then maybe that means (ta da!) that one *shouldn't* use it a lot... It's *very* tempting, when going from one language to another, to try to hang on to the tools and habits that one has evolved in the earlier language. Unfortunately, it's also quite hard to tell (well, at least for me) which tools and habits are going to be *useful* in the new language, certainly until one has enough experience in it. And it seems to me that comparing methodologies in a statically typed language where exceptions are, well, exceptional with Python, where objects are typed but names aren't, and where exceptions are fairly common [1]_, may be taken to be, well, not a labour of love. But maybe I've just programmed in enough different languages to assume that they are, in fact, different. I must admit that, since I love Python as it is, I always have some difficulty with people who want to change its appearance radically. Luckily for me, Python comes with its very own BDFL, and he *is* a good language designer, and he knows when to say no (or, perhaps more importantly, when to just ignore things). .. [1] I wonder if Edward Welbourne ever followed up on his Python-variant in which exceptions were, if I remember correctly (and I never fully understood it) the main underlying mechanism for the interpreter. Strange stuff. Tibs -- Tony J Ibbs (Tibs) http://www.tibsnjoan.co.uk/ "I'm a little monster, short and stout Here's my horns and here's my snout When you come a calling, hear me shout I will ROAR and chase you out" My views! Mine! Mine! (Unless Laser-Scan ask nicely to borrow them.) From m.faassen at vet.uu.nl Thu Nov 8 17:30:20 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 8 Nov 2001 22:30:20 GMT Subject: Australian Disco References: <9sacsk$r82$1@bugstomper.ihug.com.au> <8_dG7.4760$R43.760797@newsb.telia.net> Message-ID: <9sf11s$c4u$2@newshost.accu.uu.nl> Fredrik Lundh wrote: > Gary Stephenson wrote: >> Umm, I'm not really sure this is a claim we should be making! Next thing >> you'll have us claiming responsibility for making disco popular - and then >> they'll just have to shoot us! ;-) > but Steve Irwin is your fault, right? But Steve Irwin is the inspiration for Sluggy Freelance's absolutely wonderful Steve Uozin, demon hunter. ('kill demons? I just poke them with a stick') http://www.sluggy.com/d/001023.html and then onwards. Though if you haven't read sluggy yet, you should start at the beginning, and you're in for a treat (though the first couple of comics are weak -- it picks up when Bun Bun first appears, which luckily is fairly soon). Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From gh_pythonlist at gmx.de Mon Nov 26 23:35:26 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 27 Nov 2001 05:35:26 +0100 Subject: postgresql triggers to update GUI? In-Reply-To: <20011126.145234.816620091.2222@localhost.localdomain> References: <20011126.145234.816620091.2222@localhost.localdomain> Message-ID: <20011127053524.A931@lilith.hqd-internal> On Mon, Nov 26, 2001 at 02:52:39PM -0500, Robert Nikander wrote: > Hi, > > I am writing a python program that uses a postgresql db backend. I would > like to update the gui whenever a change in certain tables occurs, so it > would be nice to use triggers rather than generating the 'events' when I > update the db. That way I get cascading changes. Does anyone know of a > python module that supports postresql triggers? ie: you can create a > trigger that calls a python function? Is there another solution here > that I am missing? Hmm. I think you could use PostgreSQL's notification mechanism for this. pyPgSQL does support PostgreSQL notifications (look into the demo2a.py and demo2b.py files in the examples/ directory). The URL is http://pypgsql.sf.net/ I think you could have your trigger send a PostgreSQL notification and have the client side select.poll() or select.select() for the notification. The above mentioned examples show how to do this. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From peter at engcorp.com Wed Nov 28 09:43:50 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 09:43:50 -0500 Subject: Database in a simple ascii file References: Message-ID: <3C04F826.CB408C9D@engcorp.com> Rafael Mentz Aquino wrote: > > How many lines can I have in a simple ascii file before > I start to loose performance when I open this file and > put all the lines in a dict, turning the first column into the key > and the rest of the line into a list associated to that key. > > (my file has just 100 lines, but that question starts to bother me ;-) You will start to lose performance, relatively to no lines, with even one line. If you start with ten lines, you will begin losing performance after you switch to a file of 11 lines... Why focus on performance when you have no idea how fast you want your program to be? Recent advances in software development are teaching programmers *never* to optimize until the program works, and only when there is a clear requirement for more performance. If you are really concerned about performance, you will always be able to get more than a 10 times speedup by switching to a compiled language over Python. Use of Python should imply you are more interested in readability and ease of use, and thus speed of *development*, over speed of execution. (Shorter answer: don't grow any grey hairs over it.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From max at alcyone.com Sun Nov 25 14:49:45 2001 From: max at alcyone.com (Erik Max Francis) Date: Sun, 25 Nov 2001 11:49:45 -0800 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> <3C014329.7B828AE8@alcyone.com> <3c014926.1812080@news> Message-ID: <3C014B59.6F7472B2@alcyone.com> Fred Flintsone wrote: > Yes, that is the one I picked up..."Learning Python." It seems to be > intended for those with little or no programming experience. I am > that, though I have done a little work with macros in Access...the > operative word is LITTLE. That will be fine. _Programming Python_ contains all the information you need, but unfortunately it is not presented in a very convenient manner. I would recommend _Learning Python_ (even if you're a modestly experienced programmer to start with) and a reference such as _Python essential referene_. > I did download the 2.1.1 but noticed afterwards a suggestion for me to > d/l "ActiveState," which is a larger d/l, so I'm assuming it has > important goodies bundled in it. Before I get going here, should I > uninstall 2.1.1 and go for the ActiveState d/l? (This message refers > to Gillou's post above.) That I couldn't tell you, since I don't regularly use Windows. I've used the unadorned Windows deliverables with no problems at all. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From sag at hydrosphere.com Tue Nov 27 17:18:28 2001 From: sag at hydrosphere.com (Sue Giller) Date: Tue, 27 Nov 2001 15:18:28 -0700 Subject: sys.prefix in COM In-Reply-To: Message-ID: <20011127221703140.AAA217@mail.climatedata.com@SUEW2000> Gordon McMillan wrote: > There is a reason for this. sys.prefix is really only meaningful on > *nix. On Windows it is usually taken (correctly) to mean "where the > executable is". site.py & friends can be picked up from there. > > If you registered your COM objects as CLSCTX_LOCAL_SERVER you would > indeed have a sys.prefix. But if it's inprocess, the executable isn't > Python. In fact, pythoncomXX.dll loaded pythonXX.dll for you, and > without knowing where their python.exe lives, they're lost. Well, only > a little. I guess I can accept this, but how does the python path get built that has all the other python things in it: there are the various python21\lib, ... things, but not any that should be found from the .pth files. I even tried calling site.py in my test com object but that got the same results - a blank .prefix string. > I've never encountered this problem, but I'd guess you could tweak > Python's registry entries to get around this. I hate the registry - hassles abound. I would rather do anything else including hard coding the path and forcing other users to use my paths :) From jeff at ccvcorp.com Fri Nov 9 19:17:59 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 09 Nov 2001 16:17:59 -0800 Subject: count in 'for ... in ...' References: Message-ID: <3BEC7237.C0BF744A@ccvcorp.com> DeVerter at robinsonmechanical.com wrote: > Try this. > > for s in my_list: > print my_list.index(s), ".", s > > This way you don't need a counter variable. Only problem is, this fails if there are any duplicate entries in my_list. index() will always only find the first occurrence. >>> breakfast = ['spam', 'eggs', 'bacon', 'spam', 'beans'] >>> for food in breakfast: ... print breakfast.index(food), food ... 0 spam 1 eggs 2 bacon 0 spam 4 beans >>> Jeff Shannon Technician/Programmer Credit International From ws at mystrobl.de Mon Nov 12 16:57:14 2001 From: ws at mystrobl.de (Wolfgang Strobl) Date: Mon, 12 Nov 2001 22:57:14 +0100 Subject: Tkinter Crash under PythonWin References: <4OTH7.461273$ME2.55093623@typhoon.kc.rr.com> Message-ID: On Mon, 12 Nov 2001 21:08:03 GMT, "Neil Hodgson" wrote : > A modified version of the OnFileRun method of InteractivePythonApp is >attached to this mail. This method is in the >Pythonwin\pywin\framework\intpyapp.py file. > > This patch detects if you have the Scroll Lock key on when using File | >Run and if so runs the current script in a new process and console rather >than in the current process. It starts up the script with the -i flag so the >new console goes interactive after running the script. Many variations are >possible, such as dropping the -i and using various options of the >CreateProcess call to run invisibly or with different permissions or in a >different directory. Only tested on W2K. Nice! I tried it with PythonWin 2.1.1 (#20, Jul 26 2001, 11:38:51) [MSC 32 bit (Intel)] on win32 but, alas, it didn't work. >>> Traceback (most recent call last): File "H:\Python21\Pythonwin\pywin\framework\intpyapp.py", line 349, in OnFileRun dirOfScript, starter) TypeError: CreateProcess() takes exactly 9 arguments (7 given) win32ui: Error in Command Message handler for command ID 36864, Code 0 Traceback (most recent call last): File "H:\Python21\Pythonwin\pywin\framework\intpyapp.py", line 349, in OnFileRun dirOfScript, starter) TypeError: CreateProcess() takes exactly 9 arguments (7 given) win32ui: Error in Command Message handler for command ID 36864, Code 0 I added 0,0 and then None,win32process.STARTUPINFO() to the parameter list, but in vain. Now it says "TypeError: an integer is required". Oh well. -- Wir danken f?r die Beachtung aller Sicherheitsbestimmungen From ylee12 at uiuc.edu Sat Nov 3 17:02:59 2001 From: ylee12 at uiuc.edu (Young-Jin Lee) Date: Sat, 3 Nov 2001 16:02:59 -0600 Subject: [Q] Python and expert system shell Message-ID: Hi, all. I'm a python newbie and I want to get some advice. I have developed a Java application and I want to convert it to Python application. I think I can easily do most of the part except one module. In my Java application, I used a JESS (Java Expert System Shell). JESS is a CLIPS interpreter written in Java. Is there any CLIPS interpreter written in Python? Or any expert system shell in Python? I found one URL for an expert system shell in Python, http://www.python.org/ftp/python/contrib/All/holmes.tar.gz ,but it seemed be not available any more. Thanks in advance. YJ From tanzer at swing.co.at Wed Nov 28 13:03:55 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Wed, 28 Nov 2001 19:03:55 +0100 Subject: doesNotUnderstand ? In-Reply-To: Your message of "Wed, 28 Nov 2001 13:35:18 -0300." <3C051246.9C15125E@corest.com> Message-ID: > Is there a way to intercept the activation of messages which are > not implemented? > > For those of you Smalltalkers, I'm talking about > #doesNotUnderstand: > > In smalltalk, if you send a message to an object, but the object > has no implementation for it, it'll receive a doesNotUnderstand > messasge, with the failed message as argument. You can use this > mechanism to implement proxies or auto accessors, or a lot of other > interesting things... `__getattr__` is your friend. -- 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 jeroen at nspm.valcke.com Fri Nov 23 07:00:15 2001 From: jeroen at nspm.valcke.com (Jeroen Valcke) Date: Fri, 23 Nov 2001 13:00:15 +0100 Subject: test error after installation Message-ID: <20011123.130014.771151432.17893@jeroen.fw.belnet.be> Hello, I downloaded and installed Python 2.1.1 after installation I did make install and got an error. It seems to work fine when I start python. Should I be worried? ... test_xmllib test_xreadline test_zipfile test_zlib Segmentation Fault - core dumped make: *** [test] Error 139 From matt at mondoinfo.com Fri Nov 16 14:32:33 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Fri, 16 Nov 2001 19:32:33 GMT Subject: Tkinter: cleaning up when a toplevel is destroyed References: <3BF448DD.90195EA2@labs.agilent.com> Message-ID: On Thu, 15 Nov 2001 14:59:41 -0800, David R. Smith wrote: >I have a problem with how to delete a data structure when the user >deletes the associated toplevel window by clicking on its X-button in >the upper right corner. I think you want something like: root.protocol("WM_DELETE_WINDOW", destroyCB) The call is documented in Fredrik Lundh's excellent An Introduction to Tkinter at (wrapped for line length): http://www.pythonware.com/library/tkinter/ introduction/events-and-bindings.htm Regards, Matt From manufepe at navegalia.com Thu Nov 22 17:42:34 2001 From: manufepe at navegalia.com (MANUEL FERNANDEZ PEREZ) Date: Thu, 22 Nov 2001 23:42:34 +0100 Subject: Editor for Python Message-ID: <3bfd7f87@news.airtel.net> Hello, I'm looking for an editor for Python.I' m interested it works on Windows.Can anybody help me? Thank you Manuel From bedge at troikanetworks.com Tue Nov 20 18:47:17 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 15:47:17 -0800 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> <3BFAAD1E.9E9AF618@alcyone.com> <3BFAC45B.9D246137@alcyone.com> <2SzK7.605$px5.156976@newsfeed.slurp.net> Message-ID: In , Chris Liechti wrote: > [posted and mailed] > > "Bruce Edge" wrote in > news:2SzK7.605$px5.156976 at newsfeed.slurp.net: >>> It wouldn't be hard to write a simple wrapping script that takes a >>> printf format string, converts it to a regular expression, does a >>> match against a string, then pulls out the arguments and converts them >>> to types as appropriate. But one might just as well be using regular >>> expressions directly in the first place. >>> >>> >> Here's what I did to convert the format string to a regex. It's not >> pretty, and many types will break it, but it serves the purpose, for >> now: >> >> def fmtstr2regex( str ): >> regex = "" >> while len(str): >> if str[0] == '%': >> x = >> re.match("%(?P\d*)(?P\w)(?P.*)$",str) > > you don't match "%6.3f" and similar and not "%-4f" I knew it was a bad idea to post this :) You're right of course, it's far from complete. >> if not x: >> exc = CommandException() >> exc.reason = "Invalid print format specifier %s" % >> str raise exc > > when you define an exception like this: > class CommandException(Exception): pass > > you can simply call "raise CommandException("reason %s" % str) good to know. > >> length = int( x.group("len") ) > > needs an if here... maybe it _was_ a good idea to post this.... Thanks... > if x.group("len"): > length = int( x.group("len") ) > else: > length = None > > >> type = x.group("type") >> # Some types need to be changed from printf to regexp >> world if type == 'x': >> type = '['+string.hexdigits+']' >> else: >> type = "\\%s" % type > > type 's' should also be transformed to 'w' ('\s' are whitespaces) > >> regex += "(%s" % type >> if length: >> regex += "{%d,%d})" % ( length, length ) >> else: >> regex += "+)" >> str = x.group('rest') >> else: >> regex += "\%s" % str[0] > > whats the intent of '\' here if you want to escape the character you > should write two (ok "\%" -> '\\%' but writing it explicit is better, > like you did above). but escaping produces wrong regexes here. You're right. For my test case I had dots in my string. I should just do reserved chars. >>>> print fmtstr2regex("1.st %d") > \1\.\s\t\ (\d+) > > '\s', '\t', '\1' are all special commands for regexes, you realy want is > r'1\.st (\d+)' > > only reserved regex characters should be escaped. [](){}.+?*$^\ > > >> str = str[1:] >> return regex >> >> > just a sidenote: "type" is a builtin function, which you shadow with > your variable > > but overall a nice idea.. > chris > OK, I think this is a bit better, heven't tested yet: def fmtstr2regex( str ): regex = "" while len(str): if str[0] == '%': # "%6.3f" and similar and not "%-4f" not handled!! x = re.match( "%(?P\d*)(?P\w)(?P.*)$", str ) if not x: raise CommandException( "Invalid print format specifier %s" % str ) if x.group("len"): length = int( x.group("len") ) else: length = None data_type = x.group("type") # Some types need to be changed from printf to regexp world if data_type == 'x': data_type = '['+string.hexdigits+']' else: data_type = "\\%s" % data_type regex += "(%s" % data_type if length: regex += "{%d,%d})" % ( length, length ) else: regex += "+)" str = x.group('rest') else: if str[0] in "[](){}.+?*$^\\": regex += "\%s" % str[0] else: regex += "%s" % str[0] str = str[1:] return regex From burkhard.kayser at t-online.de Sun Nov 18 12:26:50 2001 From: burkhard.kayser at t-online.de (Burkhard Kayser) Date: Sun, 18 Nov 2001 18:26:50 +0100 Subject: debugging with ddd Message-ID: <9t8r2j$2vt$05$1@news.t-online.com> Hi, I'm new to python and like to debug my scripts with ddd. If I invoke the debugger with ddd -pydb test.py, than the source code is not loaded. If I load the source code by means of File->Open Source, than the script is loaded and executed immediately. After restarting ( Program->Restart ) I can debug the script. I use ddd 3.2.1 on SuSe 7.0. Unfortunately pydb was not in the package which Suse delivered. Hence I used the pydb version which comes with ddd 3.3.1. Is this the problem ? Can somebody help me. Thanks From ralph at inputplus.demon.co.uk Mon Nov 12 18:43:21 2001 From: ralph at inputplus.demon.co.uk (Ralph Corderoy) Date: 12 Nov 2001 23:43:21 GMT Subject: [PATCH] remove comma in Python/ceval.c References: Message-ID: <9spmqp$8g5$1@inputplus.demon.co.uk> Hi, > I was trying to build Python-2.2a4 on AIX using the xlc compiler. The > following trivial patch let me build the python executable. It's made it into CVS. > - WHY_YIELD, /* 'yield' operator */ > + WHY_YIELD /* 'yield' operator */ ANSI C doesn't allow trailing commas when defining enumerations. This has always seemed a little odd given they're allowed when initialising arrays. I guess some compilers allow it even though it isn't strictly legal. xlc has caught me like this before. Cheers, Ralph. From andymac at bullseye.apana.org.au Fri Nov 23 04:21:12 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Fri, 23 Nov 2001 20:21:12 +1100 (EDT) Subject: which one to choose - NumPy or Scientific Python In-Reply-To: <9thboj$ud4@r02n01.cac.psu.edu> Message-ID: On Wed, 21 Nov 2001, Rajarshi Guha wrote: > I've been doing most of my science related work using C - but for some > new work I'm starting (neural nets, QSAR etc) I'm thinking of using python. > I know there are 2 sets of libs - NumPy and Scientific Python. > > Are there any suggestion as to which one is better or more suitable - I > won't need heavy duty number crunching. I do need arrays, basic statistical > functions (I could code these myself - but their presence would be nice) Scientific Python in fact uses NumPy (if installed) to extend itself, so its not a choice between the 2, but rather whether you need the extras it supplies over NumPy. -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From matt at mondoinfo.com Sat Nov 24 23:42:07 2001 From: matt at mondoinfo.com (Matthew Dixon Cowles) Date: Sun, 25 Nov 2001 04:42:07 GMT Subject: Win98 PySol problem References: Message-ID: On Sat, 24 Nov 2001 22:52:56 GMT, Bill Melcher wrote: Dear Bill, >I found the code: > >> if os.name == "nt": >> if dither is not None: >> kw["dither"] = dither > >in tkutil.py in the PySol source package - Yes, sorry. I should have mentioned where it was. >I have commented out these lines in the module but now I have to deal >with the creation of tkutil.pyc and pysol_21.pyc -- I think! I see that Tyler Eaves has already pointed out that you don't have to do that by hand. >The makefiles that I see are clearly written for a unix-like os and I >will attempt to figure out how to do a build in the Win98 >environment. There isn't much building required. You should be able to just run it. python src/pysol.py works on my system. I think that the Makefile is just there to automate installation and a few other minor things and installation is optional. >Yeah, sure - I have messed with high level languages since Fortran I >on the I BM 704 mainframe but am stll a largely unreconstructed >(rusty) assembler programmer. Python has a few conveniences that even Fortran doesn't. And I can tell you from person experience that it's more fun than IBM 360 assembly language. Regards, Matt From loewis at informatik.hu-berlin.de Sun Nov 25 07:37:56 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 25 Nov 2001 13:37:56 +0100 Subject: How do I use and debug with locally built Python executables? References: Message-ID: "Parzival Herzog" writes: > Can anyone explain why the MyWin.pyd extension dll is not > found using Python21_d.exe? It continues to be found using > the installed Python.exe. In the debug build, extension modules end with _d.dll or _d.pyd. So you need to recompile your module for debugging as well. Regards, Martin From phd at phd.pp.ru Thu Nov 29 07:36:32 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 15:36:32 +0300 Subject: pyplets In-Reply-To: <655abd4a.0111290417.4b28a0f2@posting.google.com>; from etoffi@bigfoot.com on Thu, Nov 29, 2001 at 04:17:55AM -0800 References: <655abd4a.0111290417.4b28a0f2@posting.google.com> Message-ID: <20011129153632.Q16265@phd.pp.ru> On Thu, Nov 29, 2001 at 04:17:55AM -0800, e toffi wrote: > i was thinking (which i dont do often), and came up with an idea > (which i *do* do often -- dont ask me how). the idea is pyplets -- the > analogue to java applets with a fittingly silly name. anyway the > premise is to define an api that lets programmers write small programs > that execute in a browser. > > whatdyathink? Do you suppose to alter ALL major browsers to support Python? (You can alter Mozilla, but not Netscape, and certainly not M$IE). Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From jslowery at hotmail.com Fri Nov 30 01:20:22 2001 From: jslowery at hotmail.com (Jeremy Lowery) Date: Fri, 30 Nov 2001 00:20:22 -0600 Subject: Tools for the job Message-ID: <0rFN7.23570$8n4.1770642@e3500-atl1.usenetserver.com> I'm looking for an easy way to disconnect a class instance that contains biz logic from the presentation of that object (in this case, HTML), maybe some kind of delegation is needed. Could someone point me to a module that has a simple cure? Basically, some code like this: class CheckField(ListBaseField): """ A standard check field that is marked off as an item on the list. """ def __init__(self, name): ListBaseField.__init__(self, name) def assignValue(self, value, user): self.value = str(str2bool(value, 1)) self.user = user def display(self): print '%s' % (self.name) if self.value: print 'checked (%s)' % (self.user.display()) else: print 'unchecked' def printNewForm(self, list): print '%s ' % (self.name, list.name, self.name) def parseForm(self, list, fs): fname = '%s_%s' % (list.name, self.name) if fs.has_key(fname): self.assignValue(fs[fname]) else: return 0 return self.value As I'm sure a lot of other designers feel, I don't like plugging HTML code into strings inside my business object's defintions. Maybe a template mechanism or something? Of course, there are a lot of the usual ways to do this, I was just wondering if Python had some snazzy builtin or known module that did this kind of stuff. Jeremy From skip at pobox.com Wed Nov 28 10:46:04 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 28 Nov 2001 09:46:04 -0600 Subject: Integer Overflow In-Reply-To: References: <9u0jor$2li$1@peabody.colorado.edu> Message-ID: <15365.1724.679321.584418@beluga.mojam.com> Ursus> def Lcprng(state): Ursus> """Pass this a variable containing the seed. Don't forget to Ursus> update the seed with the returned value each time this Ursus> function is called.""" Ursus> return int((29L*state+13L) & 0x0FFFFFFFL) Ursus> .......Calling Program...... Ursus> RanNum = 987654321 # Initialize Random Number Seed Ursus> ............................................ Ursus> RanNum = Lcprng(RanNum) # Keep updating seed with value That works, however, it requires the caller to understand the mechanism involved in updating the RNG's state. With the one-element list version, you (the RNG implementer) can stuff as much in the state as you like. The user can pretend it's opaque. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From osuchw at ecn.ab.ca Thu Nov 8 11:55:26 2001 From: osuchw at ecn.ab.ca (waldekO) Date: 8 Nov 2001 08:55:26 -0800 Subject: Help! References: Message-ID: "babu" wrote in message news:... > I need a help from you. Currently i am working with Pyhon and done some > windows programming using Tk. How can i write a program to interact with IIS > using Python. > (i.e) Creating ASP pages using Python Script. > > I seached lot of site, but all will give in Unix Platform. So Please some > related links about web programming in Python > > Thanking You try: PythonDist\win32comext\axscript\demos\client\asp and http://starship.python.net/crew/pirx/asp/py_asp.html From db3l at fitlinxx.com Wed Nov 21 19:56:20 2001 From: db3l at fitlinxx.com (David Bolen) Date: 21 Nov 2001 19:56:20 -0500 Subject: Non-Indented python References: Message-ID: "Delaney, Timothy" writes: > If you use spaces everywhere, you are at the mercy of other code > that doesn't use the *same number* of spaces for indentation. For > example, if you use four spaces for indentation, and you cut and > paste code that uses two spaces per indentation, nothing will > work. You will need to reformat one or the other before copying the > code. Only if you are cut 'n pasting subsets of blocks to insert into other blocks. And if the pasted block is indented further you could always cheat and put it within an "if 1:" or something. Then again, for such small subsets, it's probably fairly easy to just reindent the copied block (environments such as python mode in emacs make that a few keystrokes operation). If you are working in complete block chunks you should be fine, as Python doesn't care if you use the same indentation for all blocks within a set of source, only that each block on its own is consistent. Of course, visually having different indents won't look any better than viewing tabs with a different configuration of spacing for each hard tab than used when written. > The problem is simply that people use the tab key and character to > mean different things. Originally the tab key was designed to do the > same thing as on a typewriter - advance to the next tab stop (i.e. a > certain number of spaces). Thus you end up with editors which > distinguish between indentation and tab because a tab is too big for > indentation. Well, I guess it depends on the definition of originally. Certainly on typewriters, the physical tab key was a mechanical way to advance to the next tab stop. I'm not sure about very early line printing devices (teletypes, etc...) but on early video display terminals they mimiced the behavior by having internal tab stops that they would move the active cursor position to upon receive of a tab character. Sometimes the settings were changeable in software, but sometimes just by the terminal setup via the keyboard. But even in the earliest video displays, and unlike with typewriters, there was no forced linkage between the tab key on the keyboard and the processing of the tab character. Yes, editors at the time often just echoed back the characters received, so pressing the tab key ended up sending the tab character out to the display where it got processed, but there was no requirement that it did so. > It would have been so much easier if it had originally been defined > that the tab key always generated a tab *character*, It did - terminals would send back a tab character when the tab key was pressed. Technically (keyboard scan codes, and virtual stuff like X mappings and what not aside) it still does that today. It's really the interpretation end that has changed - e.g., not blindly echoing that tab character back out to the display device, but doing more complicated software processing on it instead. > and that the tab *character* > had been defined as equivalent in size to four spaces (or 3 > perhaps). This rule of course would be broken by applications which > can set their own tab stops, but that's up to the application. The > important thing is that there should *always* be a direct mapping > between the tab key and the tab character. And I think there is. I think instead what you're arguing more for is on the processing end, and simply a different definition of what a display device should do upon receipt of a tab character (or even more generally, how software should emulate such behavior), which is probably an exercise in futility, since there will be such a wide variety of possibilities. -- -- 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 lac at strakt.com Wed Nov 21 13:38:19 2001 From: lac at strakt.com (Laura Creighton) Date: Wed, 21 Nov 2001 19:38:19 +0100 Subject: dictionary-question In-Reply-To: Message from wl of "Wed, 21 Nov 2001 17:14:03 +0100." <3BFBD2CB.6070100@flexis.de> References: <3BFBD2CB.6070100@flexis.de> Message-ID: <200111211838.fALIcJua029214@ratthing-b246.strakt.com> I hate it when I am writing more than one message and I send the wrong one. Sorry about that. I wasn't done yet. What I wanted to mention was that you may be wanting setdefault, not get. [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> foo={'a': 1} >>> foo.get("bar", 0) 0 >>> print foo {'a': 1} >>> foo.get("bar", 300) 300 >>> print foo {'a': 1} >>> foo.setdefault("bar",0) 0 >>> print foo {'bar': 0, 'a': 1} But you still can't assign to a function call. >>> foo.setdefault("bar",0) +=1 SyntaxError: can't assign to function call Laura From ws-news at gmx.at Fri Nov 16 06:29:16 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Fri, 16 Nov 2001 12:29:16 +0100 Subject: anonymous functions? class? References: <3bf4240d$1@207.229.64.20> Message-ID: <3bf4f951@brateggebdc5.br-automation.co.at> Hi, depending on what you want to achieve, nested functions may be what you want. Python allows nesting of function definitions: >>> def consumer(func): ... print "The function returns ", func() ... >>> def caller(): ... def producer(): ... return "Hi from nested function!" ... consumer(producer) ... >>> caller() The function returns Hi from nested function! >>> producer Traceback (most recent call last): File "", line 1, in ? NameError: name 'producer' is not defined >>> As you can see, the function defined within caller() is not visible from outside. hth Werner "Peter Bismuti" wrote in message news:3bf4240d$1 at 207.229.64.20... > I want to pass a function as an argument but don't want to have to define it > globally. > I think the proper terminology for this is "anonymous". > > The way I *don't* want to do it: > > def foo(): > pass > callFunction(foo) > > The way I want to do it: > > callFunction(def foo(): pass) > > > I'm guessing this can't be done because of Python's indenting syntax. > In ECMAscript you can send a function as an argument that is defined on the > fly such as: > > callMyFunction( new Function(){ blah blah }) > > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? > > Thanks > > From eyal at hyperroll.com Thu Nov 8 18:44:27 2001 From: eyal at hyperroll.com (Eyal Lotem) Date: Fri, 09 Nov 2001 01:44:27 +0200 Subject: New to pyton. Maybe a dumb question? References: Message-ID: <3beb180c@news.bezeqint.net> Cliff Pruitt wrote: > I'm a little confused starting off. Is it possible to create an > application with Python that will run on any machine or doe sthe client > machine have to > have a python interperater installed? I'm kind of lost as to how this all > works. > > Thanks for answerign something so mindlessly basic. Python must be interpreted, unless a native-code compiler is used. The only one I know of is the .NET ActiveState Python compiler (and I'm not even sure it is one). This means that you have to have an interpreter running where you want to run Python code. There are two approaches: A) Require the interpreter to be installed, as you said. B) Use a tool like py2exe and stick the Python code and its dependencies in the Python file, and hand over an interpreter DLL with the package. From eyal at hyperroll.com Thu Nov 29 15:07:08 2001 From: eyal at hyperroll.com (Eyal Lotem) Date: Thu, 29 Nov 2001 22:07:08 +0200 Subject: popen with separete stdout/stderr deadlock. Message-ID: <3c069454@news.bezeqint.net> When running popen with a separate stdout/stderr, can I use read() on the resulting stdout file? it seems to 'hang', and I'm assuming stderr's buffer is stuck on write (as it is all filled up), and my stdout read() is stuck on waiting for EOF, which will never come. Deadlock. Is this really what's happening and how can it be avoided? From asgard at hellnet.cz Mon Nov 5 08:59:12 2001 From: asgard at hellnet.cz (Jan Samohyl) Date: Mon, 5 Nov 2001 14:59:12 +0100 Subject: passing parameters to generators ? In-Reply-To: <3BE6606D.167514DB@student.gu.edu.au> References: <9s3gh1$vh2fi$1@ID-11957.news.dfncis.de> <3BE6606D.167514DB@student.gu.edu.au> Message-ID: <20011105145911.B4804@blackbox.hell> On Mon, Nov 05, 2001 at 07:48:29PM +1000, Joal Heagney wrote: > Emile van Sebille wrote: > > > This came up earlier this week. Here's my response to the earlier question: > > > > You can share mutable objects to pass in information: > > > > def gf(args): > > while 1: > > yield args[0]*args[1] > > > > a = [2,3] > > g = gf(a) > > print g.next() > > a[1]=4 > > print g.next() > > > > Is this what you're looking for? > > Yow! Emile, how on earth did you discover this, or should I read the PEP > a little more thoroughly? There is really nothing strange in it: a is just a reference to mutable object, so changing it changes for the generator. It has nothing to do with the generator stuff. The same trick can be used for passing variable default parameters. Regards, Jan Samohyl From dgallion1 at yahoo.com Fri Nov 2 23:40:37 2001 From: dgallion1 at yahoo.com (Darrell) Date: 2 Nov 2001 20:40:37 -0800 Subject: [ #456742 ] Failing test case for .*? Message-ID: Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import re >>> s="""a\nb\n1""" >>> re.findall("[^\n]+?\d", s) ['a\nb\n1'] Didn't get a response posting this on sourceforge. Now I'm off on vaction for a week. --Darrell Gallion From max at alcyone.com Fri Nov 16 18:24:51 2001 From: max at alcyone.com (Erik Max Francis) Date: Fri, 16 Nov 2001 15:24:51 -0800 Subject: python vs ecmascript References: <01111609593502.02629@logiplex1.logiplex.net> Message-ID: <3BF5A043.65289FE4@alcyone.com> Peoter Veliki wrote: > I'm using Python 2.0 at the moment (it is necessary as it is > integrated > into another product), perhaps this limitation was removed in later > versions. If I try to do this: > > print "integer i = " + i > > it will barf on this and tell me that i is not a string, I must do > this: That's because the i is not a separate argument to print. He was referring to the case where you write print "integer i =", i -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From david at dataovation.com Sat Nov 17 01:02:17 2001 From: david at dataovation.com (David A McInnis) Date: Fri, 16 Nov 2001 22:02:17 -0800 Subject: Regular Expression Help Needed In-Reply-To: Message-ID: But if the email address is enclosed in html, then it should be pretty easy to snag, right. Just pull out everything between . Anyway, that is my understanding, but I don't know how to make it happen. I will go check out this book tomorrow. Let me know if you have any other thoughts. David -----Original Message----- From: python-list-admin at python.org [mailto:python-list-admin at python.org]On Behalf Of Chris Tavares Sent: Friday, November 16, 2001 7:00 PM To: python-list at python.org Subject: Re: Regular Expression Help Needed "David A McInnis" wrote in message news:mailman.1005960683.29958.python-list at python.org... > Ok, I am not very good at regular expressions, so any help is greatly > appreciated. > > Here is the situation. > > I have a database table that contains a text field. This text field may or > may not contain email addresses. I know how to read the content of field to > a string. Now what I need is a regular expression that I could use to > identify any email addresses in the string. Since the email can be in mixed > case, I need a solution that is case insensitive. > > So, there may be one or more email addresses in the string. When I find > one, I need to added it to a list variable and look for other addresses in > the string. > > Thanks, > > David McInnis > Get a copy of _Mastering Regular Expressions_, by Jeffrey Friedl, from O'Reilly press. The regular expression you want is in the back. Be warned - it's over 4000 characters long, and it still doesn't work in all cases. Email addresses are not a regular language, and therefore cannot be completely matched by regular expressions. -Chris -- http://mail.python.org/mailman/listinfo/python-list From mwh at python.net Tue Nov 6 05:21:15 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 6 Nov 2001 10:21:15 GMT Subject: bg and fg References: Message-ID: barry at zope.com (Barry A. Warsaw) writes: > >>>>> "NF" == Nicholas FitzRoy-Dale writes: > > NF> On my system, "man 2 setsid" gives a useful, if terse, > NF> definition of setsid(). This was useful to me six months ago > NF> when I ran across exactly the same problem (wanted to write a > NF> daemon) and didn't understand what setsid() did. :) > > Anybody who wants to write a proper Unix daemon should read Stevens, > Advanced Programming in the UNIX Environment, Chapter 13. Actually, > if you're doing any amount of sophisticated Unix programming, with > Python or otherwise (yeah, right :), then the Stevens books are > absolutely indispensible, IMHO. And Python is a very nice language for playing about with the functions Stevens is discussing, for the most part (i.e. except signals). Certainly nicer than C. Cheers, M. -- First time I've gotten a programming job that required a drug test. I was worried they were going to say "you don't have enough LSD in your system to do Unix programming". -- Paul Tomblin -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html From logiplexsoftware at earthlink.net Wed Nov 14 15:54:41 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Wed, 14 Nov 2001 12:54:41 -0800 Subject: How to marshal a function? In-Reply-To: References: Message-ID: <01111412544105.04702@logiplex1.logiplex.net> On Wednesday 14 November 2001 12:28, Fran?ois Pinard wrote: > Hello, my friends. > > Earlier today, I wondered how to marshal a function, in view of > transmitting it to a remote machine and executing it there. The idea was > to not transmit Python source, when the byte-compilation has already been > done on this side. > > I quickly found out that, for a given `function f(...) ...' I should > transmit marshal-ed `f.func_code' instead of `f'. The resulting code > could even be eval'ed or exec'ed on the remote side, if the function > does not require arguments. I did not saw that I could usefully return > something from the function, and surely many other properties are missing. Try pickle (or cPickle) rather than marshal: import pickle def f(a, b, c): return a + b + c pc = pickle.dumps(f) # transmit pc to another machine... f = pickle.loads(pc) print f(1, 2, 3) -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From skip at pobox.com Thu Nov 1 16:25:46 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 1 Nov 2001 15:25:46 -0600 Subject: open vs. open In-Reply-To: References: Message-ID: <15329.48602.331013.479735@beluga.mojam.com> Armin> Question: is it possible to rename the __builtin__.open call to Armin> __builtin__.fopen because it does really a fopen library call?? Armin> Or does it break something ?? Any code that calls open(fname) would no longer work. You'd have to replace it with something else. -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From andreas at mtg.co.at Wed Nov 28 14:36:28 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Wed, 28 Nov 2001 20:36:28 +0100 Subject: Copy operator (was list.remove for Noivces) In-Reply-To: References: Message-ID: <200111281936.fASJaeY18472@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Mittwoch, 28. November 2001 04:54 schrieb arthur.siegel at rsmi.com: > Disagree strongly. What is being accomplished is raising the visiblity > of the issue within the language itself. I would argue that the status quo > conspires to underplay the significance of the issues involved - no harm > done to those who already understand them. Well, I never had a problem with understanding the Python semantics. There are other languages that do have similiar semantics. (Actually most OO languages use only object references, not values) > One imports copy, like one imports cgi or tokenize. To a beginner, imports > from outside modules is strictly special purpose stuff. In my case it was > a long time before much beyond math ,os and sys perhaps, were anything more > than absolute exotica. Well, then I have something quite funny to you. I've been doing quite much Python development lately (basically since 1995). I've never written "import copy" myself. I've just checked one of my bigger python projects (maintained since Python 1.3 times ;) ): .py size: 22454 lines 555633 bytes import copy: 0 times [:] shallow copy: 7 times Zope 2.3.2: .py size: 126029 4419635 import copy: 1 times (used once as copy.copy(...)) [:] shallow copy: 68 times Python 2.2b1 Standard library: .py size: 183031 6110941 import copy: 9 times shallow [:] copy: 75 times What does this tell us? IMHO, while copy is quite important functionality, most heavy Python developers don't exactly overuse it. :) > As I said, whether I am correct that it would be a significant enhancement > making Python better designed to get beginners aware of and over some > important humps, is not where my larger doubts are. Of course realizing a) > I could be missing something (but I would need convincing) and b) even if See above. Just a bit greping. Of 732 .py files installed in my Python lib directory, only 9 files (1.23%) import copy. Zope is even a better example (0.21% filewise, linewise it's just 1/1260.29 %) > I am not., that it would be a long and - if the past be a guide - probably > fruitless effort to try to convince folks there is significant merit in my > position. Well, I'm not convinced. But then I prefer the luxus cabin "Python" instead of getting my hands dirty under the hood with the "C" engine ;) (And neither my first, middle nor last name is Guido :) ) > My doubts are more as to the other implications that are more technical. > The shallow/deep copy issue I understand is there and real - but I don't > really understand the issue itself. I will do some homework. Well, it's the difference between copy only one level or down to the last level recursivly. Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8BTzEHJdudm4KnO0RAuDbAJ98bxXPjE9yk087K1ta5gb2NoFG+wCfQH3V UviT/4gE3yEtEQNgY5t2ymQ= =0VCH -----END PGP SIGNATURE----- From mbonnifait at wanadoo.fr Wed Nov 14 12:37:29 2001 From: mbonnifait at wanadoo.fr (Michel Bonnifait) Date: Wed, 14 Nov 2001 18:37:29 +0100 Subject: How program a particilar algorithm ? Message-ID: <9sua59$3lh$1@wanadoo.fr> Hello, I think my question is more on programming than specifically on programming with Python. I want to generate all possible lists with elements from another one. For example, from a list like [1,2,3,4] i want to program an algorithm which will give this result [[1,2],[1,3],[1,4],[1,2,3],[1,2,4],[1,3,4],[1,2,3,4],[2,3],[2,4],[2,3,4],[3, 4]] It's seems to me it should be a recursive programming answer but i can't find it. thanks in advance for your help ! From anton.vahcic at kiss.uni-lj.si Mon Nov 19 08:12:19 2001 From: anton.vahcic at kiss.uni-lj.si (Anton ml. Vaheie) Date: Mon, 19 Nov 2001 14:12:19 +0100 Subject: python and applets Message-ID: <9tbfav$ekt$1@news.uni-lj.si> I know it might sound silly question, but can be python run in the same mode as Java applets - you something like Python applets? Anton, ml. From jgardn at alumni.washington.edu Mon Nov 12 12:00:26 2001 From: jgardn at alumni.washington.edu (Jonathan Gardner) Date: Tue, 13 Nov 2001 02:00:26 +0900 Subject: Python Vim Module - works Message-ID: <01111302002607.00632@linux> I got it all to work. Thanks to a contribution by Tomas Zellerin, and a few more hacks, I think it all looks good. I need some help to make it professional. It's 2:00 AM here in Seoul, so I won't be getting any answers out for a few hours... =) If you can get it to compile (just edit the Makefile to make it point to the right place...) try this with Vim 6.0: $ gvim --servername TEST $ python >>> import vim >>> vim.list() ['TEST'] >>> vim.send('TEST', 'iHello World!') You should see the string "Hello World!" neatly typed into the newly opened vim window!!! Sorry, X11 only right now... Jonathan [ Note: This was cross-posted to vim-dev and python-list so I can go to bed sooner... ] From ed at iterunet.com Mon Nov 5 02:57:25 2001 From: ed at iterunet.com (Edy Lie) Date: Mon, 5 Nov 2001 15:57:25 +0800 Subject: Python Newbie Message-ID: <9s5eq8$mhk$1@newton3.pacific.net.sg> Hi Everyone, I am totally a new python wannabe coder. I have been switching between python and perl last few months. In Perl i could code some small scripts which does the work i wanted to but somehow in my mind it has been telling me that python is my choice. I have some doubts here 1. I would really want to learn this lang (What should i do?) i know instead of asking here i should start coding but i have no idea what should i code. Is there anyone in here willing to conduct a small class or at least giving out exercise to newbies to code ? 2. Another thing when doing coding if i am facing problem i tend to stop or rather wanted to learn everything in a day or as fast as i could which i believe is a wrong approach. Is there anyone kind enough to give me some direction in order i could code something useful. Thanks for all the advices. Regards, Edy Lie. From donn at u.washington.edu Tue Nov 6 14:47:42 2001 From: donn at u.washington.edu (Donn Cave) Date: 6 Nov 2001 19:47:42 GMT Subject: C callbacks ? Re: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> Message-ID: <9s9eou$214c$1@nntp6.u.washington.edu> Quoth Gordon McMillan : | Frederic Giacometti wrote: ... |> I see maintaining hybrid behavior (iterative / recursive calls to the |> interpreter, and 'recursion tolerance') as a requirement... | | True. And Stackless (as a 3rd party product) can get away with saying | "Oops, I can't do that". The bar is higher for a core language feature, | though. Which is a shame, because this turns out to be more of a | theoretical problem than a real one. I had no trouble with Python -> C -> Python, done in the normal way with PyEval_CallObject() with Stackless 2.0, and even invoked continuations from previous calls. I don't know if that's inconsistent with what you're saying, or not - maybe I was just lucky! Donn Cave, donn at u.washington.edu From oktay_safak at yahoo.com Thu Nov 22 09:19:39 2001 From: oktay_safak at yahoo.com (Oktay Safak) Date: Thu, 22 Nov 2001 06:19:39 -0800 (PST) Subject: Vpython download problem Message-ID: <20011122141939.72341.qmail@web14707.mail.yahoo.com> Hi all, I am trying to download Vpython (for Windows) but connot complete the download, it aborts all the time. I could find two sites, but both have the same problem. Any ideas or other mirrors? SourceForge doesn't have the files. The sites with the problem are http://virtualphoton.pc.cc.cmu.edu/projects/visual/win_download.html http://cil.andrew.cmu.edu/projects/visual/download.html Thanks for any help, Oktay Safak c.l.p resident lurker __________________________________________________ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 From aeoo at myspamrealbox.com Fri Nov 2 09:16:02 2001 From: aeoo at myspamrealbox.com (Leo Lipelis) Date: Fri, 02 Nov 2001 09:16:02 -0500 Subject: Exception handling wart in Python References: <7xady5oovl.fsf@ruckus.brouhaha.com> <7xn1257h0d.fsf@ruckus.brouhaha.com> Message-ID: On Fri, 02 Nov 2001 02:45:38 -0500, Paul Rubin wrote: > "Leo Lipelis" writes: >> In 99.99% of Python code, the exceptions that are thrown are well known >> in advance. Even dynamically executed strings are really not so >> dynamic, because, for example, they are often scripts that could be >> exception-checked prior to execution. > > You said "track all the exception flows". In technical subjects like > programming, "all" means 100%, not 99.99%. That was a mistake. I will be more careful next time. However, I believe I did say I would settle for a good guess also. > It's possible to write spaghetti code with exceptions, that's for sure. > It's best to avoid doing that. Your modules should generally not have > the possibility of raising a lot of different exceptions. Rather, they > should catch exceptions from modules they call, and deal with them or That's what I want to do. But without a good tool, it's very hard. It means I have to sift through endless documentation, and worse, I have to trace the execution flow by hand in order to read all the right docs. Or alternatively, I have to put a lot of faith in a docstring, thinking that the author of the docstring already traced all the exception flows for me and is informing me of all the worthwhile exceptions I should know about. > re-raise them in a uniform way. Also, use the standard exception > classes for things like system errors, attempting to raise the right > kind of exception for the condition you encounter. Designing the > exception system in a program is just like designing the class > structure--it takes a certain amount of thought and tweaking but > generally you can come up with something clean and well suited to your > program. Right. I know how to use exceptions and I agree with the above and your other advice on exception use. > >> In reality, there is no reason why you shouldn't know it. > > Well, as a matter of coding convention, that's possibly true, but in > Python it can't really be enforced, as we've seen. Well, I think it's more accurate to say that not all exceptions can be enforced, but most normal exceptions can be. Besides, I am not looking to duplicate Java by enforcing exceptions. Even Java itself doesn't enforce *all* exceptions. Java has the unenforced RuntimeException. Although you could *only* throw RuntimeException's if you wanted, it would be bad programming practice. Thus, Java is not a fascist dictator. Java does it's own thing, and it's fine. Python has a different flavour. I think Python should provide a standard tool that gives warnings about unhandled exceptions (maybe not all, but as many as possible). Invoking this tool would be up to the programmer. For small scripts it wouldn't even make sense to use it. But for a large code base, it would be a great tool. >> Then, you can deal with various exceptions differently. For some, you >> can just log them and keep going. For others, you may request the user >> to try again. For yet others you can attempt automatic recovery. All >> this is impossible if you don't know what exceptions you're dealing >> with. > > I don't know, maybe I'm missing something. It's always seemed to me > that having to declare every single exception that a function can raise > (like Java requires) goes against the principle of modularity. Callers > should not have to care about the internal intricacies of things they > call. I tend to agree with you here. That's why I wouldn't want to copy Java precisely. Maybe I shouldn't say "exception handling like in Java", but rather, "exception handling reminiscent of Java?" Forcing everything is what Java does, and it pays the price for doing that by losing some expressive power and picking up some extra verboseness. But a standard way to get hints about unhandled exceptions in Python would go a long way toward making exceptions more heavy-duty imo. It should, at the very least, be much better than just relying on the docstrings. It's like driving and seeing. Driving skill is not that useful for someone who can't see the road. Driving skill alone is not all it takes to drive. This is the same with exceptions. Just because Python allows raising and catching exceptions, doesn't mean it's providing all the functionality necessary for proper exception use. I think it's really missing a good set of eyes in the form of a tool that could trace the exception flow (in most cases). >> But, no matter how you write it, you *still have to know* what >> exceptions you need to handle. You can't magically decide it at run >> time, nor do you need to, nor should you. > > This doesn't seem like a worse situation to me than if you have a > function that returns a tuple, and you're supposed to know what the > elements of the tuple signify, and if it returns something other than > what you expected, your program has a bug. I think it's much worse! The tuple doesn't propagate until you catch it! You always have to handle the tuple at each function call, and then, if you also return a tuple, you do so willingly and there is a better chance of you documenting what you are returning. Tuples are very explicit and they do not propagate on their own. Exceptions are very sneaky and they DO propagate until they're caught. And what's worse, if they're not caught, they terminate your program, guaranteed. If you don't know what the elements in tuple are, your program could potentially terminate too, but it's not guaranteed. I think exceptions are very beneficial, and in fact, it's good that they can terminate your program and so on. That's what we want. But it's doubly good when you know what exceptions are potentially flying by, so that you can handle them. Because exceptions are not in the same category as returning tuples they deserve special attention. >> The dynamic nature of Python is absolutely not a reason for such a >> lucklaster handling of exceptions in Python. Let's get this argument >> out of the way, because I don't think it's even worth discussing >> further, unless someone can demonstrate that in 99.99% of cases you >> really can't possibly know what exceptions you should handle anyway. > > I don't think static analysis of the program can tell you what > exceptions are possible, just because if you have > > def foo(frob): > x = frob.mumble() > > you don't know what class frob belongs to, so you don't know what > exceptions it can raise. Global dataflow analysis of the whole program > can help only some of the time, or else optimizing compilers would work > a lot differently than they do. Ok looking at above it's not possible. But how about here: ---begin script--- def foo(frob): x = frob.mumble() foo("String") # let's assume that string class has mumble method foo(5) foo(gdbm.open("bar", "rf")) ---end script--- At some point you do know the type. You just have to infer it. I agree that makes it more difficult than in Java. > > It's different in java, where frob has to be declared in the function > header. If you add some syntax (or a convention) declaring what frob > is, e.g. > > def foo(frob): > assert isinstance(frob, FrobClass) > x = frob.mumble() > > then your chances are a lot better. But you really have to know the > type of everything in the program that can raise an exception. Right. >> Again, just because it's possible to use the language in a twisted >> way, doesn't mean that the other 99.99% of exceptions should be >> penalized by not having a tool that automatically warns you about >> unhandled exceptions. > > I agree that a tool like that can be useful in some situations. But I think most of the time it would be useful. It wouldn't be a guarantee like in Java, but it would go a long way to a point of "almost guaranteed unless you did something weird with dynamic execution". > knowing what something will do in the usual case (e.g. 99.99% of the > time) is a lot different than being able to make rigorous inferences > about it which require you to know what it will do 100% of the time. > Java tries to provide the latter and I thought at first that that was > what you wanted. How is providing 99% of the rigour dissimilar from 100%? From the point of view of the coder, who is using that tool, it would be practically the same. Let's keep in mind, that only in the weird cases you really couldn't guarantee correct exception flow tracing. Usually these would be the cases of bad programming practice. How much more rigorous would this be than relying on the mercy of the docs? >> I say that without such a tool, exceptions in Python are pointless at >> worst, and are very awkward to use at best. > > That seems like an extreme overstatement. There's no tool like that for > now, and exceptions still currently work pretty well, both in Python and > in millions of lines of Lisp code, though improvements are possible in > both languages. Having such a tool is one of the possible improvements. Is there any other way to improve them such that an exception flow tracing tool would become useless? From mwh at python.net Tue Nov 27 08:01:28 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 27 Nov 2001 13:01:28 GMT Subject: pyrepl-0.6 Message-ID: Michael Hudson writes: > Fernando P?rez writes: > > > Michael Hudson wrote: > > > > [pyrepl] > > > I have a new version sat on my irritatingly > > > internet-disconnected home box which I'll release as soon as I > > > remember to stick it on a floppy and bring it in to the > > > department. > > Argh! Tomorrow, maybe. And so it was (except it was a CD-R not a floopy and I forgot how to drive mkisofs and had to fiddle file names when I got it here and ...) Here's the new README: This is pyrepl 0.6, a readline-a-like for Python, which seems to be being released on 2001-11-27. http://starship.python.net/crew/mwh/hacks/pyrepl.html It requires python 2.1 (or newer) with the curses and termios modules built, and features (in less than 3000 lines of code): * sane multi-line editing * history, with incremental search * completion, including displaying of available options * a fairly large subset of the readline emacs-mode keybindings (adding more is mostly just a matter of typing) * a liberal, Python-style, license * a new python top-level * no global variables, so you can run two or more independent readers without having their histories interfering. * generally speaking, a much more interactive experience than readline (it's a bit like a cross between readline and emacs's mini-buffer) There are probably still a few little bugs & misfeatures, but _I_ like it, and use it as my python top-level most of the time. To get a feel for it, type: $ python pyrepl.py One point that may confuse: because the arrow keys are used to move up and down in the command currently being edited, you need to use ^P and ^N to move through the history. Please direct comments to mwh at python.net. (If you've released open source software you'll know how frustrating it is to see a couple of hundred downloads and only get a handful of emails, so don't think I'll be irritated by the banality of your comments!) New since 0.5.1: + Rewrote the low level code to be (hopefully) more portable and (certainly) clearer. Most of the code from 0.5.1 is still present, but it's been moved around and refactored (and the names have gotten more sensible). + The above process fixed a fair few bugs. + Implemented a few more emacs-mode bindings. + Nailed another couple of differences between my top-level and the the default one, including playing nice with Tk. + Implemented a saner way of handling window resizes (a sane way of handling signals! Call the Unix police!) + minimal testing on cygwin. New since 0.5.0: + Realizing that it wasn't going to run under 2.0 after all, I ripped out some of the 2.0 compatibility code. Planned "at some point in the future": - vi-mode - GUI toolkit friendliness (done for tk) - point-and-mark? - undo support (0.5.1 had some undo support, but it didn't really work, and 0.6.0 has none) - user customization support (maybe even try to read $INPUTRC?) - non-incremental history search? (prolly not worth it) - a more incremental way of updating the screen. An announcement will find it's way on to clpa & the usual Parnassus thing will happen soon. Enjoy! M. -- 6. Symmetry is a complexity-reducing concept (co-routines include subroutines); seek it everywhere. -- Alan Perlis, http://www.cs.yale.edu/homes/perlis-alan/quotes.html From hgg9140 at seanet.com Fri Nov 30 23:14:40 2001 From: hgg9140 at seanet.com (Harry George) Date: 30 Nov 2001 20:14:40 -0800 Subject: Python evangelists unite! References: Message-ID: brucehapman at hotmail.com (brucehapman at hotmail.com) writes: > > So, I need some help. I've checked out c.l.p and some on-line > articles, and I just can't find good practicle examples of a program > that adds members to instances (or classes) at runtime. Anybody got > any? I don't want to have to start avoiding my friend.... We have to parse various csv files. The column headers are provided in the files. For each data line, we generate an instance of a generic record class, and load the data into attributes whose names are derived from the column headers. From there the records are easy to use. -- Harry George hgg9140 at seanet.com From dalke at dalkescientific.com Wed Nov 14 22:39:50 2001 From: dalke at dalkescientific.com (Andrew Dalke) Date: Wed, 14 Nov 2001 20:39:50 -0700 Subject: Non-obvious name bindings References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> <3BF1BB43.6B4E667B@bgb.cc> <9ssf3h$dfh$1@peabody.colorado.edu> <3BF2D8CE.7CC12F87@ccvcorp.com> Message-ID: <9svdba$jf9$1@slb7.atl.mindspring.net> Rainer Deyke: >This will not compile on a conforming C++ compiler. More historically, about 5 years ago C++ switched from having for(int i=0; ...) { } put the 'i' in the scope outside the 'for' loop to only being valid inside the for loop. Andrew From kuran42 at yahoo.com Tue Nov 6 22:28:53 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Tue, 06 Nov 2001 22:28:53 -0500 Subject: wxWindows link error Message-ID: <3BE8AA75.1090101@yahoo.com> Just finished building wxPython 2.3.1 using GCC 3.0 and wxGTK 2.3.1. But to my dismay, I get the following: ~$ python Python 2.1 (#6, Sep 25 2001, 04:43:19) [GCC 3.0] on linux2 Type "copyright", "credits" or "license" for more information. >>> import wxWindows Traceback (most recent call last): File "", line 1, in ? ImportError: No module named wxWindows >>> import wxPython Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/site-packages/wxPython/__init__.py", line 20, in ? import wxc ImportError: /usr/local/lib/libwx_gtk.so: undefined symbol: __gxx_personality_v0 >>> Googling yields many results, none seem python related, most point to gcc 3.0 as the cause. Do I need a different version of GCC to use wxPython (in other words, do I need to get a different windowing library) or can someone show me how to fix this? Thanks in advance, Jp Calderone From sandskyfly at hotmail.com Fri Nov 16 09:34:02 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 16 Nov 2001 06:34:02 -0800 Subject: CGIHTTPServer and Win2k References: <4q39vt4silvue8rl0qv4ff4tar6942r9g3@4ax.com> Message-ID: > Exit status 0x2 is "file not found". > > You have a permissions problem. On Windows 2000, the user profile > directories in "Documents and Settings" are readable only by the owner. > > You should either place these in "Documents and Settings\All Users", or in > some other public directory. I don't think that will solve the problem: here's a cut-and-paste from python 2.2 module reference: "11.17 CGIHTTPServer -- CGI-capable HTTP request handler Availability: Unix. The CGIHTTPServer module defines a request-handler class, interface compatible with BaseHTTPServer.BaseHTTPRequestHandler and inherits behavior from SimpleHTTPServer.SimpleHTTPRequestHandler but can also run CGI scripts. Note: This module is Unix dependent since it creates the CGI process using os.fork() and os.exec()." regards, Sandy From terabaap at yumpee.org Wed Nov 7 16:15:42 2001 From: terabaap at yumpee.org (Manoj Plakal) Date: Wed, 07 Nov 2001 21:15:42 GMT Subject: Python VM on Lego Mindstorms References: <3BE7D665.8030904@yumpee.org> <3BE96697.69F0B6B9@juno.com> Message-ID: <3BE9A4AD.4040309@yumpee.org> Jeff Sandys wrote: > Manoj Plakal wrote: >>Has there been any work on porting the Python VM to >>run on a Lego Mindstorms RCX brick? So that robot >>control programs can be written in Python. >> > I think the better solution would be to create a set > of classes that represent the RCX primitives. Then > each class would send 'compiled' instructions to the > RCX. Then the RCX wouldn't the whole of Python. > > Forth is the only language that fully loads into > the RCX. JVM is intended to have a small footprint, > the rest of Java is outside of the RCX. Yeah, you could always run Python on the host machine and have it control the RCX via the IR link (Right now, there's a library called Pylnp that allows Python programs to talk to legOS). But that is simply no fun, from the hacking point of view :) I'd like to see Python bytecodes running inside the RCX. What is it about the JVM that makes it so much smaller than the Python VM? If you take out the libraries and just look at the language VMs, why is one smaller than the other? I'm just interested in porting the essential language core and data types to run on the RCX. Not necessarily the whole library and not all language features. So no floats, longs, complex, Unicode, files, threads, networking, garbage collection, parser/compiler etc etc. What the RCX needs is a framework to write event-driven state-machines in a scripting language like Python. That will be easier to use for most people than Java (TinyVM,leJos), Forth (pbForth) or C/C++ (legOS). Maybe continuations or micro-threading a la Stackless would be good for doing event-driven programming in a constrained space. Not sure how doable this is but for the heck of it, I've set up the PygmyVM project at Sourceforge: pygmyvm.sourceforge.net Pygmy pythons are one of the smallest pythons in the world (around 2 ft long) :) I might also look at using Lua, if Python doesn't work out. It's a pretty interesting-looking language and has a smaller profile. Manoj From jjl at pobox.com Mon Nov 5 13:54:00 2001 From: jjl at pobox.com (John J. Lee) Date: Mon, 5 Nov 2001 18:54:00 +0000 Subject: time.daylight (Daylight Saving Time) In-Reply-To: <3BE68D3B.28AEA20E@cs.utwente.nl> References: <3BE68D3B.28AEA20E@cs.utwente.nl> Message-ID: On Mon, 5 Nov 2001, Richard van de Stadt wrote: [...] > time.__docs__ shows this, concerning DST: > > --- > DST (Daylight Savings Time) flag (-1, 0 or 1) > If the DST flag is 0, the time is given in the regular time zone; > if it is 1, the time is given in the DST time zone; > if it is -1, mktime() should guess based on the date and time. > --- > > However, now that DST is over, time.daylight keeps on being 1 (on the > 5 systems located in different time zones that I've tried). > > There's no time.py, so I'm clueless about how time.daylight is supposed > to be updated. Any ideas? Is it perhaps only set at compile time (just > guessing). >From the library reference: daylight Nonzero if a DST timezone is defined. So 1 is what it's supposed to be, all year round, if your timezone has daylight savings time at any time of the year. time.localtime does what's required (returning the DST flag that you described above -- not the same as time.daylight), based on the table in your C library: DST is Daylight Saving Time, an adjustment of the timezone by (usually) one hour during part of the year. DST rules are magic (determined by local law) and can change from year to year. The C library has a table containing the local rules (often it is read from a system file for flexibility) and is the only source of True Wisdom in this respect. John From a11w at SoftHome.net Thu Nov 29 13:49:22 2001 From: a11w at SoftHome.net (Jiba) Date: Thu, 29 Nov 2001 13:49:22 -0500 Subject: pyplets References: <655abd4a.0111290417.4b28a0f2@posting.google.com> Message-ID: <3c062e76$0$2150$7a628cd7@news.club-internet.fr> e toffi wrote: > i was thinking (which i dont do often), and came up with an idea > (which i *do* do often -- dont ask me how). the idea is pyplets -- the > analogue to java applets with a fittingly silly name. anyway the > premise is to define an api that lets programmers write small programs > that execute in a browser. > > whatdyathink? > Very great idea ! I think Python has too weak point, compared to Java or other : speed (but psyco is coming) and client-side capabilities (apllet and web start). There is also another Java technology that may be MUCH easier to implement : Java Web Start. This allows to launch Java apps from the web (just by clicking an hyperlink). As you don't need to modify web browser (you can just add a mime-type for such link) it can be really easy to do, and can work with about any webbrowser. I was thinking to something like that but the lack of time as frozen it totally... If we define an API, we may try to make it language-independant (this is THE wrong point about applet !). hat about scriptlet ??? This emphase another avantage of Python (or any other script language) : you may include the source directly in the HTML ! What ever you choose, i may help you !!! I think Python time is coming ! Jiba From luiz at fabricadigital.com.br Fri Nov 23 17:17:17 2001 From: luiz at fabricadigital.com.br (Luiz Carlos Silveira) Date: 23 Nov 2001 14:17:17 -0800 Subject: dynamic parameters Message-ID: <119c3c89.0111231417.5f060692@posting.google.com> Hello, I was given the task of mixing Python with Lua (a configuration language -- www.lua.org). I already can call Lua functions from Python, but I have a problem when calling Python functions from Lua. My problem is that when I call a Python function, I don't know which function it is, so I don't now how many parameters it will take. My question is: how can I pass (dynamically) all the parameters that the function should receive? I'm using the Py_BuildValue function. As far as I could see, this function only allows me to pass a determined number of parameters. I couldn't figure out how I could call it twice or more times (like in a loop) and add each parameter dynamically. I searched the docs but had no success. If someone knows where I can find it, please give me a link. Thanks Luiz. ~ From dale at riverhall.NOTHANKS.co.uk Sat Nov 3 09:39:42 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Sat, 03 Nov 2001 14:39:42 +0000 Subject: Exception holes, again. Message-ID: On a related subject to the earlier exceptions wart thread. I want to trap the specific 'api_error' exception raised by win32api. I can't find where that exception is defined so how do I catch it? I have searched the whole Python installation for the string 'api_error' but it isn't there. -- Dale Strickland-Clark Riverhall Systems Ltd From Joelmon2001 at aol.com Fri Nov 16 21:44:31 2001 From: Joelmon2001 at aol.com (Joelmon2001 at aol.com) Date: Fri, 16 Nov 2001 21:44:31 EST Subject: Hello, question about python online script Message-ID: Hello, I created my first python script that basically asks a user to guess a number, and if they are correct, it tells them they win yipee :) But it works only when I run it at the command line how do I get such a thing to work online? I get python to work via cgi scripts but the line: password = raw_input("Password:") caused this error: Traceback (innermost last): File "/home/sites/site7/web/test/game.cgi", line 8, in ? password = raw_input("Password:") EOFError: EOF when reading a line See, raw_input as you know would allow the command line to ask me to type a number. how do I replicate this online? Thanks Joel PS. If needed, I can post source code, I chose not to in case it would be a waste of space or redundant -------------- next part -------------- An HTML attachment was scrubbed... URL: From chrishbarker at home.net Wed Nov 28 15:50:34 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 28 Nov 2001 12:50:34 -0800 Subject: how to call external functions from python References: Message-ID: <3C054E1A.A3E2E582@home.net> weeang wrote: > i need help on the following: > > 1) find all files in inbox directory and zip them > 2) move the zipped file to outbox > 3) copy the zipped file to a remote directory > > pls help on the following as i m very new to python, and could not > find the exact help that i need in the faq, help, etc. > > i m using python 2.1, using windows for my initial testing. however, > i will subsequently use the script on a linux box instead. What you probably want is some combination of: import os os.system() os.listdir() os.rename() and you also might want to look at the shutil module and the zipfile module The Library Refernece is your friend! http://www.python.org/doc/current/lib/lib.html -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From sholden at holdenweb.com Fri Nov 30 08:59:21 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 08:59:21 -0500 Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: Message-ID: "Michael Abbott" wrote in message news:Xns91697EB73ACCmichaelrcpcouk at 194.238.50.13... > Skip Montanaro wrote in > news:mailman.1007090560.18985.python-list at python.org: > > > You were relying on undocumented behavior. There is no obvious ordering > > between integers and None. > > > > So why don't comparisons of this type generate an exception? Because comparisons are used in sorts, for example, and it wasn't considered helpful for sorts of lists of arbitrary datatypes to raise errors. regards Steve -- http://www.holdenweb.com/ From jeff at ccvcorp.com Fri Nov 23 17:10:04 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 23 Nov 2001 14:10:04 -0800 Subject: Beginner's question... References: <9tlmkh$3gnos$1@ID-59885.news.dfncis.de> <3BFEADBB.68E786C2@verizon.net> Message-ID: <3BFEC93C.78DB7D98@ccvcorp.com> Power-Tech wrote: > I am a very newby at phyton, actually I started messing with it two days > ago. I have a > question that may be so dumb that I was afraid of posting in the > mailgroup, could anyone answer me or direct me to someone who can? > The problem is: > I create a small program with the Python IDLE gui, save it as a .py > file, when I double click to open the file, a DOS window opens but > closes immediately, without running the program, or if it is a > calculating program, as soon as I type something, the window closes. > I am using Windows 98 OS. > Thanks for your reply... > Willie The program *is* running, it's just that the DOS window closes as soon as the program finishes--before you've had a chance to see the result. (Is this in the FAQ? If not, it probably should be...) There are a couple of ways to deal with this problem. 1. Run the program within IDLE. I don't use IDLE so I'm not sure exactly where to find it (probably in the file menu), but there is an option to run a script file within IDLE's interactive window. 2. Open a regular DOS window, cd to the directory of your script, and run it by typing "python myscript.py". This way, since the window is separate from the Python program, it won't close when the program is finished. If you're doing repeated runs of the same script, you can run DOSkey and then you can repeat the command with up-arrow. 3. At the very end of your script, add this line: raw_input("Press Enter to Finish") This will prompt for an enter before the script ends, and your DOS window will stay open until it gets that enter. Hope this helps... Jeff Shannon Technician/Programmer Credit International From pinard at iro.umontreal.ca Sun Nov 25 15:22:57 2001 From: pinard at iro.umontreal.ca (=?iso-8859-1?q?Fran=E7ois?= Pinard) Date: 25 Nov 2001 15:22:57 -0500 Subject: vCard parser anywhere ? In-Reply-To: <9trh93$o1e$1@norfair.nerim.net> References: <9trh93$o1e$1@norfair.nerim.net> Message-ID: [Gillou] > I'm looking for a vCard parser that changes a vCard stream into a > Python object. Did not find this treasure in Vault of Parnassus ! If I had this precise problem, I would probably fetch and study: http://www.splode.com/users/friedman/software/emacs-lisp/src/vcard.el then translate it to Python according to my needs. Noah Friedman wrote it, and Gnus happily uses that package automagically whenever it is available. -- Fran?ois Pinard http://www.iro.umontreal.ca/~pinard From fardal at coral.phys.uvic.ca Wed Nov 28 20:31:22 2001 From: fardal at coral.phys.uvic.ca (Mark Fardal) Date: 28 Nov 2001 17:31:22 -0800 Subject: Copy operator (was list.remove for Noivces) References: <3C054C58.9961A62@home.net> Message-ID: Chris Barker writes: > ... > Here is a little example: > ... nice example snipped ... >From a newbie, thanks. I would sum this up with "a Python variable name is a reference; a list is a series of references". Why isn't this sort of example prominent in, say, the tutorial? But I'm still confused. For one thing, NumPy seems to behave differently. Apparently a Numeric array is not a series of references, but a reference to a series... python> a = range(4) python> a [0, 1, 2, 3] python> b = a python> b = a[:] python> a[0] = 666 python> b [0, 1, 2, 3] python> a = arange(4) python> a array([0, 1, 2, 3]) python> b = a[:] python> a[0] = 666 python> b array([666, 1, 2, 3]) python> a = arange(4) python> a array([0, 1, 2, 3]) python> import copy python> b = copy.copy(a) python> a[0] = 666 python> b array([0, 1, 2, 3]) This crucial difference in the behavior of the [:] operator seems to be inadequately explained in the Numeric manual, which just says: In other words, [:] with no arguments is the same as [:] for lists - it can be read "all indices along this axis". Also, it is not necessarily clear to me when assignment creates a new object (freeing the reference to the old object), and when it modifies the old object. Apparently alist.append(7) modifies the old object. How about alist = alist * 2? Looks like a new object. How about a = 3 and then a *= 2? (With Python 1.5.2 I don't have the *= operator.) I guess a is immutable so it must create a new object... > What I get from this is that someone using Python had better understand > how Python name binding, mutable types, copying, and deep copying work > in order to not get bit eventually. ... > > -Chris Absolutely. The introductions to the language that I've seen so far (Tutorial, Numeric documentation, FAQ, Andre Lessa's book) do an poor job of explaining these issues, in my opinion. The information is either not there or not stressed enough. Which is why you guys have to keep explaining them to newbies. thanks, Mark Fardal University of Victoria PS: I'm using Python 1.5.2 and Numeric 15.2, if that makes a difference. From anton.vahcic at kiss.uni-lj.si Mon Nov 19 12:27:15 2001 From: anton.vahcic at kiss.uni-lj.si (Anton ml. Vahèiè) Date: Mon, 19 Nov 2001 18:27:15 +0100 Subject: python and applets Message-ID: <9tbff1$sjg$1@planja.arnes.si> I know it might sound silly question, but can be python run in the same mode as Java applets - you something like Python applets? Anton, ml. From root at rainerdeyke.com Wed Nov 28 09:37:59 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 28 Nov 2001 14:37:59 GMT Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C02E8FD.740D82FE@cosc.canterbury.ac.nz> <3C045F92.AD720B@engcorp.com> <3C04768A.CFDC1CE8@engcorp.com> Message-ID: "Peter Hansen" wrote in message news:3C04768A.CFDC1CE8 at engcorp.com... > Rainer Deyke wrote: > > > > "Peter Hansen" wrote: > > > Greg Ewing wrote: > > > > for 0 <= i < 5: > > > > ... > > > > > > -1 for being ambiguous to newbies. > > > > The same could be said for 'for i in range(5)', since 'i in range(5)' is an > > expression that is roughly equivalent to '0 <= i < 5'. > > But range() can be looked up. You can type range(5) > at the interactive prompt (where a newbie would live) > and see [0, 1, 2, 3, 4] and infer immediately that > you are stepping through the items one at a time. > Typing 0 <= i < 5 at the prompt gives you either > 0 or 1, or NameError: name 'i' is not defined. > Not helpful for a newbie. You are missing the point. Typing 'i in range(5)' gives the same result at the interactive prompt. So does 'i in [0, 1, 2, 3, 4]'. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From bigredlinux at yahoo.com Thu Nov 29 15:49:42 2001 From: bigredlinux at yahoo.com (Dan Allen) Date: 29 Nov 2001 12:49:42 -0800 Subject: finding a value in a tuple Message-ID: <28d73ad6.0111291249.6fb9b6eb@posting.google.com> Say I have mylist = ['one','two','three'] which I presume is a "tuple" as I have been scanning the manual. Now, is there a way to run the php-like function in_array() on this. Consider this, I want to know if one of the values in that tuple is exactly equal to "four". The answer of course is no, but how would I find it. Here is what I have so far, which works, but it is ugly.. d = {} for value in mylist d[value] = 1 try: if d['four']: print "your value was found" except: print "your value was not found" Two question here, is that a bad use of try/except? Second is, is there an array_flip, or do you just have to do what I did above? I would imagine there is a way to search down the tuple. Thanks! Dan From root at rainerdeyke.com Wed Nov 7 09:09:09 2001 From: root at rainerdeyke.com (Rainer Deyke) Date: Wed, 07 Nov 2001 14:09:09 GMT Subject: Q: Feature Wish: "%" Extension References: <_SZF7.57706$IR4.31105048@news1.denver1.co.home.com> <3BE9338B.70257B81@earthlink.net> Message-ID: <9gbG7.58629$IR4.32167958@news1.denver1.co.home.com> "Hans Nowak" wrote in message news:3BE9338B.70257B81 at earthlink.net... > > Rainer Deyke wrote: > > > "John Roth" wrote in message > > news:tugphsjop81s04 at news.supernews.com... > > > Integer division is not an inverse of integer multiplication, therefore > > > the proposed counterexample fails. > > > > What do you mean? '(a * b) / b' equals 'a' for all integers 'a' and 'b' > > (assuming 'a * b' evaluates without overflow), except when 'b' equals 0. > > I think the idea is that (a / b) * b does not equal a in current > (non-__future__) Python...? > > >>> (9 / 4) * 4 > 8 That would be a multiplication problem, wouldn't it? By the same token, we could want '(2 * 0) / 0 == 2'. It is the nature of integer multiplication that 'a * b' yields a multiple of 'b'. Integer division is the inverse of that, except that you can't divide by zero. If you feed it input that isn't the result of multiplication, it's your own damn fault. -- Rainer Deyke (root at rainerdeyke.com) Shareware computer games - http://rainerdeyke.com "In ihren Reihen zu stehen heisst unter Feinden zu kaempfen" - Abigor From kfarmer at thuban.org Mon Nov 26 04:07:34 2001 From: kfarmer at thuban.org (Keith Farmer) Date: Mon, 26 Nov 2001 09:07:34 GMT Subject: FW: [wxPython] How to trigger EVT_SIZE from external source? Message-ID: Working in Win32... I'm trying to find a message id which wxPython would accept from an external source, which I can use as a callback message for an event which would be passed by the OS. I can tell the OS the window handle (referring to a subclass of wxFrame) and the message id to use, but so far, no message id I've specified (including wxEVT_SIZE) triggers the event. How would I go about finding a message id which the OS could pass to the window, and make sure the window is able to receive and act upon this message? I've included the source code as it stands now for reference. The message id gets assigned to abd.uCallbackMessage in the Dock() function. Based on my testing to date, the values for abd are passed correctly to the system -- I'm just wanting to make sure if (1) what I'm seeking is possible, (2) if so, what my error is. I'd rather not try to tackle PythonWin. ---------- Keith J. Farmer kfarmer at thuban.org http://www.thuban.org from wxPython.wx import * import shellapi, PyAppBar, win32api, win32con class AppBarFrame(wxFrame): edges = (shellapi.ABE_TOP, shellapi.ABE_LEFT, shellapi.ABE_RIGHT, shellapi.ABE_BOTTOM) def __init__(self): wxFrame.__init__(self, None, -1, "", style=wxFRAME_TOOL_WINDOW | wxSIMPLE_BORDER) self.SetPosition((0,0)) self.SetSize((1024, 100)) self.n_edge = 0 self.IsDocked = 0 self.hWnd = self.GetHandle() EVT_LEFT_DOWN(self, self.OnClick) EVT_RIGHT_DOWN(self, self.OnChange) EVT_SIZE(self, self.OnSize) self.Dock() self.Show(true) def OnClick(self, evt): print "OnClick()" self.UnDock() self.Close() def OnSize(self, evt): print "OnSize()" self.ReDock(evt) def OnChange(self, evt): print "OnChange()" self.UnDock() self.n_edge = (self.n_edge + 1) % 4 self.Dock() def ReDock(self, evt): print "ReDock()" self.UnDock() self.Dock() def CurrEdge(self): result = self.edges[self.n_edge] if result == shellapi.ABE_BOTTOM: side = "Bottom" elif result == shellapi.ABE_LEFT: side = "Left" elif result == shellapi.ABE_RIGHT: side = "Right" elif result == shellapi.ABE_TOP: side = "Top" print "CurrEdge(): n_edge = %s -> %s" % (self.n_edge, side) return self.edges[self.n_edge] def UnDock(self): print "UnDocking...", rect = self.GetRect() abd = PyAppBar.AppBarData() abd.hWnd = self.hWnd abd.uEdge = self.CurrEdge() (abd.rc.left, abd.rc.top, abd.rc.right, abd.rc.bottom) = (rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()) PyAppBar.SHAppBarMessage(shellapi.ABM_REMOVE, abd) self.IsDocked = 0 print "done" def Dock(self): print print "Docking...", rect = self.GetRect() abd = PyAppBar.AppBarData() abd.hWnd = self.hWnd abd.uEdge = self.CurrEdge() (abd.rc.left, abd.rc.top, abd.rc.right, abd.rc.bottom) = (rect.GetLeft(), rect.GetTop(), rect.GetRight(), rect.GetBottom()) abd.uCallbackMessage = wxEVT_SIZE if (PyAppBar.SHAppBarMessage(shellapi.ABM_NEW, abd) == 0): print "Failed to register" return 0 self.AppBarQueryPos(abd) self.IsDocked = 1 print "done" return 1 def AppBarQueryPos(self, abd): print "Querying Position...", iHeight = 100; iWidth = 100; screenX = win32api.GetSystemMetrics(win32con.SM_CXSCREEN) screenY = win32api.GetSystemMetrics(win32con.SM_CYSCREEN) print "screenX, Y = %s, %s" % (screenX, screenY) # Copy the screen coordinates of the appbar's bounding # rectangle into the APPBARDATA structure. abd.rc.top = 0 abd.rc.bottom = screenY abd.rc.left = 0 abd.rc.right = screenX if (abd.uEdge == shellapi.ABE_LEFT): abd.rc.right = abd.rc.left + iWidth elif (abd.uEdge == shellapi.ABE_RIGHT): abd.rc.right = screenX abd.rc.left = abd.rc.right - iWidth elif (abd.uEdge == shellapi.ABE_TOP): abd.rc.bottom = abd.rc.top + iHeight elif (abd.uEdge == shellapi.ABE_BOTTOM): abd.rc.top = abd.rc.bottom - iHeight # Query the system for an approved size and position. print "initial abd = " + str(abd) PyAppBar.SHAppBarMessage(shellapi.ABM_QUERYPOS, abd) # Adjust the rectangle, depending on the edge to which the # appbar is anchored. if (abd.uEdge == shellapi.ABE_LEFT): abd.rc.right = abd.rc.left + iWidth elif (abd.uEdge == shellapi.ABE_RIGHT): abd.rc.left = abd.rc.right - iWidth elif (abd.uEdge == shellapi.ABE_TOP): abd.rc.bottom = abd.rc.top + iHeight elif (abd.uEdge == shellapi.ABE_BOTTOM): abd.rc.top = abd.rc.bottom - iHeight #Pass the final bounding rectangle to the system. print "final abd = " + str(abd) PyAppBar.SHAppBarMessage(shellapi.ABM_SETPOS, abd) self.SetDimensions(abd.rc.left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top) print "done" class App(wxApp): def OnInit(self): frame = AppBarFrame() return true if __name__ == '__main__': app = App(0) app.MainLoop() From jeff at ccvcorp.com Wed Nov 28 14:33:08 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Wed, 28 Nov 2001 11:33:08 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <3BFFACFB.36AF1DB2@engcorp.com> <3C005692.173907B3@engcorp.com> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> Message-ID: <3C053BF3.8B0CC128@ccvcorp.com> Huaiyu Zhu wrote: > On Tue, 27 Nov 2001 18:34:18 +0000 (UTC), Marcin 'Qrczak' Kowalczyk > wrote: > > >Let's suppose I'm editing a file written by somebody else. I want to > >insert a statement so I hit Enter at the end of a line. The editor > >automatically indents the new line. Later it causes SyntaxError > >because the file happened to use tabs and I've set my editor to use > >spaces for indentation. > > An easy and brutal solution is to mandate that tab is the only indent > charactor. A better long term solution is to write a smarter > python-mode for your editor. An easier and less brutal solution is to mandate that space is the only indent character. It's easier to teach your editor to convert tabs to spaces as you type them, than it is to teach every single person who might ever want to write a short Python script that spaces don't work. Jeff Shannon Technician/Programmer Credit International From samschul at pacbell.net Mon Nov 26 18:38:57 2001 From: samschul at pacbell.net (Samuel Schulenburg) Date: 26 Nov 2001 15:38:57 -0800 Subject: WINDOWS USERS???? References: <3C0151C3.2903A9F5@verizon.net> <%TeM7.7220$TN1.727727@news000.worldonline.dk> Message-ID: "maxm" wrote in message news:<%TeM7.7220$TN1.727727 at news000.worldonline.dk>... > "Power-Tech" wrote in message > news:3C0151C3.2903A9F5 at verizon.net... > > > I've downloaded the regular Python and had some problems running the .py > > files, > > Inside the editor in PythonWin you should be able to pres "F5" and have your > program run. > > > today I found > > that "ActivePython" should be the best download for windows users.... > > Can anyone throw some light on this? > > It is indeed a very god distribution of Python for Windows. > > > Is this group too advanced for me? > > It's probably as advanced as you want it to be ;-) > > regards Max M ActiveState's distribution includes the Pythonwin extentions taht have been developed by Mark Hammond, who now works for ActiveState. This module provides the best interface to the Windows API that exists. The only other interface you may need is Sam Rushings Windll, and Dynawin package. This package provides a lower level interface to windows dll's. Sam Schulenburg From richard at sunsetandlabrea.com Sun Nov 18 12:42:54 2001 From: richard at sunsetandlabrea.com (Richard Chamberlain) Date: Sun, 18 Nov 2001 17:42:54 +0000 Subject: Python IDE Opinion Request References: Message-ID: It hasn't got a gui builder but I really, really like WingIDE (http://archaeopteryx.com/). It has a really good debugger, a nice editor and a great source browser. Their support is also excellent, I submitted a request for the source browser to include .cgi files as well as .py files and had a patch within 24 hours - you can't get much better than that. I've tried Komodo, Blackadder, Pythonworks and idle- all of which have some nice features. Komodo was good but quite slow (especially on my 366), Blackadder didn't feel quite finished ( which is in fact the case because it's still in beta ), and Pythonworks seemed ok but was way out of my price range. Idle is nice but obviously isn't as featureful as some of the commercial offerings. hth, Richard From phr-n2001d at nightsong.com Tue Nov 6 02:04:12 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 23:04:12 -0800 Subject: Help Help Help References: <3be77f95@152.65.161.36> Message-ID: <7x3d3s8jo3.fsf@ruckus.brouhaha.com> "Kojo Duncan" writes: > Write a program that lists all prime numbers less than a prime number a user > inputs. Post on site for all to see. Do your own homework ;-) From era_akost at yahoo.de Thu Nov 29 09:12:49 2001 From: era_akost at yahoo.de (Era Akost) Date: 29 Nov 2001 06:12:49 -0800 Subject: Should I use threads here? References: <83bshmv8yf.fsf@panacea.canonical.org> Message-ID: <6749bb94.0111290612.45c060ac@posting.google.com> Hi again, Reading now a new email on the group "Strange Tkinter behaviour" I realized that probably my problem has to do with the Tkinger widget. So, I just inserted a self.text.update() and the output starts imediately apparing, as I wanted. The widget is sort of "frized" while the .exe program is still running (cannot scroll), but perhaps I can arrange that later. Anyway, pointing out the difference between readline() and readlines() was absolutely right from your side. Now that I added .update(), I checked both and only readline() does what I exptected. So, really thanks and sorry for bringing out the question of threads. I just have to understand better some os stuff. Era From boud at rempt.xs4all.nl Sun Nov 4 02:40:14 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 4 Nov 2001 07:40:14 GMT Subject: Python/QT Book no in final edit References: <7xady4cxng.fsf@ruckus.brouhaha.com> <9s1bo2$goc$1@news1.xs4all.nl> <7x3d3v1xvs.fsf@ruckus.brouhaha.com> Message-ID: <9s2rcu$jhe$1@news1.xs4all.nl> Paul Rubin wrote: > boud at rempt.xs4all.nl (Boudewijn Rempt) writes: >> >>Looks nice. It would be nice to have a link to render it all on one web >> > page. >> >> > why not just wgetting it! (wget exists also for ms-dos and it's a really >> > cute software) >> >> > wget -m -c -np http://stage.linuxports.com/projects/pyqt > I just want to read it on the screen without having to click links > all the time. But you really don't want to load 700 a4 pages worth of text with a few hundred illustrations into you webbrowser in one go :-). I mean, even the html-one-page version of the Emacs manual takes a serious time to load, and that doesn't have any images. When I was last able to generate a PDF of the book (it's too big for my system right now), it was 3.5 mb... -- Boudewijn Rempt | http://www.valdyas.org From sasoft at gmx.de Sun Nov 4 11:25:51 2001 From: sasoft at gmx.de (Stefan Antoni) Date: Sun, 4 Nov 2001 11:25:51 -0500 Subject: bg and fg Message-ID: <20011104112551.A14309@cruciatuz.de> - i am using linux - i got a script that takes the time.ctime string and compares it with a set time. if the time is the same as the set time, it will do something. - the script is a non-gui application (see bottom of this mail) question: 1. how can i move my process in the background after i started it (like: myscript & -> but automatically). 2. how do i move it back in the foreground when the action for the set time is performed? ... i had a look at the "os" module, but i dunno what i should use (do i have to fork my script in the bg or something?) #!/usr/bin/env python import time, sys, os def main(hour, minute): print "clock set to %s" % (hour + ":" + minute) time.sleep(1) while 1: try: currentTime = time.ctime(time.time()) if (currentTime[11] + currentTime[12]) == hour and \ currentTime[14] + currentTime[15] == minute: print "\a" time.sleep(0.5) else: pass except KeyboardInterrupt: print "ctrl+c pressed, exiting" sys.exit(1) if __name__ == '__main__': try: main(str(sys.argv[1]), str(sys.argv[2])) except IndexError: print "format is: wecker hour minute" -- thx in advance Stefan Antoni From tim.one at home.com Sun Nov 4 00:00:49 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 00:00:49 -0500 Subject: Sorting (not Python-specific) In-Reply-To: Message-ID: [Marcin 'Qrczak' Kowalczyk] > What are advantages and disadvantages in parametrizing sorting either > by '<' or by the 3-way comparison? Primarily cultural, I think: depending on which one you pick, you'll confuse either C or Lisp programmers. Python's internals are in an odd state now, where for backward compatibility a comparison function passed to list.sort() must follow the 3-way scheme, but the sorting routine only asks "less than 0, or not?", i.e. "__lt__, true or false?" is the only comparison outcome it wants. And objects that support *only* __lt__ comparison sort fine by default: >>> class C: ... def __init__(self, n): ... self.n = n ... def __lt__(x, y): ... print "asked %d < %d?" % (x.n, y.n) ... return x.n < y.n ... def __cmp__(x, y): ... print "OOPS!" ... >>> x = map(C, range(10)) >>> import random >>> random.shuffle(x) >>> x.sort() asked 5 < 7? asked 5 < 7? asked 2 < 7? asked 2 < 5? asked 9 < 5? asked 9 < 7? asked 6 < 7? asked 6 < 5? asked 8 < 6? asked 8 < 9? asked 8 < 7? asked 0 < 7? asked 0 < 5? asked 0 < 2? asked 3 < 6? asked 3 < 2? asked 3 < 5? asked 4 < 6? asked 4 < 3? asked 4 < 5? asked 1 < 5? asked 1 < 3? asked 1 < 2? asked 1 < 0? >>> Note that if huge masses of equal elements are an expected case, you may *want* to use a 3-way scheme for clarity and efficiency inside the sorting routine. Indeed, Python's internal sort does a bit of "OK, it was not the case that x < y, and also not the case that y < x, therefore if this ordering is sane for sorting at all, it must be the case both that x >= y and y >= x, so that x == y" deduction. But there's *just& "a bit" of that, and using equality-testing too wouldn't speed it up. if-equality-is-a-slippery-concept-then-so-is-inequality-ly y'rs - tim From phd at phd.pp.ru Wed Nov 14 10:45:49 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 14 Nov 2001 18:45:49 +0300 Subject: Optik 1.0 In-Reply-To: <20011114104256.A22700@gerg.ca>; from gward@python.net on Wed, Nov 14, 2001 at 10:42:56AM -0500 References: <20011112175357.F26476@phd.pp.ru> <20011114104256.A22700@gerg.ca> Message-ID: <20011114184549.F24995@phd.pp.ru> On Wed, Nov 14, 2001 at 10:42:56AM -0500, Greg Ward wrote: > On 12 November 2001, Oleg Broytmann said: > > Or mix options and arguments? > > > > --file outfile infile -q > > OK, this is now implemented and tested, but not yet documented. You can > get the code (via CVS) from optik.sf.net. > > I still want to add a "store_many" action, then document these changes. > That'll be Optik 1.1. Thank you. Please continue to inform us via the newsgroups/maillists (including announce group/list). Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sholden at holdenweb.com Thu Nov 8 12:52:53 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 8 Nov 2001 12:52:53 -0500 Subject: WSC in python clears method arguments References: Message-ID: "T Malcolm" wrote ... > I'm calling a WSC written in Python from a VBS script that is task > scheduled. This WSC is a "friendly" interface to the Python ftp > library. All is well, except for one quirk. When I call methods on > the WSC, it will clear the variable I pass as an argument. > So the scripting component is an object, and you are creating instances... > > Example vbs client script(where objFTP is an instance of the Python > WSC): > ---- > strRemotePath = rs.Fields("RemotePath").Value > > 'strRemotePath has a value here > > objFTP.cwd(strRemotePath) So here you appear to be calling a method of the instance you created... > > 'strRemotePath is now a nullstring, the cwd command has succeeded. > ---- > > Python code in WSC (objFTP is an instance of FTP imported from > ftplib): > ---- > def cwd(RemotePath, FTP=objFTP): > FTP.cwd(RemotePath) > ---- But this appears to be a function definition, not a method. Surely cwd() shouod be defined inside the definition of the class instantiated as objFTP. Its first argument should be self -- that's how ytou'd expect to [pick up the object on which the method is being called. > > I had to use the FTP=objFTP as an argument because I couldn't > reference objFTP in the function from the "global" namespace where it > resides (another quirk?). > Erm, objFTP shouldn't (and probably doesn't) reside in your Python module's namespace. It should be created dynamically and referred to as self (method 1st argument) when required. > Anyway, does anybody have any idea how I can get this thing to quit > "eating" my variable values? There's probably something I'm missing here. Have you got a copy of Hammond and Robinson's "Programming Python on Win32"? Great reference to all this stuff. regards Steve -- http://www.holdenweb.com/ From danm at ActiveState.com Wed Nov 28 20:42:48 2001 From: danm at ActiveState.com (Dan Milgram) Date: Wed, 28 Nov 2001 17:42:48 -0800 (PST) Subject: KOMODO not working properly In-Reply-To: <3C056B94.15574.247DE4@localhost> Message-ID: On Wed, 28 Nov 2001, A wrote: > Does anyone use KOMODO by ActiveState to write programs > together with Python and particularly with wxPython? > What experience do you have? It does not work properly for me. > Thanks for reply > Ladislav > > Ladislav, can you specify what isn't working? Dan -- Dan Milgram/ActiveState Developer New! ASPN - ActiveState Programmer Network Essential programming tools and information http://www.ActiveState.com/ASPN From sandskyfly at hotmail.com Sun Nov 18 10:39:27 2001 From: sandskyfly at hotmail.com (Sandy Norton) Date: 18 Nov 2001 07:39:27 -0800 Subject: The AOS Platform: a future python VM? Message-ID: Having just recently downloaded an early seed version of David Simmons' AOS/Smallscript system from http://www.smallscript.com, I must say I'm very impressed: Mr. Simmons seemed to have built a very fast virtual machine with a 'quasi-language-independent' architecture that can handle the overhead and complexity of dynamically typed languages, and compile straight to highly optimized machine code or to intermediate bytecode that can run on the .NET platform. Of more interest to pythonistas is that he has explicitly indicated an interested in creating a python implementation that utilizes the AOS virtual machine. Here's a direct quote from Simmons in a prior posting: ---snip--- http://groups.google.com/groups?q=g:thl1777651169d&hl=en&rnum=2&selm=bq%25F6.22782%24Jh5.22352484%40news1.rdc1.sfba.home.com > What do you mean by "quasi language independent" -- that it supports > SmallScript and the "convential" AOS Smalltalk? Will it support python, for > example? This 4th generation of the AOS Platform has been developed and tested for dynamic (and dynamically typed) languages and is geared as an adaptive virtual machine jitting model. Specific work has not been done, in this generation, for implementing a particular statically typed (compiled) language. The object model and internal architecture are designed with such languages in mind. But, there are areas in the architecture that have not been fleshed out and validated. So, it is really wrong to declare it as a generic language independent UVM. As to Python specifically, I want to stress that work is currently focused on delivering the .NET, PPC, and x86 platform versions. The SmallScript language layer and related general compiler frameworks are basically completed and have been for some time. The compiler architecture and SmallScript language design has, from its inception, been geared for enabling hi-performance support of a variety of Scripting languages. Out of the dirth of scripting languages available, Python and PHP are at the top of our well-known candidate list. There are parties who have either expressed an interest in or are working on languages such as Scheme, JScript, and Basic. Once the other pieces are in place, more attention will be focused on work in Python and PHP. Reality dictates that direct compilation/execution support for Java and C# are also worthy of serious consideration at some stage. As an aside, the execution performance numbers for SmallScript/Smalltalk are directly indicative of the level of performance one could expect for Python or PHP on the same platform. ---snip--- With Armin Rigo's uber-cool efforts on Psyco (Python specializing compiler), the possibility of an AOS/Python implementation, and the interesting stuff that's being done on Parrot(a common language runtime for perl and python): the future for python looks extremely sunny! Now if only we had a time machine... (-: regards, Sandy From tdickenson at devmail.geminidataloggers.co.uk Tue Nov 13 07:55:07 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Tue, 13 Nov 2001 12:55:07 +0000 Subject: [Python-Dev] Re: [Import-sig] Re: Proposal for a modified import mechanism. References: <3BED5AD8.24350.78407262@localhost> <3BEFE249.371EA5FD@interet.com> <15343.61552.414932.44100@monster.linux.in> <15343.63951.137972.487852@slothrop.digicool.com> <15344.4849.71643.868791@monster.linux.in> <15344.5763.557118.787529@walden.zope.com> <15344.43730.821724.769885@monster.linux.in> Message-ID: <5q52vtgjkn38etn7tpu8eji4r9k0oaguk9@4ax.com> barry at zope.com (Barry A. Warsaw) wrote: >Why does B have to add packages to A's namespace? Why can't the B >author simply use distutils to ensure that vanilla A is installed, >import the bits and pieces of A that you want to expose, overriding >what you want to change, and export an interface through B that >clients can use instead of A? Two reasons have ocurred in my projects over the last year: 1. A and B have the same author, and he want to *permanently* repackage B inside A. Maybe he developed A independantly without considering where it would be finally packaged 2. Maybe A needs to use an old version of B, or a version of B that has been hacked for an A-specific reason. Toby Dickenson tdickenson at geminidataloggers.com From cliechti at gmx.net Sun Nov 18 17:20:55 2001 From: cliechti at gmx.net (Chris Liechti) Date: 18 Nov 2001 23:20:55 +0100 Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> Message-ID: [posted and mailed] Uwe Schmitt wrote in news:9t95gu$ab7l1$1 at hades.rz.uni- sb.de: > Hi, > > i there a nice python shortcut for: > if idx=0: > a=val > elif idx=1: > b=val > > ??? > I tried > (a,b)[idx] = val > > but this does not work, i get an error message. > > Greetings, Uwe. if you have an object: setattr(obj,('a','b')[idx], val) or a bit uglier obj.__dict__[('a','b')[idx]] = val some hacky tries: if a and b are initalized: a,b = idx and (a,val) or (val,b) if repr gives a valid python expr.: exec '%s=%s'%('a','b')[idx], repr(val)) the cleanest i can find for globals is: import __main__ __main__.__dict__[('a','b')[idx]] = val depends on your situation, but maybe its easier to use a dict to store the values. d = {} d[('a','b')[idx]] = val tell us more about the situation were you use it, maybe there is a complete other way to achieve the desired results. -- Chris From gh_pythonlist at gmx.de Mon Nov 5 18:50:45 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 6 Nov 2001 00:50:45 +0100 Subject: Remote debugging? In-Reply-To: <3BE72194.414BDD9B@ix.netcom.com> References: <3BE72194.414BDD9B@ix.netcom.com> Message-ID: <20011106005044.B1810@lilith.hqd-internal> On Mon, Nov 05, 2001 at 11:33:12PM +0000, Jive Dadson wrote: > Can IDLE be connected via TCP/IP or whatever to a Python program that's > running on a different machine? -- one that does not have windowing > capability? If not, how much effort would it take to make it so that it > could? There's an unfinished remote debugging IDLE patch floating around on Sourceforge: http://sourceforge.net/tracker/?group_id=5470&atid=305470&func=detail&aid=440407 Also the commercial WingIDE Python IDE does already support remote debugging. I didn't buy it but liked the demo very much. http://archaeopteryx.com/ Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From spam at melkor.dnp.fmph.uniba.sk Wed Nov 28 04:21:02 2001 From: spam at melkor.dnp.fmph.uniba.sk (Radovan Garabik) Date: Wed, 28 Nov 2001 10:21:02 +0100 Subject: all process list on Linux? References: Message-ID: Brian Lee wrote: : I'm newbie at Python programming. : How can I get all processes list on Linux OS? I need PID : and process name (like the result of ps command). I found : setproctitle have many usefull function but it is not : supported on Linux. : Any modules which return all process list on Linux? Thank : you for your help. :) os.listdir('/proc') then take only numerical directories -- ----------------------------------------------------------- | Radovan Garabik http://melkor.dnp.fmph.uniba.sk/~garabik | | __..--^^^--..__ garabik @ fmph . uniba . sk | ----------------------------------------------------------- Antivirus alert: file .signature infected by signature virus. Hi! I'm a signature virus! Copy me into your signature file to help me spread! From peter at engcorp.com Mon Nov 19 23:09:53 2001 From: peter at engcorp.com (Peter Hansen) Date: Mon, 19 Nov 2001 23:09:53 -0500 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <9tcias$4md$1@peabody.colorado.edu> Message-ID: <3BF9D791.BEA22D61@engcorp.com> Fernando P?rez wrote: > > > I'm curious, however, why you believe you need to optimize Python's > > execution speed so much? Do you have some application which is not > > performing adequately? The usual approach is simply to profile the > > code and recode the "hot spot" in C. > > I can mention one: scientific computing. Python is becoming very popular in > that field, and Numeric goes a long way. But sometimes it's not enough, and > being saved from dropping down to C for anything but the truly ugliest would > be a big blessing. And yes, in scientific computing, things are *never* fast > enough. If you can improve the speed of a code even by a factor of 2 only, > that can be big news. Waiting for 2 days is still better than waiting for 4 > days for your simulation to finish. I understand these issues, but I really wanted to know why the *OP* thought he needed more speed (which I inferred was the only serious advantage he felt he'd found with LISP over Python). I certainly know of applications which need more speed. I just don't think those applications would be the kind involved in a decision such as "should I switch from Python to LISP?" I thought I smelled in the emphasis on speed the common phenomenon of a programmer picking the faster of two languages when higher speed than that already provided by the slower of the two was *not* a requirement, at the expense of less "tangible" benefits such as ease of maintenance and so forth. (And all that without going into the point about how changing Python to a compiled language, or going with something like C, let alone LISP, is not likely to improve the performance of scientific computing over that provided by an efficient library such as Numeric nearly so much as it would in other areas.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From stewart at sig.com Fri Nov 9 16:05:05 2001 From: stewart at sig.com (Rob Stewart) Date: 9 Nov 2001 13:05:05 -0800 Subject: How Can I Capture the Class Object for a Python Class Derived From My C API Metatype? Message-ID: <3a5a7d54.0111091305.70bad186@posting.google.com> I need to create a metatype, using the C API, that can save the class objects for Python classes derived from it. I need to be able to use the class object to instantiate objects of that class under C (C++) program control, and to discover the methods that have been defined to override default behavior so C++ virtual function calls can be forwarded to Python methods. My current, flailing (and failing) attempt was to create a metatype, for which ob_type is set to the address of a PyTypeObject which starts out being a copy (via memcpy()) of PyType_Type. I set the tp_new slot of that type object (the meta-metatype, if you will) to a function that can capture the class object and inspect it for methods. I've been tweaking the tp_bases and tp_mro fields of that type object, but haven't found the right combination of values to get things working. For example, type_new() was complaining at first because my meta-metatype wasn't its own supertype. I tried setting tp_mro to NULL, but that wreaked havoc elsewhere. So, I created a tuple containing just the meta-metatype. That got me farther, but I then found that I needed to put &PyType_Type in the tuple. Unfortunately, having done that, I merely stumble upon other problems. The point is, the approach I'm taking is a hack, and it's brittle, assuming I can even make it work. That makes it highly undesirable. Hopefully, then, there's a better way to go about this. Thanks for any help you can offer. Rob From shriek at gmx.co.uk Tue Nov 13 19:14:34 2001 From: shriek at gmx.co.uk (Stephen) Date: 13 Nov 2001 16:14:34 -0800 Subject: Sockets and messaging services References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> Message-ID: <97ae44ee.0111131614.57ff3098@posting.google.com> Thanks for the reply Laurent > > I have a CGI script which takes a HTTP request then sends > > a message to a custom server built on top of SocketServer.ThreadingTCPServer. > > Not that there is much chance of webserver CGI saturating the latter, > > but does Python have a messaging framework, similar to JMS for Java ? > > http://developer.java.sun.com/developer/technicalArticles/Networking/messaging/ > > Not that I'm aware. > > However, why reinvent the wheel and a new messaging framework? > > IMHO the SMTP and POP protocols provide the same benefit (and there > are Python modules for those protocols). Using a mailserver as a messaging platform for middleware ? Now that's lateral thinking. It also screams of "huge hack" and I can't imagine it would be as flexible or scalable as a proper message queue server. Alternatives might be Pyro/CORBA/etc but I don't think they deal with the queueing aspect. Stephen From threeseas at earthlink.net Mon Nov 5 12:50:16 2001 From: threeseas at earthlink.net (Timothy Rue) Date: Mon, 05 Nov 2001 17:50:16 GMT Subject: IBM autonomic computing perspective Message-ID: <655.709T1411T8194573threeseas@earthlink.net> IBM (detail non-specific) http://www.ibm.com/research/autonomic Core specific functionality http://www.mindspring.com/~timrue/KNMVIC.html http://www.mindspring.com/~timrue/python/ http://www.mindspring.com/~timrue/vic-construct.html It's an open project. Anyone interested? --- *3 S.E.A.S - Virtual Interaction Configuration (VIC) - VISION OF VISIONS!* *~ ~ ~ Advancing How we Perceive and Use the Tool of Computers!* Timothy Rue What's *DONE* in all we do? *AI PK OI IP OP SF IQ ID KE* Email @ mailto:timrue at mindspring.com >INPUT->(Processing)->OUTPUT>v Web @ http://www.mindspring.com/~timrue/ ^<--------<----9----<--------< From loewis at informatik.hu-berlin.de Fri Nov 9 05:21:33 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Nov 2001 11:21:33 +0100 Subject: Is Stackless Python DEAD? References: <184fbd02.0110262039.74799675@posting.google.com> Message-ID: Michael Hudson writes: > I wasn't trying to justify the existing implementation, just explain it. Thanks, and that is much appreciated. I'll save your article for future reference; it has many details that anybody diving into stackless should know. > Yeesss, but does anyone have the time for this? I mean, I've just > spent an hour or so I probably shouldn't have writing this article, > and I've barely scratched the surface. Same with me, when I inspected the diffs a few days ago. I'm not saying that you should be the one cleaning it all up, either. I just wanted to make it clear that it is not lack of interest that Stackless isn't integrated into core Python yet, but that a lot of work needs to be done to the code before an integration could be attempted. So answering the question in the subject: Stackless Python is not dead; it is just a sleeping beauty, waiting for a prince to kiss her awake. Regards, Martin From tanzer at swing.co.at Tue Nov 13 02:15:56 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Tue, 13 Nov 2001 08:15:56 +0100 Subject: Is this considered black magic? In-Reply-To: Your message of "Mon, 12 Nov 2001 17:02:38 +0100." <200111121602.fACG2cua014004@ratthing-b246.strakt.com> Message-ID: > I have a new problem. I've just lost a major amount of precision in my > language usage. What is the collective noun for 'attributes that aren't > methods (you can't call them)'? Well, why not just call them (plain old) attributes and callable attributes? -- 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 gdemmy at layton-graphics.com Sat Nov 17 10:33:56 2001 From: gdemmy at layton-graphics.com (George Demmy) Date: 17 Nov 2001 10:33:56 -0500 Subject: identity = lambda x: x -- a Pythonic idiom? References: <3BF67CD5.1380F667@earthlink.net> Message-ID: Hi Hans. Hans Nowak writes: > > > > data = filter(identity, crufty_list) > > Note that this can be written as > > data = filter(None, crufty_list) > > with the same result. Indeed... thanks for the tip -- just like the library reference says. Missed that. Interestingly, from the filter entry in library reference v. 2.0 (underscore emphasis mine): filter(function, list) Construct a list from those elements of list for which function returns true. If list is a string or a tuple, the result also has that type; otherwise it is always a list. If function is None, the __identity function__ is assumed, i.e. all elements of list that are false (zero or empty) are removed. Wouldn't an explicit identity function built-in make this more "guessable"? Guessability is one of the things I love about Python. Actually, an identity function is explicit... no need to guess. > > There are, of course, other nifty things to do with identity, and I > > find it used all the time -- far more often than many Python > > built-ins. How prevalent is identity usage in the Python community? Is > > there anyone that would rather suffer hellfire and damnation that do > > something like this? > > I don't really know what you mean by identity here... lambda x: x, or > None, in a filter function filters out everything that evaluates as > "false". I mean making use of an explicitly defined identity function, or implicitly defined via lambda x:x, in a variety of contexts, not just filter. Sorry about the lack of clarity... Thanks again for pointing out the filter tip. I use filter much I never would have thought to look it up in the library reference :/ Can't re-RTFM enough, I 'spose. G -- George Demmy From tdickenson at devmail.geminidataloggers.co.uk Mon Nov 5 09:17:36 2001 From: tdickenson at devmail.geminidataloggers.co.uk (Toby Dickenson) Date: Mon, 05 Nov 2001 14:17:36 +0000 Subject: no setuid for CGI scripts? References: <4b4c5d99.0111050348.6d7c9406@posting.google.com> Message-ID: (posted and cc'ed to robin) Robin Becker wrote: I dont think thats safe 'system' uses many environment variables that could be used to change the behavior of this program to be something other that what you expected. >here wrapper is a program that you create to be setuid in your >name/group. > >my code for the wrapper looks like below. I only allow it to work for >the owner and the nobody user. > > >#include >#include >#define SRCUID 1234 /*our UID so we can do things ourselves*/ >#define NOBID 65535 /*another possible ID (nobody*)/ >#define TGTUID 1234 /*the desired run UID*/ >#define TGTGID 7890 /*the desired run group*/ >#define TGTUSER "myusername" >#define TGTHOME "/usr/home/" TGTUSER >int main(int argc, char**argv) >{ > size_t i, n=0; > char *buf; > n = getuid(); > if(n!=NOBID && n!=SRCUID) exit(-1); > for(i=1;i if(!n) exit(0); > buf = malloc(n+argc+1); > *buf = 0; > for(i=1;i if(i>1) strcat(buf," "); > strcat(buf,argv[i]); > } > setuid(TGTUID); > setgid(TGTGID); /*users*/ > setenv("USER",TGTUSER,1); > setenv("HOME",TGTHOME,1); > system(buf); >} Toby Dickenson tdickenson at geminidataloggers.com From rnd at onego.ru Sun Nov 4 07:27:17 2001 From: rnd at onego.ru (Roman Suzi) Date: Sun, 4 Nov 2001 15:27:17 +0300 (MSK) Subject: Solving Partial Differential equation in Python In-Reply-To: <3BE51085.90702@stu.ust.hk> Message-ID: On Sun, 4 Nov 2001, Calvin wrote: >Greetings, > Did anyone have the experience in solving a PDE numerically in Python. >The PDE is a Euler-Lagrange equation. In fact it is a simulation of LCD >modeling. I search the web and find many libraries like Numeric Python. >But I cannot find any library aim at solving PDE. So I think I have to >design my own Algorithm. Could anyone help me. Probably, if you could find library like LAPACK for linear algebra and use SWIG to make bindings to C for Python, you will have PDE solving functionality in Python. I am not sure how such library is called, but that is a task for google. >-Calvin > > Sincerely yours, Roman Suzi -- _/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/ _/ Sunday, November 04, 2001 _/ Powered by Linux RedHat 6.2 _/ _/ "PC! Politically Correct (or) Pure Crap!" _/ From gh_pythonlist at gmx.de Fri Nov 2 14:59:01 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Fri, 2 Nov 2001 20:59:01 +0100 Subject: simple eval question In-Reply-To: <1f5252d4.0111021241.643efe1e@posting.google.com> References: <1f5252d4.0111021241.643efe1e@posting.google.com> Message-ID: <20011102205901.A49029@lilith.hqd-internal> On Fri, Nov 02, 2001 at 12:41:28PM -0800, N Becker wrote: > What is wrong with this? > > eval ("print \"hello\"') > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1 > print "hello" > ^ > SyntaxError: invalid syntax > > I expected that eval takes a string an evaluates it as input to the > interpreter, as if it had been typed into the command line. Was I > wrong? You were almost right. eval() takes an expression, while exec() takes statements. print is a statement, not an expression, so you need exec() here. Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From ajs at ix.netcom.com Sat Nov 17 17:32:48 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Sat, 17 Nov 2001 17:32:48 -0500 Subject: Teaching python (programming) to children Message-ID: <000d01c16fb7$cc8ee660$a9e1fea9@carol> As it had come up, I offer this in support of my intuitive sense that relying on Piaget ain't *it* -when considering children's understanding of numbers, and in connection with efforts to nurture that sense. http://www.cut-the-knot.com/ctk/inv-piaget.html The fact is I know little of Piaget's theories. But I do seem to have a consistent distaste for projects aimed at children with justify themselves as being based on those theories. Art From phd at phd.pp.ru Fri Nov 16 09:15:10 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Fri, 16 Nov 2001 17:15:10 +0300 Subject: OT:This group archived? In-Reply-To: <9t367u$kg6$1@neptunium.btinternet.com>; from Dlal@btinternet.com on Fri, Nov 16, 2001 at 02:01:45PM -0000 References: <9t367u$kg6$1@neptunium.btinternet.com> Message-ID: <20011116171510.E22329@phd.pp.ru> On Fri, Nov 16, 2001 at 02:01:45PM -0000, DL wrote: > just a quick question from someone new to Python. Is this group archived > anywhere to save me > bothering everyone with questions which have been asked hundreds of times. http://www.python.org/cgi-bin/faqw.py http://www.python.org/psa/MailingLists.html http://groups.google.com/groups?lr=&safe=off&group=comp.lang.python Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From stephan.diehl at gmx.net Thu Nov 15 08:10:57 2001 From: stephan.diehl at gmx.net (Stephan Diehl) Date: 15 Nov 2001 05:10:57 -0800 Subject: wrapper for swish-e? Message-ID: Hallo, is a python wrapper for swish-e available? Thanks for your help. Stephan From daniel.rose at datalinesolutions.com Sun Nov 4 19:10:42 2001 From: daniel.rose at datalinesolutions.com (Daniel Rose) Date: Sun, 4 Nov 2001 16:10:42 -0800 Subject: PyGreSQL for Windows Message-ID: Howdy, Does anyone know where i can get a copy of pygresql for windows and python 2.1? highqualdev seems to point to some search site. Thanks all From bill-bell at bill-bell.hamilton.on.ca Mon Nov 5 13:36:20 2001 From: bill-bell at bill-bell.hamilton.on.ca (Bill Bell) Date: Mon, 5 Nov 2001 13:36:20 -0500 Subject: find network drives, win In-Reply-To: <1004981199.10004.26612.m9@yahoogroups.com> Message-ID: <3BE695D4.21206.3DB2821@localhost> stojek at part-gmbh.de (Marcus Stojek) wrote, in part: > under windows I have to find out for a given path whether > the drive is local or a network drive To find out whether a drive 'X' is local use: >>> 'X' in filter ( lambda x: exists ( x + ':\\'), uppercase ) 0 To find out whether a drive 'X' is on the network: >>> from win32com.client import Dispatch >>> network = Dispatch ( 'Wscript.Network' ) >>> networkDrives = network.EnumNetworkDrives ( ) This failed for me just now, presumably because I'm running Win2K standalone. So let me simulate what would happen were I connected to a network that makes drives available. >>> networkDrives=[ ( 'M:', '\\SERVER1' ), ( 'N:', '\\SERVER2' ) ] Assuming this is ok, one can then use >>> 'X' in map ( lambda x: x[0][0], networkDrives ) Good luck, Marcus. Bill "It is the time that you have wasted for your rose that makes your rose so important."--St-Exupery From chrishbarker at home.net Thu Nov 29 13:05:19 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 10:05:19 -0800 Subject: Non-Indented python References: Message-ID: <3C0678DF.2DFE924A@home.net> Tim Peters wrote: > > If it is true that there is general consensus about this, is there any > > movement to disallow it altogether in the Python interpreter? > > Nope. The "nanny" in "tabnanny" is there for a reason: grownups have no > problems here. I don't think that's true. I often start working on a file I got from elsewhere with tabs in it, get some wierd error, eventually think to check for tabs. Then I run a script on it, clean it up, and all is well. This would be a WHOLE LOT easier if I got a "syntax error: mixed tabs and spaces" the first time I ran it. And what would we lose??? There are a lot of issue swith backward compatabilty, but this is one cse where you could run a simple script over any previously valid code and get valid code back. No problem there. By the way, speaking of editors, I think any "Decent Editor" should provide a way to display a special charactor in place of a tab, so that I can SEE what is in the file. I havn't found a way to get XEmacs to to that. > > Personally, I would prefer that future versions of Python would allow > > ONLY tabs or ONLY spaces, but clearly there would be a major > > disagreement about which to use. > > It would be spaces -- "4-space indents, no hard tab characters anywhere" is > the coding standard for the Python library. I imagine Huaiyu, if no one else, would take issue with this. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From aa at bb.cc Mon Nov 5 05:20:52 2001 From: aa at bb.cc (Károly Ladvánszky) Date: Mon, 5 Nov 2001 11:20:52 +0100 Subject: Python Newbie References: <9s5eq8$mhk$1@newton3.pacific.net.sg> Message-ID: <3be66493_4@corp-goliath.newsgroups.com> Hi Edy, I completely agree with you that it is both more efficient and more entartaining to learn a programming language through working on a useful task. If you are a student, I'd advise you pick up an interesting math problem and work on it using Python. I'm sure your teacher will be happy to help you find something. This way you will make progress in both math and Python. Good luck, K?roly "Edy Lie" az al?bbiakat ?rta a k?vetkez? ?zenetben: news:9s5eq8$mhk$1 at newton3.pacific.net.sg... > Hi Everyone, > > I am totally a new python wannabe coder. I have been switching between > python and perl last few months. In Perl i could code some small scripts > which does the work i wanted to but somehow in my mind it has been telling > me that python is my choice. > > I have some doubts here > 1. I would really want to learn this lang (What should i do?) i know instead > of asking here i should start coding but i have no idea what should i code. > Is there anyone in here willing to conduct a small class or at least giving > out exercise to newbies to code ? > > 2. Another thing when doing coding if i am facing problem i tend to stop or > rather wanted to learn everything in a day or as fast as i could which i > believe is a wrong approach. Is there anyone kind enough to give me some > direction in order i could code something useful. > > Thanks for all the advices. > > Regards, > Edy Lie. > > ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net From tdelaney at avaya.com Mon Nov 26 22:22:25 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Tue, 27 Nov 2001 14:22:25 +1100 Subject: function operators Message-ID: > From: Terry Reedy [mailto:tjreedy at home.com] > "Hans Nowak" wrote in message > > Does 2.2 allow one to inherit from type 'function'? So one could do > this without extra level on indirection? # 2.2b1 from __future__ import nested_scopes class ComposableFunction(function): def __init__(self, f): self.f = f def __call__(self, *args, **kwargs): return apply(self.f, args, kwargs) def __add__(self, other): assert isinstance(other, ComposableFunction) def glue(*args): return self.f(*args) + other.f(*args) return ComposableFunction(glue) NameError: name 'function' is not defined from __future__ import nested_scopes from types import FunctionType as function class ComposableFunction(function): def __init__(self, f): self.f = f def __call__(self, *args, **kwargs): return apply(self.f, args, kwargs) def __add__(self, other): assert isinstance(other, ComposableFunction) def glue(*args): return self.f(*args) + other.f(*args) return ComposableFunction(glue) TypeError: type 'function' is not an acceptable base type So, no. Whether it should or not is another question of course ... :) Tim Delaney From chris.gonnerman at newcenturycomputers.net Thu Nov 8 08:54:30 2001 From: chris.gonnerman at newcenturycomputers.net (Chris Gonnerman) Date: Thu, 8 Nov 2001 07:54:30 -0600 Subject: problems when starting python References: <8ec33ba5.0111062326.1035edf2@posting.google.com> <8ec33ba5.0111080207.2e3c4b0@posting.google.com> Message-ID: <005f01c1685c$e6f9e020$0101010a@local> ----- Original Message ----- From: "barabba" > Hi, > > this is driving me crazy !!! > if I create file containing print "hi" and name it test.pyw and then > click on it with the right button it says edit with IDLE but then > nothing happen when i click on this item. Can't explain this, as I never use IDLE. > If I double click on the file to run it...same...nothing happens !!! > why ???? This has been answered already, but I'll answer it again. Follow: .py files are executed by python.exe .pyw files are executed by pythonw.exe And: python.exe opens a console window pythonw.exe does not open a console window So: print "hi" in a file with a .pyw extension will appear to do NOTHING. in a file with a .py extension will show a console window with hi in it. This window may disappear almost immediately, though, depending on your system settings. Try putting this in a .py file and running it: print "hi" raw_input() > I have python at home and it works fine but I have noticed that even > there IDLE starts fine if I run it from start | programs | IDLE but if > I start it from the program icon (c:\winnt\etc etc) it doesn't > start...why ???? What is the "program icon" (application file) doing in THAT folder? It should be in C:\Python21\Tools\idle, named idle.pyw. > Thank you > Barabba Good luck. From skip at pobox.com Wed Nov 14 04:12:46 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 10:12:46 +0100 Subject: Python implementations (was: Benefits of moving from Python to Common Lisp?) In-Reply-To: References: <7xlmhddlr3.fsf@ruckus.brouhaha.com> <9sp2in$o4e$1@slb3.atl.mindspring.net> Message-ID: <15346.13710.332365.769190@beluga.mojam.com> url="http://starbase.neosoft.com/~claird/comp.lang/python/python_varieties.html" url = url.replace("lang/python", "lang.python") ;-) Skip From ee_fhw at stu.ust.hk Sun Nov 18 01:58:07 2001 From: ee_fhw at stu.ust.hk (Calvin) Date: Sun, 18 Nov 2001 14:58:07 +0800 Subject: What is Type Error? Message-ID: <3BF75BFF.7070107@stu.ust.hk> Greetings, I'm developing a simlator for LCD and get stuck with the Type Error. The attached is my LCD.py file, when compile I got the following error: Traceback (most recent call last): File "", line 1, in ? File "C:\Python21\LCDSim\start.py", line 5, in ? lcd.elastic_energy() File "C:\Python21\LCDSim\LCD.py", line 33, in elastic_energy self.__energy[n]=1/2(self.__lc.k1(self.__azimuth[n])*d_azimuth**2+self.__lc.k2(self.__azimuth[n])*d_twist**2 +self.__lc.k3(self.__azimuth[n])*d_twist**2) TypeError: object of type 'int' is not callable could anybody point out how can I solve it, I just got no ideas :( Thank you (if you can email me, please email me) -Calvin -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: LCD.py URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: LC.py URL: -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: start.py URL: From m.faassen at vet.uu.nl Thu Nov 1 18:50:03 2001 From: m.faassen at vet.uu.nl (Martijn Faassen) Date: 1 Nov 2001 23:50:03 GMT Subject: Underscore data hiding (was python development practices?) References: <7xitcwpq9r.fsf@ruckus.brouhaha.com> <9rpbk1$19rg$1@nntp6.u.washington.edu> <9rq2v2$fko$1@newshost.accu.uu.nl> <7xlmhrs5u5.fsf@ruckus.brouhaha.com> Message-ID: <9rsn3b$cvu$2@newshost.accu.uu.nl> Paul Rubin wrote: > m.faassen at vet.uu.nl (Martijn Faassen) writes: >> Data hiding isn't there to prevent evil programmers from doing evil >> things anyway; it's there to communicate intent and to prevent people >> from tripping over problems. > That's true a lot of the time, but it's not universally true. In java > for example, data hiding is definitely intended to thwart evil > programmers, and any failure of the data hiding is considered a > security bug requiring an immediate patch. The closest Python has to > that is the rexec mechanism. I'd like it a lot if Python extended > such protection to private instance variables. Well, I see this as a different mechanism. I don't see data hiding itself as a security mechanism; it is an abstraction mechanism. I realize Java combines the two, but Python doesn't. Zope's through the web security model for instance features security rather separate from data hiding; you can't access attributes that start with an underscore in through the web code. Other attributes can be private or public depending on security declarations (besides the brokeness that methods without docstring will automatically be considered private). I think there's an advantage in having your security infrastructure be separate from your data hiding mechanism; it leads to less programmer overhead in the abundant cases where such strict security is not necessary. It also leaves one up to devise ones own security system that is more suited to the needs at hand. Regards, Martijn -- History of the 20th Century: WW1, WW2, WW3? No, WWW -- Could we be going in the right direction? From fuessler at demokrit.informatik.uni-mannheim.de Thu Nov 15 02:55:12 2001 From: fuessler at demokrit.informatik.uni-mannheim.de (Holger Fuessler) Date: 15 Nov 2001 08:55:12 +0100 Subject: Sending EOF (CTRL-D) to a subprocess Message-ID: Hi all! Can anybody tell me how to send a C-D to a subprocess opened with os.popen()? Cheers Holger -- Holger Fuessler Praktische Informatik IV Tel: +49 621 181 2605 University of Mannheim Fax: +49 621 181 2601 L15, 16 68131 Mannheim, Germany fuessler at informatik.uni-mannheim.de From cliechti at gmx.net Wed Nov 28 14:40:57 2001 From: cliechti at gmx.net (Chris Liechti) Date: 28 Nov 2001 20:40:57 +0100 Subject: rxvt + python problem: script output buffered and interactive output missing References: <3C04A742.50700@yumpee.org> Message-ID: Manoj Plakal wrote in news:3C04A742.50700 at yumpee.org: > Hi, > > I'm encountering a strange problem when I run > Python scripts and the Python interpreter in > an rxvt window (with tcsh) on the latest Cygwin. > This is with Win98/BeOpen Python 2.0/Cygwin 1.3.5/rxvt-2.7.2. > > The scripts print some messages to stdout but > these gets buffered and appear only when the > app exits (it runs for a while). If I add > calls to flush stdout, then the messages appear > as they are printed. > > If I run the Python interpreter itself, I > get no output at all, the shell just hangs, > I get the hourglass icon and I can eventually > break out with Ctrl-C's. > > Things work fine with bash in a DOS box. Makes > me think that something is wrong with rxvt's > handling of stdout/stderr. But it seems to > work with some other console apps (like sftp). yes i have the same behaviour on my machine... python mistakenly thinks that it has to thake its input from stdin/pipe instead of running interactive. python runs if you specify "-i" explicit. i guess that it has something to do with the terminal name that rxvt sets, so that an app doesn't know that its a console window. chris > Manoj > > -- Chris From cliechti at gmx.net Fri Nov 9 16:03:10 2001 From: cliechti at gmx.net (Chris Liechti) Date: 9 Nov 2001 23:03:10 +0200 Subject: newbie Python OO vs Tcl References: Message-ID: [posted and mailed] "b t" wrote in news:mailman.1005338712.31805.python-list at python.org: > Hi, > > I am having the argument of whether I should use Python or Tcl for > extend a C++ class library. > > > Considering the followings are Python's advantages: > > Object oriented > Class > Module > Type extension > Class exntension by Boost.Python add a great, frendly and competent newsgroup. and realy simple to embedd and/or extend in C (C++) > Is there anything similar in Tcl? So far I can only think of its lax > syntax... i don't know TCL. so i would definetly take python and i guess the other 99% in this newsgroup would vote for python too, especialy as this is the python newsgroup / mailing list ;-) chris > Thanks in advance. Any comments would be appreciated. > > Ben > > _________________________________________________________________ > Get your FREE download of MSN Explorer at > http://explorer.msn.com/intl.asp > > > -- Chris From atuells at integralab.com Fri Nov 30 12:34:03 2001 From: atuells at integralab.com (Andres Tuells) Date: Fri, 30 Nov 2001 18:34:03 +0100 Subject: ANNOUNCE: WeakList Message-ID: <005201c179c5$3465ce90$f575393e@integralabzenon> What is: Python implementation of weaklist: list whose entries are weak references, and are removed when the original object is garbage collected. They are useful for example when you want a publisher/subscriber list. Subscriber are authomatically removed from the publisher list when they are gc (and can be gc). You can do: for subscriber in weaklist_subscribers: self.notify(subscriber, message) If a subscriber is gc while the for is running, then it will be removed also be removed from the weak_list. WeakList has an iterator that constains a weaklist. I think that WeakList place is inside weakref.py, but I don't now how to contribute to python code. -------------- next part -------------- An HTML attachment was scrubbed... URL: From simonb at webone.com.au Wed Nov 14 00:16:07 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Wed, 14 Nov 2001 16:16:07 +1100 Subject: reusable software components References: Message-ID: <3BF1FE17.7050101@webone.com.au> Well, yes im working on this stuff now; trying out ideas anyway. i was wondering about this aswell, searching from the point of view of design patterns, rather than beans. still i found little. the design patterns SIG is dead and burried, not even the archives are available right now. My suspician is that all this framework stuff is so easy to do in python that no one bothers to "encapsulate" it for others. A lot of the design patterns are one-liners in python! Still, i am interested. it has a lot of relevance, i think, eg. anygui, types-sig, CP4E, beans, design patterns. Anyway, u r talking about the bean trick in particular. i was never convinced that Bean Info was all that necessary to accomplish the task at hand. what im thinking of is full introspection coupled to direct user manipulation. this is not so bad in java where u can find out what to plug into what, but the type system in python is ... absent? or just dynamic, i guess. Although, we do have doc strings, and we can parse our own code... Beans are a kind of type system, if u like. and this is one thing i think a SuperPythonMachine should incorporate... :) Simon Burton Kevin Altis wrote: >Are there any current efforts to build cross-platform Python components or >standardize a Python component model? > >I've been thinking about creating a component framework for PythonCard, >which will use wxPython for its GUI widgets. The component framework is >mostly going to be a set of conventions to follow, so that a visual >environment can hook together components and make compound components. Since >Python itself already provides introspection, what seems to be missing are >the hints to use at design time for specifying the properties and events for >the component. While Python doesn't use strong typing, components need type >info, especially when the component is wrapping a native control written in >C/C++. > >There is no particular reason the conventions need to be limited to >wxPython, they could be applied to tkinter components or even non-visual >components. > >Software components are described by the excellent Java Beans intro, which >you should take ten minutes to read if you don't know what software >components are: > >http://developer.java.sun.com/developer/onlineTraining/Beans/Beans1/index.ht >ml > >Anyway, I searched the comp.lang.python archive and a few other sources and >except for some older messages talking about COM and CORBA and Java Beans, I >didn't find any current efforts to make a standard set of conventions for >Python components. The PyXPCOM stuff looks like it is stalled out. > >I would appreciate any feedback, suggestions, or links on software >components for Python. > >Thanks, > >ka >ps. My first post seems to have been eaten by my ISP, but apologies in >advance for a double-post if it shows up (I posted the first one over six >hours ago). > > From slhath at home.com Fri Nov 16 22:43:48 2001 From: slhath at home.com (Scott Hathaway) Date: Sat, 17 Nov 2001 03:43:48 GMT Subject: Hello, question about python online script References: Message-ID: You must create an html form and submit it to the python script to get the user's guess. Scott wrote in message news:mailman.1005965124.18814.python-list at python.org... Hello, I created my first python script that basically asks a user to guess a number, and if they are correct, it tells them they win yipee :) But it works only when I run it at the command line how do I get such a thing to work online? I get python to work via cgi scripts but the line: password = raw_input("Password:") caused this error: Traceback (innermost last): File "/home/sites/site7/web/test/game.cgi", line 8, in ? password = raw_input("Password:") EOFError: EOF when reading a line See, raw_input as you know would allow the command line to ask me to type a number. how do I replicate this online? Thanks Joel PS. If needed, I can post source code, I chose not to in case it would be a waste of space or redundant From max at alcyone.com Sat Nov 17 15:01:06 2001 From: max at alcyone.com (Erik Max Francis) Date: Sat, 17 Nov 2001 12:01:06 -0800 Subject: identity = lambda x: x -- a Pythonic idiom? References: Message-ID: <3BF6C202.7EB544E0@alcyone.com> George Demmy wrote: > I do a bunch of list-oriented programming with a bunch of one-off > programs. For a variety of reasons these lists tend to have a bit > of cruft associated with them (I don't write it -- just process > it!). So stuff like this shows up quite a bit: > > data = filter(lambda x: x, crufty_list) This doesn't even make sense to me. filter applies the function for each element in the sequence, and returns a new list of only those elements for which the function returned true. Why is using the identity function for this purpose useful? If you really want to select the true sequence, then from a mathematical standpoint what you want is operator.truth, not the identity function. Obviously they do the same thing in this context, but they have different meanings. (Or a None passed as the function would as well.) > There are, of course, other nifty things to do with identity, and I > find it used all the time -- far more often than many Python > built-ins. How prevalent is identity usage in the Python community? Is > there anyone that would rather suffer hellfire and damnation that do > something like this? There's nothing wrong with using an identity function in context (though your claim that you use it more often than many builtins is strange, since it explicitly doesn't do anything). I'm just curious what you're doing such that the identity function pops up very frequently. It could be there's a better way to get what you're going after. -- Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/ __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE / \ Laws are silent in time of war. \__/ Cicero Esperanto reference / http://www.alcyone.com/max/lang/esperanto/ An Esperanto reference for English speakers. From padhia at yahoo.com Fri Nov 2 13:03:44 2001 From: padhia at yahoo.com (P Adhia) Date: 2 Nov 2001 10:03:44 -0800 Subject: ReXX Style translate() function for strings ? References: <3281a460.0110301257.1a4d9a14@posting.google.com> <9rnk6n$usmo3$1@ID-11957.news.dfncis.de> Message-ID: <3281a460.0111021003.6a501447@posting.google.com> steve at ferg.org (Stephen Ferg) wrote in message news:... That's pretty close to what I ended up writing. However, I found out that, you need to watch out for "None"; otherwise, len() function fails. I can't imagine why one would use None for pad, but... if pad != None and len(pad) != 1: . . . > I'm working on a Python module called rexx.py that implements > REXX-like functions in Python. I will post it on my web page this > evening, at > http://www.ferg.org >From what I have seen so far, this is an impressive effort. Definitely a good exercise to familiarize yourself with new language. P. Adhia From dcinege at psychosis.com Sat Nov 24 19:54:34 2001 From: dcinege at psychosis.com (Dave Cinege) Date: Sat, 24 Nov 2001 19:54:34 -0500 Subject: Indenting with tabs vs spaces In-Reply-To: References: Message-ID: On Saturday 24 November 2001 0:56, you wrote: > Right. You should be able to hit the "tab" key 10 times (or 5 times) to > get 40 spaces, but the file you save to disk should have spaces. Damn, that's stupid! A tab has a byte value of '9'. How it's is displayed is completely arbitary, subjective, and the job of your editor. The fact the file will look different between editors is a good thing. The idea all source files should not be able to be displayed any otherway then how the author first created them is: _DUMB_ (^^Yes and I just tabbed you!! HAHA) Quite moot however....GOD has already decided. From sholden at holdenweb.com Mon Nov 12 21:33:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 12 Nov 2001 21:33:47 -0500 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <3BF07BC8.3090405@yumpee.org> <3BF07FA7.10807@yumpee.org> Message-ID: "Manoj Plakal" wrote in ... > Manoj Plakal wrote: > [ ... ] > > Forgot to add: the requirement could > be re-stated as that of a portable, light-weight > library for "instant-messaging" between applications > running on the same machine. > A somewhat loose specification... > This might cover a lot of cases where you don't > need RPC semantics (no return value expected) But some sort of response will usually be required, even if it's a simple ACK. > and you're sending simple data values (so no > need of full-blown XML or other elaborate encoding). How simple is simple? ASCII strings of less than 256 characters you might get away with...\ > And you may not even need a reliable transport > protocol (so no need of HTTP or even TCP). > XML-RPC is cool but it seems like a really > big and overweight hammer. > Oh, so you don't mind if Word prints file "xyy.doc" when you ask it to print "xyz.doc"? > E.g., sending a message to Word asking it > to print a file, or asking Mozilla to open > a web page, or an MP3 playlist manager > accepting a request to play/pause/stop, etc. > Can we say "UDP? not-reinventing-wheels-is-good-ly y'rs - steve -- http://www.holdenweb.com/ From fungho at sinaman.com Wed Nov 21 21:31:51 2001 From: fungho at sinaman.com (Stephen) Date: 21 Nov 2001 18:31:51 -0800 Subject: how to express the following regular expression? References: <9tft7a$30$1@helix.cs.uoregon.edu> Message-ID: Thank you very much! "Carl Howells" wrote in message news:<9tft7a$30$1 at helix.cs.uoregon.edu>... > "Stephen" wrote... > > I want to search the following formats: > > > > ([1234567890]*)R > > or > > P([1234567890]*) > > > > this means there must be a 'P' before the number or a 'R' after the > > number. However, I think I can't use this: > > P?([1234567890]*)R? > > because the number without P and R is also matched! > > > > How can I express it? > > Exactly you you'd expect... One or the other: > > (P\d*)|(\d*R) > > You could also use [0-9] in place of \d, if you were really set on using the > [] notation. But there's no reason to use [1234567890]. From bedge at troikanetworks.com Tue Nov 20 16:43:26 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 13:43:26 -0800 Subject: sscanf ? References: <20011120222250.3156d74e.use-net@schabi.de> Message-ID: In <20011120222250.3156d74e.use-net at schabi.de>, Markus Schaber wrote: > Hi, > > Am Tue, 20 Nov 2001 09:17:21 -0800 schrieb Bruce Edge: > >> Is there an equivalent function in python? >> I know about all the regex stuff, but I have the format string that >> was used to generate a string, which I'd like to use to decompose it >> back into it's source data: >> >> fmtstr = "%02d.%02d" >> >> str = fmtstr % ( x, y ) >> >> # Now get x any y back using only str and fmtstr: >> >> (x, y ) = ? >> >> >> I suppose I could write something to convert printf style format >> strings into regexp format, but it seems like there's gotta be an >> easier way. > > The problem is that there is no general solution for this problem. > > How would you parse a text that was generated with a fmtstr like "%s%s"? > > This is impossible. So there can't be a general scanstr function. C > provides you with a crippled one, python provides you with string.split > and regexp module. > > > > Gru?, > Markus > Agreed, but sometimes a crippled one is all you need. -Bruce. From chrishbarker at home.net Thu Nov 29 15:04:38 2001 From: chrishbarker at home.net (Chris Barker) Date: Thu, 29 Nov 2001 12:04:38 -0800 Subject: Copy operator (was list.remove for Noivces) References: <3C054C58.9961A62@home.net> Message-ID: <3C0694D6.2F143D59@home.net> Mark Fardal wrote: > But I'm still confused. For one thing, NumPy seems to behave > differently. Apparently a Numeric array is not a series of > references, but a reference to a series... I suppose that's sort of right, but it's not that simple either. First of all, you shouldn't be surprised that a NumPy Array is different than a list, because is a different type of sequence a tuple is different than a list as well. > python> a = range(4) > python> a > [0, 1, 2, 3] > python> b = a > python> b = a[:] # why both of these? a typo? > python> a[0] = 666 > python> b > [0, 1, 2, 3] Right, a slice of a list is a copy. > python> a = arange(4) > python> a > array([0, 1, 2, 3]) > python> b = a[:] > python> a[0] = 666 > python> b > array([666, 1, 2, 3]) A slice of an array is a reference. This is different than a list. Use: b = a.copy() If you want a copy. This is, in fact, alluded to in the docs (although the copy method is not well documented either), but not made very clear. In the 7th paragraph of "Array Basics" in my copy of the docs, it says: "functions which return arrays which are simply differnt views of the same data will in fact share their data" This applies to slices, but I agree that that is not made clear AT ALL in that section of the docs. The second item in the FAQ (http://pfdubois.com/numpy/numerical_python_faq.htm) is: Assignment doesn't make a copy? Right. The statement y=x just creates a new name for the same array object. While consistent with Python, this is upsetting to users of other array languages. Likewise, x[i:j] is not a copy. Please read the manual. Unfortunately, the manual really doesn't make this clear. I don't remember how I learned it. Probably trial and error. One common problem with Docs for open source projects is that when you need the beginner stuff, you aren't qualified to write it, and when you are qualified to write it, you don't need it, and often forget what the stumbling blocks were when you were just getting started. I would suggest posting a note to the NumPy list, suggesting an enhancment to the slicing section of the docs. > Also, it is not necessarily clear to me when assignment creates a new > object (freeing the reference to the old object), and when it modifies > the old object. Assignment always creates a new binding. > Apparently alist.append(7) modifies the old object. This is not an assignment. There is no equals sign. > How about alist = alist * 2? Looks like a new object. yes, it is: >>> alist = [1,2,3] >>> blist = alist >>> # we now have two bindings to the same list ... >>> alist = alist * 2 >>> alist [1, 2, 3, 1, 2, 3] >>> blist [1, 2, 3] >>> # alist is now bound to the new list created by the multiplication, and blist is still bound to the old one. ... What's important here is that assignment always creates a new binding. Whether a new object is created depends on the operation. It is the "*" in the previous example that created the new list, not the "=". > How about > a = 3 and then a *= 2? (With Python 1.5.2 I don't have the *= operator.) > I guess a is immutable so it must create a new object... yup, and since that's the only option with an immutable object, it makes little difference. Note that *= (and kin) generally does not create a new object for a mutable type: >>> a = [1,2,3,4] >>> b = a >>> a *= 2 >>> a [1, 2, 3, 4, 1, 2, 3, 4] >>> b [1, 2, 3, 4, 1, 2, 3, 4] This is particularly usefull for Numeric Arrays, and is the reason that adding the *= operators was not just syntactic sugar. > PS: I'm using Python 1.5.2 and Numeric 15.2, if that makes a difference. I'm not entirely sure if the array.copy() method is there in that version. Try it out. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From phr-n2001d at nightsong.com Sun Nov 11 00:25:11 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 10 Nov 2001 21:25:11 -0800 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> Message-ID: <7xpu6plw08.fsf@ruckus.brouhaha.com> Erno Kuusela writes: > | The security issue with pickle.loads that we spent a long time > | discussing is something I think the perl developers would not have > | tolerated. > > could you describe the security issue in some detail? Basically if you unpickle a string that came from an untrusted source (say, a browser cookie from the Cookie module), the string can make pickle load arbitrary modules and call arbitrary object constructors in your application. The docs for the cookie module mention this and there's an bug open on sourceforge to fix the pickle docs. From skip at pobox.com Thu Nov 29 08:45:32 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 29 Nov 2001 07:45:32 -0600 Subject: xmlrpc tutorial? In-Reply-To: <3C063569.8230ADD0@snakefarm.org> References: <3C063569.8230ADD0@snakefarm.org> Message-ID: <15366.15356.932901.119251@beluga.mojam.com> Carsten> is there any step-by-step intro to the xmlrpc module? I'm not Carsten> very happy with the online docs especially concerning the Carsten> server setup. No simple intro that I'm aware of. I wrote a simple server about 18 months ago to run the XML-RPC validation suite. Search for "xml" at http://musi-cal.mojam.com/~skip/python/ I just ran it using Python 2.1.1 to make sure it still works. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From mwh at python.net Thu Nov 22 11:59:03 2001 From: mwh at python.net (Michael Hudson) Date: Thu, 22 Nov 2001 16:59:03 GMT Subject: Non-Indented python References: Message-ID: philh at comuno.freeserve.co.uk (phil hunt) writes: > For C there is a program (I think it's called indent) that re-does > the indentation of a source code file according to defined criteria. > > Perhaps there should be somertyhing similar for python? When someone > checks code out of CVS it could automatically indent it the way the > user desired, and when checking basck in to CVS, indent it according > to the project standards. > > Does anything like this exist? I'm pretty sure python-mode in emacs will reindent chunks of code to different indentation levels, although I don't recall how to get it to do this. There's also Tim Peter's reindent.py, which lives in Tools/scripts/ in CVS which will convert Python to the One True Indentation Format, i.e. the one recommended in PEP 8. It could probably be rigged to do other formats too - but that would be heresy . Cheers, M. -- C is not clean -- the language has _many_ gotchas and traps, and although its semantics are _simple_ in some sense, it is not any cleaner than the assembly-language design it is based on. -- Erik Naggum, comp.lang.lisp From tavis at calrudd.com Fri Nov 23 20:32:29 2001 From: tavis at calrudd.com (Tavis Rudd) Date: 23 Nov 2001 17:32:29 -0800 Subject: several distutils packaging questions Message-ID: Hi, I've got a few questions about distutils: 1) Is there any easy way to use distutils to allow third-party developers to install sub-packages of an already installed package using their own setup.py script? For example, I have a package called 'ThePackage' installed in /usr/local/lib/pythonXXX/site-packages/ThePackage. I want to install 'ASubPackage' to /usr/local/lib/pythonXXX/site-packages/ThePackage/ASubPackage using separate setup.py. The 'extra_path' option adds 'ThePackage.pth' to site-packages, which is not what I want. Is there another way? 2) Is the .pth convention a feature that's here for the long-haul or a hack for backwards compatibility that might be deprecated? Cheers, Tavis From schrist at gmx.net Wed Nov 7 02:58:28 2001 From: schrist at gmx.net (Christian Schnell) Date: Wed, 07 Nov 2001 08:58:28 +0100 Subject: Beginner in Python References: <3BE85DF9.CDF844D2@gmx.net> <9s9pp2$11iio5$1@ID-11957.news.dfncis.de> Message-ID: <3BE8E9A4.B5367A1E@gmx.net> Hi, thank you. This was my mistake. I also tried it at the dos promptyesterday, but I worked in the wrong directory. Thanks, Christian Emile van Sebille schrieb: > Hah... I got caught explaining this one last week. ;-) > > You are to type "python helloworld.py" at the dos prompt > ("C:\Dir\Of\HelloWorld>"), not the python prompt (">>>"). I suspect that as > double click it in the explorer that everything else required is already in > place. > > -- > > Emile van Sebille > emile at fenx.com > > --------- > "Christian Schnell" wrote in message > news:3BE85DF9.CDF844D2 at gmx.net... > > Hi, > > > > I wanted to start programming in python today and had some problems. > > I wrote the famous "Hello, world"-programm and saved it as > > helloworld.py. If I open the programm directly in the explorer it works > > but I cannot start it from Ms-Dos. If I type python helloworld.py I get > > the message: > > > > File "", line 1 > > python helloworld.py > > ^ > > > > SyntayError: invalid syntax > > > > What is my mistak? Can anyone help me? > > > > Thank you, > > > > Christian > > > > -- > > Don't panic. > > > > ICQ 116707729 > > > > -- Don't panic. ICQ 116707729 From dale at riverhall.NOTHANKS.co.uk Mon Nov 5 08:26:48 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Mon, 05 Nov 2001 13:26:48 +0000 Subject: Exception holes, again. References: <9s1sen$1sdd$1@feed.teaser.net> Message-ID: "Frederic Giacometti" wrote: > >"Dale Strickland-Clark" wrote in message >news:sj4autoi1lbtvsiccf5kaadabb6ru4nnoe at 4ax.com... >> "Olivier Deckmyn" wrote: >> >> >Did you look in the C sources ? >> > >> I don't have the C source. I shouldn't need it. > >Tough luck. You can try to fix the English documentation, too. > >Meanwhile, "The documentation is the source code"... > >FG > > That is such a stupid attitude. -- Dale Strickland-Clark Riverhall Systems Ltd From tsshivaprasad at yahoo.com Tue Nov 27 23:32:36 2001 From: tsshivaprasad at yahoo.com (tsshivaprasad at yahoo.com) Date: Wed, 28 Nov 2001 04:32:36 -0000 Subject: Background python thread for Pmw based GUI Message-ID: <9u1pd4+ioo3@eGroups.com> Dear Friends, Hi I am new to Python programming. I would be grateful if any of you could manage to send me a complete sample code in which a Background python thread keeps checking some activity and display the updates in Pmw based or Tkinter based GUI.. If some can let me know in which website i can find such sample ,would be highly appreciated From aeoo at myrealbox.com Thu Nov 1 19:35:46 2001 From: aeoo at myrealbox.com (Leo Lipelis) Date: Thu, 01 Nov 2001 19:35:46 -0500 Subject: Exception handling wart in Python Message-ID: Hi Pythoneers, I'd like some help with an issue I have with Python. Simply put, I think having an exception mechanism is a waste if there is no tool that will let you know which unhandled exceptions exist at point foo. I have spoken about this issue briefly with Neal, of the PyChecker fame, and he seemed to agree with me. I realize that it's a difficult problem to solve, but I think it would be worth solving at the language level, similarly to the way it's done in Java. Let's say I call a function in some module, a = some_module.func(b) Now, what I would like, is to know as precisely as possible (but I would be happy with an intelligent guess also), what exceptions are possible as a result of that function call, so that I can decide which ones to handle and which ones to not handle, etc. Considering that in Python exceptions are matched by identity instead of equivalence, it's possible to track all the exception flows, right? I think relying on documentation for this is not an option. First, there is never a guarantee of documentation, and I would like this feature to be guaranteed. Second, it becomes very problematic with deeply nested functions and inheritance. Why should I have to search through all those docs for something that compiler should tell me anyway? This is just the kind of monotonous task that needs to be done by a computer program instead of a human. I realize that something like PyChecker can eventually check for unhandled exceptions, but I think this is important enough to be done at the core language level. I mean this should be done by a tool that's present in a standard Python tarball. I agree with whoever said that a race horse doesn't belong in the glue factory. It seems like Python is being used for serious programming, and it seems to me, if it supports exceptions, it should support them all the way. It's fairly pointless to provide exceptions if you really never know whether you handle all the relevant exceptions or not, without the ugly, bad, and stupid except: foo() statements to catch *all* exceptions. Leo "__who_doesnt_like_underscores_and_many_selves_at_all__" Lipelis P.S.: The double leading underscore is the ugliest thing I've ever seen in language syntax. I've been writing some Python code that uses that feature, and man, it looks ugly. For a language that prides itself on indentation based code blocks for readability, double underscore is an ugly wart that needs to be fixed. That, and having to constantly type self.__quax, self.__foo, self.__bar(), self.__foobar()... That's *SEVEN* whopping useless characters on every line. P.P.S.: Otherwise Python is a very pleasant and productive language. From tim.one at home.com Sat Nov 17 19:44:48 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 17 Nov 2001 19:44:48 -0500 Subject: float( ) inconsistency? In-Reply-To: <1006034457.123813@isis.esoterica.pt> Message-ID: [Jos? Rui Faustino] > I am a little bothered by float( ) behaviour. > > I think float( '1.0e' ) or float( 1.0e-' ) should not raise an error. > After all x = 1.0e or x = 1.0e- both are legal floats. They're not in Python 2.2. From the NEWS file for 2.2a4: - The syntax of floating-point and imaginary literals has been liberalized, to allow leading zeroes. Examples of literals now legal that were SyntaxErrors before: 00.0 0e3 0100j 07.5 00000000000000000008. - An old tokenizer bug allowed floating point literals with an incomplete exponent, such as 1e and 3.1e-. Such literals now raise SyntaxError. The incomplete literals were never legit according to the Python reference manual, or to tokenize.py. From wurmy at earthlink.net Fri Nov 30 22:07:45 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sat, 01 Dec 2001 03:07:45 GMT Subject: load a class dynamically References: Message-ID: <3C08497D.2C92F2B9@earthlink.net> Jeremy Lowery wrote: > > I know that implementing this may be a little bit of work, but could someone > point me in the right direction? > > Have a text file that only contains a class definition, or just a string for > the sake of simplicity. > > str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1" > > #the magical code goes here. > > obj = myClass() > # of course, it doesn't have to be called like that, but to > #get the ability to instantainate that class. You can use the exec statement, but you should end the string in a newline, though... >>> str = "class myClass:\n\tdef __init__(self):\n\t\tself.v = 1" >>> exec str Traceback (most recent call last): File "", line 1, in ? exec str File "", line 3 self.v = 1 ^ SyntaxError: invalid syntax >>> str = str + "\n" >>> exec str >>> obj = myClass() >>> obj <__main__.myClass instance at 00AB5ED4> >>> --Hans From donn at drizzle.com Tue Nov 13 01:54:09 2001 From: donn at drizzle.com (Donn Cave) Date: Tue, 13 Nov 2001 06:54:09 -0000 Subject: Designing socket messaging format References: <97ae44ee.0111111912.14006c7f@posting.google.com> <29e28c51.0111120234.35d10048@posting.google.com> <97ae44ee.0111121735.ebbca1@posting.google.com> Message-ID: <1005634445.168925@yabetcha.sttl.drizzle.com> Quoth shriek at gmx.co.uk (Stephen): | Just read Dan Bernstein's description. Interesting note about | security considerations using CRLF, which follows on from an | earlier post in this thread. | | | 4. Security considerations | | The famous Finger security hole may be blamed on Finger's use of the | CRLF encoding. In that encoding, each string is simply terminated by | CRLF. This encoding has several problems. Most importantly, it does | not declare the string size in advance. This means that a correct | CRLF parser must be prepared to ask for more and more memory as it is | reading the string. In the case of Finger, a lazy implementor found | this to be too much trouble; instead he simply declared a fixed-size | buffer and used C's gets() function. The rest is history. | | In contrast, as the above sample code shows, it is very easy to | handle netstrings without risking buffer overflow. Thus widespread | use of netstrings may improve network security. Widespread use of decent programming languages would do a lot more in the same direction. This one is a problem with C, not with CRLF data. The notion that we should tailor our data protocols to keep programmers away from fixed-size buffers is kind of sick, and it's frustrating to think that it's a serious practical consideration outside the cozy haven of c.l.p. Donn Cave, donn at drizzle.com From glchapman at earthlink.net Thu Nov 15 10:36:54 2001 From: glchapman at earthlink.net (Greg Chapman) Date: Thu, 15 Nov 2001 15:36:54 GMT Subject: How Can I Capture the Class Object for a Python Class Derived From My C API Metatype? References: <3a5a7d54.0111091305.70bad186@posting.google.com> <3a5a7d54.0111120608.1f9833b2@posting.google.com> Message-ID: <03o7vt0n0hfflt3kb5jdrasbei6te5kvfm@4ax.com> On 12 Nov 2001 06:08:52 -0800, stewart at sig.com (Rob Stewart) wrote: >stewart at sig.com (Rob Stewart) wrote in message news:<3a5a7d54.0111091305.70bad186 at posting.google.com>... >> I need to create a metatype, using the C API, that can save the class >> objects for Python classes derived from it. I need to be able to use >> the class object to instantiate objects of that class under C (C++) >> program control, and to discover the methods that have been defined to >> override default behavior so C++ virtual function calls can be >> forwarded to Python methods. >As I understand the mechanism, T's tp_call slot function is invoked to >instantiate a class object describing P. If T is PyType_Type, then >tp_call is defined to call the tp_new slot on the type of the new >object, which ultimately should call tp_new on T (since the derived >type's tp_new should call the base's tp_new. At that point, T can >save the PyObject * for the class object being created for later use >by the C++ code. > >At that point, it should, I think, also be possible to capture the >methods implemented or inherited by P. For each method of an >expected, predetermined name, I can capture the PyObject * for that >method for subsequent invocation by the C++ code. The notion here, is >that if the method hasn't been overridden, then I can provide the >default behavior in C++ rather than always forwarding to a method in >the metatype. This is merely a performance optimization. First, take a look at the metatypes in Lib\test\test_descr.py to try to get a general idea of what should happen. I think what you need to do is create a PyTypeObject for your metatype which has a base class (tp_base) of PyType_Type (as well as an ob_type of PyType_Type). PyType_Type is marked as Py_TPFLAGS_BASETYPE so that should work. Provide a tp_new handler which will give you the chance to look at classes as they are created. The parameters to tp_new (when creating types/classes) are the name of the new class, a tuple of base classes, and a dictionary with the members (including methods) declared in the to-be-created class. Looking at Misc\xxsubtype.c indicates that if all you need is notification that a new class is being created, your metatype does not need much besides tp_new, tp_flags, and tp_base -- it will inherit everything else it needs from PyType_Type. Finally, declare a base class that declares its __metatype__ as your metatype, and inherit your classes from this base class; when this base class and its descendants are created, your metatype's tp_new will be called. Again, a good idea is to look at test_descr.py, and then try to work out what you want using a metatype written in Python to start with. Once you've gotten things working, you can convert your Python metatype to C. I haven't tried doing such a conversion, but it looks like it ought to be fairly straightforward. --- Greg Chapman From phr-n2001d at nightsong.com Sat Nov 3 14:20:22 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 03 Nov 2001 11:20:22 -0800 Subject: Program very slow to finish References: <3BE41CBE.94AED22@nospamco.com> Message-ID: <7xy9lnzmo9.fsf@ruckus.brouhaha.com> Fred writes: > Is this a garbage collection issue? Is there a better way to count the > individual values than dictionaries? I put the sys.exit call in while > trying to figure out what was happening but it didn't make a difference. There's only about 120,000 hash entries in your example run. It shouldn't take anything like 1 minute for sys.exit to free them. Something else is going on. I'd be interested to know what sys._exit does. However, it's pretty bad if freeing the entries is that slow--bad enough that I'd probably open a bug. Also, counting the entries with len(nacc.keys()) is pretty horrendous if the number of entries is very large (several million). For 120,000 it's probably tolerable. If you expect to get a much larger number of distinct values (like 10's or 100's of million distinct) in your 100 GB data set, you probably don't want to use Python dictionaries to remember them. The overhead per value is rather large, like dozens of bytes. If you can convert the keys (the substrings line[8:14] and so forth) into integers (they're account numbers and such?) and they're not too sparse, you can use a bit map to record which ones you've seen, then iteratively count the set bits at the end. If they're sparse but you don't mind slight inaccuracy in the final counts, you can hash them into integers and then use a bit map. If you need a precise count, and the values are sparse, and there's too many to fit it memory, you can divide the data into smaller pieces, count each piece, then merge the counts. If you're just processing a single data set once, the simplest (but not fastest) thing to do is select out the keys and write them to a file. Then use the Unix sort utility to sort the file discarding duplicates (sort -u), then count the lines in the output. The sort utility knows how to handle files that don't fit in ram. From sabren at manifestation.com Thu Nov 15 16:14:08 2001 From: sabren at manifestation.com (Michal Wallace) Date: Thu, 15 Nov 2001 16:14:08 -0500 (EST) Subject: Explain string boolean expression In-Reply-To: <3bf428ba@skynet> Message-ID: On Thu, 15 Nov 2001, Serg wrote: > Explain please what exactly > "" or "Some" or "abbyds" Well, if you type it into the python prompt, you'd see it prints "Some"... :) "" is a false value, "Some" and "abbyds" are true values. So it's the same as saying: (false) or (something true) or (something else true) And if you look at the order of operations, this compares the first two, returns "something true" and forgets about the the final value. Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From kragen at pobox.com Thu Nov 29 14:07:46 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 29 Nov 2001 14:07:46 -0500 Subject: Problem using exec function & classes References: <9u5qfk$rjt$1@wanadoo.fr> Message-ID: <834rndv1j1.fsf@panacea.canonical.org> "news python" writes: > def test2(): > exec("class c2:\n global n1,n2") > exec("global verify2") > exec("verify2=c2()") > > >> test2() > >>verify2 > NameError: name 'verify2' is not defined > > is somebody have any idea why "exec" instruction don't do the same thing, > and how to correct this problem, please let me know You need exec("global verify2; verify2=c2()") or exec("global verify2\nverify2=c2"). HTH. From skip at pobox.com Tue Nov 27 12:16:24 2001 From: skip at pobox.com (Skip Montanaro) Date: Tue, 27 Nov 2001 11:16:24 -0600 Subject: python vs ecmascript In-Reply-To: References: <01111609593502.02629@logiplex1.logiplex.net> <3c03b0a8$0$25399$edfadb0f@dspool01.news.tele.dk> Message-ID: <15363.51816.645556.770056@beluga.mojam.com> >> Python library reference: >> 2.1.5.2 String Formatting Operations >> (I had to search long and hard for it too. Sometimes the manual could >> be a bit more cross referenced.) Yong> Agree, and maybe the index should be a little more comprehensive. Take a look at the "development" docs. The general index is at http://python.sourceforge.net/devel-docs/lib/genindex.html and is about 330kbytes long and contains about 4500 index entries. If you search for "formatting" or "printf" or "sprintf", you'll find several links to it. I think the Lib Ref index is getting pretty darn comprehensive. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From d_blade8 at hotmail.com Sun Nov 11 23:10:18 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 11 Nov 2001 20:10:18 -0800 Subject: open(.xls file, 'w') so that hyperlinks appear Message-ID: <7396d2b2.0111112010.7649efa1@posting.google.com> I feel kind of silly asking this question but I have a hard time with the internal workings of MS products. I have the Win32 Python book by Oreilly, but I think I just have a learning block or something. Enough of that, here is my question: I made a program that takes input from a file (text file with \n splits). I search a public database and find more links (using the urllib.urlopen function). I want to plug these links into Excel and have them as functional links, but all I get is text (a Unicode translation thing, I assume). Is there a way to modify the output so that they will show up as links in Excel? I can send my code to anybody who wants to see it (it is big and hairy so I don't want to waste the space here). Thanks From glennfulford at bigpond.com Wed Nov 21 22:25:01 2001 From: glennfulford at bigpond.com (Glenn R Fulford) Date: Wed, 21 Nov 2001 19:25:01 -0800 Subject: MatPy question References: <9tb8k1$ah779$1@hades.rz.uni-sb.de> <9tdhon$aht52$1@hades.rz.uni-sb.de> Message-ID: "Huaiyu Zhu" wrote in message news:slrn9vlstk.4ut.huaiyu at gauss.almadan.ibm.com... > On 20 Nov 2001 12:19:35 GMT, Uwe Schmitt wrote: > >I'd prefer indexing from one, because it's the notion used in > >mathematics, most existing algorithms are formulated this way. > > Mathematicians do not really care about whether the index starts with zero > or one. They just need some index, which could start from 42 if you want. > But when they do care, such as defining the axioms of natural numbers, they > seem to prefer starting from zero as well On the other hand, most work with matricies has indexing starting from 1. Noone uses matrix indices (0,0). Note that MatLab does it's indexing from 1, and I thought that nupy is thought of as a replacement for matlab? The whole idea of using software to do mathematics is to have a language which feels natural to translate the maths into the program. . I initially learned > programming in Fortran, but when I learned C later it felt much more > natural. I guess some other people might feel the same way too. Not me! Glenn. From nomad*** at ***freemail.absa.co.za Wed Nov 14 07:32:29 2001 From: nomad*** at ***freemail.absa.co.za (Nomad) Date: Wed, 14 Nov 2001 14:32:29 +0200 Subject: Sockets and messaging services References: <97ae44ee.0111112119.e8f42d2@posting.google.com> <3BF13501.BEFF4899@q-survey.be> <97ae44ee.0111131614.57ff3098@posting.google.com> Message-ID: On Wed, 14 Nov 2001 10:15:27 +0100, Skip Montanaro wrote: > > >> IMHO the SMTP and POP protocols provide the same benefit (and there > >> are Python modules for those protocols). > > shriek> Using a mailserver as a messaging platform for middleware ? > >It's not all that far-fetched. I know some people have experimented with >XML-RPC over SMTP (which is no longer XML-RPC, but that's a nit). You could also use a custom jabber handler. There was a really nice article in Linux Magazine (IIRC in either the July or August issue) about jabber and creating your own handlers in perl. Although I haven't tinkered with it enough to give you an example, I'm sure you could easily use JabberPy (see jabberpy.sourceforge.net) for it. -- Nomad Wondering of the vast emptyness of the 'net in search of something cool. From lac at strakt.com Mon Nov 12 13:42:33 2001 From: lac at strakt.com (Laura Creighton) Date: Mon, 12 Nov 2001 19:42:33 +0100 Subject: A Python GUI Book. In-Reply-To: Message from philh@comuno.freeserve.co.uk (phil hunt) of "Mon, 12 Nov 2001 16:41:26 GMT." References: <3beedf26@nntp.server.uni-frankfurt.de> <3BEF0436.33D7F2A5@earthlink.net> Message-ID: <200111121842.fACIgXua014731@ratthing-b246.strakt.com> One defect that most GUI books I am aware of suffer from is that they are written almost exclusively from the point of view of providing ways for users to provide _input_ to your program, database, or whatever. This is easy to teach, and works well with the philosophy that the user should be in complete control, and that nothing should happen until the user asks for it, by clicking a button or whatever.... And then, on your first job, you have to write code that handles real-time updates of a package tracking system. Many people need to write applications where the user _is_ a passive receiver of data. This is hard to do well, and worth a chapter all to itself, in my opinion. Laura Creighton From aidan.finn at ucd.ienospam Tue Nov 20 11:12:56 2001 From: aidan.finn at ucd.ienospam (Aidan Finn) Date: Tue, 20 Nov 2001 16:12:56 +0000 Subject: Still on python GUI toolkit References: Message-ID: <20011120.161256.933110197.8583@ucd.ienospam> In article , "Tyler Eaves" wrote: > Unless you used Tkinter's canvas widget, this wasn't a fair test. I haven't used any GUI toolkit other than Tkinter. Is the canvas widget in Tkinter significantly better/worse than those in other toolkits? From andymac at bullseye.apana.org.au Thu Nov 15 05:04:03 2001 From: andymac at bullseye.apana.org.au (Andrew MacIntyre) Date: Thu, 15 Nov 2001 21:04:03 +1100 (EDT) Subject: os.mkfifo in linux vs freebsd In-Reply-To: Message-ID: On Wed, 14 Nov 2001, Andrei Kulakov wrote: > Should I go to some freebsd groups (I hear they don't like to answer > questions, though)? Most of the FreeBSD people only look at the mailing lists, and they are usually quite helpful provided that you show some commitment by supplying useful information pertinent to your problem. Most of the team are far too busy to try and look at requests for help that just say "its broke". -- Andrew I MacIntyre "These thoughts are mine alone..." E-mail: andymac at bullseye.apana.org.au | Snail: PO Box 370 andymac at pcug.org.au | Belconnen ACT 2616 Web: http://www.andymac.org/ | Australia From loewis at informatik.hu-berlin.de Mon Nov 26 12:28:23 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Nov 2001 18:28:23 +0100 Subject: bugs in `gc.get_referents()' References: Message-ID: Zooko writes: > But the remaining six entries are data structures from my code which > do *not* refer to the object in question, and curiously those six > data structures (or ones like them -- I'm not sure) are *always* > returned from any call to gc.get_referents()! Could you create a test case? I cannot reproduce such behaviour, and I cannot see anything in the code of get_referrers that may cause such problems. That you are getting into this list indicates, to me, that there is a bug in the C type of the tp_traverse function of that object (this is not one of the Object types of core Python, is it?) Each container is supposed to invoke the visitproc, and return its return value if that is non-zero. Otherwise, it shall continue to iterate over all objects, and return zero when done. Could you provide a link to the source of the relevant tp_traverse function for inspection? Regards, Martin From C.Fuhrmann at gmx.de Sun Nov 25 06:50:44 2001 From: C.Fuhrmann at gmx.de (Christian Fuhrmann) Date: Sun, 25 Nov 2001 12:50:44 +0100 Subject: Clear screen Message-ID: <9tqlu7$47pu5$1@ID-110600.news.dfncis.de> Hi! How do I Clear the screen in the normal line-commanded window. (In C/C++ I say cls();) Chris (C.Fuhrmann at gmx.de) -- --------------------------------------------------------- www.Chr-Fuhrmann.de From tim.one at home.com Sat Nov 3 14:03:38 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 14:03:38 -0500 Subject: [BUG ?] Slicing a 'struct_time' can crash Python interpreter In-Reply-To: Message-ID: [Defresne Sylvain] > I'm trying to take a slice of a 'struct_time' returned by > time.gmtime() with version 2.2b1 of Python. This is what I'm getting : > > Python 2.2b1 (#1, Oct 24 2001, 23:50:39) > [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 > Type "help", "copyright", "credits" or "license" for more > information. > >>> import time > >>> x = time.gmtime() > >>> x > (2001, 11, 3, 18, 25, 35, 5, 307, 0) > >>> type(x) > > >>> x[:3] > (2001, 11, 3) > >>> x[3:] > (, , , 18, 25, 35) > >>> x[:3] + x[3:] > Segmentation fault This is a bug in 2.2b1 that was fixed last week (it works fine in current CVS Python). > ... > I wanted to know if this is a bug in my version of python (provided > by debian), or a bug in Python 2.2 itself. I'm confused. Python 2.2 has not been released, and won't be until December -- 2.2b1 is a beta release, and nobody should be shipping a beta version in a production system (we guarantee that beta releases have nasty bugs ). So if you're not confused, Debian is. From mats at laplaza.org Mon Nov 26 17:02:33 2001 From: mats at laplaza.org (Mats Wichmann) Date: Mon, 26 Nov 2001 22:02:33 GMT Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> <3BFFF06A.F7A3C69@tundraware.com> Message-ID: <3c029b06.260094476@news.laplaza.org> On Sun, 25 Nov 2001 15:55:32 -0800, Tim Roberts wrote: :Tim Daneliuk wrote: :> :>This is not a problem, but an intentional design point in both operating :>systems. You do not want a random user process to be able to fiddle with :>the runtime environments of other users. This is intentionally possible :>only by an act of system administration... :> :>It is a bit unclear exactly what the original poster was trying to :>accomplish, ... : :I thought his goal was clear, and actually quite reasonable: he'd like to :modify the environment of his processes parent, so that succeeding :processes inherit his changes. He's not trying to change another user's :environment, he's just trying to use the environment to pass data from one :program to another in the same session. : :It is a common goal, although unachievable without a certain amount of :magic. Depends on how you define magic. If you want this to happen, the child needs to tell the parent to modify its' environment. It can't do so directly. Using some upstream communication mechanism can accomplish this, whether that is to put stuff in a file, use a pipe, socket, shared memory segment, or other. Environment variables are purely downstream, if you want to think of them that way: I like to present them as a way to avoid invoking a program with a few hundred bytes worth of command-line options Mats Wichmann From db3l at fitlinxx.com Tue Nov 27 19:19:44 2001 From: db3l at fitlinxx.com (David Bolen) Date: 27 Nov 2001 19:19:44 -0500 Subject: sys.prefix in COM References: Message-ID: sag at hydrosphere.com (Sue Giller) writes: > I guess I can accept this, but how does the python path get built that > has all the other python things in it: there are the various > python21\lib, ... things, but not any that should be found from the > .pth files. I even tried calling site.py in my test com object but that > got the same results - a blank .prefix string. I expect its loaded from the information in the registry (HKLM\Software\Python\PythonCore\#.#\PythonPath), which is I believe where the default sys.path is kept under Windows. > I hate the registry - hassles abound. I would rather do anything else > including hard coding the path and forcing other users to use my > paths :) Unfortunately, given the way in which COM objects may be invoked, the registry really is the most appropriate (and guaranteed easy to locate) source of information. Note that you could also install your own sub-key beneath the PythonPath key (that's how the win32 extensions do it). I believe that any sub-key can contain a default value which is automatically appended to sys.path. There's not much different from adding such a key to the registry (just publish a .reg file for your users to use) and hardcoding a path. -- -- 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 nico.hartmann at daimlerchrysler.com Fri Nov 30 02:17:58 2001 From: nico.hartmann at daimlerchrysler.com (Nico Hartmann) Date: Fri, 30 Nov 2001 08:17:58 +0100 Subject: decoding floats References: <9u2buq$jo9$1@news.sns-felb.debis.de> <9u4lqh$gc7$1@news.sns-felb.debis.de> <3C06634A.B802A165@email.sps.mot.com> Message-ID: <9u7bju$k8p$1@news.sns-felb.debis.de> Hi, > >>> import marshal > >>> s = marshal.dumps(3.14) > >>> s > 'f\x043.14' ^^^^^^^^^ Unfortunately this is clearly not the byte code of an IEEE floating point value. However, unless we don't intend to exchange data with other applications in binary form, that marshal interface looks quite simple but inefficient to me (marshal.dumps(math.pi) takes 15 bytes). Greets, nico From chrishbarker at home.net Wed Nov 28 15:43:04 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 28 Nov 2001 12:43:04 -0800 Subject: Copy operator (was list.remove for Noivces) References: Message-ID: <3C054C58.9961A62@home.net> arthur.siegel at rsmi.com wrote: > One imports copy, like one imports cgi or tokenize. To a beginner, imports > from outside modules is strictly special purpose stuff. In my case it was a > long time before much beyond math ,os and sys perhaps, were anything > more than absolute exotica. If anything, this is a good argument for making copy() and deepcopy() a built-in, rather than part of a mmodule. The funny thing is: I have hardly ever used the copy module. In fact, since I discovered that NumPy arrays have a copy() method, I don't hink I have used it at all. I have no idea if I am typical, but Python's "everything is a reference" approach is simple and powerful to me, and I find I have littel use for copies. > a) I could be missing something (but I would need convincing) You make it clear that you are with this statement: > The shallow/deep copy issue I understand is there and real - but I don't > really understand the issue itself. >I will do some homework. Here is a little example: >>> import copy >>> a = [1,2,3] >>> b = [4,5,6] # a and b are bound to lists of integers, a concept that is pretty easy for newbies to grasp >>> c = [a,b] >>> c [[1, 2, 3], [4, 5, 6]] # c is now bound to a list that contains two other lists (the ones bound to a and b) >>> d = copy.copy(c) # d is bound to a copy of the list c is bound to. >>> e = copy.deepcopy(c) # e is bound to a deep copy of the list that c is bound to >>> d [[1, 2, 3], [4, 5, 6]] >>> e [[1, 2, 3], [4, 5, 6]] # they look the same, so what is the difference? # let's say we change the list that a is bound to. >>> a.reverse() >>> d [[3, 2, 1], [4, 5, 6]] # d contains that same list, so it has changed >>> e [[1, 2, 3], [4, 5, 6]] # e contains a copy of that list, so it is not changed. # so, in what sense is d a copy at all? >>> c[0] = 6 >>> c [6, [4, 5, 6]] # c has now changed >>> d [[3, 2, 1], [4, 5, 6]] # but d hasn't What I get from this is that someone using Python had better understand how Python name binding, mutable types, copying, and deep copying work in order to not get bit eventually. I don't think making it easier tao make a trivial copy will help that, rather it will hinder it. If there is something you need to learn, the sooner the better! -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From jerry at sky.net.ua Thu Nov 15 15:38:53 2001 From: jerry at sky.net.ua (Serg) Date: Thu, 15 Nov 2001 22:38:53 +0200 Subject: Explain string boolean expression Message-ID: <3bf428ba@skynet> Explain please what exactly "" or "Some" or "abbyds" does? -- Keep in touch. Your partner Maltsev. From pobrien at orbtech.com Thu Nov 29 22:51:24 2001 From: pobrien at orbtech.com (Patrick K. O'Brien) Date: Fri, 30 Nov 2001 03:51:24 GMT Subject: Why Python? Message-ID: <0nDN7.14999$WC1.1783701@newsread2.prod.itd.earthlink.net> I've added a Python advocacy page to our company website and I'm looking for suggestions for improvements or additional material. Take a look at http://www.orbtech.com/why_python.htm and let me know what you think. The intended audience is a business person who wants to know why they should support Python in their organization. So the writing needs to be as non-technical as possible. Thanks. -- Patrick K. O'Brien Orbtech.com - Your Source For Python Development Services From tim.one at home.com Fri Nov 30 13:38:07 2001 From: tim.one at home.com (Tim Peters) Date: Fri, 30 Nov 2001 13:38:07 -0500 Subject: New updates needed for an old computer language humor piece In-Reply-To: Message-ID: [Nick Mathewson] > Basic Python > You shoot yourself in the foot. > ... LOL! Thanks, Nick -- we're going to retract all the new 2.2 features out of embarrassment . From flynt at gmx.ch Fri Nov 23 16:20:28 2001 From: flynt at gmx.ch (flynt) Date: Fri, 23 Nov 2001 22:20:28 +0100 Subject: syntax-error? References: <20011123193458.A7362@cruciatuz.de> Message-ID: <3BFEBD9C.C0572DDA@gmx.ch> Stefan Antoni wrote: > > I got the following script and it produces a syntax error which drives > me crazy. it says: > > File "", line 24 > j = 0 # a counter > ^ > SyntaxError: invalid syntax > > Why? > > is j = 0 invalid? > > here's the script (anybody who can help me?): > > import httplib > > # request the page and get it > def GetUrl(ServerAdr, PagePath): > http = httplib.HTTP(ServerAdr) > http.putrequest('GET', PagePath) > http.putheader('Accept', 'text/html') > http.putheader('Accept', 'text/plain') > http.endheaders() > httpcode, httpmsg, headers = http.getreply() > if httpcode != 200: > raise "Could not get document: Check URL and Path" > doc = http.getfile() > data = doc.read() > doc.close() > return data > > # parse the page and return the content between the start and end token > def ExtractData(in_string, start_line, end_line): > lstr = in_string.splitlines() > j = 0 # a counter > for i in lstr: > j = j+1 > if i.strip() == start_line: slice_start = j # find slice start > elif i.strip() == end_line: slice_end = j # find slice end > return lstr[slice_start:slice_end] # return the slice > > # handle the returned stuff and generate a new page > def main(): > # parameter and constants > ServerAdr = 'www.onlinekosten.de' > PagePath = '/' > > StartLine = '' > EndLine = '' > > Head1 = '' > Head2 = '' > > Foot = '' > > # call functions > RawData = GetUrl(ServerAdr, PagePath) > v = ExtractData(RawData, Startline, EndLine) > > # return result and construct page > print Head1.strip() + ServerAdr.strip() + Head2.strip() > for i in v: > print i.strip() > print Foot.strip() > > if __name__ == '__main__': > main() > > -- > thx in advance, > Stefan Antoni Hi Stefan I look at the lines: def ExtractData(in_string, start_line, end_line): lstr = in_string.splitlines() j = 0 # a counter for i in lstr: j = j+1 What is *not* clear to me: 1. Is your intendation consistent (only tabs or only always the same number of spaces ? 2. after *lstr = in_string.splitlines()* you intend again. Why ? the following line *j = 0 # a counter* belongs to the same block as one line higher. So do you have an intendation too much ? Regards --- Flynt From donn at drizzle.com Mon Nov 26 12:40:18 2001 From: donn at drizzle.com (Donn Cave) Date: Mon, 26 Nov 2001 17:40:18 -0000 Subject: popen3 stdin problem References: None <57c2c2f1.0111260642.22b4cf30@posting.google.com> Message-ID: <1006796415.531417@yabetcha.sttl.drizzle.com> Quoth en at enlightened.de (Nicolai Ehemann): | I have a strange problem using popen3() on a linux machine with python | 2.1.1: | I use | | inf, outf, erff os.popen3("cmd ....") | | to start a process which makes a lot of output to stdout and awaits | user input on stdin. Capturing the output with outf.readline() works | perfectly, but as far as I can see sending input to the process via | inf.write("command") or inf.write("command\n") does not get through to | the child process. When called interactively, cmd reacts to input from | stdin with some status output, and there is a /QUIT-Command which | should stop the program. Nothing of this happens (outf.readline() | never gets EOF). | | Any ideas what the problem could be? Try inf.flush() after writing. The functions in popen2 return file objects, which will be block buffered. You have to flush manually, or use the underlying file descriptors (fileno()). Donn Cave, donn at drizzle.com From donn at u.washington.edu Thu Nov 8 18:10:05 2001 From: donn at u.washington.edu (Donn Cave) Date: 8 Nov 2001 23:10:05 GMT Subject: Two way communication between a python class and a C++ class References: <0r0mut8npqtk8cfp1nato7fmslfkqcv0ki@4ax.com> Message-ID: <9sf3cd$13oo$1@nntp6.u.washington.edu> Quoth Firestar : | I am having a problem obtaining two way communication between a python | class and a c++ class. I can get a python class to communcate with a | c++ class and a c++ class to communicate with a python class, but i | cannot seem to get the communication to go both ways. | | i.e I have a class CTest in c++ and a class PTest in python and when i | create an instance of CTest in c++ it creates an instance of PTest in | python, i then want PTest to be able to call methods in the instance | of CTest that created the instance of PTest. How can i do this? there | seems to be no way to pass the c++ pointer into the python class in | the constructor... The closest I have come to this is an approach like the one described here: http://www.python.org/workshops/1995-12/papers/ahlstrom1.html It doesn't work exactly like you describe - at least in mine, neither class is created by other, nor would that be useful. You may also find something interesting at http://www.boost.org/. Donn Cave, donn at u.washington.edu From anthony at interlink.com.au Thu Nov 8 21:16:02 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Fri, 09 Nov 2001 13:16:02 +1100 Subject: variable function call In-Reply-To: Message from Uwe Schmitt of "08 Nov 2001 15:49:22 GMT." <9se9i2$972fn$1@hades.rz.uni-sb.de> Message-ID: <200111090216.fA92G2A06034@mbuna.arbhome.com.au> >>> Uwe Schmitt wrote > def wrapper(fun, *args): > ... do some checks ... > fun(args) > ... do some update of states ... > > But if I use the function > def sum(a,b): return a+b > and do > wrapper(sum,1,2) Change fun(args) to apply(fun, args) Anthony From mwh at python.net Wed Nov 14 13:17:03 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 18:17:03 GMT Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: modman at altavista.com (Modman) writes: > Michael Hudson wrote in message news:... > > Roy Smith writes: > > > > > ianb at colorstudy.com (Ian Bicking) wrote: > > > > If you look under the hood, Python is much more like Smalltalk than > > > > Java. > > > > > > I'm having trouble parsing that. Which of the following did you mean? > > > > > > 1) Python is more like Smalltalk that Python is like Java > > > 2) Python is more like Smalltalk than Java is like Smalltalk > > > > I think 1). > > > > Cheers, > > M. > > both mean the same thing. No they don't. 1) means Smalltalk Python Java ^ ^ little gap big gap 2) means Python Smalltalk Java ^ ^ little gap big gap both are true, but they're not the same. > Python is closer to smalltalk than Java is so the ST guru buddie was > a bit off base to be compairing Py to J. Quite, i.e. 1) above. Cheers, M. -- Counting lines is probably a good idea if you want to print it out and are short on paper, but I fail to see the purpose otherwise. -- Erik Naggum, comp.lang.lisp From phd at phd.pp.ru Thu Nov 15 11:38:47 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 15 Nov 2001 19:38:47 +0300 Subject: convert a string to a method call ? In-Reply-To: <25SI7.32$Qh1.10549@newsfeed.slurp.net>; from bedge@troikanetworks.com on Thu, Nov 15, 2001 at 08:29:39AM -0800 References: <25SI7.32$Qh1.10549@newsfeed.slurp.net> Message-ID: <20011115193847.E5833@phd.pp.ru> On Thu, Nov 15, 2001 at 08:29:39AM -0800, Bruce Edge wrote: > I have an object, say xObj, which has a bunch of methods. > I have the method I want to call in a string, say str. > > How do I call method str on xObj? > Use eval? If so, the syntax eludes me. method = getattr(xObj, "str") method(param1, param2...) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From DeVerter at robinsonmechanical.com Fri Nov 9 17:37:01 2001 From: DeVerter at robinsonmechanical.com (DeVerter at robinsonmechanical.com) Date: Fri, 9 Nov 2001 15:37:01 -0700 Subject: count in 'for ... in ...' Message-ID: Try this. for s in my_list: print my_list.index(s), ".", s This way you don't need a counter variable. Mark d. "Achim Domma" cc: Sent by: Subject: count in 'for ... in ...' python-list-admin@ python.org 11/06/01 08:50 AM Hi, if I have a list of strings and want to display with a count in front of it I usualy do something like: for i in range(len(my_list)): print i,". ",my_list[i] but I think the for s in my_list: print ... Syntax is much cleaner, because it clearly says what I'm doing. So I asked myself : is there a way to get the internal count in 'for ...in' ? Of course it would be the same as the first version, but in my opinion it would fit perfectly in the 'python-way' to say what one is doing. greetings Achim -- http://mail.python.org/mailman/listinfo/python-list From claysjunkmail at yahoo.com Fri Nov 30 05:05:35 2001 From: claysjunkmail at yahoo.com (Clayton Brown - Emmie Osawa) Date: 30 Nov 2001 02:05:35 -0800 Subject: Library os.path.isfile(filename) - long filenames error. Message-ID: <1b9aff84.0111300205.60095d6d@posting.google.com> I have a filename which is about 90 chars in length, three character extension. The python os.path.isfile() function gets a system error: "Filename or extension is too long." when tested on this file.. Anyone come up against this or know a workaround? I also have nasty characters like spaces, +, = and - in the filename just for fun, so have to test filename as: "c:\path\path\path\kddf-slgjsfdljgklsj+=lkjdlfks jdlfkjsdk_lfjsdklfj+=ljk sjflksdj fklsdjf.ext" From mgerrans at ix.netcom.com Fri Nov 16 03:15:08 2001 From: mgerrans at ix.netcom.com (Matt Gerrans) Date: Fri, 16 Nov 2001 00:15:08 -0800 Subject: A Python GUI Book. References: <3beedf26@nntp.server.uni-frankfurt.de> Message-ID: <9t2ht5$pvi$1@slb3.atl.mindspring.net> I like the idea of incorporating design patterns (suggested elsewhere in the thread), where appropriate. How about developing a Python GUI IDE (like Delphi, Kylix, C++ Builder, etc.) that lets you design the UI and choose any of the toolkits as the implementation? This would perhaps be ambitious, but it would generate a useful tool and be a self-validating (and self-referential) example of what you are illustrating. - mfg Michael 'Mickey' Lauer wrote in message news:3beedf26 at nntp.server.uni-frankfurt.de... > Hi group, > > I'm currently writing a Python GUI book, where several toolkits > (most likely PyGTK, PyQt, FOXpy, PyFLTK, wxWindows and... > of course... Tkinter) are presented and explained. > My idea is that besides going into some detail of every Toolkit I > construct _one_ application scenario with a skeleton, which I > later complete with each of the toolkits. > This should give the reader the means to choose the toolkit > which matches their personal taste & programming philosophy. > > Given this approach, the main question I'm currently trying to > figure out is: What application shall I present? It must be complicated > enough to show some advanced topics (not only presenting a tour of > the widgets and voila...) but at the same time small enough to cover > it within 50 pages or so (remember: for each toolkit!). > > I first thought of some contact application - in outlook style - or > some kind of presentation program - powerpoint style - ... here's a plea > for your input. > > What do you think would be a good application to show the basics and a few > more sophisticated topics in programming GUI applications with Python? > > Apart from this concrete question do you have some topics which you > think should be a _must_ in such a book? Imagine you're a not a total newbie > in python GUI programming... what did you want to read in such a book? > > thanks for your input! > > Yours, > > Mickey. > From prabhu at aero.iitm.ernet.in Tue Nov 6 00:09:05 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 6 Nov 2001 10:39:05 +0530 Subject: RE Module Question. In-Reply-To: References: Message-ID: <15335.28785.989697.340423@monster.linux.in> >>>>> "AV" == Adonis Vargas writes: AV> test = "this is a test" if "test" in test: print "found AV> string." AV> this is just pseudocode to get the concept im trying to AV> achieve. In python2.x >>> test = "this is a test" >>> if test.find ('test'): ... print "Yes!" ... Yes! for python 1.5.x >>> import string >>> test = "this is a test" >>> if string.find (test, 'test'): ... print "Yes!" ... Yes! Also, read the regex-howto from here: http://py-howto.sourceforge.net/regex/regex.html HTH, prabhu From ullrich at math.okstate.edu Tue Nov 6 10:28:12 2001 From: ullrich at math.okstate.edu (David C. Ullrich) Date: Tue, 06 Nov 2001 15:28:12 GMT Subject: Freeware Python editor References: <3be2c653.1205904380@news> <3BE48284.36F4D0AD@student.gu.edu.au> Message-ID: <3be80162.248764327@news> On Sun, 04 Nov 2001 09:49:24 +1000, Joal Heagney wrote: >"David C. Ullrich" wrote: >> >> On Wed, 31 Oct 2001 08:08:22 -0600, Kemp Randy-W18971 >> wrote: >> >> >Check out the free Python editor at www.crimsoneditor.com. >> >> Not that it matters to me, but it seems like someone >> should ask: What does it do that other free(?????????) >> Python editors don't do? >> >> David C. Ullrich > >*chuckles* Oh dear, I'm gonna have to add you to my "Voices of >Sanity"-list now David! That's going to cause a lot of confusion. But you're fr, um, I mean you can do that if you want. >"pointedly-ignoring-voices-of-insanity-(except-for-DeepBlue-who-seems-kinda-nutty)"-ly >y'rs, >-- > Joal Heagney is: _____ _____ > /\ _ __ __ _ | | _ ___ | > /__\|\ || ||__ |\ || |___|/_\|___] | > / \ \_||__ ||___| \_|! | | \ \ ! David C. Ullrich From lac at strakt.com Sat Nov 10 11:33:25 2001 From: lac at strakt.com (Laura Creighton) Date: Sat, 10 Nov 2001 17:33:25 +0100 Subject: Teaching python (programming) to children In-Reply-To: Message from Sheila King of "Sat, 10 Nov 2001 06:38:33 GMT." Message-ID: <200111101633.fAAGXPua010988@ratthing-b246.strakt.com> Sheila King: > I don't see why this "circle" would bother any classroom practitioner at > all. Because teachers really do get to decide what they want to do, to a > large extent, when they go into their classroom with their students and > close the door. I have a problem. I can't pick the _students_ that come into my classroom. And wherever I have come across a student that learned calculus from the graphing-calculator school, I have found somebody who does not understand, really understand, what 'this function is increasing' _means_. They are incapable of doing their own visualization of that. Fortunately for me, I don't run into these people that often. But they are crippled, so much that it shows. It is evident in trying to have the simplest of conversations with them. They have little or no mathematical intuition at all. So either a) the method is bad, and cripples minds (period) or b) the method, if not taught according to some vigorous standard and in conjunction with some other methods, cripples minds (or doesn't allow them to expand properly). (For purpose of argument only I am willing to believe that _somewhere_ it is working.) If the second is the case, then high school teachers must not be allowed to pick and chose what to do, because with the best intentions in the world they will produce a program that will produce people are mathematically naive. Which is my experience. We have people who never made the leap from arithmetic to mathematics. They are human calculators, tied to machine calculators, but have no mathematical intuition whatsoever, and a great difficulty in thinking abstractly. It is frightening. They do get correct answers, as long as their calculators have batteries, but they can't understand them. One must never design educational policy thinking only how the best teachers will educate the most exceptional students (exceptionally good or exceptionally poor.) The policy must instead focus on the worst third of teachers. This is hard on the gifted teacher, indeed, but the alternative is hard on _everybody_. Laura Creighton From peter at engcorp.com Thu Nov 22 00:54:04 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 22 Nov 2001 00:54:04 -0500 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> <3BFC1E16.62F22494@home.net> Message-ID: <3BFC92FC.FEEC75BF@engcorp.com> Chris Barker wrote: > > Peter Hansen wrote: > > The usual approach is simply to profile the > > code and recode the "hot spot" in C. > > This is a problem, not a solution! Most of the code I write is in Python > and it is "fast enough", but not all. And while I end up having to write > only little bits in C, those little bits take me a whole lot longer than > a large bits of Python code. I still see it as a solution, but obviously that's a personal opinion (which, as the "customer", I then impose on the team :-). I consider 95% of all optimization that programmers do to be entirely unnecessary, amounting to nothing more than "faster" and for no other reason than "we need it faster" (which is usually not true). The only acceptable reason for optimization (in this view) is "our customer requires response time of X and we are running at Y" (where Y is slower than X). The only acceptable amount of optimization is up to the point where Y equals X. So far, other than casual improvements as we refactor the code for other reasons, we have not in two years of use of Python actually *needed* to optimize anything. I can readily dissuade anyone in our group from trying very hard to optimize by pointing out that their best efforts would produce only a tiny fraction of the speedup we would see by using C. The fact that rewriting in C is non-trivial just serves to keep us focused back on functionality that *is* required by the customer, rather than constantly answering the siren song of "faster, faster". (Yes, obviously a somewhat obtuse attitude, and no doubt we're not quite that extreme, but I think it makes the point.) But then again, I'm still using a Pentium 233 MMX which is lots fast enough for home use. Those with PCs slower than this might have more credibility arguing for speed-ups in Python than those with the latest 2GHz chips... -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From ajs at ix.netcom.com Wed Nov 7 21:04:12 2001 From: ajs at ix.netcom.com (Arthur Siegel) Date: Wed, 7 Nov 2001 21:04:12 -0500 Subject: Teaching python (programming) to children Message-ID: <000001c1684b$1f152580$a9e1fea9@carol> Jeff Shannon writes - >Except that, the whole idea of CP4E and teaching programming languages to all >(or most) schoolchildren, is that most of these students will *never* become >programmers. They will do other things, but will benefit from having some idea >of how to program a computer. Programmers will still need to know the details >of how a computer works, but they'll pick that up later on (as they learn other >languages, and advanced data structures, and so on). >But to the person who's just trying to write a script to, say, generate a >catalog of all the mp3 ... The problem with this slant is that there is little justification to bring the necessary resources to bear for "teaching programming languages to all (or most) schoolchildren" if the end result is scripts cataloging mp3s. If the end result is a deeper appreciation of math concepts, scientific concepts, etc. - much educational productivity can be leveraged, given students with just some fundamentals under their belt. But I think we are missing the CP4E boat when we focus on one hand on training computer scientists starting at age 12, or, on the other, believing that the educational value of the context of the programming-related curriculum is not of the essence. Art From shalehperry at home.com Sat Nov 3 17:16:50 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sat, 03 Nov 2001 14:16:50 -0800 (PST) Subject: dictionaries and 'in' in 2.1 In-Reply-To: Message-ID: On 03-Nov-2001 John J. Lee wrote: > > The Python 2.1.1 manual, section 2.1.6, says: > > k in a 1 if a has a key k, else 0 > k not in a 0 if a has a key k, else 1 > > Odd, I thought you had to do "key in dict.keys()". From joseph at arbitrary.org Fri Nov 30 12:30:01 2001 From: joseph at arbitrary.org (Joseph Santaniello) Date: Fri, 30 Nov 2001 09:30:01 -0800 Subject: pygettext examples? In-Reply-To: References: Message-ID: Hi Martin, I've gotten my code marked up: (test.py) #!/usr/bin/python2 import gettext def _(msg): return gettext.dgettext("test", msg) def do_stuff() print _("I don't know.") if __name__ == '__main__': do_stuff() I've run pygettext.py and it made a messages.pot file that I translated: msgid "I don't know." msgstr "Jeg vet ikke." And I ran msgfmt -o test.mo messages.pot And test.py runs successfully, but prints: I don't know. Shouldn't it print "Jeg vet ikke." ? And when I want to use multiple languages, how does the .mo file identify itself as being for a particular language? I see the stuff in the gettext docs on Python.org for installing languages, but how do I tell it what's what? Thanks, Joseph On 30 Nov 2001 at 13:48, Martin von Loewis wrote: > Joseph Santaniello writes: > > > Does anyone have a link or some info on how in practical terms to use the > > pygettext module? I've looked at the online docs, and they do a good job > > of explaining in theory how to add multiple languages to an app, but they > > haven't got me to where I need to be... I need some examples and recipes > > to be able to figure it out. > > I think mailman uses gettext these days. > > I'd really recommend that you start using it, and ask any questions > that you have in the process. Here are the rough steps: > > 1. Import or assign _ in your module, e.g. by doing > > import gettext > def _(msg): > return gettext.dgettext("demoapp",msg) > > 2. Mark-up all messages with _ > > 3. Extract the message catalog > > 4. Translate it > > 5. Compile the translations > > 6. Run the application > > If any of these steps, if executed in this order, gives problems, > don't hesitate to ask for further details. > > Regards, > Martin > > From tim.one at home.com Sun Nov 4 01:59:01 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 01:59:01 -0500 Subject: PEP 237; isinstance(i, integer) In-Reply-To: Message-ID: [Mark J] > In PEP 237, Rationale, point 2, it mentions being able to use > "isinstance(i, integer)" which returns true if i is either type int or > long. > > Does anyone know if this is planned for v2.2? I see that it is not > yet implemented in v2.2b1. It is not planned for 2.2. The stuff in "Phase A" is implemented in 2.2b1, and that's all of PEP 237 scheduled for 2.2. From tdelaney at avaya.com Sun Nov 4 19:09:09 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Mon, 5 Nov 2001 11:09:09 +1100 Subject: Exception handling wart in Python Message-ID: > Going back to generic nature of Python's functions, I think, > obviously, > most of the functions in real Python programs are not generic > at all, even > though from the point of view of Python compiler, they are > generic. But > from a higher level point of view, they're not generic. I'll use a concrete example here. Every single function in Python which uses a callback is very generic. It can accept any callable object. These include functions, but include many other objects (class objects, class instances, etc). How would you trace the "exceptions that can be thrown" from a function such as map()? It's callback function can do anything it pleases. And yet, this is an incredibly simple function - almost the equivalent of: def map (callable, seq): l = [] for i in seq: l.append(callable(seq)) return l This is a very common idiom through the Python libraries. Tim Delaney From bit_bucket5 at hotmail.com Thu Nov 15 20:06:54 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Fri, 16 Nov 2001 01:06:54 GMT Subject: Python & cgi on win98--tinyweb problems, etc Message-ID: I'm looking for a solution to this: I want to run a personal web server to run python cgi scripts that interact with a mysql database on a windows 98 pc that's connected to the internet via cable modem. I would rather avoid all security issues and only allow the web server to serve pages to localhost--this setup will be for a single user of the pc, no remote users, etc. Very simple. So, I don't need a fancy web server. Any advice? I have tried apache and it works fine, of course, but I think it's too heavyweight for what I want here. I found tinyweb on the internet, and it looks promising, but I can't get it to run a python cgi script. It will run a test windows executable that I placed in the cgi-bin directory, so it's some problem specific to python and tinyweb. Any clues? The tinyweb documentation is pretty minimal. Any other recommendations for small simple web servers for this project? Many thanks! Chris From logiplexsoftware at earthlink.net Mon Nov 5 12:28:56 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 5 Nov 2001 09:28:56 -0800 Subject: Freeware Python editor In-Reply-To: <3be33e4e.31678681@127.0.0.1> References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <3be33e4e.31678681@127.0.0.1> Message-ID: <01110509285600.18194@logiplex1.logiplex.net> On Friday 02 November 2001 16:44, Fish wrote: > Oleg, kindly go away. You do *nothing* to improve this newsgroup when you > rant about free speech versus free beer. In fact, you *HURT* the group. > > Go away. Oleg was here first. You go away. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From wtanksle at dolphin.openprojects.net Thu Nov 15 20:56:50 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 16 Nov 2001 01:56:50 GMT Subject: Returning values from a lambda References: Message-ID: On Fri, 16 Nov 2001 10:36:06 +1000 (EST), John McMonagle wrote: >I wish to return values from a lambda function which is bound to the >Tkinter button command option. For example, Wait a second. You don't want to return values; you want to modify variables. There's a HUGE difference; lambdas can do the first, but they don't support any of the syntax to do the second. The solution is to not use a lambda. Just define a function which modifies the variables you need, and pass that function's name in place of the lambda. >def operations(a,b): > return a+b, a*b def operations(a,b): x = a+b y = a*b >from Tkinter import * >root = Tk() >btn = Button(root, text='Press Me', command=lambda a=2, b=5: operations(a,b)) >btn.pack() With the function I've defined, things should work. >John -- -William "Billy" Tanksley From robin at stop.spam.alldunn.com Thu Nov 15 22:07:34 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Fri, 16 Nov 2001 03:07:34 GMT Subject: GUI toolkit References: Message-ID: > Platforms would be Linux (primary), Windows, and AIX (didn't see any > prebuilt code for wxPython). wxGTK and wxPython have been built for AIX in the past, but I don't know of its status currently. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From kragen at pobox.com Tue Nov 27 17:18:12 2001 From: kragen at pobox.com (Kragen Sitaker) Date: 27 Nov 2001 17:18:12 -0500 Subject: wxPython: problems with doubleclick References: <9u0um2$b9p93$1@hades.rz.uni-sb.de> Message-ID: <83d7236eor.fsf@panacea.canonical.org> Uwe Schmitt writes: > just a little problem: I use wxFileDialog in order to load data. > When I select a file with a double-click, the second click is buffered, > that is, the file is opened and the buffered click yields painting > in the canvas... > > How can I avoid this behavior ? Is there a possibility to empty > this mouse click buffer ??? I don't think you can avoid this reliably, although I'm not familiar with wxPython. What if the dialog box is completely gone and forgotten by the second click? The click won't have to wait around in any buffers, it'll just be processed. I wonder if the dialog box could be convinced to hang around and discard clicks until two or three times the double-click interval. I'm not sure this is something I'd want. Perhaps saving a file could reset the painting tool to a no-op tool? From prabhu at aero.iitm.ernet.in Sun Nov 4 12:50:54 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 4 Nov 2001 23:20:54 +0530 Subject: Solving Partial Differential equation in Python In-Reply-To: References: <3BE51085.90702@stu.ust.hk> Message-ID: <15333.32766.887100.72400@monster.linux.in> >>>>> "RS" == Roman Suzi writes: RS> Probably, if you could find library like LAPACK for linear RS> algebra and use SWIG to make bindings to C for Python, you RS> will have PDE solving functionality in Python. RS> I am not sure how such library is called, but that is a task RS> for google. If you are seriously interested in numerics, http://www.scipy.org is a must look. prabhu From jeff at ccvcorp.com Mon Nov 19 21:12:04 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Mon, 19 Nov 2001 18:12:04 -0800 Subject: List-of-lists (aka array) mystery References: <4f49f3e8.0111181832.7162be1b@posting.google.com> Message-ID: <3BF9BBF4.77783EFE@ccvcorp.com> aardvark wrote: > Hi everyone > [snip discussion of list-of-list behaviors] > > Why is this? It would seem that multiplying the result of the range() > function twice returns pointers to a single list rather than discrete > lists. This is, indeed, exactly the case, and is deliberate behavior. It has nothing to do with range(), either, and your example would work exactly the same if you replaced your range(-1,0) with a simple [-1]. It's just the way that multiplication works on lists -- '[object] * n' creates a list of n references to object, not n copies of object. The distinction is minimal, though, unless object is mutable (like, say, a list, dict, or class instance). > Is there a better way to initialize lists-of-lists? Should I be > going about this differently? Two possibilities-- x = [] for i in range(3): x.append( [-1] * 3) x = [ [ inner] * 3 for inner in ( [-1] * 3)] These both work by constructing a separate (though equal) inner list each time. Jeff Shannon Technician/Programmer Credit International From teg at redhat.com Fri Nov 30 11:17:53 2001 From: teg at redhat.com (Trond Eivind =?iso-8859-1?q?Glomsr=F8d?=) Date: 30 Nov 2001 11:17:53 -0500 Subject: pygettext examples? References: Message-ID: Joseph Santaniello writes: > Does anyone have a link or some info on how in practical terms to use the > pygettext module? I've looked at the online docs, and they do a good job > of explaining in theory how to add multiple languages to an app, but they > haven't got me to where I need to be... I need some examples and recipes > to be able to figure it out. Take a look at various python apps in Red Hat Linux - like anaconda, dateconfig, redhat-config-network and more. -- Trond Eivind Glomsr?d Red Hat, Inc. From kuran42 at yahoo.com Sat Nov 10 07:17:18 2001 From: kuran42 at yahoo.com (Jp Calderone) Date: Sat, 10 Nov 2001 07:17:18 -0500 Subject: Simple Thread Program not working (Newbie: Python) References: Message-ID: <3BED1ACE.8030408@yahoo.com> Take a close look at your __init__ declarations :) karthik Guru wrote: > hello all, > Am not sure why am getting the errors at the specified place ( I have pasted > the error on those lines) > Can someone help. > --------------- > > import threading, time > > class Test: > def __init__(self): > self.data = "start" > def change(self,data): > self.data = data > def __str__(self): > return self.data > def __repr__(self): > return self.data > > class ChangeThread(threading.Thread): > def __init_(self,val,a): > self.ref = a > threading.Thread.__init__(None,self) > def run(self): > count = 1 > while 1: > self.ref.change(s,count) # AttributeError: ChangeThread instance > has no attribute 'ref'..this is the error. > count+=1 > time.sleep(1) > > class WatchThread(threading.Thread): > def __init_(self,val,a): > self.ref = a > threading.Thread.__init__(None,self) > def run(self): > while 1: > print 'changed data : ' + self.ref.data # AttributeError: > ChangeThread instance has no attribute 'ref' > time.sleep(3) > > > def execute(): > print 'Start execute' > t = Test() > t1 = WatchThread(None,t) > t2 = WatchThread(None,t) > t3 = WatchThread(None,t) > t1.start() > t2.start() > t3.start() > time.sleep(2) > > t4 = ChangeThread(None,t) > t4.start() > > if __name__ == '__main__': > execute() > > > > This is the trace: > > Start execute > Exception in thread Thread-1: > Traceback (most recent call last): > File "d:\python21\lib\threading.py", line 378, in __bootstrap > self.run() > File "thread1.py", line 30, in run > print 'changed data : ' + self.ref.data > AttributeError: WatchThread instance has no attribute 'ref' > > Exception in thread Thread-2: > Traceback (most recent call last): > File "d:\python21\lib\threading.py", line 378, in __bootstrap > self.run() > File "thread1.py", line 30, in run > print 'changed data : ' + self.ref.data > AttributeError: WatchThread instance has no attribute 'ref' > > Exception in thread Thread-3: > Traceback (most recent call last): > File "d:\python21\lib\threading.py", line 378, in __bootstrap > self.run() > File "thread1.py", line 30, in run > print 'changed data : ' + self.ref.data > AttributeError: WatchThread instance has no attribute 'ref' > > Exception in thread Thread-4: > Traceback (most recent call last): > File "d:\python21\lib\threading.py", line 378, in __bootstrap > self.run() > File "thread1.py", line 20, in run > self.ref.change(s,count) > AttributeError: ChangeThread instance has no attribute 'ref' > > > > From kevinperson at topicbox.com Fri Nov 2 03:49:37 2001 From: kevinperson at topicbox.com (Kevin Turner) Date: Fri, 2 Nov 2001 00:49:37 -0800 Subject: eval() of a __name__ Message-ID: <20011102004937.A3934@troglodyte.menefee> I walked through compile and eval'd myself, wond'red if I had a name. I looked at my __name__tag and saw it said "__builtin__", a problem apparent quite plain: You looked for a __name__ in namespaces local; Failing to locate, you tried going global; Found there some __builtins__, a module named __builtin__, in which you found me a __name__. No suprise that a __name__ in a module for built-ins should be the string "__builtin__" when read. But I for one knew that that was not *my* name -- what should they call me instead? I consulted my friends, the __str__ and the __repr__; recommending brackets both ends. Between them I'd put maybe a classname, an identifier or two. A key '__name__' in globals, a value of "", with this I was sure I was through. (...Phew!) But as I did use it I grew more confus?d, my imports behaving quite strange -- The keys to the values in system dot modules had been given all the wrong names! 'import this.that' became " <9terl6$s3m$1@peabody.colorado.edu> Message-ID: Fernando P?rez wrote in news:9terl6$s3m$1 at peabody.colorado.edu: > Laurent Pointal wrote: > >> GUI in Java >> | CORBA ORB for Java (OpenORB or other) >> | >> | >> | CORBA ORB for Python (omniORBpy) >> | >> scripting and processing in Python > > Just curious: why the extra Java layers? Naively I'd have the > impression that from within python alone you can easily do the top part > of your diagram without needing Java. Yes, we have a working wxPython interface on an experiment - but directly connected to the multithreaded experiment scripts. We have already CORBA between Python experiment scripts and commercial plotting application Igor Pro. > One more language adds overhead > both of execution and development/maintenance. I'm sure you guys have > very good reasons for what you're doing but I'm curious. Is it that the > currently available gui toolkits are that inferior to swing to justify > the extra complexity? Or do you have other reasons? Several reason: -Its not for realtime video or things needing high bandwidth, so execution overhead is not a problem. -Java RAD tools, especially for GUI building, are good and make GUI development times shorter. We think of building base interface objects as beans, and let advanced users construct their experiment interfaces with these beans. We will need a CORBA connection bean too. -In respect to Sun action (and money...) around Java, the growth of tools is quicker than for Python. -Java is THE language used in many computer learning classes, it will be more easy to find Java developers than Python ones (I know, Python is really easy to learn). -Using CORBA for remote control of our experiment scripts: these are for experiments running 24h/24, and scientific experiment managers would like to be able to operate on the experiment from home to be able to help a user without having to move - when possible. It will also be possible to have a small experiment status running on desktop computer of experiment managers or users (applets & Co). But we will continue to use Python for experiment scripts, where it fit really better than Java (IMHO). And C/C++ when needing speed with instrument devices :-) Different tools for different purpose, and connect them together. Currently I work on the Python side for controling experiments in a common reusable framework 'pyexp' - the first priority before the "clickodrome", we must have running experiments with that around march 2002. We recently get a new coworker which has experiment with Java, and I hope we use his knowledge when doing GUI and beans. > cheers, > > f. A+ Laurent. From glchapman at earthlink.net Tue Nov 27 14:41:30 2001 From: glchapman at earthlink.net (Greg Chapman) Date: Tue, 27 Nov 2001 19:41:30 GMT Subject: question: metaclass and C - a new general style References: <3c02343d@netnews.web.de> Message-ID: <6vq70u8leoeqabp1cgn7kile6mgdki2c66@4ax.com> On 26 Nov 2001 13:23:17 +0200, Jens Gelhaar wrote: >I am working serveral years with Python, but I am new to the C stuff. I need an >hint, to change the source code to get the following behaviour: > When I compile a module with an class in it, I would like to call a special >function: __metainit__ after the class has been compiled. The calling parameters >should the be the class itself and the enviroment one step up. Rather than changing the source code, I recommend looking at test_descr.py in the 2.2 beta. The __new__ method of the various metaclasses demonstrated there seems to me to be essentially what you are calling __metainit__. At any rate, it looks like it should be possible to use a metaclass __new__ (or __init__ for that matter) to accomplish what you described. --- Greg Chapman From amyk at foretec.com Tue Nov 13 15:14:49 2001 From: amyk at foretec.com (Amy Katherine) Date: Tue, 13 Nov 2001 15:14:49 -0500 Subject: Python 10 Registration Opens Online Message-ID: <5.1.0.14.2.20011113124507.00acaac0@colossus.foretec.com> Foretec Seminars invites you to be a part of the action at the Tenth International Python Conference! When: February 4th through 7th, 2002 Where: The Hilton Alexandria Mark Center in Alexandria, Virginia Save $$$ with Special Early Bird Registration Rates starting November 12th, 2001 and good when you register online before January, 7th 2002 To Register Today, Visit: http://www.python10.org/p10-regInfo.html For Further Details, Visit: http://www.python10.org From peter at engcorp.com Tue Nov 13 20:39:11 2001 From: peter at engcorp.com (Peter Hansen) Date: Tue, 13 Nov 2001 20:39:11 -0500 Subject: Filecount References: <43246c37.0111131305.105e9fe3@posting.google.com> Message-ID: <3BF1CB3F.D91EE1CD@engcorp.com> Dumbledore wrote: > > Is it possible to use a Jpython script to count files in a certain directory? > If yes, how is the script look like? >>> print len(filter(os.path.isfile, os.listdir('.'))) 24 Only works in the current directory as written... note that the list returned by listdir() doesn't include path information, so you'd have to add that to improve it. -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From jriveramerla at yahoo.com Mon Nov 12 19:10:24 2001 From: jriveramerla at yahoo.com (Jose Rivera) Date: 12 Nov 2001 16:10:24 -0800 Subject: ZODBCDA Error...python15.dll not found!! Message-ID: <11e94203.0111121610.63995fae@posting.google.com> Hi... I just installed ZOPE 2.4.2 on NT, and works great, I downloaded ZODBCDA unzipped on "c:\program files\ZopeTest\" and when I start Zope reports an error: Unable to Locate Python15.dll !!! I think that this DLL it's old... because Python 2.1 it's the newer version... So.. please tell me whats wrong.... please... Thanks... From dale at riverhall.NOTHANKS.co.uk Thu Nov 15 13:08:56 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Thu, 15 Nov 2001 18:08:56 +0000 Subject: Inter-Thread Communication References: <4go7vtc8dqm8qsfq8ttv95bopidscj56l2@4ax.com> <3bf3fcfa$1@brateggebdc5.br-automation.co.at> Message-ID: <4018vt4s27jv3ranig9apbeonfjsgp5ke1@4ax.com> Thanks. That should do the job nicely. A wrapper class to make it two way will help, I think. I wonder how many more standard modules I have no clue about. -- Dale Strickland-Clark Riverhall Systems Ltd From lac at strakt.com Tue Nov 13 12:23:24 2001 From: lac at strakt.com (Laura Creighton) Date: Tue, 13 Nov 2001 18:23:24 +0100 Subject: Somebody just wanted to run wxPython asynchronously Message-ID: <200111131723.fADHNOlF016460@ratthing-b246.strakt.com> and I just went and deleted that piece of mail because I am an idiot, so I can't put this in the correct thread. And I have no idea who it was, etc. but use this: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/82965 change the Tkinter references to your equivalent wxPython ones. There is nothing in this that requires Tkinter. Laura Creighton From skip at pobox.com Thu Nov 29 18:23:23 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 29 Nov 2001 17:23:23 -0600 Subject: Whatever happened to String Interpolation? In-Reply-To: <9u6dbn$nsj$1@peabody.colorado.edu> References: <9u6dbn$nsj$1@peabody.colorado.edu> Message-ID: <15366.50027.50925.750093@beluga.mojam.com> fp> I'm a big fan of Ka-Ping Yee's Itpl module (which allows strings of fp> the form 'the value of x is $x', but I often find myself not using fp> it so as not to add an extra dependency to a program I want to keep fp> small. I know it's a little more verbose, but what's wrong with 'the value of x is %(x)s' % locals() (or something similar? As has been demonstrated recently on the list, you can easily create a dict-like object that allows you to interpolate complex expressions as well. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From prabhu at aero.iitm.ernet.in Tue Nov 20 09:17:19 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Tue, 20 Nov 2001 19:47:19 +0530 Subject: Still on python GUI toolkit In-Reply-To: References: Message-ID: <15354.26095.184491.577376@monster.linux.in> >>>>> "LF" == Luca Fini writes: LF> I'm trying to make a sound decision of which GUI toolkit to LF> use for a new software project (it is the control and [snip] LF> After browsing through the various comparisons I could find LF> around I stripped down the list to three of them: Tkinter, LF> wxWindows, PyQt. One big advantage of Tkinter over almost any other toolkit is that you can use/script an application written with it directly from the Python interpreter on different platforms. This can be *very* powerful. To do this with wxPython you have to do something like what scipy's gui_thread does which is not a clean enough solution. I have no idea about pyQt. LF> 3. wxWindows and PyQt are richer than Tkinter in that they LF> both provide more complex widgets and more control on many LF> aspects. I've also the feeling that PyQt/wxWindows True, but Tkinter is very basic. To look at *much* nicer controls/widgets that are much better looking I'd urge you to look at Tix. http://tix.sourceforge.net I myself found this only recently - but it looks _really_ nice and IIRC is part of Python >= 2.1. So maybe you should look at this too. prabhu From kragen at canonical.org Tue Nov 20 06:10:39 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 20 Nov 2001 06:10:39 -0500 Subject: [Python-Dev] Re: PEP 276 Simple Iterator for ints References: <15347.37907.247581.153829@beluga.mojam.com> Message-ID: <83d72du28g.fsf@panacea.canonical.org> "M.-A. Lemburg" writes: > Skip Montanaro wrote: > > * it should cause no backward compatibility issues (you can't put "..." > > in a list now, can you? NumPy?) You can't, no. > Here's a slightly different approach which works now (= it doesn't > even require a PEP :-): > > With the new iterator support in Python, it should be > easily possible to write a module which exposes a singleton > infinite sequence called e.g. "integers". Then, using the slicing > notion we already have in Python, you could write: > > for i in integers[0,...,10]: > print i I don't know what the new iterator support in Python is, but here's an implementation of your suggested syntax in pure, backward-compatible Python. I really don't like naming the range inclusively, but that's pretty much what this syntax requires. # Iterate.py # There's a PEP on better ways of writing integer sequences. e.g. [0, # .. 10] or [0, 2, .. 10]. This module gives you a variant of that # syntax proposed by M.-A. Lemburg . class RangeClass: def __getitem__(self, slice): if type(slice) is not type((1, 2, 3)): raise TypeError, 'Range syntax %s wrong' % slice if len(slice) not in (3, 4) or slice[-2] is not Ellipsis: raise TypeError, 'Range syntax %s wrong' % slice start = slice[0] stop = slice[-1] if len(slice) == 3 and start <= stop: step = 1 elif len(slice) == 3 and start > stop: step = -1 else: step = slice[1] - start stop = stop + step return xrange(start, stop, step) Range = RangeClass() From fredrik at pythonware.com Wed Nov 7 02:30:17 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 07:30:17 GMT Subject: count in 'for ... in ...' References: <9s90mr$osk$00$1@news.t-online.com> <9s91c3$94mgs$1@hades.rz.uni-sb.de> <9s91je$2o0$01$1@news.t-online.com> Message-ID: David Bolen wrote: > > > | for i in range(len(my_list)): > > > | print i,". ",my_list[i] > > > > > What about the following ? > > > > > > idx=0 > > > for s in my_list: > > > print idx,".",s > > > idx+=1 > > I'm not sure there's that much of a difference in this case the former is about 10% faster, in most typical cases. > but the second form is arguably more readable since the primary > function (iterating over the list) is more clearly stated, and the > use of the index variable is clear. which is exactly why I prefer to use the latter myself. (but usually spell it out as "idx=idx+1", which isn't only faster, but also runs under 1.5.2) From aeoo at myspamrealbox.com Sat Nov 3 12:30:35 2001 From: aeoo at myspamrealbox.com (Leo Lipelis) Date: Sat, 03 Nov 2001 12:30:35 -0500 Subject: Exception handling wart in Python References: Message-ID: On Thu, 01 Nov 2001 19:35:46 -0500, Leo Lipelis wrote: > Hi Pythoneers, [snip] Thanks to all who replied to my posts. As a result of this, I hope that I was able to highlight an important (at least to me) weakness in the way exceptions are treated in Python. I have, in turn, learned a few things as well. For one, the generic nature of Python functions makes tracing exceptions more difficult (but not impossible). Another thing I have realized, is that in Java the process of tracing exceptions is made much easier by the fact that you either have to catch it, or declare it in "throws" statement. That means Java compiler doesn't have to search deep. I think this difficulty is much more significant than the generic nature of Python's functions, because it would force the exception checker to trace deeply, and thus would become time and memory consuming. Going back to generic nature of Python's functions, I think, obviously, most of the functions in real Python programs are not generic at all, even though from the point of view of Python compiler, they are generic. But from a higher level point of view, they're not generic. It's possible to use some heuristics or assumptions to distinguish generics from non-generics. One heuristic that could be attempted is to cound all the methods used by all class objects, and then determine the 5-10% of the most often used methods. For example, many objects have __str__ method, and so on. This way you can determine (in a fuzzy way) all the methods that are applicable for generic programming. Obviously it's not perfect, but it's better than nothing, and it might actually work quite well. Another thing is to assume that all class object methods are non-generic and all module methods are generic. This is a bit artificial and would force the programmer who wants to use exception checker to put more methods in classes. Yet another thing that could be done is to not guarantee the same results for one function, but rather make the results depend on how it's used. Since this tool is only a *warning* tool and since it's not meant to force anything, no harm is done. That way, a generic function will get different warnings depending on how it's used. Because the exception handling is not *forced*, this can work *very well*. Then, the exception checker tool could get some hints to turn off warnings for some functions that are generic and that are library functions used in many places. Another thing that could also be done is not to generate any warnings for any library functions, including standard Python libs and everything in site-packages. Thanks again to everyone. I now consider this thread closed to myself. If you want to discuss further, please note that I won't be reading it and I won't be able to reply. From plakal at cs.wisc.edu Mon Nov 12 09:06:43 2001 From: plakal at cs.wisc.edu (Manoj Plakal) Date: Mon, 12 Nov 2001 08:06:43 -0600 Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: <3BEFD773.3080204@cs.wisc.edu> Marco Antoniotti wrote: > "Morten W. Petersen" writes: > Apart from the existence of very good native compilers, there are a > number of nice features - all standard - that allow you to use Common > Lisp as a "language kit": something very few other language are good at. > > Take for example one of the latest additions to Python: list > comprehension. > > This is essentially incorporating regular set-theoretic notation in > the language. I.e. to have notation that allows you to say things like > > {x | even(x) /\ x >= 0 /\ x <= 100} > > (the set of "numbers" between 0 and 100 - assuming integers or rational, > this is a finite, enumerable set). > > To get this kind of notation into Python (alas a similar one), AFAIU, > the (1) parser had to be modified, and (2) the interpreter had to be > modified as well. This are not things that (AFAIK) where done in > Python itself. > > In Common Lisp you just changed the "readtable" to recognize the > special nature of the characters #\{, #\}, #\[, and #\] (think of > Emacs and what it does with characters) and you write a couple of > macros. The code is all written in CL and the above example may be > rendered as > > {x / x in (range 0 100) / (evenp x)} > > This effectively constructs a list of the even integers. All of this is > all CL and it is all compiled down to native code. (The above expression > "expands" into a LOOP, which is happily compiled by the CL system. The > code runs on all CL implementations and it can be used to shorten your > programs. I'm curious (I haven't done much programming in Lisp). Doesn't this make CL programs harder to read? I can see why a programmer would love it since it allows you to define your own little language that fits your way of thinking and a problem domain. I've heard of Lisp programmers going gaga over the macro facility. But isn't it going to be difficult for someone other than the original programmer to come along and try to figure out what's going on? They're going to have to absorb the macro definitions before trying to read even a small part of the code that uses these macros. A similar thing happens when people go nuts with the C preprocessor or C++ operator overloading. You get either innocent-looking code that actually has very different semantics than what you thought, or completely baroque code which can only be understood by reading a whole lot of other code that is defining macros and stuff. How much of a problem is this in practice for CL? Manoj From ws-news at gmx.at Tue Nov 20 05:08:00 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Tue, 20 Nov 2001 11:08:00 +0100 Subject: Can python do this? References: <3BF976C9.49AE31AB@hotmail.com> Message-ID: <3bfa2c45$1@brateggebdc5.br-automation.co.at> Hi, yes this is very possible. And there are a lot of ways to do so. You can use exec and eval to run code or evaluate expressions in your current python context. The Python C API also allows you to run arbitrary code. There are also ready made solutions available for running Python code through the web. I. e. you can use Python as language for ASP pages when you have the windows extensions installed. Zope also provides a lot of possibilities to run Python code (Scripts, external methods, Products - in order of complexity ;-) hth Werner "Ken" wrote in message news:3BF976C9.49AE31AB at hotmail.com... > Is it possible to have a program running (either C or Python) and have > that program dynamically load Python functions while its executing? > > The idea is to have a server running that users can connect to, and be > able to change functionality without having to restart the executable. > Objects/variables loaded into memory (ie. who's connected) would > also need to be saved. > > If it is possible, would it be terribly difficult? > From chrishbarker at home.net Tue Nov 20 19:14:15 2001 From: chrishbarker at home.net (Chris Barker) Date: Tue, 20 Nov 2001 16:14:15 -0800 Subject: Python to compile to Java-bytecode References: <61f6bfa8.0111200558.2f52ad44@posting.google.com> <9te18701qf8@drn.newsguy.com> Message-ID: <3BFAF1D7.FF234D7E@home.net> Armin Steinhoff wrote: > Stupid question ... and why is for C-Python not possible to compile it to C++ ?? > > Armin It is. See Py2C. Unfortunately, I don't think it has seen development for a while, and some would argue that therre is not much point anyway. The point of Jython is to be able to run code on a JVM (and to be able to interact with JAVA code). That doesn't apply to CPython. -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From chrishbarker at home.net Wed Nov 21 16:35:18 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 21 Nov 2001 13:35:18 -0800 Subject: Python execution speed References: <3BF9AF6B.6329BDF5@engcorp.com> Message-ID: <3BFC1E16.62F22494@home.net> Peter Hansen wrote: > The usual approach is simply to profile the > code and recode the "hot spot" in C. This is a problem, not a solution! Most of the code I write is in Python and it is "fast enough", but not all. And while I end up having to write only little bits in C, those little bits take me a whole lot longer than a large bits of Python code. Part of the problem for me is that I am not very fluent in C, but that is the point, you should not have to be fluent in C to use Python effectively. I also now have to distribute a compiled library with my code, or presume all my users have compilers. Given the other options, I still think Python is worth it, but it would still be a much greater language if you could get it to run as fast as C! Frankly, if the organization I work for was at all open to it, I'd give LISP shot: the dynamiscm and the speed...pretty tempting! BTW, if it wasn't for NumPy, I could only use Python for little scripts, it would be just too slow for most of what I do (A lot of numerics). -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From tdelaney at avaya.com Thu Nov 8 22:13:45 2001 From: tdelaney at avaya.com (Delaney, Timothy) Date: Fri, 9 Nov 2001 14:13:45 +1100 Subject: C-extension in Python -- returning results Message-ID: > From: deoradh at yahoo.com [mailto:deoradh at yahoo.com] > > deoradh at yahoo.com (Keith Farmer) wrote in message > news:... > > for (j = 1; j < 11; j++) > > tpow[j] = tpow[j-1] * t0; /* tpow[j] = > t0^j = tpow[j-1] * t0 */ > > sumsX[j] += tpow[j]; /* sumsX[j] = Sum(t0^j) */ > > I misdiagnosed where the error was. Rule Zero of C-Programming: It's > Not Python -- Remember Braces. In all C-style languages (C/C++/Java, etc) my fingers automatically insert the braces. The keystrokes are something like ... (non-printable keys delimited by <>) for (int i = 0; i < ...; i++){}... Don't even think about it ... the braces are *always* there by the time I start writing the enclosed code, properly indented. Tim Delaney From patricg at fys.uio.no Thu Nov 8 05:55:04 2001 From: patricg at fys.uio.no (Patrick Guio) Date: Thu, 8 Nov 2001 11:55:04 +0100 Subject: HOWTO execute an external program? Message-ID: Dear all, I would like to use python as a scripting language to run my simulation code. I would like to know how do I do that ? Is there a way to evaluate how long it took to run the command (make a kind of summary/log of the run)? Sincerely Patrick From tomdavies at optushome.com.au Wed Nov 28 03:16:40 2001 From: tomdavies at optushome.com.au (Tom Davies) Date: Wed, 28 Nov 2001 19:16:40 +1100 Subject: a question of using regular expression References: Message-ID: <3c049c48$0$13482$afc38c87@news.optusnet.com.au> "Stephen" wrote in message news:b551ef53.0111272346.68222906 at posting.google.com... > I am now using org.apache.regexp as the regular expression library in > my Java code. I meet a difficulty in implementating the following > regular expression, I don't know how to describe it (because of my > poor English), so I take an example: > > String sText0 = "good morning!"; > String sText1 = "morning! you are very good!"; > > RE r = new RE("???????????"); // I have no idea in this > > actually, I just want to get the string which has string "good" at the > start. Therefore, in this case, sText0 can be got only. How can I do > this? Thanks! What is it about that string which makes it match? If you want 'all strings which start with "good"', then something like: [start of line]good[any character][0 or more repetitions] would work. In java.util.regex this would be "^good.*" Tom From kalipygian at hotmail.com Tue Nov 20 19:32:54 2001 From: kalipygian at hotmail.com (Kali Kim) Date: Wed, 21 Nov 2001 09:32:54 +0900 Subject: Getting the class of a method in Python 2.2 (semantic change from 2.1) Message-ID: class A: def aaa(self): pass class B(A): def bbb(self): pass def whosemethod(method): return method.im_class.__name__ With Python 2.1, >>> whosemethod(B.bbb) 'B' >>> whosemethod(B.aaa) 'A' But with Python 2.2, >>> whosemethod(B.bbb) 'B' >>> whosemethod(B.aaa) 'B' I want to know where B.aaa is getting inherited from, but can't find a *easy and obvious* (tm) way with Python 2.2. Can anyone help me? From greg at cosc.canterbury.ac.nz Thu Nov 8 22:37:18 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Fri, 09 Nov 2001 16:37:18 +1300 Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <3BEB4F6E.A173C05D@cosc.canterbury.ac.nz> Rainer Deyke wrote: > > Seriously, I don't see how this is worse or less Pythonic than, say, 'for > line in file'. It makes sense to think of files as containing lines, but it's stretching things to think of the integer 10 somehow "containing" the integers 0 to 9. -- Greg Ewing, Computer Science Dept, University of Canterbury, Christchurch, New Zealand To get my email address, please visit my web page: http://www.cosc.canterbury.ac.nz/~greg From phr-n2001d at nightsong.com Sat Nov 3 02:33:11 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 02 Nov 2001 23:33:11 -0800 Subject: http session module References: <9s05ru$br7$1@news1.ucsd.edu> Message-ID: <7x4roc2ts8.fsf@ruckus.brouhaha.com> Jeff Davis writes: > Can someone reccommend a good http session module? I would > prefer a stable, fairly scalable session module (one I downloaded just > used pickle, which seems like it wouldn't work for concurrent access). I > know there are a couple out there, but the "Vaults of Parnassus" didn't > have many such modules. > > I am planning to use mod_python, so if there is some trick I can > do with persistant memory, that would also be helpful. It's not such a simple thing to do with apache. You have to use a shared memory scheme, or something like "shelve" to store session info on disk (but you need a concurrent database like Sleepycat dbm for that). See http://mambo.peabody.jhu.edu/omr/omi/source/shm_source/shm.html for a shared memory module. This is the first thing I'd try if I wanted to implement sessions. If you just want a little bit of per-session info, you can put it in browser cookies and just send it back to the server on every http request. This is the simplest and most scalable method since it works seamlessly across load balancers, failover between servers, etc. Note, Do NOT serialize the session with pickle if you use cookies (it creates a security hole). Use marshal or some other method instead. Finally, you could look at some of the fancier application shells, like Twisted Matrix, to see how they take care of these things. From sabren at manifestation.com Thu Nov 15 15:46:43 2001 From: sabren at manifestation.com (Michal Wallace) Date: Thu, 15 Nov 2001 15:46:43 -0500 (EST) Subject: PIDDLE/SPING?? In-Reply-To: <7d38vt0br1abnvg30j9lettstbq6lh5k89@4ax.com> Message-ID: On Thu, 15 Nov 2001, Richard West wrote: > I was looking into PIDDLE today and it seems the only web > address I could find is a little out dated: > > http://piddle.sourceforge.net/ ... > Is this a dead project? Are there any alternative > competing projects? Does anyone know if this will work > bug free under Python 2.1 or 2.2, and the latest version > of PIL? Or do I just not have the latest web address? Hey Rich, I wrote an aritcle about piddle for O'Reilly a few months ago: http://www.onlamp.com/pub/a/python/2001/05/31/piddle.html I contacted the current maintainer about a patch described in the article, and he mentioned that he was pretty swamped with school. Haven't talked to him since though. I use piddle with python 2.0 and PIL 1.1.1 and haven't had any problems. Cheers, - Michal http://www.sabren.net/ sabren at manifestation.com ------------------------------------------------------------ Give your ideas the perfect home: http://www.cornerhost.com/ cvs - weblogs - php - linux shell - perl/python/cgi - java ------------------------------------------------------------ From logiplexsoftware at earthlink.net Mon Nov 5 15:27:21 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 5 Nov 2001 12:27:21 -0800 Subject: Freeware Python editor In-Reply-To: <3be786c8.5732843@127.0.0.1> References: <81F59ACE9063D511A5BB0002B328D226511601@il93exm20.css.mot.com> <9s1j3a$10c61g$1@ID-11957.news.dfncis.de> <3be786c8.5732843@127.0.0.1> Message-ID: <01110512272105.18247@logiplex1.logiplex.net> On Sunday 04 November 2001 10:24, Fish wrote: > >"Fish" wrote in message > > news:3be7390b.3387240 at 127.0.0.1... > > > >> On Sat, 3 Nov 2001 14:08:42 +0300, Oleg Broytmann wrote: > >> >On Sat, Nov 03, 2001 at 12:44:13AM +0000, Fish wrote: > >> >> Oleg, kindly go away. You do *nothing* to improve this newsgroup > >> >> when As an interesting aside, I notice that you've posted to this list 6 times, (in the 7000+ messages I have archived) and every one of these 6 messages is in regard to the "free speech vs free software" debate. Oleg at least contributes useful knowledge in other threads, so who is really doing "nothing" to improve this newsgroup? -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From michael at stroeder.com Fri Nov 30 03:27:46 2001 From: michael at stroeder.com (Michael =?iso-8859-1?Q?Str=F6der?=) Date: Fri, 30 Nov 2001 09:27:46 +0100 Subject: M2Crypto, LDAP and python References: Message-ID: <3C074302.47A6F894@stroeder.com> Stuffed Fried Red Pepper wrote: > > Is there an LDAP client library for python? http://python-ldap.sf.net (current CVS version not usable under Win32 since OpenLDAP 2 libs not available on Windows). Ciao, Michael. From tjreedy at home.com Tue Nov 13 11:55:48 2001 From: tjreedy at home.com (Terry Reedy) Date: Tue, 13 Nov 2001 16:55:48 GMT Subject: Proving optimized function is still correct References: <9sq46c$o93$1@news.carib-link.net> Message-ID: "Terry Reedy" wrote in message news:ct2I7.212078$5A3.78366686 at news1.rdc2.pa.home.com... > > wrote in message > news:9sq46c$o93$1 at news.carib-link.net... > > I gave a colleague of mine a Python function to optimise: ... > description of what your function computes: the number of ways of > distributing n indistinguishable items among m labelled bins, with > bins possibly left empty, and where 'labelled' means that each > permutation among bins is counted separately. ... > The following is a more direct recursion: ... > def d(m,n): > if m == 1 or n == 0: return 1 > cnt = 0 > for i in range(n+1): cnt = cnt + d(m-1,n-i) # put i items in 1 bin and distribute rest > return cnt After posting above, I realized that d(m,n) == sum(i=0,n; d(m-1, n-i)) == sum(i=n,0; d(m-1,n-i)) == sum(i=0,n; d(m-1,i)) and d(m,n-1) = = sum(i=0,n-1; d(m-1,i)) imply the simpler recursion d(m,n) = d(m,n-1) + d(m-1,n), with easily proven solution (n+m-1)!/n!(m-1)!. A recursive implementation like def d(m,n): return (m == 1 or n == 0) and 1 or d(m,n-1) + d(m-1,n) is inefficient in the same way as recursive fibonacci def fib(n): return n <= 1 and 1 or fib(n-2) + fib(n-1) in that both needlessly recompute the function for 'lower' values of the parameter(s). The following iterative solution computes each function value only once. def d2(m,n): if m == 1 or n == 0: return 1 temp = (n+1) * [1] # change 1 to 1L to force long computation to avoid overflow for i in range(2,m+1): for ni in range(1,n+1): temp[ni] = temp[ni-1] + temp[ni] return temp[n] >>> d2(6,4) 126 Unlike the factorial formula, this does not overflow until the answer does. If one needed to call this function many times for small enough values of m and n, one could modify d2 to save all computed values in a table for later lookup. Terry J. Reedy From emile at fenx.com Wed Nov 14 12:06:16 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 14 Nov 2001 09:06:16 -0800 Subject: sending a function on the fly? References: <3bf2a06f$1@207.229.64.20> Message-ID: <9su8ka$15c0qr$1@ID-11957.news.dfncis.de> "Peter Bismuti" wrote in message news:3bf2a06f$1 at 207.229.64.20... > > In ECMAscript you can send a function as an argument that is defined on the > fly such as: > > callMyFunction( new Function(){ blah blah }) > > Something like that. Here the function has not been named and was not > defined outside of the call. Can this be done in Python? > Simple one-line functions are created using lambda. If it gets more involved, try currying from class instances or functions. -- Emile van Sebille emile at fenx.com --------- From phr-n2001d at nightsong.com Thu Nov 8 17:50:43 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 08 Nov 2001 14:50:43 -0800 Subject: Shelve problem: why so big? References: <9sdol4$2te$1@samos.cs.uu.nl> <9se1du$6eg$1@samos.cs.uu.nl> Message-ID: <7xbsicev24.fsf@ruckus.brouhaha.com> geert at cs.uu.nl (Geert-Jan Giezeman) writes: > This FAQ advises to move to a newer version of the Berkeley DB library. > How do I know which version I use? How do I replace it with a newer? > (I installed the standard Python 2.1 distribution for Windows). www.sleepycat.com From gbcs1978 at hotmail.com Tue Nov 6 12:11:57 2001 From: gbcs1978 at hotmail.com (Glauco Silva) Date: Tue, 6 Nov 2001 15:11:57 -0200 Subject: help - Create dll Message-ID: Hi , How can i create a dll file ( C dynamic library) from windows to be imported by python . Thank you Glauco -------------- next part -------------- An HTML attachment was scrubbed... URL: From boud at rempt.xs4all.nl Tue Nov 20 12:39:10 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 20 Nov 2001 17:39:10 GMT Subject: Still on python GUI toolkit References: <20011120.161256.933110197.8583@ucd.ienospam> Message-ID: <9te4fu$crl$1@news1.xs4all.nl> Aidan Finn wrote: > In article , "Tyler > Eaves" wrote: >> Unless you used Tkinter's canvas widget, this wasn't a fair test. > I haven't used any GUI toolkit other than Tkinter. Is the canvas widget > in Tkinter significantly better/worse than those in other toolkits? There is one area where the Tkinter canvas is more capable than the Qt canvas, and that's in that it has a multi-line text item. Qt's QCanvasText is single-line. On the other hand Qt canvas items can be animated and automated. I don't know whether Tkinter allows the multiple views on the same canvas that Qt allows. By the way, I don't think that a canvas, whether Q or Tk would be the solution for a data visualisation problem that involves pixel-plotting. I'd use Gerard Vermeulen's PyQwt for that, which neatly interfaces with numpy. (http://gerard.vermeulen.free.fr/ and http://stage.linuxports.com/projects/pyqt/a8739.htm, still without the screenshots) -- Boudewijn Rempt | http://www.valdyas.org From pmai at acm.org Fri Nov 16 10:28:23 2001 From: pmai at acm.org (Pierre R. Mai) Date: 16 Nov 2001 16:28:23 +0100 Subject: Benefits of moving from Python to Common Lisp? References: <8827e15d.0111132137.5beb1809@posting.google.com> <3BF2E82C.D0FB6320@removeme.gst.com> <7xy9l9ne1b.fsf@ruckus.brouhaha.com> <7xhervy3v9.fsf@ruckus.brouhaha.com> <4nofm2bzbm.fsf@rtp.ericsson.se> Message-ID: <87bsi2d9bc.fsf@orion.bln.pmsf.de> Raymond Toy writes: > >>>>> "Daniel" == Daniel Lakeland writes: > > >> CMUCL uses different GC's on different platforms? Or do you mean you > >> were using CMUCL on one box and a different CL on the other? > > Daniel> Yes CMUCL uses (or used in Feb 2000) different GC's on different > Daniel> platforms. > > That is still true today and for the foreseeable future as well. To give slightly more details for the reasons: CMU CL (nee Spice Lisp) was originally developed on (RISC) workstations. In order to allow the direct operation on unboxed/untagged data, it partitions the register set of the underlying processor into tagged and untagged register subsets (and corresponding stacks), so that garbage collection can occur at (nearly) any point in time, without having to worry about untagged values being mistaken for lisp pointers, etc. When CMU CL was ported to x86 in the 90s, keeping up this partitioning scheme would have resulted in very bad performance, given the relative scarcity of general purpose registers on x86 machines, and the resulting register pressure. For that reason CMU CL on x86 needed a conservative GC, that could deal with unboxed/untagged values in normal registers and the stack. That is where the divergence started. Since most development on certain areas of CMU CL happened on x86 during the 90s, CMU CL on x86 currently has a number of features that haven't been (fully) ported to the other platforms, like e.g. multi-processing and the generational aspects of the conservative GC on x86. Regs, Pierre. F'up to comp.lang.lisp set, since I don't think that further discussion is that interesting to those that use Python the language (and not Python the CMU CL compiler). Feel free to ignore it, if I'm mistaken... -- Pierre R. Mai http://www.pmsf.de/pmai/ The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. -- Nathaniel Borenstein From ahamm at programmer.net Thu Nov 29 22:49:30 2001 From: ahamm at programmer.net (Andrew Hamm) Date: Fri, 30 Nov 2001 14:49:30 +1100 Subject: New updates needed for an old computer language humor piece References: Message-ID: <3c0701c9$1_1@news.iprimus.com.au> Ric Werme wrote in message ... >The following wandered into my mail box for the first time in a year >or two. Since I've been learning a bit of Python this year, it seems >to me an update is needed. > >For Logo, perhaps: Draw a foot, draw a gun, but the bullet comes out >the handle and misses the foot altogether. > SQL: insert into foot select bullet from gun where calibre = "0.45"; commit work; -- Space Corps Directive #997 Work done by an officer's doppleganger in a parallel universe cannot be claimed as overtime. -- Red Dwarf From ophiel_magick at yahoo.com Thu Nov 29 09:55:30 2001 From: ophiel_magick at yahoo.com (Ophiel Magic) Date: Thu, 29 Nov 2001 14:55:30 GMT Subject: If UR brand spanking new to programming (like me)... Message-ID: <3c064aa3.8700849@news> I just started working with Python last week. I have had NO programming experience, other than writing macros for Access. I was fortunate to find this group and found, through the group, MANY online resources. Being a book-person, I also wanted to pick up a physical book I could read when I'm sitting in coffee shops, or whatever. Gotta have a book or two. Borders had a decent selection of texts and I went for the O'Reilly's book on "Learning Python," the Lutz/Asher book. It stated somewhere it was for the newbie type like me. I bought that book and by page three was totally lost. I bet it's a good book IF you already know about programming. After returning it that same day, I found two other books that are geared to my level, "Learn Program Using Python" by Alan Gauld and "Python 2.1 Bible" by Bruock/Tanner. The Gauld book takes one thru the simpliest concepts of programming and helped make sense of all those mysterious lines of words. The Bible has a short introduction to programming as well. This taught me a lesson...even though a book is advertised as appropriate for a particular level, I'm going to take the time to sit down and read a few pages and make sure it does just that. Please post any responses to this to this newsgroup. From joonas at olen.to Sat Nov 3 17:28:57 2001 From: joonas at olen.to (Joonas Paalasmaa) Date: Sun, 04 Nov 2001 00:28:57 +0200 Subject: [Q] Python and expert system shell References: Message-ID: <3BE46FA9.72DFFDB0@olen.to> Young-Jin Lee wrote: [...] > I found one URL for an expert system shell in Python, > http://www.python.org/ftp/python/contrib/All/holmes.tar.gz ,but it seemed > be not available any more. I can e-mail it to you if you want. From emile at fenx.com Fri Nov 2 10:53:05 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 2 Nov 2001 07:53:05 -0800 Subject: extending yield's functionality References: <3be2b616@news.bezeqint.net> Message-ID: <9rufr1$vnr8o$1@ID-11957.news.dfncis.de> "Eyal Lotem" wrote in message news:3be2b616 at news.bezeqint.net... > I was excited to find out about the new yield functionality, of generator > functions, that will be formally in 2.3 > > I wanted to ask if its possible to have yield receive some more information > from the caller, between the yield stages. > You can share mutable objects to pass in information: def gf(args): while 1: yield args[0]*args[1] a = [2,3] g = gf(a) print g.next() a[1]=4 print g.next() Is this what you're looking for? -- Emile van Sebille emile at fenx.com --------- From scott at mischko.com Wed Nov 21 20:58:27 2001 From: scott at mischko.com (Scott Chapman) Date: Wed, 21 Nov 2001 17:58:27 -0800 Subject: Python startup problem. I'm lost! Message-ID: <3BFBEB43.10012.14497CDC@localhost> More information I should have included in the previous post: I upgraded python then downgraded it again on my linux box. I get this whenever I try to run python and I can't figure out where these things are set. I don't want to set them in environment variables but rather permanently in a config file somewhere. # python -v > Could not find platform independent libraries > Could not find platform dependent libraries > Consider setting $PYTHONHOME to [:] > 'import site' failed; traceback: > ImportError: No module named site > Python 2.1.1 (#1, Nov 18 2001, 17:15:47) > [GCC 2.95.2 19991024 (release)] on linux2 > Type "copyright", "credits" or "license" for more information. Any help would be greatly appreciated! I'm not on the high-volume mailing list so please reply to me at scott at mischko.com. Thanks! Scott From emile at fenx.com Fri Nov 2 17:00:36 2001 From: emile at fenx.com (Emile van Sebille) Date: Fri, 2 Nov 2001 14:00:36 -0800 Subject: Freeware Python editor References: <9rv2o6$vgjpo$1@ID-11957.news.dfncis.de> Message-ID: <9rv5bo$vr9mg$1@ID-11957.news.dfncis.de> "Cliff Wells" wrote in message news:mailman.1004736845.23325.python-list at python.org... > On Friday 02 November 2001 13:16, Emile van Sebille wrote: > > > No, no, no. You're wrong. > > No, you are. But the GPL gives you that freedom, as long as you don't > prevent others from being wrong as well. > > > I'm sorry. I thought it was the PSU that gav From xx758 at cam.ac.uk Fri Nov 2 11:05:49 2001 From: xx758 at cam.ac.uk (root) Date: Fri, 02 Nov 2001 16:05:49 +0000 Subject: Install Tkinter for Python20 under Linux Message-ID: <3BE2C45D.6FE2C0E2@cam.ac.uk> An HTML attachment was scrubbed... URL: From just at letterror.com Sun Nov 18 16:23:02 2001 From: just at letterror.com (Just van Rossum) Date: Sun, 18 Nov 2001 22:23:02 +0100 Subject: RANSOM DEMAND: Image Held Hostage! References: Message-ID: <3BF82779.CB973988@letterror.com> Fredrik Lundh wrote: > import Image Eh, isn't from PIL import Image the recommended form these days? These days I install PIL so you _have_ to use the latter form. Just From syver-en at online.no Thu Nov 22 00:23:13 2001 From: syver-en at online.no (Syver Enstad) Date: 22 Nov 2001 06:23:13 +0100 Subject: How to change HTTP version during HTTPlib? References: <9thtih$2jde2$1@ID-54723.news.dfncis.de> Message-ID: "Benjamin Wu" writes: > hi, I use HTTPlib to do some coding, How do change HTTP version during I > send http request? I just use HTTP class to do so but it work in HTTP > version 1.0, and I also know that there is another class named > HTTPconnection work in HTTP version, How should I do? Use the HTTPConnection class, this uses 1.1. ex httplib.HTTPConnection Use the source to find out how to use it. It's pretty well documented. P.S. The last time I used I had to do a little hack to make it behave with IIS servers, using POST requests. Using GET is should work fine. I can supply you the hack if you want to. -- Vennlig hilsen Syver Enstad From boud at valdyas.org Mon Nov 5 08:52:10 2001 From: boud at valdyas.org (Boudewijn Rempt) Date: Mon, 05 Nov 2001 14:52:10 +0100 Subject: BlackAdder References: <4a249347.0111050504.6f126ae5@posting.google.com> Message-ID: <3be69836$0$203$e4fe514c@newszilla.xs4all.nl> Robert wrote: > How close is this to being completed? > Perhaps your best bet would be to ask TheKompany.com - they should know best! I only know that Phil has been very busy porting PyQt to Qt 3 - a task that's nearly completed. I'm already using the prereleases for Kura and for my editor project. (I'm trying to implement an editor according to Craig Finseth's book in Python.) -- Boudewijn Rempt | http://www.valdyas.org From gat at jpl.nasa.gov Fri Nov 30 15:00:57 2001 From: gat at jpl.nasa.gov (Erann Gat) Date: Fri, 30 Nov 2001 12:00:57 -0800 Subject: A modest indentation proposal References: Message-ID: In article , wrote: > Do you think this indentation stuff will have any bearing at all on any > of this? Erann, there are much bigger fish to fry. I apologize, but this > is really a nit-pick issue. Surely the people you're trying to sell this > to can come up with better reasons as to why Python is not suitable. I > mean, if they are complaining about this then I am *really* curious about > what languages they *do* find acceptable. I guarantee that, given any > language (including Python!), we can come up with more serious and > reasonable objections than this one. Yes, of course it's a nit-pick issue. These arguments are not entirely rational (though I actually do believe this argument has some merit, not that that matters). These things have as much to do with fashion and ass-covering than with technical arguments. What languages do "they" find acceptable? C++. Java is starting to make some inroads, but it's still a hard sell. > Congratulations on getting them this far (I'm serious). You've obviously > done a lot of selling to them to get them to the point that these are the > types of objections they're raising. Thanks. > The thing to do now is to convince > them to let you use Python on a minor project or two so that they can > *objectively* judge the merits of Python. You need to help them get out of > the respond-to-whatever-problems-we-can-dream-up mode and into the > see-what-problems-really-occur-and-how-often mode, and then you can > accurately judge the suitability of Python. Yes, that will help, but not nearly as much as being able to come up with a technically sounds response to this objection. I got NASA to fly Common Lisp, so I've had some experience selling these people on unusual languges. Please believe me, I've been here before. > Yes, in theory, their > objection can cause problems. In practice, however, it rarely does. Rarely isn't good enough. The annals of catastrophic failures are chock-full of multi-million-dollar failures that were the result of things that "rarely" caused problems. This argument works only for the currently popular thing, not for the underdog, and at the moment Python is still the underdog. (In fact, the main reason I've gotten as far as I have is that very few people around here know Python, so they've got relatively open minds about it.) It's not fair, it's not rational, but that's the way it is. > Right now you're essentially in the tough position of showing that Python > is perfect, which it's not, so you're bound to lose the argument. You misjudge the situation. I like Python a lot, but I don't really have what you would call a passion for it. (My passions run in other directions.) What's happening here is that I see an opportunity for Python potentially expanding into a cool new market, but meeting resistance. I see a way to overcome that resistance while at the same time IMO improving the language with minimal impact on existing infrastructure. But I am not engaged in any argument with anyone, so I'm not "bound to lose." All I'm doing is bringing a problem and a suggestion for a solution to your attention for your consideration. E. From lucio at movilogic.com Thu Nov 22 15:51:56 2001 From: lucio at movilogic.com (Lucio Torre) Date: Thu, 22 Nov 2001 17:51:56 -0300 Subject: Python Persistant Object Shell Message-ID: <3BFD656C.5030604@movilogic.com> Hello, I want to write an aplication that is a python shell plus: + a visible tree of the namespace + everything is persistant + a visual object inspector + remote access + multi user permissions its something like zope, but with this differences: + meant to be used by an application, not web broser (better ui) + much less hassle in 'publishing' objects, all objects get published by default using introspection, lists and dicts have special 'morphs' + not meant to be a pretty display, more of an excel than a word. + its somehting like te skeak enviroment + morphicWrappers, but with this differences: + its in python :) + its distributed (ala lotus notes/groove) [ you can set access control lists to you objects, and make your namespace a mix of local and remote objects ] + has a bit more of structure ( morphs are too diverse, not so easy to manage ) + has a tool for manipalting live objects, not just the inspector, but an object browser it has something of excel and access also. something of self would be nice. any ideas? comments? similar proyects you know of? something to add to this loose description? questions? thanks in advance. lucio. From fredrik at pythonware.com Wed Nov 21 13:45:58 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 21 Nov 2001 18:45:58 GMT Subject: Still on python GUI toolkit References: Message-ID: Tyler Eaves wrote: > > > The application I tested is a pixel-intensive type of application because > > it is the most challenging of the tools I will need: it displays > > continuously an 80x80 syntetic image randomly generated with 256 > > graytones, by using small filled squares for each pixel > > Unless you used Tkinter's canvas widget, this wasn't a fair test. if he *did* use the canvas widget, it wasn't a fair test. the Tkinter canvas is optimized for applications that create a model once, and then make relatively minor modifications to it (e.g. graphics editors). if you have data that changes rapidly, you'll likely to spend more time tranferring data between Python and the canvas model than you spend on updating the screen. better use a data display widget (try searching google for "custom Tk widgets"), or use something like Tkinter 3000's WCK: http://www.pythonware.com/products/tkinter/tkinter3000.htm as an example, here are timings for Gordon Williams' oscillo- scope benchmark (search the archives for source code; the Tkinter 3000 version is available in the WCK source kit): - Python 1.5.2, Tkinter Canvas: 2.3 frames/second - Python 2.0, Tkinter Canvas: 12 fps - Python 2.0, Tkinter 3000 w. Tk driver: 500 fps - Python 2.0, Tkinter 3000, native Win32 driver: 800 fps (benchmarked on an old 200 MHz PC running W2K) From fredrik at pythonware.com Wed Nov 7 13:56:46 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Wed, 07 Nov 2001 18:56:46 GMT Subject: Creating a list of files in a directory References: Message-ID: Jeff Klassen wrote: > I am new to Python. As a non-programmer I am encouraged by the level of > 'success' I feel I have had, relative to similar learning attempts in other > languages. > > I would like to simply do the following: > - read all of files of a particular form (e.g. *.cev) from a particular > directory files = glob.glob("*.cev") for file in files: > - manipulate them with a series of re.sub expressions are you sure? > - write each file to its own output file with a certain form (e.g. *.out). note that there's plenty of filename-manipulating stuff in the os.path module. for example: # split filename in file and extension part file, ext = os.path.splitext(file) outfile = file + ".out" > workingdir=dircache.listdir('/jobs/python/learning/') you're sure using somewhat confusing names; are you sure you didn't really mean: workingdir='/jobs/python/learning/' allfiles = dircache.listdir(workingdir) > filespec = re.compile(r'.*?\.cev') > filestoprocess = [] > > for allfiles in workingdir: > matchedfile=filespec.match(allfiles) for file in allfiles: matchedfile = filespec.match(file) > filestoprocess.append(matchedfile.group()) > > print filestoprocess > ---------------------------- > > When I run this script I am returned: > AttributeError: 'None' object has no attribute 'group' the match method returns a match object (with a group method) if it matches. but if it doesn't, you get None. this should work (but you probably want glob.glob anyway): matchedfile=filespec.match(allfiles) if matchedfile: filestoprocess.append(matchedfile.group()) hope this helps! From stephan at 3w4u.de Wed Nov 21 08:55:12 2001 From: stephan at 3w4u.de (stephan) Date: 21 Nov 2001 05:55:12 -0800 Subject: Pil-Libary---write text into an image file Message-ID: <3fea95b3.0111210555.5f2ee93@posting.google.com> Hi there, is it possible to open a image file, write text inside and save it in an image file iI can display in common Browsers. Do I have to use the PIL-Libary? Please help, we are desperate... And Tommy is suffering... Thank you. -- Stephan From fperez528 at yahoo.com Sat Nov 10 13:44:21 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sun, 11 Nov 2001 18:12:21 +2328 Subject: doc generator References: <9skvfn$fg9$1@peabody.colorado.edu> Message-ID: <9sn7o9$8d0$1@peabody.colorado.edu> radix wrote: > > Ok, it turns out that Teud does indeed use pydoc as it's backend. I don't > know any more than this; I asked Itamar about it and that's all he told > me, and he said he didn't have enough time to follow up to the thread. Fair enough. Maybe later he'll have some time to drop by and give us a quick rundown of the differences/benefits of Teud vs basic pydoc. Cheers, F. From ykingma at accessforall.nl Sun Nov 18 15:23:35 2001 From: ykingma at accessforall.nl (Ype Kingma) Date: Sun, 18 Nov 2001 21:23:35 +0100 Subject: Speed Comparisons: Python vs Java References: <3BF75F10.B049F3E2@engcorp.com> Message-ID: <3BF81889.76E95521@accessforall.nl> Peter Hansen wrote: > > "A. Keyton Weissinger" wrote: > > > > I've seen some Java/Python comparisons, but none that show side by side > > performance tests of any real depth. Has anyone seen any? If so, where? > > Readily found from a search with > > - http://www.google.com/search?hl=en&q=comparing+python+java+performance > > was the following: > > - http://twistedmatrix.com/users/glyph/rant/python-vs-java.html > > (most humorous in the relative lengths of the samples) > > and: > > - http://wwwipd.ira.uka.de/~prechelt/Biblio/jccpprtTR.pdf > > which compares Python, Java, C, C++ and others for a particular > string-processing program. > > Of course, speed of execution usually gets too much attention, > and you should probably be more concerned about speed of > development, ease of maintenance, and fun, which are all areas > where Python wins hands down... Besides the fun, there is also: http://aspn.activestate.com/ASPN/Mail/Message/Jython-users/638627 which states that there are circumstances in which Jython (ie. Python implemented _in_ Java, not vs Java) outperformes CPython. Regards, Ype -- email at xs4all.nl From gustafl at algonet.se Mon Nov 12 08:23:55 2001 From: gustafl at algonet.se (Gustaf Liljegren) Date: Mon, 12 Nov 2001 14:23:55 +0100 Subject: Post HTML checkboxes? References: <9soc2i$ch$1@green.tninet.se> Message-ID: <9soias$bfm$1@green.tninet.se> "Skip Montanaro" wrote: > You need a "name" attribute in there somewhere. I don't recognize "id". I > suspect it should be "name" instead. Thanks, you're right! I'm trying to do this according to the current standards, and 'id' has indeed replaced 'name' in most cases, and I thought that was the case with forms elements too and that new web clients where already aware of it. Section 4.10 in XHTML 1.0 says: "In order to ensure that XHTML 1.0 documents are well-structured XML documents, XHTML 1.0 documents MUST use the id attribute when defining fragment identifiers, even on elements that historically have also had a name attribute." And: "Note that in XHTML 1.0, the name attribute of these elements is formally deprecated, and will be removed in a subsequent version of XHTML." But for some reason this has *not* happened in the forms module in XHTML 1.1: http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_extformsmo dule The current forms module will soon be replaced by XForms, but in the meantime I take it as if we should have both 'id' and 'name' in elements. Thanks again, Gustaf From steven.smith at level3.com Tue Nov 13 09:52:35 2001 From: steven.smith at level3.com (steve) Date: 13 Nov 2001 06:52:35 -0800 Subject: python path - pdflib References: Message-ID: "Steve Holden" wrote in message news:... > You are mistaken in believeing that the Python path (effectively, sys.path) > affects how the system finds data files. The path mechanism is used only for > locating modules to be imported. You will therefore need to either locate > the data files in a known directory or programmatically try the directories > on the path until you find it. > > Probably a good compromise is having a default location hard-wired into the > program, but allowing an environment variable (found in the os.environ > dictionary) to override the default if/when set. > > regards > Steve I tried setting an absolute path also, but this doesn't work. As I also said, the first file I try to find, whatever it is, is found. After that file is found, I can't find another file, even if it is in another directory. Since the absolute path won't work, I would believe there is something wrong with pythons path abilities. Is it possible that after python has found a file in a certain directory, that it works relative to only that directory? From fredrik at pythonware.com Tue Nov 6 15:49:41 2001 From: fredrik at pythonware.com (Fredrik Lundh) Date: Tue, 06 Nov 2001 20:49:41 GMT Subject: [ #456742 ] Failing test case for .*? References: <9s0rqo$rrg$1@bob.news.rcn.net> Message-ID: Greg Chapman wrote: > I did a little tracing through the SRE code, and it looked to me that the change > labled 133283 caused this. ouch. this change (proposed by Darrell, btw) isn't supposed to be there. I'll look into this asap. thanks /F From sag at hydrosphere.com Mon Nov 19 16:32:22 2001 From: sag at hydrosphere.com (Sue Giller) Date: Mon, 19 Nov 2001 14:32:22 -0700 Subject: Numercial Reduction question In-Reply-To: Message-ID: <20011119213112634.AAA238@mail.climatedata.com@SUEW2000> I am working with Numerical arrays, and I need to be able to do some reductions along axis to aggregate data. The reduction needs to be able to skip cells that have a given value in them, denoting a missing value. For example, I might have a 31 by 12 array (days by months) of data. Some cells have a special value in them to denote that there is no data for that day (either it's an invalid date, or there was no data for that day). I want to be able to collapse along the day axis (31) to create monthly data, say summing the values, or averaging the values. I could do add.reduce (array), but this will not skip the cells with the missing value. Does anyone have a suggestion on how to do this, other than iterating through all the values on a given dimension and doing the aggregation that way? TIA. sue From shalehperry at home.com Sat Nov 3 12:08:13 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Sat, 03 Nov 2001 09:08:13 -0800 (PST) Subject: String argument -> name of list? In-Reply-To: Message-ID: > > I wonder if it is any simple syntax for converting a string to the name of > a list? Or should I use another structure instead, like a dictionary with > strings + lists, or a list with strings + lists? > from your description a dictionary is exactly what you want. scales['ionian'] would give you [0, 2, 2, 1, 2, 2, 2]. You could then use random.choice(scales.keys()) to get a random name. The only time this could be a problem is if you care about the order of the names. Then you will have code like: print scales['ionian'] print scales['dorian'] ... print scales['locrian'] instead of looping over the names. From sill at optonline.net Sun Nov 11 20:59:27 2001 From: sill at optonline.net (Andrei Kulakov) Date: Mon, 12 Nov 2001 01:59:27 GMT Subject: distutils for apps? Message-ID: Hello pygang, I just read distutils docs and I can't figure out how to tell it to install one file into path. I have a bunch of .py files, one of them is meant to be executed by the user, and the rest are modules. Do I copy it to /usr/local/bin myself? It just seemed logical that distutils would do that. - Andrei -- Cymbaline: intelligent learning mp3 player - python, linux, console. get it at: cy.silmarill.org From sandysj at juno.com Wed Nov 7 17:43:20 2001 From: sandysj at juno.com (Jeff Sandys) Date: Wed, 7 Nov 2001 22:43:20 GMT Subject: OT: Teaching Logo (programming) to children References: <3BE82570.D76DCAE9@juno.com> <7xwv13kkko.fsf@ruckus.brouhaha.com> <7xsnbqdir8.fsf@ruckus.brouhaha.com> Message-ID: <3BE9B908.4DC5E1C4@juno.com> Paul Rubbing wrote: > > ... (The Logo Foundation): > http://el.www.media.mit.edu/groups/logo-foundation/ If you go to the products / software page you will find free versions of Logo at the bottom of the page. I recommend UCBLogo for the PC, (dos or windows), mac, (68xxx or powermac) and c source for unix. It features a lambda function and macros with other advanced features. The distribution includes documentation, help files and the Jove (a mini emacs) editor. There is also a Logo mode available for emacs. It is under the GNU license. MSWLogo is a full up windows version of UCBLogo and it includes access to some windows widgets. Elica is a Logo dialect with object extensions. StarLogo is written in Java, runs on power macs and windows. Each turtle and background cell can be programmed, new turtles and cells can have inheritance. It is useful for cellular automata and system simulations. Thanks, Jeff Sandys From me at mikerobin.com Fri Nov 9 23:03:28 2001 From: me at mikerobin.com (Michael Robin) Date: 9 Nov 2001 20:03:28 -0800 Subject: iters on ints? (reducing the need for range/xrange) References: <52e5ab5f.0111090851.2d4e023d@posting.google.com> Message-ID: <52e5ab5f.0111092003.56966343@posting.google.com> Marcin 'Qrczak' Kowalczyk wrote in message news:... > 9 Nov 2001 08:51:05 -0800, Michael Robin pisze: > > > > Only one of these can work - the above are either equivalent to > > the interval [0..9] or [0..10] > > No, they both work, because it would be equivalent to [0..9]. Well, there is no "it" right now - but I assume that's what you want it to mean. I was just saying that I think in most other languages that specify numeric targets of "for" without extra syntax or an explicit test expression the endcases are inclusive. (Pardon me if I'm wrong on any of these...) Consider: for i = 0 to 10 (0 to: 10) do: for I in 0..10 loop for i := 0 to 10 do begin (loop for i from 0 to 10 do ...) all have their last iters at 10. So, if for i in 10: doesn't include 10, it could be confusing. But I guess if it's used only as a shortcut for range(len()), I guess it does the right thing. (But I still like range(seq) more then len(seq) as shorthand for range(len(seq)).) m From wtanksle at dolphin.openprojects.net Fri Nov 16 16:57:12 2001 From: wtanksle at dolphin.openprojects.net (William Tanksley) Date: Fri, 16 Nov 2001 21:57:12 GMT Subject: Recap: PEP 276 Simple Iterator for ints References: Message-ID: On Fri, 16 Nov 2001 11:55:12 -0800, James_Althoff at i2.com wrote: >William Tanksley wrote: >>I've lost track of why we're arguing about this. Why should we >>make any change here? What are we fixing? >Nonetheless, as stated several times before, PEP 276 does not preclude the >adoption of a new mechanism for specifying lists of numbers similar to any >of the above proposals -- it doesn't have to be an "either or" choice. It >simply provides a convenient way to access indexed structures in a >for-loop. So it's intended primarily as a way to iterate through the indices in a list. I think as such it should be part of PEP 212, which offers some other ways of doing the same thing. I don't like this, really. It has severe effects on currently-legal Python usage, and doesn't match with established Python behavior. >Jim -- -William "Billy" Tanksley From skip at pobox.com Thu Nov 29 20:35:05 2001 From: skip at pobox.com (Skip Montanaro) Date: Thu, 29 Nov 2001 19:35:05 -0600 Subject: problems with DBM nonuniformity In-Reply-To: References: Message-ID: <15366.57929.747462.677279@beluga.mojam.com> Jason> On Linux, "whitelist.db" = whitelist.db when the default module is Jason> dbhash, so there is no problem: ... Jason> However on Solaris for example (default module of dbm): Jason> % python -c "import anydbm;wl = anydbm.open('whitelist.db','c')" Jason> % ls -l whitelist* Jason> -rw------- 1 jason users 0 Nov 29 19:13 whitelist.db.dir Jason> -rw------- 1 jason users 0 Nov 29 19:13 whitelist.db.pag Jason> Under Linux, the dbm module acts differently, adding a '.db' Jason> suffix to the given filename: Jason> % python -c "import dbm;wl = dbm.open('whitelist.db','c')" Jason> % ls -l whitelist* Jason> -rw------- 1 jasonrm acl 16384 Nov 29 17:21 whitelist.db.db Jason> So, I can't rely on comparing "whitelist" with "whitelist.db" Jason> filename to filename since the latter might not exist. ... Jason> Does anyone have some suggestions on how I might support this Jason> feature in a cross-platform, and generic fashion? Seems to me the natural thing to do would be to add "get_data_filename" and "get_index_filename" methods (or something similar) to the underlying modules (dbhash, bsddb, dbm, etc) and expose them through anydbm. It's too late for 2.2, but I suspect if you implemented something and method name(s) could be settled on it would make it into CVS early in the 2.3 cycle. This seems like a small enough change that you just file a bug report on SourceForge with the proposal and add an implementation when you have something workable. -- Skip Montanaro (skip at pobox.com - http://www.mojam.com/) From johnroth at ameritech.net Sun Nov 25 20:31:10 2001 From: johnroth at ameritech.net (John Roth) Date: Sun, 25 Nov 2001 17:31:10 -0800 Subject: application scripting References: Message-ID: "Chris Liechti" wrote in message news:Xns9165290659FCcliechtigmxnet at 62.2.16.82... > [posted and mailed] > > recordable apps have to provide a menu point to start/stop recording, > because only the app itself knows what input events create what actions in > the script. I believe there is a lower level API in Windows that allows recording events and playing them back. It's frequently used by automation packages and GUI testing tools that are not application specific. I don't know whether the API is implemented in either of the Windows Python distributions, however. Having event recording within the application is a good idea, because external recording tends to be very fragile. John Roth From phr-n2001d at nightsong.com Mon Nov 5 20:39:29 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 05 Nov 2001 17:39:29 -0800 Subject: Teaching python (programming) to children References: Message-ID: <7xsnbs65ke.fsf@ruckus.brouhaha.com> Brian Elmegaard writes: > So, any comments are appreciated, especially on: Are there good reasons > for advocating python being a language one could teach children > programming with and are there perspectives in translating python to many > different languages in order to facilitate this, or will children not be > ready for learning programming before they have learnt English after all? What age of children are you talking about? I think not everyone here is thinking of "children" as meaning the same thing. From jerry at sky.net.ua Thu Nov 15 23:43:20 2001 From: jerry at sky.net.ua (Serg) Date: Fri, 16 Nov 2001 06:43:20 +0200 Subject: Can't add modules? References: <3bf428b9@skynet> Message-ID: <3bf49a60$1@skynet> I'm quite a newbie with setting python. I've downloaded sources, compiled for win32 platform and first thing I wanted to do is to add some library and test its work. The problem is: pythonpath is set for d:\python\lib; in that directory there is directory Optic. In it __init__.py and options.py. Ok I write thimple python program from optik import otion # or it was from optik import * option(100) I get Traceback (most recent call last): File "a.py", line 1, in ? from optik import * ImportError: No module named optik At the same time I create in the same lib directory my directory b and in it file bb.py def aa(some): print some I start the following program from optik import * aa(100) And it prints 100. What did I do wrong? >>> import sys >>> sys.path ['', 'D:\\', 'd:\\python\\lib', 'D:\\PYTHON\\lib\\lib-tk', 'D:\\PYTHON'] python 2.2b1 -- Keep in touch. Your partner Maltsev. From nospam at bigfoot.com Sun Nov 25 14:11:35 2001 From: nospam at bigfoot.com (Gillou) Date: Sun, 25 Nov 2001 20:11:35 +0100 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> Message-ID: <9trfct$llh$1@norfair.nerim.net> Don't panic ;-) You can use the latest stable "official" python from BeOpen (official) http://www.python.org The latest official release + nice Windows extensions and an IDE at ActiveState in One dowload bundle. http://www.activestate.com Good tutorials can be read at /downloaded from: http://diveintopython.org/ I dunno the O'Reilly book, but Python is very portable and most scripts for python 1.5.2 work with python 2.1.1. HTH --Gillou "Fred Flintsone" <__x__ll at yahoo.com> a ?crit dans le message news: 3c013d0d.26717374 at news... > Hi. I went to the Python.org page to pick up a copy of Python, and > was faced with a choice of which version I want to d/l. As a rank > beginner, does it matter? I'll be working on a Windows ME machine. > Between the O'Reilly book I just bought, and all those great looking > tutorials, I'm anxious to dig in. > > Thanks. > FF > Please post any responses to this to this newsgroup. From zope at thewebsons.com Fri Nov 16 10:35:26 2001 From: zope at thewebsons.com (Ben Ocean) Date: Fri, 16 Nov 2001 07:35:26 -0800 Subject: Sizing Up Graphics Automatically Message-ID: <5.1.0.14.0.20011116073052.00a37c60@thewebsons.com> Hi; Is it possible to automatically size up a graphic upon upload and programmatic insertion into a script? I use Zope and want to build a through-the-Web interface to enable my client to automatically change/add photos, but I want to set the site up such that all the dimensions of graphics, font sizes, etc., are resized depending on the visitor's browser resolution. In order to do that, I *must* somehow capture the dimensions of the uploaded graphic programmatically? Any ideas how to do this? Anybody have some code they'd like to share? TIA, BenO From chrishbarker at home.net Wed Nov 28 17:19:32 2001 From: chrishbarker at home.net (Chris Barker) Date: Wed, 28 Nov 2001 14:19:32 -0800 Subject: Non-Indented python References: <9sbd8i$680$1@wanadoo.fr> <_rNM7.262451$5A3.99660755@news1.rdc2.pa.home.com> <9u21ch$bonls$1@fido.engr.sgi.com> Message-ID: <3C0562F4.7EE7D682@home.net> After reading a whole lot of sometimes ugly bickering, it seems to me that most of us Python users do agree on one thing: Mixing tabs and spaces is a BAD idea. If it is true that there is general consensus about this, is there any movement to disallow it altogether in the Python interpreter? Personally, I would prefer that future versions of Python would allow ONLY tabs or ONLY spaces, but clearly there would be a major disagreement about which to use. Frankly, I wouldn't even care which, although tabs may be a better choice because while "any decent editor" can be taught to insert N spaces when a tab key is pressed, apparently not all editors are "decent". I have found that using tabs for indenting is the only viable option for me on the Mac, and I have to change to all spaces when I move code to *nix/Windows, because the editors/IDEs I use there assume spaces. A real pain. If only one option were mandated by Python, any editor that pretended to have a Python mode would use it (The MacPython IDE comes to mind) -Chris -- Christopher Barker, Ph.D. ChrisHBarker at home.net --- --- --- http://members.home.net/barkerlohmann ---@@ -----@@ -----@@ ------@@@ ------@@@ ------@@@ Oil Spill Modeling ------ @ ------ @ ------ @ Water Resources Engineering ------- --------- -------- Coastal and Fluvial Hydrodynamics -------------------------------------- ------------------------------------------------------------------------ From peterb at cortland.com Sun Nov 25 11:44:15 2001 From: peterb at cortland.com (Peter Bismuti) Date: Sun, 25 Nov 2001 08:44:15 -0800 Subject: any utilities to parse code?? References: Message-ID: <3c007810$1@207.229.64.20> There is a "compiler compiler" called JavaCC that can be used to parse source code, it can be used to write compilers and it can also be used to write tools for coding like "intellisense" which offers a list of matching variable names, class methods, etc to the user on-the-fly as they code. This is in fact what I'm doing, developing a voice driven IDE. Python is the scripting language for both the voice recognition software and for my editor. I am looking for something similar but in Python. Of all the languages to parse by hand, I'd say that Python is probably the easiest, but I'm not sure if embarking on a mission to parse languages like Java is practical. I'd rather look for something that already exists. I want to be able to parse source code and accurately generate lists for the names of the following entitites: modules variables arrays hashtables functions classes methods buffers I could then issue a command as follows: "import module" I would then be shown a list of module names and I could choose one by issuing the command" "choose 8" or "choose system" THanks if you have had the patience to read this far. From robin at stop.spam.alldunn.com Thu Nov 8 17:23:30 2001 From: robin at stop.spam.alldunn.com (Robin Dunn) Date: Thu, 08 Nov 2001 22:23:30 GMT Subject: Fatal Python error: ceval: tstate mix-up References: Message-ID: wrote in message news:ud72tjrne.fsf at cs.unc.edu... > >This is probably going to be a bug in wxPython, but I'm not sure. > >Have you got the latest version of such? > > Yes, I'm running wxpython 2.3.1. I was thinking that I didn't use any > wxpython code in the second thread but now I see that I *do* call > wxWakeUpIdle to get my GUI idle loop code to process the notification > that the send is complete. Maybe wxWakeUpIdle isn't thread safe? I'll > have to try using an event like the theaded example does. > It is safe, and is called from within the wxPostEvent function as well. Are you by chance on a SMP box? There was a long standing bug that only showed up when using threads on an SMP machine that manifested as a tstate problem. The bug has been squashed in the 2.3.2 beta version. -- Robin Dunn Software Craftsman robin at AllDunn.com Java give you jitters? http://wxPython.org Relax with wxPython! From LLoeffler at home.com Mon Nov 26 15:14:45 2001 From: LLoeffler at home.com (Luke) Date: Mon, 26 Nov 2001 14:14:45 -0600 Subject: postgresql triggers to update GUI? References: <20011126.145234.816620091.2222@localhost.localdomain> Message-ID: <3C02A2B5.4040006@home.com> Seems to me that stored python procedures executed by postgres would be executed in an entirely different process than the program that is working the db. Could be wrong though. > I am writing a python program that uses a postgresql db backend. I would > like to update the gui whenever a change in certain tables occurs, so it > would be nice to use triggers rather than generating the 'events' when I > update the db. That way I get cascading changes. Does anyone know of a > python module that supports postresql triggers? ie: you can create a > trigger that calls a python function? Is there another solution here > that I am missing? > > Thanks, > Rob > From desibtis at hotmail.com Tue Nov 27 00:23:02 2001 From: desibtis at hotmail.com (Sang DeSibtis) Date: 26 Nov 2001 21:23:02 -0800 Subject: Regular expression Message-ID: <6039af6a.0111262123.54806bb7@posting.google.com> import re,sys,string for line in open('junk', 'r').readlines () a = re.compile('AAAA') b = re.compile('BBBB') re.sub(a, 'aaaa', line) re.sub(b, 'bbbb', line) print line # nothing got changed print re.sub(a, 'aaaa', line) # works print re.sub(b, 'bbbb', line) # works, however the line above doesn't work Questions: how do I make a global replacements in the 'line' that read from the file object (buffer in memory? ).Obviously, this is my first attemp at Python and I am not sure how things work. I want to replace all strings (not necessary 'AAAA' or 'BBBB' as illustrated here) in one pass. Will some one please explain in detail !!!!!!!!!!!!!!!! TIA From anthony at interlink.com.au Wed Nov 7 19:58:30 2001 From: anthony at interlink.com.au (Anthony Baxter) Date: Thu, 08 Nov 2001 11:58:30 +1100 Subject: [ANN] pyLaTeX -LaTeX to HTML, XML, etc. Conversion Framework In-Reply-To: Message from Kevin.Smith@themorgue.org (Kevin Smith) of "Wed, 07 Nov 2001 23:45:15 GMT." Message-ID: <200111080058.fA80wUU25445@mbuna.arbhome.com.au> So, can it replace the latex2html generated python docs? That would be the acid test... (and would probably make Fred happy, too...) Anthony >>> Kevin Smith wrote > pyLaTeX 1.0 alpha-1.1 > -------------------------------- > > pyLaTeX is a LaTeX document processing framework written entirely in Python. > It comes bundled with HTML and generic XML renderers, and other renderers can > be added as well. > > pyLaTeX differs from other tools like LaTeX2HTML, TeX4ht, TtH, etc. in that > the parsing and rendering of the document are completely separated. This > separation makes it possible to render the document in multiple output > formats. It also allows the parser to create a cleaner document object, so > that the rendering process is easier. > > This is the first public release of pyLaTeX and is not yet feature complete. > Most notably, there is no functionality for generating images from graphical > LaTeX environments and equations. > > Full documentation and downloads are available at > http://pylatex.sourceforge.net/. > > Kevin Smith > > -- > http://mail.python.org/mailman/listinfo/python-list > -- Anthony Baxter It's never too late to have a happy childhood. From sigma at safepassage.ca Sun Nov 18 02:38:47 2001 From: sigma at safepassage.ca (Reid Nichol) Date: Sun, 18 Nov 2001 01:38:47 -0600 Subject: ssl error References: Message-ID: <%yJJ7.1850$7b2.60534@news1.mts.net> Gerhard H?ring wrote: > On Sat, Nov 17, 2001 at 01:40:22PM -0600, Reid Nichol wrote: >> I got a client/server app that I am triing to build and am having >> problems. >> [snip] > > The Python builtin SSL doesn't support servers, but only SSL clients. > > On my homepage (see sig), you can find a short, unfinished overview of the > available alternatives. Use the "Python/SSL" link. I'd probably go for > M2Crypto. > > HTH, > > Gerhard Do you know if there is any plans to fix this issue? ----- If you truly love the memory, you must set it free()! From andreas at mtg.co.at Sun Nov 4 13:37:12 2001 From: andreas at mtg.co.at (Andreas Kostyrka) Date: Sun, 4 Nov 2001 19:37:12 +0100 Subject: bg and fg In-Reply-To: <20011104172118.A15499@cruciatuz.de> References: <20011104112551.A14309@cruciatuz.de> <001101c1653f$3f9a33e0$0101010a@local> <20011104172118.A15499@cruciatuz.de> Message-ID: <200111041837.fA4IbHE14792@lap1.mtg.at> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am Sonntag, 4. November 2001 23:21 schrieb Stefan Antoni: > if os.fork() == 0: > os.setsid # what does THAT mean? it was in the example. > # i looked into "pydoc os" but i didn't understand > # find an explantation This makes the process it's own session leader. ;) Andreas - -- Andreas Kostyrka; Raiffeisenstr. 16/9; 2320 Zw?lfaxing Tel: +43/676/4091256; Fax: +43/1/7065299 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE75YrbHJdudm4KnO0RAvYDAJsHIsAVM8/ASMdP0HGL+epciCX/qQCg4iM7 8FRjPPnHMT9KynCs3I+S10Q= =YeNW -----END PGP SIGNATURE----- From James_Althoff at i2.com Thu Nov 1 12:53:57 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Thu, 1 Nov 2001 09:53:57 -0800 Subject: Why 'self' ? Message-ID: Tim wrote: >plus-llambda-will-be-spelled-with-two-els-ly y'rs - tim Finally! BTW, do we pronounce that "yam-duh" ? Jim From logiplexsoftware at earthlink.net Mon Nov 5 13:52:18 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Mon, 5 Nov 2001 10:52:18 -0800 Subject: Process intercommunication In-Reply-To: References: Message-ID: <01110510521801.18247@logiplex1.logiplex.net> On Monday 05 November 2001 02:06, Mikael Olofsson wrote: > Process A is supposed to be running all the time, while process B will > only live for a short period of time. Both processes are supposed to > live on the same machine. After collecting some data, B needs to > communicate that data to A and A is supposed to acknowledge to B that > the received data is OK. B is therefore supposed to identify A, and set > up a two-way communication link to A (with A's help, I suppose). After > the necessary comunication has taken place, the communication link is > supposed to be shut down, and B will soon die. B is only supposed to > know under what name A is running. > > Later, A is supposed to be able to repeat the whole thing with a new B. > > There may be more than one process (but probably not more than ten) > knocking on A's door, and A is supposed to deal with them one by one. Probably the easiest way is to have A listen on a specified network port (using select()), and have B connect to that port and pass its data that way. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From sholden at holdenweb.com Fri Nov 30 17:34:05 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 30 Nov 2001 17:34:05 -0500 Subject: cgi problem using FieldStorage(). References: Message-ID: <8MTN7.9130$FP6.323616@atlpnn01.usenetserver.com> wrote in message news:mailman.1007156321.27358.python-list at python.org... > Hi, > I'm learnning cgi and html having a bit of a problem passing values to > my cgi script. > Here is the first script: > ======================================== > #!/usr/bin/python > > theSalesOrder = """Content-type: text/html\n > > The Test > >
>

Customer PO #:

> >

>
""" > > print theSalesOrder > ========================================= > > Here is the script that is called my the script above: > ------------------------------------------- > #!/usr/bin/python > import cgi, sys > sys.stderr = sys.stdin > > theSalesOrder = """Content-Type: text/html\n > > my test > >

%s

> """ > > form = cgi.FieldStorage() > line1 = form['customer'].value > > print theSalesOrder % (line1) > > ---------------------------------- > > I'm running Redhat 7.1 with the lastest release of mozilla, althought I get > my error if I use Netscape 4.X, and I'm using Apache 1.3.20. > Here the error from apache's error-log: > > [wayne at localhost online-ledger]$ tail /usr/local/Apache/logs/error_log > Traceback (innermost last): > File "/usr/local/Apache/cgi-bin/saleOrderAddProc.py", line 13, in ? > line1 = form['customer'].value > File "/usr/lib/python1.5/cgi.py", line 907, in __getitem__ > raise KeyError, key > KeyError: customer > [Fri Nov 30 15:22:19 2001] [error] [client 127.0.0.1] Premature end of > script headers: /usr/local/Apache/cgi-bin/saleOrderAddProc.py > [Fri Nov 30 15:24:30 2001] [error] [client 127.0.0.1] Premature end of > script headers: /usr/local/Apache/cgi-bin/saleOrderAddProc.py > [Fri Nov 30 15:27:19 2001] [error] [client 127.0.0.1] Premature end of > script headers: /usr/local/Apache/cgi-bin/saleOrderAddProc.py > > When I enter data in the first script and submit it, I set the > following URL address in my browser; > http://localhost/cgi-bin/salesOrderAddProc?customer%3C%2Finput=data entered > If I remove the %3C%2Finput and run that it works. > > WHAT AM I DOING WRONG? > Thanks Wayne. > Your input tag is malformed: you don't need a closing TAG, you need a closing angle-bracket. Replace the line that reads with Then cgi will see an input with the name you expect. regards Steve -- http://www.holdenweb.com/ From zammon at libero.it Tue Nov 6 09:42:09 2001 From: zammon at libero.it (zammon at libero.it) Date: Tue, 06 Nov 2001 15:42:09 +0100 Subject: Having a builtin exit function in python interpreter References: <3BE7B2D7.3080605@sferacarta.com> Message-ID: <3BE7F6C1.8060604@libero.it> > Hi, > > I don't know if this is the right mailing list to send this message, > anyway, I'm having the following problem and maybe I'm not the only one. > I think this interest every else programming with curses or slang. > As you know these libraries change the terminal to the raw mode, > and if your program aborts before it restores the terminal mode, > the EOF character is changed. > Take a look... > > Python 2.0 (#3, Nov 3 2000, 13:02:11) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> quit > 'Use Ctrl-D (i.e. EOF) to exit.' > >>> ^D > File "", line 1 > ^ > SyntaxError: invalid syntax > >>> exit > 'Use Ctrl-D (i.e. EOF) to exit.' > >>> import sys > >>> sys.exit(0) > ----------------------------------------------------------------------- > > How to solve this problem: > > > Why not to print the way to exit from python in like this... > > Python 2.0 (#3, Nov 3 2000, 13:02:11) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "copyright", "credits" or "license" for more information. > Type quit() or Ctrl-D (i.e. EOF) to exit. > > and modify site.py like this... > > # Define new built-ins 'quit' and 'exit'. > # These are simply strings that display a hint on how to exit. > #if os.sep == ':': > # exit = 'Use Cmd-Q to exit.' > #elif os.sep == '\\': > # exit = 'Use Ctrl-Z plus Return to exit.' > #else: > # exit = 'Use Ctrl-D (i.e. EOF) to exit.' > import __builtin__ > __builtin__.exit = __builtin__.quit = sys.exit > #del exit > > I think it whould be very useful to have a builtin function quit() or > exit() to avoid to import the sys module to exit from python. > site.py already imports sys module, why I have to import it again? > I modified site.py in my system. What about to have this modify in the > official release? > > Best regards > Jose Soares > From cliechti at gmx.net Sun Nov 25 18:13:23 2001 From: cliechti at gmx.net (Chris Liechti) Date: 26 Nov 2001 00:13:23 +0100 Subject: application scripting References: Message-ID: [posted and mailed] Keith Ray wrote in news:k1e2i3t4h5r6a7y-477B3A.14113525112001 at news1.rdc1.sfba.home.com: > So... no one has every implemented recordability in a Python-scriptable > application? no i have that done neither but i write down my thoughts so that you're not left alone with you message ;-) > In article > , > Keith Ray wrote: >> Introduction: >> >> AppleScript is the only ScriptingArchitecture that I know about that >> allows recording. An application is recordable when all (or most) >> user-interface handling results in the generation of one or more >> AppleEvents, which are directly routed to the application itself for >> execution. The AppleScript system can record these AppleEvents in a >> script, which the user can then edit. This can be a very user-friendly >> way for a user to start scripting, but of the relatively few >> applications that support AppleScript, even fewer support >> recordability. >> >> Mac Applications that are scriptable, but not recordable, have an >> architecture something like this: >> >> [GUI] -> commands -> [Model] <- commands <- [ScriptEngine] >> Scripts or AppleEvents --^ >> >> but recordable applications have an architecture like this: >> >> [GUI] -> AppleEvents -> [ScriptEngine] -> commands -> [Model] >> Scripts or AppleEvents --^ i dont know the mac that good. i guess that you want to say that there is a mac specific way to do control apps (AppleEvents). This seems to be similar to COM in the windows world. recordable apps have to provide a menu point to start/stop recording, because only the app itself knows what input events create what actions in the script. the text below does not use system specific features, only embedded python. >> Questions: >> >> Can anyone describe how recordability would be implemented in a C++ >> application with (embedded) Python? i assume that the python interpreter is embedded and available for the user that wants to write scripts (eg a menu entry to start the recorded scripts and maybe an interactive console, could be nice for testing). your app has to provide a module that exposes the methods of your model to python (load/save file, modify data etc.). a python script with recorded commands for your app begins with "import app". for simple apps it is sufficient to provide some functions in the module, for larger apps i would recomend an object oriented approach. >> Would a Python-embedded application have to generate Python source >> code, to implement the recordability pattern shown above? yes, but thats realy simple. every action just writes out one line of python code plus some standard text would be copied at the begining of a script. example: import app app.open("file") app.insert("hello") app.save("filename") for OO scripts you would have to generate some variable names too: import app document = app.open("file") document.insert("hello") document.save() maybe you want to have a look at some sample COM scripts. the approch is slightly diffrent but its the way msword, excel and may other windows software is scriptable (ms uses vbscript but there are python bindings too (win32com extension modules from active state)) HTH chris -- Chris From ssthapa at classes.cs.uchicago.edu Fri Nov 23 10:05:19 2001 From: ssthapa at classes.cs.uchicago.edu (Suchandra Thapa) Date: Fri, 23 Nov 2001 15:05:19 GMT Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfcce0b$0$89809$edfadb0f@dspool01.news.tele.dk> Message-ID: Max M wrote: >I think you will find that the general concensus is that Python is a >"complete" language. Which PHP is not. Python can be used for both web >scripting and, shell scripting, application development, small tools and gui >apps. And is very good at all of them. Wheras PHP is only useable for >scripting web pages. PHP has a command line interpeter so it can be used for scripting and the like. I believe there is even a gtk library so it's conceivable to create a gui app in php. However using php for something other than web scripting is very rare. >Furthermore PHP kind of forces you to write web-apps in one way with >presentation and logic mixed. Also when your web-apps can do all the >standard fare that is the staple of PHP you will suddenly need some feature >that's not available in PHP. Then it is much easier to use the Python >standard library to roll your own solution. Actually, there are template based packages for php, and it isn't too difficult to create a new template handling class if you don't like the existing ones. To be fairly, a standard python cgi will also force you to mix presentation and logic since all your html will be in print or stdout.write statements inside your script. However, PHP has some fairly large flaws in comparision to python. For example, using a variable that has never been declared or initialized will silently be treated as using an empty string (e.g. if you make a typo while entering a variable's name, you won't get an error). PHP also has some issues with case sensitvity. Variable names are case sensitive while function names are not. In addition, function calls are handled poorly. If you call a function with 3 parameters when it was declared with less than 3 parameters, php will silently ignore the extra parameter. All of these things basically make php code a lot harder to debug and maintain then python code. I would prefer python if given a choice. -- ---------------------------------------------------------------------------- | Suchandra Thapa | "There are only two kinds of math . s-thapa-11 at NOSPAMalumni.uchicago.edu | books. Those you cannot read beyond | the first sentence, and those you | can not read beyond the first page." | -C.N. Yang ---------------------------------------------------------------------------- From robin at jessikat.fsnet.co.uk Wed Nov 14 14:45:03 2001 From: robin at jessikat.fsnet.co.uk (Robin Becker) Date: Wed, 14 Nov 2001 19:45:03 +0000 Subject: reportlab question References: Message-ID: <0o+s9LA$ms87Ewxn@jessikat.demon.co.uk> In article , Scott Hathaway writes >Hello All, > >I have a simple script that I am using to create form letters from a text >file with reportlab. >It works ok until the text is longer than xx characters long. Then the text >is just cut off, not >word wrapped as I would like. How to I cause reportlab to word wrap the >text? > ... Hi Scott, you'll probably get better results from the users list at reportlab-users at yahoogroups.com. Any how you'll either need to chop the words your self or use the platypus framework to establish frames and handle wrapping. A relatively simple example is in reportlab/platypus/doctemplate.py (just run and look at the output). -- Robin Becker From m.hadfield at niwa.cri.nz Thu Nov 29 20:16:17 2001 From: m.hadfield at niwa.cri.nz (Mark Hadfield) Date: Fri, 30 Nov 2001 01:16:17 +0000 (UTC) Subject: A modest indentation proposal References: Message-ID: <001d01c1793c$997c3fa0$d938a8c0@Hadfield> From: "Skip Montanaro" > In my book trailing single-character punctuation should be > avoided wherever possible. I think that's very sound advice Oops, I mean very sound advice. --- 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 skip at pobox.com Wed Nov 14 04:07:24 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 10:07:24 +0100 Subject: PEP 276 Simple Iterator for ints In-Reply-To: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> References: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> Message-ID: <15346.13388.182098.148832@beluga.mojam.com> Magnus> I'd love to drop range() or xrange() from my for loops... (I Magnus> would like some pseudocode-like literal like 0..n myself, but I Magnus> see the [0:n] PEP has been rejected, so... :|) The proposed integer iterator would replace the most common range/xrange usage directly, but wouldn't supplant them completely without some help. Of course you could twiddle the index at the beginning of the loop to acheive the desired effect: for i in 10: i = -i # for i in range(0, -10, -1) for i in 10: i = 2*i # for i in range(0, 10, 2) for i in 10: i = i+1 # for i in range(1, 11) for i in 10: i = 3*i+1 # for i in range(1, 11, 3) etc. Taking that one gruesome step farther, one could envision a further extension to for loops: for i=-i in 10: ... for i=2*i in 10: ... for i=i+1 in 10: ... for i=3*i+1 in 10: ... but I won't even suggest it as more than an idle thought... ;-) -- Skip Montanaro (skip at pobox.com) http://www.mojam.com/ http://www.musi-cal.com/ From philh at comuno.freeserve.co.uk Fri Nov 23 11:43:11 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Fri, 23 Nov 2001 16:43:11 +0000 Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: On Fri, 23 Nov 2001 00:35:09 GMT, Todd Boyle wrote: > >But, what is the best way to build web-based database applications >like accounting systems, on Python? i.e. what is the equivalent >of ASP pages or PHP pages or JSP pages, for Python?? Shouldn't >we be learning THAT instead of PHP??? Someone did a Python Server Pages, but I've never used it. Is it still under active development? -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From grante at visi.com Fri Nov 9 22:49:51 2001 From: grante at visi.com (Grant Edwards) Date: Sat, 10 Nov 2001 03:49:51 GMT Subject: I just got in! References: <9sep77$eg6$1@slb4.atl.mindspring.net> <9sf2n1$c4u$3@newshost.accu.uu.nl> <3BEBA214.4A206D96@student.gu.edu.au> <3BEC9870.746F2407@engcorp.com> Message-ID: In article <3BEC9870.746F2407 at engcorp.com>, Peter Hansen wrote: >> *chuckles* Or maybe it's just that behaviour is contagious. Shout at >> others, eventually they'll leave or shout back. Be polite and kind, and >> point out that kindness is expected ... >> >> *grins* Of course I HAVE to believe this explanation. Despite being >> "officially grown up" at 24, I really can't think of myself as "mature" >> by any stretch of the imagination!!! > > Don't worry... adding 10 years doesn't make any difference. :-) Neither does adding 20 -- except that miscellaneous body parts start to ache (seeming at random), and people start to roll their eyes when you tell stories about PDP-11s and paper tape... "And we had to walk to school and back barefoot in snow so deep we tripped over telephone wires -- and it was uphill both ways!" -- Grant Edwards grante Yow! Civilization is at fun! Anyway, it keeps visi.com me busy!! From fperez528 at yahoo.com Thu Nov 29 10:28:13 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 30 Nov 2001 14:56:13 +2328 Subject: summing NumPy byte arrays References: <3C07DA0A.2DB4F78C@alex2.labs.agilent.com> <3C07EB40.1EFC594B@home.net> Message-ID: <9u8vbf$p1g$1@peabody.colorado.edu> Chris Barker wrote: >> How can I get it to sum the array in a full-width accumulator, >> without making an up-sized copy of the array? > > I'm pretty sure you can't. That would take some preety fancy > footwork in the typecasting code. > >> ps. The array I am working with is a 2-d noncontinguous slice. > > Your options are to either upcast the whole thing (you can make a > copy of that slice, and only upcast the copy), > >>>> from Numeric import * >>>> X = arange(216, typecode='b') >>>> X.shape = (6,6,6) >>>> s = sum(X[3,:,:].copy().astype(Int)) >>>> s > array([738, 744, 750, 756, 762, 768]) > > Or to write a little C routine, which would be pretty > straightforward if you only need it to work for one type, and one > rank. > > -Chris > Just curious: why not call reduce() with an object whose __add__ method does the work of adding an int +byte as int? The loop would be done in C (by reduce) and the tying should work ok. Maybe I'm missing something, f From mwh at python.net Mon Nov 26 07:21:48 2001 From: mwh at python.net (Michael Hudson) Date: Mon, 26 Nov 2001 12:21:48 GMT Subject: prep my types for 2.2? References: <3BFEF3DF.5030103@shinners.org> <3BFFD5C4.5080500@shinners.org> Message-ID: Pete Shinners writes: > > Python will look at the type of your_type (which will be the type > > type), and then look at its tp_call slot > > (i.e. typeobject.c:type_call). That, in turn, will use tp_new. > > this is where i start to get confused? > isn't the "Type type" the same for all type objects? for example.. > > >>> type(int) is type(float) > 1 > > since this is both the same thing, how can i change the tp_call for > only one of the types? class C: def foo(self): print 1, id(self) c = C() d = C() c.foo() d.foo() But how can these calls be different? c.__class__ is d.__class__! Same thing. In less obscure terms: when you call (stuff), the first argument to the C function that implements this (Objects/typeobject.c:type_call) is . It's this type object's tp_new that is called. If you were calling type(int)(1), then you'd have a point. > i was guessing there was some sort of new function slot for this, but > the docs on all this are a little sparse. This is true. Cheers, M. -- In general, I'd recommend injecting LSD directly into your temples, Syd-Barret-style, before mucking with Motif's resource framework. The former has far lower odds of leading directly to terminal insanity. -- Dan Martinez From emile at fenx.com Mon Nov 5 08:52:48 2001 From: emile at fenx.com (Emile van Sebille) Date: Mon, 5 Nov 2001 05:52:48 -0800 Subject: Question: Error or misconcept References: <3be65da4$1_3@corp-goliath.newsgroups.com> <9s62qa$11k821$1@ID-11957.news.dfncis.de> <3be69395_1@corp-goliath.newsgroups.com> Message-ID: <9s65ru$10mk5k$1@ID-11957.news.dfncis.de> "K?roly Ladv?nszky" wrote in message news:3be69395_1 at corp-goliath.newsgroups.com... > Thank you for your answer. > > > You've just created a class level shared object a1. > > Ok, but then I'd expect the same behaviour when a1 is a number. > Try this: > > class c: > a1=0 You will shortly create an instance variable a1. When this happens, you no longer reach the class variable from instance references. Test further by creating a2 at the class level. > def f1(self,a): > self.a1=a > > Now: > o1=c() > o1.f1(99) you've just set the instance's a1 - not c.a1 (try it!) > o1.a1 ==> 99 > o2=c() > o2.a1 ==> 0 ! Shouldn't it reflect the change in the class level object's > value just like in the case a1 is a list? No. But after adding a2 (as per above), try: o2.a2 # should be as init'd in class c c.a2 = 2 o2.a2 # s/b 2 o1.a2 # s/b 2 The two places to find instance attributes are in the instance, the class, and in __bases__ of class. No wait, that's three... ok... The three places to find instance attributes are in the instance, the class, in __bases__ of class, and in the module. No wait, that's four... ok... The four places to find instance attributes are in the instance, the class, in __bases__ of class, in the module, and in builtin. There! ;-) Bases-search-order-subject-to-python-release-ly y'rs, -- Emile van Sebille emile at fenx.com --------- From db3l at fitlinxx.com Mon Nov 12 20:32:46 2001 From: db3l at fitlinxx.com (David Bolen) Date: 12 Nov 2001 20:32:46 -0500 Subject: " <024801c16762$024a1530$1395003e@rashome> <015801c16767$4d5edec0$ced241d5@hagrid> <20011110130113.274$u8@news.newsreader.com> Message-ID: David Eppstein writes: > Sure. But if you want to parse HTML that you don't control, you are going > to have to be ready to handle invalid input and do something reasonable > with it. Yep - although "reasonable" could be declare it invalid depending on the problem space :-) I do think in this case the right thing is actually happening - the document is generating an SGMLParseError due to bad syntax. But true, I expect the original poster needs to determine how best to handle the problem document since I expect just rejecting it is not desirable. The code that is parsing it will have to decide what to do (e.g., "guess" at what the document author meant to write since it wasn't valid HTML), but I don't think that's a problem with the parser module - it just places a bigger burden on the application using the module if it wants to support problem documents. Personally, I think this is precisely the sort of subtle issues that arise when browsers try to be "nice" and accept invalid documents, and then web sites "work best with IE 5.x or greater" or whatever. It's not just that you use non-standard features, but you end up with undocumented heuristics in a limited number of browsers, which in turn permit the writing of invalid documents, which then hurts folks trying to write other parsers and applications to deal with those documents. You end up not only having to properly parse SGML, but guess at what exceptions to allow to work like the common browsers, since that's what most people will have tested against (in lieu of validating their HTML against the DTD or something). But it's not HTML that leads to this state, but trends where the standards are not obeyed. -- -- 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 hamish_lawson at yahoo.co.uk Tue Nov 6 09:32:19 2001 From: hamish_lawson at yahoo.co.uk (Hamish Lawson) Date: Tue, 06 Nov 2001 14:32:19 -0000 Subject: Yahoo Groups archive of python-list wiped - what happened? Message-ID: <9s8s9j+utk1@eGroups.com> The Yahoo Groups archive of python-list seems to have started over with message #1 dated 5 November 2001, losing all messages before that. Does anyone know what happened? http://groups.yahoo.com/group/python-list/messages/1 Hamish Lawson From mwh at python.net Tue Nov 27 05:15:48 2001 From: mwh at python.net (Michael Hudson) Date: Tue, 27 Nov 2001 05:15:48 -0500 (EST) Subject: bugs in `gc.get_referents()' In-Reply-To: <200111270833.fAR8X5Z23184@paros.informatik.hu-berlin.de> Message-ID: On Tue, 27 Nov 2001, Martin von Loewis wrote: > Again, this might go away with the patch. get_referents isn't supposed > to trigger a garbage collection. All those PyList_Appends might, though. Cheers, M. From schrist at gmx.net Tue Nov 6 17:02:34 2001 From: schrist at gmx.net (Christian Schnell) Date: Tue, 06 Nov 2001 23:02:34 +0100 Subject: Beginner in Python Message-ID: <3BE85DF9.CDF844D2@gmx.net> Hi, I wanted to start programming in python today and had some problems. I wrote the famous "Hello, world"-programm and saved it as helloworld.py. If I open the programm directly in the explorer it works but I cannot start it from Ms-Dos. If I type python helloworld.py I get the message: File "", line 1 python helloworld.py ^ SyntayError: invalid syntax What is my mistak? Can anyone help me? Thank you, Christian -- Don't panic. ICQ 116707729 From kragen at canonical.org Mon Nov 26 14:32:39 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 14:32:39 -0500 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <83bshqtek2.fsf@panacea.canonical.org> <3c021cd7@brateggebdc5.br-automation.co.at> <3C02792B.3748A916@earthlink.net> Message-ID: <83zo59s4yw.fsf@panacea.canonical.org> Hans Nowak writes: > I have a follow-up question though. The project I'm currently > working on is well suited for third-party contributions; it makes > sense for others to add modules if they want to. If my code is > released under, say, the GPL, what happens when someone else wants > to contribute to it? Does the new code have to be GPL too? Or > GPL-compatible? Briefly, yes. The GNU General Public License does not allow other people to incorporate your program into a program that is licensed more restrictively. So if someone writes a module they want to become part of your program, they must either grant people the right to use, copy, modify, and redistribute their code under the GNU GPL or get you to grant a more liberal license to your code. Other ('non-copyleft') licenses, such as the BSD license, don't impose this restriction. As a result, if you license your code under the BSD license, someone can add some proprietary modification, run py2exe on it, and sell it under a standard proprietary-software EULA for $500 a pop: "Purchaser agrees not to decompile, reverse-engineer, or disassemble the Software." Some people see this as an advantage of non-GPL licenses like Python's, which result in the software being used more widely; other people see this as an advantage of the GPL, which results in all the users of the software having the freedoms to use, copy, modify, and redistribute it. From TomH at optiscan.com Wed Nov 21 01:33:42 2001 From: TomH at optiscan.com (Tom Harris) Date: Wed, 21 Nov 2001 17:33:42 +1100 Subject: deleting directory tree Message-ID: Greetings, Can someone explain what os.removedirs() does? I needed a function to remove a directory and all its files and subdirectories, and ended up writing one. It seems that there should be such a function in os, but I drew a blank. Tom Harris, Software Engineer Optiscan Imaging, 15-17 Normanby Rd, Notting Hill, Melbourne, Vic 3168, Australia email tomh at optiscan.com ph +61 3 9538 3333 fax +61 3 9562 7742 This email may contain confidential information. If you have received this email in error, please delete it immediately,and inform us of the mistake by return email. Any form of reproduction, or further dissemination of this email is strictly prohibited. Also, please note that opinions expressed in this email are those of the author, and are not necessarily those of Optiscan Pty Ltd. From cookedm+news at physics.mcmaster.ca Sun Nov 11 17:11:34 2001 From: cookedm+news at physics.mcmaster.ca (David M. Cooke) Date: 11 Nov 2001 17:11:34 -0500 Subject: C modules with gcc 3.0.x References: <20011111.154717.381570572.10034@localhost.localdomain> Message-ID: At some point, "Robert Nikander" wrote: > Has anyone been using gcc 3 with python C modules? When gcc 2.95 compiles > the module everything works fine, but if I use gcc 3 I get this.... > > Python 2.2b1 (#2, Nov 11 2001, 12:36:39) [GCC 2.95.3 20010315 (release - > Linux-Mandrake 8.0 for PPC)] on linux2 Type "help", "copyright", "credits" > or "license" for more information. > >>> import spam > Traceback (most recent call last): > File "", line 1, in ? > ImportError: libgcc_s.so.1: cannot load shared object file: No such file > or directory > >>> > >>> Well, I think that's pretty obvious :-) The loader can't find the 'libgcc_s.so.1' library. GCC 3, instead of statically linking in a runtime library libgcc.a, now links to a shared library instead. Check to see if you have it somewhere (probably in /lib). Otherwise, you'll have to install it (on Debian, it's the libgcc1 package -- I don't know what it is for Mandrake). -- |>|\/|< /--------------------------------------------------------------------------\ |David M. Cooke |cookedm(at)physics(dot)mcmaster(dot)ca From shalehperry at home.com Thu Nov 22 11:34:02 2001 From: shalehperry at home.com (Sean 'Shaleh' Perry) Date: Thu, 22 Nov 2001 08:34:02 -0800 (PST) Subject: Newbie needs "interface" In-Reply-To: <3BFD2536.7B4AFFC6@irisa.fr> Message-ID: On 22-Nov-2001 Roberto Bonato wrote: > Hi all > > > I'm writing a function that implements an algorithm and that > prints intermediate results all along the (usually very long) > computation. Sometimes I want the results to be written on the stdout, > sometimes on a Tkinter Text widget, sometimes to a file. I feel the need > of something like a Java Interface with a method "write" to wrap all > such devices into. > Since I'm a newbie at programming and at Python in particular I still > cannot find a simple and elegant way to do that. Thanks for any help. > python does a similar thing to what java does. stdout has methods to act like files (sys.stdout.write()). The only missing piece is some glue to make the Tkinter widget act like a file. It may be there, it may not. From bryan at eevolved.com Fri Nov 30 02:13:33 2001 From: bryan at eevolved.com (Bryan) Date: Fri, 30 Nov 2001 02:13:33 -0500 Subject: CryptKit 0.9 released Message-ID: This is a release notification for the CryptKit Project: http://eevolved.com/cryptkit/ CryptKit is a developer's toolkit implementing several of the most modern and efficient cryptographic algorithms. The kit is primarily written in ANSI C for speed and subsequently wrapped with SWIG for ease of use in python. The goal of this kit is twofold: - Efficiency and size. The kit is considerate of developer constraints on size and speed of applications. That is why CryptKit implements only the most efficient algorithms ( AES, ECC, DH, NR ) while maintaining small library size ( around 100KB compared to 2.1 MB for openSSL 0.9.6 ). - Ease of use. The kit aims to free programmers from having to understand the underlying cryptographic concepts that guarantee security. Instead, the structure is organized in a modular fashion, with wrapper classes that provide all the functionality. Ample documentation provides examples of usage. CryptKit is small and fast, mainly because it implements excellent algorithms: Rijndael (AES), SHA 256 bits, Elliptic Curve PKI, Diffie-Hellman key exchange and Nyberg-Ruppel signature/verification. These modules are combined to provide a faster, lighter and easier to use secure socket alternative to SSL. CryptKit is not compatible with SSL. Whereas SSL aims to support a wide variety of algorithms that essentially perform the same task ( like DES/RC4/RC2 or MD5/SHA ), CryptKit takes the minimalist approach of implementing only one version of each crypto primitve. Great care went into selecting the best of what was available. CryptKit sports a the BSD license. All comments welcome, -- <=====================================> Bryan Mongeau Lead Developer, Director eEvolved Real-Time Technologies Inc. Website: http://www.eevolved.com Public key: http://eevolved.com/bcm.pk <=====================================> "My religion consists of a humble admiration of the illimitable superior spirit who reveals himself in the slight details we are able to perceive with our frail and feeble mind."-- Einstein From simonb at webone.com.au Sun Nov 25 07:48:53 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Sun, 25 Nov 2001 23:48:53 +1100 Subject: A permutation on permutations References: Message-ID: <3C00E8B5.3060105@webone.com.au> well, i'd like to see this list comprehension implemented properly ; it doesn't compute as it stands (on 2.1.1)...? But i understand the problem; one way to solve it efficiently is to choose one permutation out of the reflected pair, as u build. Unfortunately, this nice peice of list comprehensions will (AFAICS) be disposed of. To choose, eg. pick only perms whos first entry is less than the last :) Simon B Arthur Siegel wrote: >What I've come up with is: > >L is my list of arbitrary length. >M= [i for i in range (len(L))] > >#thanks to Rainer Deyke's post >def perms(L): > if list == [] : > return [[]] > return [[list[i] + p for i in range(len(list))\ > for p in perms(list[:i] + list[i+1:])] > >def removedups(t): > for p in t: > m=copy.copy(p) > m.reverse() > if m in t: > t.remove(m) > >def drawcurve(t): > #t is M or a slice of M > perm=perms(t) > removedups(perm) > for i in range(len(perm)): > cp=[L[j] for j in perm[i]] > BezierCurve(cp) > >It seems to work. > >But I wonder if there is a significantly more >efficient solution > >Art > > From phd at phd.pp.ru Tue Nov 27 11:01:55 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Tue, 27 Nov 2001 19:01:55 +0300 Subject: Pine and MIME... In-Reply-To: <1006858608.3010.23.camel@del-vap-bos.ralphpill.com>; from vincent_a_primavera@netzero.net on Tue, Nov 27, 2001 at 10:56:48AM +0000 References: <1006858608.3010.23.camel@del-vap-bos.ralphpill.com> Message-ID: <20011127190155.Q25831@phd.pp.ru> On Tue, Nov 27, 2001 at 10:56:48AM +0000, Vincent A. Primavera wrote: > Using mimetools and MimeWriter I am trying to write a program to send > an E-Mail with a .xls attachment. I have gotten to the point where the > MIME encoded message will appear correctly with it's attachments with > KMail, Evolution, and Outlook Express. But, when the message is viewed > with Pine it is not broken down into it's parts/attachments. Any > suggestions? I notice that any existing messages with attachments in > Pine display correctly broken down. > > P.S. I have added the Content-Disposition header... And other headers? Pine is really strict about standards. And MIME is well-defined standard. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From bernhard at intevation.de Mon Nov 26 14:55:46 2001 From: bernhard at intevation.de (Bernhard Reiter) Date: 26 Nov 2001 19:55:46 GMT Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <83bshqtek2.fsf@panacea.canonical.org> <3c021cd7@brateggebdc5.br-automation.co.at> <3C02792B.3748A916@earthlink.net> Message-ID: <9tu6o2$4k7na$3@ID-89274.news.dfncis.de> In article <3C02792B.3748A916 at earthlink.net>, Hans Nowak writes: > The project I'm currently working on > is well suited for third-party contributions; > it makes sense for others to add modules if they want to. > If my code is released under, say, the GPL, what > happens when someone else wants to contribute to it? Does the > new code have to be GPL too? Or GPL-compatible? The new code has to be GPL compatible so that somebody can include it in a joined distribution which will be under GPL. Bernhard -- Professional Service around Free Software (intevation.net) The FreeGIS Project (freegis.org) Association for a Free Informational Infrastructure (ffii.org) FSF Europe (fsfeurope.org) From fabella at free.fr Thu Nov 29 17:28:17 2001 From: fabella at free.fr (news python) Date: Thu, 29 Nov 2001 23:28:17 +0100 Subject: Python to .dll ? References: <9u63rp$v5g$06$1@news.t-online.com> Message-ID: <9u6cp4$nl4$1@wanadoo.fr> I think it will be better to create COM objet using python instead of dll...you can have informations about building com in python at www.python.org/windows/win32com FA "Dennis Conrad" a ?crit dans le message news: 9u63rp$v5g$06$1 at news.t-online.com... > Hi, > > Is there a possibility to create a (win32) .dll from a Python-script? I know > there is py2exe, maybe there is something like py2dll...? > > Thank you very much > > Dennis > > > From hartanto at telusplanet.net Fri Nov 9 18:16:07 2001 From: hartanto at telusplanet.net (harry) Date: Fri, 09 Nov 2001 23:16:07 GMT Subject: data size References: <_6FG7.33159$i4.5175661@news0.telusplanet.net> <8ZXG7.5723$Yh.305712@atlpnn01.usenetserver.com> Message-ID: > He is probably asking you which C library your version of Python was > compiled with. But you don't need to know that, either. > > All Python dictionaries are a standard 2.5 cm by 3.6cm. Integers have no > width and are all 1.2 cm in length. Strings are all 2 mm times the number of > characters, except Unicode strings, which are 4 mm times the number of > characters. could you explain further about the metric standard you're using. this is the first time a size of data structure is measured using meters instead of byte/bit. i need the information for my post-mortem of my assignment to explain why using python data structure would be efficient. yes, i'm only a studemt who is still need to learn lots of stuffs. thanks. From ssmith619 at hotmail.com Sun Nov 25 12:45:35 2001 From: ssmith619 at hotmail.com (Stephen Smith) Date: Sun, 25 Nov 2001 17:45:35 GMT Subject: Free Python Server References: <15353.40372.784126.72589@beluga.mojam.com> Message-ID: <37aM7.256063$5A3.96426335@news1.rdc2.pa.home.com> I am currently using port5.com, and I don't like the service. What are some of those Russian ones? "Oleg Broytmann" wrote in message news:mailman.1006245388.23205.python-list at python.org... > On Mon, Nov 19, 2001 at 06:03:00PM -0600, Skip Montanaro wrote: > > Stephen> Hey, does anyone know of any free web hosting solutions that > > Stephen> offer Python, and no banners or pop-up ads? > > > > I hate to play the devil's advocate here, but if they don't charge for their > > web hosting and don't put up ads, how are they supposed to make the money > > necessary to keep offering their services to you? Oh, right, they take your > > personal info and sell it to direct marketing folks. > > http://www.port5.com/ does this - 15 megs, no banner, ftp access, email > forwarding, statistics - all for free. But no Python. > > There are few Russian free webservers providers that have no Python, but > have shell access, so I just installed Python myself. I am pretty sure > there other, not Russian providers. Of course, there are banners and all > that. > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru > Programmers don't die, they just GOSUB without RETURN. > From k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m Sun Nov 25 22:55:07 2001 From: k1e2i3t4h5r6a7y at 1m2a3c4.5c6o7m (Keith Ray) Date: Mon, 26 Nov 2001 03:55:07 GMT Subject: application scripting References: Message-ID: In article , "John Roth" wrote: > "Chris Liechti" wrote in message > news:Xns9165290659FCcliechtigmxnet at 62.2.16.82... > > [posted and mailed] > > > > > recordable apps have to provide a menu point to start/stop recording, > > because only the app itself knows what input events create what > actions in > > the script. > > I believe there is a lower level API in Windows that allows recording > events and playing them back. It's frequently used by automation > packages and GUI testing tools that are not application specific. > > I don't know whether the API is implemented in either of the Windows > Python distributions, however. > > Having event recording within the application is a good idea, > because external recording tends to be very fragile. Thanks for your responses. In MacOS, the recording menu is external to the application (in the Script Editor application). From r.b.rigilink at chello.nl Mon Nov 5 20:06:41 2001 From: r.b.rigilink at chello.nl (Roeland Rengelink) Date: Tue, 06 Nov 2001 01:06:41 GMT Subject: Program very slow to finish References: Message-ID: <3BE737A8.8CF867A5@chello.nl> Tim Peters wrote: > > > I can't make time for it now, but "someone should" try this test using > Vladimir Marangozov's PyMalloc package (shipped with Python 2.1 but turned > off by default -- see the 2.1 NEWS file). > Well, aint that nice 2.2b1 --with-pymaloc size: 10000, creation: 29.94, destruction: 0.61 size: 20000, creation: 30.10, destruction: 0.64 size: 50000, creation: 30.73, destruction: 0.71 size: 100000, creation: 30.72, destruction: 0.68 size: 200000, creation: 30.95, destruction: 0.69 size: 500000, creation: 30.62, destruction: 0.67 size: 1000000, creation: 30.71, destruction: 0.68 malloc is faster too ;) >From the NEWS file An optional object allocator has been included. This allocator is optimized for Python objects and should be faster and use less memory than the standard system allocator. It is not enabled by default because of possible thread safety problems. The allocator is only protected by the Python interpreter lock and it is possible that some extension modules require a thread safe allocator. The object allocator can be enabled by providing the "--with-pymalloc" option to configure. Are extension modules in the Python std library affected? Thanks for all the help, Roeland (Who's never used a dict with more than 1000 items in 'real' code) -- r.b.rigilink at chello.nl "Half of what I say is nonsense. Unfortunately I don't know which half" From syver-en at online.no Tue Nov 20 04:00:45 2001 From: syver-en at online.no (Syver Enstad) Date: 20 Nov 2001 10:00:45 +0100 Subject: Environment variables in Windows 2000 References: <9tcobh$qql@news.or.intel.com> Message-ID: "Brian Geddes" writes: > All - > > I've been trying to store/pass information in environment variables in > Windows 2000, but things aren't working the way I expect them to. > The docs > state that by making changes to the os.system dictionary, It's the os.environ dictionary >the changes should > be carried over in environment space automatically by os.putenv(). And it works on my machine (BTW win2k pro) example: #script1.py import os os.environ['DUMMYTEST'] = 'Transfer' os.system('python script2.py') ---------------------------------------------------------------------- # script2.py import os assert os.environ['DUMMYTEST'] = 'Transfer' print "success" Running script1.py should print success to stdout (put both files in the same directory >However, > the following which looks like it should work, does not: No it shouldn't both putenv and assignment just creates entries for the current environment, this is inherited by process started by that proces but doesn't affect the environment for the whole OS. I think you'll have to modify the registry to change environment variables globally. At least I know that that is one way to acheive it. Under 2000 it you assign to the following key make a new system environment variable: [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Session Manager\Environment] For a user specific environment variable: [HKEY_CURRENT_USER\Environment] (Take a look with regedit yourself to see the layout of it). Use win32 all to write to the registry, or there maybe support for writing to the registry in the main distribution now. (Haven't checked it out). Hope this helps :-) -- Vennlig hilsen Syver Enstad From tim.one at home.com Sat Nov 3 00:42:45 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 00:42:45 -0500 Subject: Feature Wish: "%" Extension In-Reply-To: <3BE34077.8EA553CB@spam.net> Message-ID: [anonymous] > ... > For number->string conversion (see it coming yet?), the handy overloaded > "%" operator handles radices 8, 10, and 16 -- with padding, > zero-filling, prefixing (e.g. "0x"). Historically, this is simply because "%" is a C sprintf clone, and bases 8, 10 and 16 are handled by C by 2 isn't. Greg Wilson submitted a patch to add base 2: Unfortunately, it's got no review yet and 2.2 feature freeze is in effect. > ... > PS: I'm still dumbfounded why Python's division operator must behave > differently than that in php, js, java, perl, awk, and C/C++ -- colleges > do not teach BASIC anymore -- as I worry about all of my hardware > interface code and auto-comment-wrapping editor :-) Of the languges you mention, "integer" division in AWK, JavaScript and Perl returns a floating-point result. PHP does integer or float division, after first checking to see whether the remainder is 0. Java, C and C++ truncate to an integer (although it's ill-defined in C89 when mixing signs). Since the languages you hold up as models actually have nothing in common here, it's a bit of a challenge to guess what the heck you think "the obviously correct way" may be. rest-assured-python-will-act-like-one-of-them-ly y'rs - tim From jeff at ccvcorp.com Fri Nov 16 13:14:44 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 16 Nov 2001 10:14:44 -0800 Subject: Returning values from a lambda References: Message-ID: <3BF55793.861911BF@ccvcorp.com> John McMonagle wrote: > William Tanksley wrote: > > > On Fri, 16 Nov 2001 10:36:06 +1000 (EST), John McMonagle wrote: > > > >>I wish to return values from a lambda function which is bound to the > >>Tkinter button command option. For example, > > > > The solution is to not use a lambda. Just define a function which > > modifies the variables you need, and pass that function's name in place of > > the lambda. > > But I need to use a lambda in order to pass arguments to the function. If you want to get fancy, you can create a callable class instance with your arguments as member variables. Something like: class Operations: def __init__(self, a, b): self.a = a self.b = b def __call__(self): global x global y x, y = a + b, a * b And then use it like so: btn = Button(root, text'Press Me', command=Operations(2,5)) If you want to avoid using global variables, then you can pre-create your class instances, and store the results of the operations as another set of member variables that can be retrieved elsewhere later. If this looks useful to you, then you may want to search ActiveState's Python Cookbook for recipes on currying. My code here is a very simple example of a concept that is treated in much more detail there. Jeff Shannon Technician/Programmer Credit International From jeff at ccvcorp.com Fri Nov 16 13:23:57 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Fri, 16 Nov 2001 10:23:57 -0800 Subject: PIL Installation on windows98 - from newbie References: Message-ID: <3BF559BD.ADEA01D6@ccvcorp.com> Tech wrote: > I downloaded the file for my version of python and ran the setup > executable that I downloaded. Next, I tried to test the installation > by running some of the test scripts that came with PIL. Each time I > tried I got the following error... > > Python 2.1.1 (#20, Jul 20 2001, 01:19:29) [MSC 32 bit (Intel)] on > win32 > Type "copyright", "credits" or "license" for more information. > IDLE 0.8 -- press F1 for help > >>> > Traceback (most recent call last): > File "C:\py21\Samples\viewer.py", line 7, in ? > import Image, ImageTk > ImportError: No module named Image This is almost certainly a search-path issue. If you create a file called PIL.pth in your python directory, containing a single line consisting of the full path to your PIL installation, that ought to solve the problem. Jeff Shannon Technician/Programmer Credit International From kentsmith at dxsys.com Sat Nov 10 20:13:47 2001 From: kentsmith at dxsys.com (kentsmith at dxsys.com) Date: Sat, 10 Nov 2001 20:13:47 -0500 Subject: IsPython really O-O? Message-ID: A Smalltalk guru in our organization looked at Python last weekend (after I had made a big scene saying that it may be a solution to some of our cross-platform issues) and came away saying that it was no more object-oriented than Java. I sputtered around a bit but could hardly make a decent argument, as I'm a mere designer. We do very large-scale industrial work here, all O-O, with object databases (I thought the ZODB business looked great). Is my friend right? Is Python not "really" appropriate for true O-O applications, in the sense that Viz-Age Smalltalk and Eifel and so on are??? Kent Smith From AdrianLeu at kelseus.com Wed Nov 14 10:31:43 2001 From: AdrianLeu at kelseus.com (Adrian Leu) Date: 14 Nov 2001 07:31:43 -0800 Subject: re. module Message-ID: <993ae4ca.0111140731.3c11e6d5@posting.google.com> I am trying to figure out a solution for the following: import re text = 'name_0 goto place' string = 'name|name_0|name_1' pattern = re.compile(string, re.I) d = pattern.search(text) return d.group(0) The problem is that my program will return 'name' to this. What I want is for the search to return a match (if it exists) only after looking at the whole string (name_0 in this case). I.e. in my example I would like the program to return 'name_0' not 'name'. Any ideas how I could do that? Thanks. Adrian. From hungjunglu at yahoo.com Thu Nov 29 14:48:58 2001 From: hungjunglu at yahoo.com (Hung Jung Lu) Date: 29 Nov 2001 11:48:58 -0800 Subject: Python, licenses and CVS References: <3C0181DA.2DB715B9@earthlink.net> <3C02D7A2.A7D6EC6E@engcorp.com> <7xelmjbgwz.fsf@ruckus.brouhaha.com> <3C0597E9.4CEB1455@ccvcorp.com> Message-ID: <8ef9bea6.0111291148.1c5d4fa@posting.google.com> David Bolen wrote in message news:... > Gerhard =?unknown-8bit?Q?H=E4ring?= writes: > > If this is because it's a Micro$oft shop, Visual Source"safe" is a reasonable > > version control software. Btw. CVS also has deficiencies like no history of > > meta-operations like file moving/renaming, etc. > (minor MS-bash .. Definitely agree on the CVS shortcomings, but but at > least CVS handles branching reasonably) > ... > From my perspective, I haven't been overly enthusiastic about WinCVS > (the cvsgui link), at least not enough to try to promote its use. I'll speak for one here, on my own experience. I honestly tried very hard to switch from SourceSafe to CVS. But the CVS world just seemed kind of immature for Windows platform, and the disdain attitude of some CVS developers towards the Windows platform did not help. After wasting some time on various Windows adaptations of CVS, I gave up. Enterprise Visual Studio is not that expensive anymore (especially if you go to eBay). Given the long track record of CVS, I really don't understand why the windows adaptation is still so primitive, why documentations are so badly written. Website CVS resources are so badly organized, too. I know CVS is free, but it ended up costing me development time and money. I am sure CVS will get better, but I'll give it a few more years. Meanwhile, I use SourceSafe. Hung Jung From gh_pythonlist at gmx.de Tue Nov 13 23:01:41 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Wed, 14 Nov 2001 05:01:41 +0100 Subject: How do you get persistent database connections with Python? In-Reply-To: <9sshgb$eh4$1@laptop.local> References: <9sshgb$eh4$1@laptop.local> Message-ID: <20011114050140.A76172@lilith.hqd-internal> On Tue, Nov 13, 2001 at 08:30:51PM -0500, mark at laptop.local wrote: > How do you create persistent database connections with Apache, Python, > and PostgreSQL? Any generic methods of creating persistent database connections > would be helpful. > > I have been trying like crazy to find information on the topic, but I can't > find any useful information. > > I am using mod_python and also PyGreSQL modules. I can switch to others > if need be. The db module doesn't matter. What you probably need to check out is the Python documenation (wrt. importing modules). Your mod_python handler lives as long as the Apache process lives. So, you just have to instantiate a db connection in the handler's module and store the connection object it in the module. That's all there is to it. There are three alternatives to PyGreSQL: pyPgSQL, psycopg and PoPy (I'm a developer in the pyPgSQL project). I'd recommend you check out the alternatives, too if you're interested in a good db module 4 PG. Iff you want to continue using PyGreSQL, I recommend you check out the latest version from *PostgreSQL* CVS - it contains several bugfixes when compared to the latest "released" version of PyGreSQL (3.2). Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From rockvz at yahoo.com Thu Nov 1 07:54:25 2001 From: rockvz at yahoo.com (Rock VZ) Date: Thu, 1 Nov 2001 04:54:25 -0800 (PST) Subject: Component model Message-ID: <20011101125425.55301.qmail@web13507.mail.yahoo.com> Hi, Does Python have support for the component model followed by Bonobo or KPart. I'm currently working with python and wxPython. I will be developing a set of independent applications that will later need to be "merged" into one GUI. Is this possible using python? and also the app should run on unix and windows. Thanks Rock ===== __________________________________________________ Do You Yahoo!? Make a great connection at Yahoo! Personals. http://personals.yahoo.com From wzdd at lardcave.net Tue Nov 6 14:39:51 2001 From: wzdd at lardcave.net (Nicholas FitzRoy-Dale) Date: Wed, 7 Nov 2001 06:39:51 +1100 (EST) Subject: How much is set in stone? In-Reply-To: <3BE70BB6.A2D0FCEC@ix.netcom.com> Message-ID: On 5 Nov, Jive Dadson wrote: > Chris Barker wrote: >> If you start changing that too, you >> really won't have Python anymore!! > > The changes I've proposed do not conflict in any way with the > "Python-ness" of the language. If you don't put "option explicit" at > the top of your module, it will behave exactly the same as it did > before. Good point! Based on that, here is my Python "Enhancement" proposal: Let's make it so that placing "option disturbing" at the start of a module turns on "C Mode". In this mode, Python's behaviour would be modified in the following ways: * Use of curly braces to delineate syntax blocks, rather than indentation; * The C ternary operator would be fully supported, as would fall-through "switch" statements (as long as the type being switch()ed is some kind of number, of course); * Class support would be removed, but everyone knows all you need is support for struct{} anyway. Structs could only contain the types "IntType", "FloatType" and "StringType", but when you get down to it it's all numbers anyway; * We'd finally get our beloved "goto" statement. Fortunately, none of this will affect the "Python-ness" of the language - without "option disturbing", it will behave exactly as before! -- - Nicholas FitzRoy-Dale http://www.lardcave.net I'm thinking of getting a pet cheese. I already have the cheese food. - http://www.enweirdenment.org/cgi-bin/cube-hof.html From db3l at fitlinxx.com Fri Nov 2 17:48:59 2001 From: db3l at fitlinxx.com (David Bolen) Date: 02 Nov 2001 17:48:59 -0500 Subject: Zugriff auf Windows Dateieigenschaften References: Message-ID: "Steve Holden" writes: > still-worrying-about-april-2038-ly y'rs - steve I thought it was January? >>> max=0x7fffffff >>> time.ctime(max) 'Mon Jan 18 22:14:07 2038' although if we can get stuff to switch consistently to unsigned for time_t before then, we'll buy plenty of time :-) -- -- 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 zope at thewebsons.com Sun Nov 18 13:11:12 2001 From: zope at thewebsons.com (Ben Ocean) Date: Sun, 18 Nov 2001 10:11:12 -0800 Subject: RANSOM DEMAND: Image Held Hostage! Message-ID: <5.1.0.14.0.20011118100745.00a12170@thewebsons.com> I need a way to size up images via script. Now, in that inferior scripting language known as PHP, *they* have such a tool: getimagesize(). Can it be that God's gift to scripting languages, Python, can't compete here? If it's true that PHP has one up on us here, how can I write a script that bridges this dastardly gap? TIA, BenO From sholden at holdenweb.com Fri Nov 16 10:57:19 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 10:57:19 -0500 Subject: CGIHTTPServer and Win2k References: <4q39vt4silvue8rl0qv4ff4tar6942r9g3@4ax.com> Message-ID: [cc'd to python-docs at python.org] "Sandy Norton" wrote ... > > Exit status 0x2 is "file not found". > > > > You have a permissions problem. On Windows 2000, the user profile > > directories in "Documents and Settings" are readable only by the owner. > > > > You should either place these in "Documents and Settings\All Users", or in > > some other public directory. > > I don't think that will solve the problem: here's a cut-and-paste from > python 2.2 module reference: > > "11.17 CGIHTTPServer -- CGI-capable HTTP request handler > > Availability: Unix. > > The CGIHTTPServer module defines a request-handler class, interface > compatible with BaseHTTPServer.BaseHTTPRequestHandler and inherits > behavior from SimpleHTTPServer.SimpleHTTPRequestHandler but can also > run CGI scripts. > > Note: This module is Unix dependent since it creates the CGI process > using os.fork() and os.exec()." > I suspect this is a documentation bug, because since 2.0 (?) the code uses fork() if it can, popen2() otherwise; if neither of these are available it will run imported Python scripts as CGIs. Here's a quote from the docstring at the head of the 2.0 module: """If the os.fork() function is not present (e.g. on Windows), os.popen2() is used as a fallback, with slightly altered semantics; if that function is not present either (e.g. on Macintosh), only Python scripts are supported, and they are executed by the current process.""" regards Steve -- http://www.holdenweb.com/ From huaiyu at gauss.almadan.ibm.com Mon Nov 19 15:07:42 2001 From: huaiyu at gauss.almadan.ibm.com (Huaiyu Zhu) Date: Mon, 19 Nov 2001 20:07:42 +0000 (UTC) Subject: Are there any list comparison optimizations in Python? References: <3BF0883B.62473129@engcorp.com> <3BF47762.4322913A@engcorp.com> Message-ID: On Thu, 15 Nov 2001 21:18:10 -0500, Peter Hansen wrote: > >Well, you just pointed out one case, which is probably enough reason >not to add a special case to the language itself. Should this one case itself be considered a special case? >Other practical uses I can think of start with using it during >testing, to verify that a particular code path will actually >work if it is taken, or for troubleshooting a particularly >unclear problem which involves comparisons. What would such examples look like? I can only think of cases where the problems are caused exactly by (a is b) and (a!=b) both being true. They would dissappear if (a is b) implies (a==b). A good example might be something that uses == for a task that is semantically different from the concept "equal", yet it still needs to be spelt as == to utilize other facilities that rely on it. >Not that it should necessarily matter. If == is defined >as using __cmp__, then for consistency (principle of >least surprise) one should be able to rely on that definition. Yes, if that is the definition. But the definition has not always been this way. The question is whether another definition (which happens to be an older definition) is better. Huaiyu From tjreedy at home.com Fri Nov 2 09:05:37 2001 From: tjreedy at home.com (Terry Reedy) Date: Fri, 02 Nov 2001 14:05:37 GMT Subject: Source files? References: <3BE200BA.3F271DA0@ix.netcom.com> <7x668toosz.fsf@ruckus.brouhaha.com> <3BE21A76.F6E72CDA@ix.netcom.com> Message-ID: > I didn't download a tarball. I downloaded a .ext ("shield"), as the > instructions said Windows (spit!) users should do. I'll try downloading > the tarball. Most Windows users have no interest in reading or facility to compile the C sources, so they are left out of that binary distribution. Saves bandwidth and disk space. However, the sources are very much available and worth perusing. Terry J. Reedy From bit_bucket5 at hotmail.com Fri Nov 16 21:10:43 2001 From: bit_bucket5 at hotmail.com (Chris Stromberger) Date: Sat, 17 Nov 2001 02:10:43 GMT Subject: Python & cgi on win98--tinyweb problems, etc References: Message-ID: <3jhbvtolcur3sn3ali0r2er16dgddfaaca@4ax.com> On Fri, 16 Nov 2001 09:46:10 -0500, "Steve Holden" wrote: >"Chris Stromberger" wrote in message >news:p6p8vtk41q0dsf46tv00d60t2vuom3vmvd at 4ax.com... >> I'm looking for a solution to this: >> I want to run a personal web server to run python cgi scripts that >> interact with a mysql database on a windows 98 pc that's connected to >> the internet via cable modem. I would rather avoid all security >> issues and only allow the web server to serve pages to localhost--this >> setup will be for a single user of the pc, no remote users, etc. Very >> simple. So, I don't need a fancy web server. Any advice? >> >> I have tried apache and it works fine, of course, but I think it's too >> heavyweight for what I want here. >> >> I found tinyweb on the internet, and it looks promising, but I can't >> get it to run a python cgi script. It will run a test windows >> executable that I placed in the cgi-bin directory, so it's some >> problem specific to python and tinyweb. Any clues? The tinyweb >> documentation is pretty minimal. >> >> Any other recommendations for small simple web servers for this >> project? >> >Run, do not walk, to www.xitami.com, and download the freeware load. > >It runs well, with a very small footprint, and besides allowing CGI >scripting and having web-based administration it also lets you build >long-running web processes in Python! Naturally you can specify which >interfaces you want to use to serve web content (and naturally you will want >to limit yourself to 127.0.0.1). I ditched PWS a year ago and have never >looked back. > >regards > Steve I'll check it out. Could you expound a bit on your statement that "it also lets you build long-running web processes in Python"? What does that imply? Thanks for the suggestion. -Chris From nas at python.ca Fri Nov 30 12:44:17 2001 From: nas at python.ca (Neil Schemenauer) Date: Fri, 30 Nov 2001 09:44:17 -0800 Subject: What's the value of "None" between 2.1.1 and 1.5.2 In-Reply-To: ; from sholden@holdenweb.com on Fri, Nov 30, 2001 at 12:13:28PM -0500 References: Message-ID: <20011130094417.C4450@glacier.arctrix.com> Steve Holden wrote: > But for your existing simulation, where you seem to be using None to > record "No Value" (?) you can get away with > > something = min([x for x in a if x]) Nope: >>> a = [0.0, 1.0, None] >>> min([x for x in a if x]) 1.0 You want: min([x for x in a if x is not None]) Cheers, Neil From phd at phd.pp.ru Thu Nov 29 03:43:47 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Thu, 29 Nov 2001 11:43:47 +0300 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) In-Reply-To: ; from philh@comuno.freeserve.co.uk on Wed, Nov 28, 2001 at 11:36:29PM +0000 References: <3bfe9816.152519843@news.cortland.com> Message-ID: <20011129114347.D16265@phd.pp.ru> On Wed, Nov 28, 2001 at 11:36:29PM +0000, phil hunt wrote: > According to Microsoft, open source is un-American. And, also according > to Microsoft, they are responsible for open source. I guess Microsoft > must be un-American. Certainly :))) Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From emdpek at chron.com Fri Nov 2 10:59:16 2001 From: emdpek at chron.com (emdpek) Date: 2 Nov 2001 07:59:16 -0800 Subject: Python extension modules References: <7fd99f9.0110311606.7e0a5836@posting.google.com> Message-ID: <7fd99f9.0111020759.2d8ce91c@posting.google.com> Thanks for the response, Mark! > Check out the struct module. It allows you to pack and > unpack "blobs" of data (usually in a string), given a > format string. The one drawback is the "native" C struct being returned by the library may have contain several megabytes of data. Converting these values back and forth between C and Python might prove too much overhead. (Correct me if I am wrong!!!) Just a thought, but are there examples Py_BuildValue's "O&" modifier? This might provide another solution... > > static PyObject* > > MyNew_getattr(MyNew *self, char *name) > You should use Python declarations exactly - use > "PyObject" instead of "MyNew". MyNew may fail in some C++ > scenarios. I was wondering about this. Guess I really need a cast: static PyObject* instance_method(PyObject *self, PyObject *args) { MyNew *real_self = (MyNew *)self; etc... } And in response to other posts, today I spend the day learning SWIG. Thanks for the help! emdpek From christof at hurst-web.de Sun Nov 18 06:52:12 2001 From: christof at hurst-web.de (Christof Hurst) Date: Sun, 18 Nov 2001 12:52:12 +0100 Subject: Python servlet with DB Message-ID: <3BF7A0EB.C73F67C7@hurst-web.de> i must call a python-servlet out of a java applet. It's part of a diploma, where python is compared with java. now i don't know, how to make a connection to ma python, and how to make the python servlet talk to the DB. All DB-modules, i'va tried, didn't work. I want to send an image from the java applet to the python servlet to write this in a BLOB in my oracle Database. Who can help me? -- \|/ (@ @) +-------------oOO--(_)--OOo---------------+ |Christof Hurst | |Augustastr. 8, 76137 Karlsruhe | |Fon: 0721 / 82 00 954 | |mobil: 0172 / 38 04 322 | |Fax: 089 / 244316708 | |e-mail : Christof at hurst-web.de | |http://www.hurst-web.de | |UIN : 12030451 | =================ooO=Ooo=================== From loewis at informatik.hu-berlin.de Sat Nov 24 06:10:49 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 24 Nov 2001 12:10:49 +0100 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> <3bfecd77@brateggebdc5.br-automation.co.at> <97ae44ee.0111232129.550244cd@posting.google.com> Message-ID: shriek at gmx.co.uk (Stephen) writes: > Makes me wonder why more people don't use the rotor when they need > "just enough" encryption without going the full hog with PKI. I believe the algorithm used is cryptographically weak. As the comments suggest, the algorithm is the one used by the German Enigma machine from WWII. For those, a team lead by Alan Turing eventually implemented computing hardware that would break the new codes every day. > Just to clear up my own understanding, is it fair to say that > a "built-in" module can be defined as one that is included in > the core Python distributed, and is written in C as oppopsed > to Python, but which still needs to be imported before use ? Almost correct. There is a slight overloading of names here. Traditionally "builtin" modules are the ones listed in sys.builtin_module_names, which in turn are the ones statically linked with the compiler. These days, most installations build the modules shipped with Python as shared libraries, so they are strictly speaking "extension modules". However, to distinguish them from third-party extension modules, they are often called "builtin" even if not linked with the interpreter. Regards, Martin From madsurfer2000 at hotmail.com Sat Nov 17 15:34:16 2001 From: madsurfer2000 at hotmail.com (-) Date: 17 Nov 2001 12:34:16 -0800 Subject: How to know when a variable is set References: Message-ID: Michael Hudson wrote in message news:... > madsurfer2000 at hotmail.com (-) writes: > > > How can I test if a variable has been given a value, or if it's undefined? > > Why would you want to do that? Specificaly, in what context do you > want to know? > I like the idea of structs, and I was planning to use a class the same way, like class info: pass ... info.name = ... These would be set in an event driven GUI, and I needed to know if an attribute had been set before I saved the information. Now that I have thought more about it, an hash table would be a better choice. From fperez528 at yahoo.com Thu Nov 22 12:09:20 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Fri, 23 Nov 2001 16:37:20 +2328 Subject: Colored console on Windows References: <1712.011122@storm.ru> <9tjflj$j08$1@peabody.colorado.edu> Message-ID: <9tmmku$4e6$3@peabody.colorado.edu> Michael Hudson wrote: >> quick question: does your readline module handle multi-line edits? That is, >> if I have a multi-line statement, does it bring it back as a single >> editable entity (which would be great) or as the 'real' readline does, as a >> series of single-line statements (clumsy). > > My pyrepl package > > http://starship.python.net/crew/mwh/hacks/pyrepl.html > > does that. It's unix only, and a bit rough around the edges. I have > a new version sat on my irritatingly internet-disconnected home box > which I'll release as soon as I remember to stick it on a floppy and > bring it in to the department. I actually have your module in mind for a project of mine, but haven't used it yet. Why is it unix-only, though? My project is currently unix-only also but I'd like to offer MS people readline-type support and was hoping that your module would help in that respect. Cheers, f From boud at rempt.xs4all.nl Sun Nov 25 08:44:10 2001 From: boud at rempt.xs4all.nl (Boudewijn Rempt) Date: 25 Nov 2001 13:44:10 GMT Subject: GUI toolkit References: <9tb6ke$1evoq$3@ID-89274.news.dfncis.de> <9td9lv$c8p$1@tyfon.itea.ntnu.no> Message-ID: <9tqsja$qep$1@news1.xs4all.nl> Andreas Kostyrka wrote: > Now to follow the license faq from Trolltech I'd have to fork over 5k$ (for a > tripple license, I'm interested in PDA and Win32 versions too ;) ). For an > app I'll try to release under GPL? Perhaps it's worthwhile to understand that you can release your application under multiple licenses, yourself. On the other hand, you can just release the sourcecode under GPL, and have people do what they want on their own platform. -- Boudewijn Rempt | http://www.valdyas.org From rdsteph at earthlink.net Sat Nov 3 02:32:24 2001 From: rdsteph at earthlink.net (Ron Stephens) Date: Sat, 03 Nov 2001 07:32:24 GMT Subject: Jython and Python Libraries Message-ID: <3BE39ED5.28009771@earthlink.net> Will the Python libraries work well with Jython? I am particularly interested in whether urllib works under Jython. In other words, will a Python program that uses urllib but is otherwise pretty simple and straightforward be likely to work as a Java program after being complied using jythonc? From fperez528 at yahoo.com Fri Nov 30 09:01:14 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Sat, 01 Dec 2001 13:29:14 +2328 Subject: variable scoping across imports? References: <7b408077.0112010826.47a6a758@posting.google.com> Message-ID: <9ubekc$ped$2@peabody.colorado.edu> Roy Mathew wrote: > I have read the rules on variable scoping pretty carefully, I think. > Are the circular imports confusing python. (BTW, I am using > "ActivePython 2.1, build 210 ActiveState"). > > What am I missing? Circular inclusions tend to be a sign that you have to stop and rethink your construction in a fundamentally cleaner manner. There *maybe* cases where they're justified, but in general they are just the sign of a misunderstood design. cheers, f From tanzer at swing.co.at Mon Nov 12 03:34:41 2001 From: tanzer at swing.co.at (Christian Tanzer) Date: Mon, 12 Nov 2001 09:34:41 +0100 Subject: Is this considered black magic? In-Reply-To: Your message of "Sun, 11 Nov 2001 14:37:07 +0100." <200111111337.fABDb7eR012232@ratthing-b246.strakt.com> Message-ID: Laura Creighton wrote: > I want to do something which is conceptually very simple. Given a list of > objects, call make everybody call the same method you want to run. Sort > of like apply(), but for methods. > > This is what I came up with: (snip) > def foreach(name_key, object_list, *args): > print 'foreach: args are ' + `args` > for object in object_list: > try: > object.__class__.__dict__[name_key](object, *args) > except KeyError: > pass Hi Laura, Using `__class__.__dict__` to access the method means that neither inherited methods nor methods in the instance dictionary are handled correctly. `getattr` is the better choice (and less magic). I'd also add `** kw` to the function. Christian -- Christian Tanzer tanzer at swing.co.at Glasauergasse 32 Tel: +43 1 876 62 36 A-1130 Vienna, Austria Fax: +43 1 877 66 92 From brueckd at tbye.com Wed Nov 14 12:16:02 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Wed, 14 Nov 2001 09:16:02 -0800 (PST) Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) In-Reply-To: <97ae44ee.0111140921.281c4b7@posting.google.com> Message-ID: On 14 Nov 2001, Stephen wrote: > I've been trying to benchmark socket server and can't seem > to get it past serving 200 requests per second. [snip] Thread-per-request servers can't scale up too high (although it might be interesting to see what stackless + microthreads would do). You'll need to use the asynchronous I/O support (see the select module for lower level stuff, asyncore/asynchat for slightly higher stuff). If you don't want to build it yourself then you should consider some of the third-party frameworks like Twisted. Also, a lot of the server tuning guidelines that apply to things like Apache can be helpful to you. > Am-I-asking-too-much-of-Python-ly-your's, Not necessarily. If your program is mostly I/O bound then the slowness of Python (vs. C for example) becomes less of a factor. A Python server we're building at my work is tuned towards data throughput (and not so much towards connections per second, but still shoots for several hundred), and it easily pushes 1 Gbps on a single CPU P3-933. :) -Dave From emile at fenx.com Thu Nov 8 06:44:29 2001 From: emile at fenx.com (Emile van Sebille) Date: Thu, 8 Nov 2001 03:44:29 -0800 Subject: complex() bug or feature? References: <3BEA6446.8D8B4012@snakefarm.org> Message-ID: <9sdrg0$126e5a$1@ID-11957.news.dfncis.de> "Carsten Gaebler" wrote in message news:3BEA6446.8D8B4012 at snakefarm.org... > Hi there, > > is this the way complex() is supposed to work? > > Python 2.2b1 (#2, Oct 22 2001, 10:47:30) > [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 > Type "help", "copyright", "credits" or "license" for more information. > >>> complex('1', '1') > (1+0j) > >>> > > If complex() allows stings as arguments (like float()), what's > happened to the imaginary part? > It looks like you never get what you'd expect when you pass in a string. >>> complex('3',1) (3+0j) >>> complex(3,1) (3+1j) >>> complex('3','1') (3+0j) >>> complex(3,'1') Traceback (most recent call last): File "", line 1, in ? TypeError: complex() arg can't be converted to complex But it looks like you can work around it using complex(float(i), float(j)). But you probably already figured that out, which leaves us both wondering why it doesn't raise an error. ;-) -- Emile van Sebille emile at fenx.com ---------' From hfoffani at yahoo.com Sun Nov 11 07:23:49 2001 From: hfoffani at yahoo.com (Hernan M. Foffani) Date: Sun, 11 Nov 2001 13:23:49 +0100 Subject: The Best solution? References: Message-ID: <20011111072428.244$mI@news.newsreader.com> "A" escribi? en el mensaje news:mailman.1005420856.5731.python-list at python.org... > Hello, > I need from my program send an email and I would like to send it in > a different thread or process. > Can you please give me an example how I can start a new thread > or process Under Win32 systems? > using processes: >>> import os >>> os.system("dir") or os.spawnv(...), etc. see the os module in the Python Library Reference chapter 6.1.5 Process Management Regards, -Hernan From eliotm at pacbell.net Mon Nov 12 17:49:38 2001 From: eliotm at pacbell.net (Eliot Miranda) Date: Mon, 12 Nov 2001 22:49:38 GMT Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) References: <9s2hl0$u6o$1@bugstomper.ihug.com.au> <9s2rob$5p8$1@bugstomper.ihug.com.au> <3be5d7b5.186523676@news.tesco.net> Message-ID: <3BF05392.49270626@pacbell.net> seb wrote: > > On Sun, 4 Nov 2001 18:58:09 +1100, "Gary Stephenson" > wrote: > > >I think in fact it was > > > > "There once was a man from Peru, > > Whose limericks always ended at line two" > > > >cheers > > > >gary > > > > > > Milligan was brill. My fave: > > Dr O'Dell fell down a well > And broke his collar bone > But doctors should attend the sick > And leave the well alone Which reminds me of the immortal Bugs (with apologies for the speeling): Spring is sprung, The grass is riz, I wonder where the birdies is. The birdz is on the wing. But that's absoid! The wing is on the boid! -- _______________,,,^..^,,,____________________________ Eliot Miranda Smalltalk - Scene not herd From sholden at holdenweb.com Thu Nov 15 13:41:24 2001 From: sholden at holdenweb.com (Steve Holden) Date: Thu, 15 Nov 2001 13:41:24 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: Message-ID: <2YTI7.30749$vQ1.1137481@atlpnn01.usenetserver.com> "David Eppstein" wrote in message news:eppstein-5F01F0.09594315112001 at news.service.uci.edu... > In article , > com-nospam at ccraig.org (Christopher A. Craig) wrote: > > > You think that is bad. What do you think "1, 2 .. 5" specifies? > > > > 1) 1, 2, 3, 4, 5 > > 2) 1, 3, 5 > > 3) 1, 3 > > > > If I saw it on a math paper, I would immediately presume (1). After > > all, (2) and (3) don't even include "2" which, it would seem should be > > the second element of the sequence. If it is (1), then what do we do > > about "0, 2 .. 6"? Is this "[0, 2, 5]"? > > No, it is [0,2,4,6]. > More generally, as I said before, I would expect [a, b, ... c] > to be essentially equivalent to range(a, c+b-a, b-a) -- i.e. > the step size should be b-a and the last element in the range should be c. Wouldn't conventional mathematical notation (rather than Haskell, about which I have no knowledge) use a comma both before and after the ellipsis? i.e., {1,2,3,4,5} would be shown as 1, 2, ..., 5 Whether or not either comma is (even optionally) necessary syntactically, the main problem with any such representation is the impedance mismatch with [x]range(), which are built on the half-open interval. Particularly difficult to explain the mismatch to newbies, I think. If I have a vote, I'm afraid it's -1 regards Steve -- http://www.holdenweb.com/ From emile at fenx.com Tue Nov 6 13:31:17 2001 From: emile at fenx.com (Emile van Sebille) Date: Tue, 6 Nov 2001 10:31:17 -0800 Subject: split(None) References: <9s98o6$ilj$1@isp-m-srv06.izb.net> Message-ID: <9s9aii$121pt9$1@ID-11957.news.dfncis.de> "Oliver Fromme" wrote in message news:9s98o6$ilj$1 at isp-m-srv06.izb.net... > The library reference says the following about the "split" > string method: > > | If sep is not specified or None, any whitespace string > | is a separator. > > So I thought that foo.split() and foo.split(None) should > return the same result. However: > > >>> "foo bar baz".split() > ['foo', 'bar', 'baz'] > > >>> "foo bar baz".split(None) > ['foo bar baz'] > I don't get the same results. F:\Python21>python ActivePython 2.1, build 210 ActiveState) based on Python 2.1 (#15, Apr 19 2001, 10:28:27) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> "foo bar baz".split(None) ['foo', 'bar', 'baz'] >>> "foo bar baz".split(None, 1) ['foo', 'bar baz'] >>> It look to me like it works the way you would expect it to. Emile van Sebille emile at fenx.com From James_Althoff at i2.com Wed Nov 14 18:04:56 2001 From: James_Althoff at i2.com (James_Althoff at i2.com) Date: Wed, 14 Nov 2001 15:04:56 -0800 Subject: PEP 276 Simple Iterator for ints (fwd) Message-ID: Magnus Lie Hetland wrote: >IMO it's really a pity that we don't have this sort of thing in Python, >including possibly a version without the brackets (for iterators, >perhaps? Or I guess tuples would be more natural, although less suited >for for loops): > > for i in 1 .. 10: print i > >or > > for i in 0, 2 .. 20: print i > >But I guess getting this in as part of the language isn't very realistic. Which of the below would "0 .. 5" specify? 1) 0,1,2,3,4,5 2) 1,2,3,4 3) 0,1,2,3,4 4) 1,2,3,4,5 If not 3), then there is the issue of having to do an extra computation for the common case of indexing a sequence as in, e.g., for i in 0 .. len(sequence)-1: OTOH, would it be transparent for "0 .. 5" to mean "0,1,2,3,4"? In any event, PEP 276 doesn't preclude one from devising such an addition to Python (PEP 276 is *not* a proposal for a competing, alternative new syntax for integer sequences). Indeed, if a new syntax allowed one to create an integer iterator as in: for i in 0 .. table.getRowCount(): # assumes open interval on the right why not make it even easier for the most common case (since using 0 as the starting index is such a strong convention) and leave out the "0 .. " by default to create an integer iterator as in: for i in table.getRowCount(): # a la PEP 276! :-) (Remember, the real bad guy is xrange ;-) Jim From peter at engcorp.com Thu Nov 29 00:31:01 2001 From: peter at engcorp.com (Peter Hansen) Date: Thu, 29 Nov 2001 00:31:01 -0500 Subject: The Editor Poll results are in! References: <3bfd7f87@news.airtel.net> <3C03CFAC.6A29863@earthlink.net> <01112813100206.00609@linux> Message-ID: <3C05C815.63749B67@engcorp.com> marduk wrote: > > I move for a recount! > > Besides, how many readers of c.l.p actually use Python? What's "Python"? > In article , "Jonathan > Gardner" wrote: > > > The results are in! > > > > Emacs: 13 > > Rude people that use emacs: 1. >:-P (No, RMS did not reply.) > > *MicroSoft* Visual SlickEdit: 1 brave soul ActiveState Komodo 1.1: 1 > > lone voice > > Vim (NOT vi): 7592 > > Really cool people that use Vim: All of 'em. > > > > This poll had a total of 7607 respondents, myself included. Therefore, > > if you are using emacs and you haven't tried vim yet, you should know > > that you are in the minority here! HAHAHA! How does it feel to be the > > underdog now? NYA NYA NYA NYA NYA! > > > > This poll is not affected in any way to my aversion to Emacs. Nope, not > > one bit. I am, after all, a saint, because I use Vim. =) I also > > remembered to *accidentally* delete the emails so... > > > > Jonathan > > > > * Disclaimer for the tragically humor-impaired: No, I don't hate emacs. > > No, I don't hate you. (Well, maybe YOU, but not you.) Yes, I did > > manipulate the results, and yes, I am a jerk. Yes, it looks like about > > 75% of the people here use emacs. Can't blame them - python mode is > > really good. > > Posted Via Usenet.com Premium Usenet Newsgroup Services > ---------------------------------------------------------- > ** SPEED ** RETENTION ** COMPLETION ** ANONYMITY ** > ---------------------------------------------------------- > http://www.usenet.com -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From zayats at blue.seas.upenn.edu Fri Nov 16 12:32:29 2001 From: zayats at blue.seas.upenn.edu (Salim Zayat) Date: 16 Nov 2001 17:32:29 GMT Subject: Unicode and string conversions Message-ID: <9t3ijd$1lr$1@netnews.upenn.edu> Hey there. I was wondering something. I understand that if you type in something like: uni = u'\u0621\u0622' uni becomes a unicode string, with two characters and all. That's cool. What I dont understand is how to start with a normal string, something like : str = '\u0621\u0622' or some other way of packaging that info and convert it to a unicode string that will yield the same result as uni above. Is this even possible? I have this feeling I am missing some glaringly obvious detail. Any help, including any links to handling unicode strings as a whole, would be appreciated. Salim From phr-n2001d at nightsong.com Mon Nov 12 23:46:34 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 12 Nov 2001 20:46:34 -0800 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> <7x8zddnroj.fsf@ruckus.brouhaha.com> Message-ID: <7xwv0vl1lh.fsf@ruckus.brouhaha.com> Erno Kuusela writes: > | In fact it does the opposite--both the documentation and the pickle > | implementation (look at the "security" check for pickled strings) > | appear written with the idea that unickling is intended to be safe for > | untrusted strings. > > i can't see that idea in the documentation even if i try. The pickle docs mention the non-pickle-ability of code objects as a security advantage of pickle over marshal. Clearly the doc writer wasn't aware that unpickling is insecure for other reasons. Also, the docs for marshal recommend using pickle instead of marshal for RPC. Any pickle-based RPC server exposed to the internet (see for example pyro.sourceforge.net) would of course have a security hole. > i don't know what the "security" check in the source code is about, > perhaps the pickle author was planning to make it safe for untrusted > data at some point. More likely the original version of pickle was intended to be safe for untrusted data, and the __getinitargs__ scheme was added later without considering the security implications. > the fact that pickle shouldn't be fed untrusted data has been common > knowledge in the python user and developer communities as long as i > can remember. It sure shocked the heck out of me! I discovered it as a result of making a sourceforge bug report (#467384) requesting that marshal be documented so it could be used for RPC, and Tim suggested I use pickle instead. So even Tim (one of the main authorities on Python's implementateion) wasn't aware of the problem at the time. The authors of the Cookie and Pyro modules weren't aware of it either. So this type of "common knowledge" needs, at the very least, to be clearly documented! It's not reasonable to expect programmers of a supposedly easy to learn language to absorb all kinds of unwritten folklore before they can safely write as common an application as a simple cgi script. > iirc the cookie module had this erroneous code before it was accepted > into the library. > > when it was put in the library, warnings were put in its documentation > to warn against anyone ever using the functionality. However, "Cookie" is still aliased to SmartCookie in the module, supposedly for backward compatibility. That is, to leave a security hole in any existing servers using the module. SmartCookie and SerialCookie should be disabled altogether. If the holes were known before the module was accepted to the library, that's even worse. It should never have been accepted with holes like that. From syring at email.com Thu Nov 22 06:33:20 2001 From: syring at email.com (Karl M. Syring) Date: Thu, 22 Nov 2001 12:33:20 +0100 Subject: Read MS Visual Studio Project files References: <3bfcdcfe$1@brateggebdc5.br-automation.co.at> Message-ID: <9tinq2$2t716$1@ID-7529.news.dfncis.de> "Werner Schiendl" schrieb > Hello, > > I'd need a tool to read MS Visual Studio Project files (.dsp). > > I want to be able to get the 'Folders' and 'Files' from it as well as the > existing configuration options. > I think such a thing does exist already, but I don't seem able to find 'em > on google. Not exactly what you want, but http://jrfonseca.tripod.com/gnu-win32/software/msds/ has an awk-script (dsp2mak.awk) that converts .dsp's to GNU makefiles. This may give you a start. Karl M. Syring From philh at comuno.freeserve.co.uk Thu Nov 22 11:26:13 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Thu, 22 Nov 2001 16:26:13 +0000 Subject: Non-Indented python References: Message-ID: On 22 Nov 2001 00:25:28 -0500, David Bolen wrote: >Chris Liechti writes: > >> tabs are specified as 8 characters. only programmers that use tabs to >> indent make them 4 or 3 characters... > >Well, you have to be a little careful how you phrase this. I'm not >aware of any global document or specification that actually makes a >pronouncement that tabs are 8 characters I am aware of one such document. It's called the "Python Reference Manual": First, tabs are replaced (from left to right) by one to eight spaces such that the total number of characters up to and including the replacement is a multiple of eight (this is intended to be the same rule as used by Unix). The total number of spaces preceding the first non-blank character then determines the line's indentation. Indentation cannot be split over multiple physical lines using backslashes; the whitespace up to the first backslash determines the indentation. >> the Java styleguide says that you should use 4 characters indentation and >> that you can write a tab for 8 characters, so they made it correct, same as >> python has it correct too. > >"correct" is too absolute (although personally I agree that using 8 - >not a fixed 8, but a multiple of 8 - is the most logical choice), >since tab widths have been "correctly" changeable back to very early >video displays. For C there is a program (I think it's called indent) that re-does the indentation of a source code file according to defined criteria. Perhaps there should be somertyhing similar for python? When someone checks code out of CVS it could automatically indent it the way the user desired, and when checking basck in to CVS, indent it according to the project standards. Does anything like this exist? -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From wpmelcher at snet.net Tue Nov 27 08:14:05 2001 From: wpmelcher at snet.net (Bill Melcher) Date: Tue, 27 Nov 2001 13:14:05 GMT Subject: Win98 PySol problem References: <83r8qmtgu9.fsf@panacea.canonical.org> <83u1vhs2j2.fsf@panacea.canonical.org> Message-ID: "Bill Melcher" wrote in message news:uaCM7.538$yq7.150911048 at newssvr10.news.prodigy.com... > > "Kragen Sitaker" wrote in message > news:83u1vhs2j2.fsf at panacea.canonical.org... > > "Bill Melcher" writes: > > > > > "Kragen Sitaker" wrote in message > > > news:83r8qmtgu9.fsf at panacea.canonical.org... > > > > "Bill Melcher" writes: > > > Which brings up my latest problem: > > I managed to re-compile all the bits and pieces (except I see no pysol.pyc) > but the pysol_xx.pyc modules are some kind of concatenation of all those > bits and pieces and I don't know how to build that sucker. In my situation > I could build only pysol_21.pyc since I have only python21 installed, but > that's OK, I don't need the others in any event. (I think). > > I have seen Py2exe but I don't think that's what I'm after. > > Any ideas? I have discovered that pysol.py in .../src is supposed to create the 'bundle' so all I have to do is discover where the output module (pysol.pyc) has gone or why it did not get created. I have got some ideas about that - in particular, I think the pysol bundler needs access to more stuff than comes with the src distribution file, speciffically cardsets, music, etc. I do know that the thing won't compile at all unless license.html is available. My original problem, with -dither, has been fixed, so on to the next! BTW: For me Neil's SciTE rules! This thing takes care of all the DOS nasties, looks great and works! > > -- > Cheers, Bill > TANSTAAFL! > > > From tavis at calrudd.com Fri Nov 9 15:48:47 2001 From: tavis at calrudd.com (Tavis Rudd) Date: 9 Nov 2001 12:48:47 -0800 Subject: type(__builtins__) strangeness Message-ID: Hi, why does type(__builtins__) return when called in the __main__ scope and when called inside an imported module? ## a.py print type(__builtins__) ## from the interactive prompt >>> import a >>>print type(__builtins__) Cheers, Tavis From ursus_horibilis at hotmail.com Tue Nov 27 13:03:25 2001 From: ursus_horibilis at hotmail.com (Ursus Horibilis) Date: Tue, 27 Nov 2001 13:03:25 -0500 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: "Hans Nowak" wrote in message news:3C03D04B.D89F97A2 at earthlink.net... > Ursus Horibilis wrote: > > > > Is there a way to force the Python run time system to ignore > > integer overflows? I was trying to write a 32-bit Linear > > Congruential Pseudo Random Number Generator > > Say what? > > > and got clobbered > > the first time an integer product or sum went over the 32-bit > > limit. > > Use longs: > Okay. My next project was to do the same thing with 64-bit numbers. So how do I disable trapping for integer overflow? (And don't tell me to use very longs ;-) From Michael.L.Schneider at eds.com Tue Nov 27 01:29:36 2001 From: Michael.L.Schneider at eds.com (Michael Schneider) Date: Tue, 27 Nov 2001 01:29:36 -0500 Subject: [help] Driving Visual Studio From Python Message-ID: <3C0332D0.8C7BC844@eds.com> Hello All, I am an old unix developer finally moving to Windows Visual C++. I have been using python on Unix since 96, and have been really happy with python as a scripting/tools language. I need to drive visual studio to create projects, add configurations, and add files to projects. The COM extensions make it look like it is possible to do this, but I am having trouble getting it going. I have ran makepy and added the visual studio type libs. I copied the following code from a post ----------------------------------------- import win32com.client app = win32com.client.Dispatch( 'MSDev.Application') wnd = app.ActiveWindow if wnd.Type == 'Text': print wnd.Selection app = None ------------------------------------------ This prints on the selected test. I can't seem to get the syntax to obtain and print out project properties, or to add a project Could someone help my out by giving me the python code to try to get this to go, I am missing something very basic here. Thanks Mike PS. I added the MSDEV links to the visual studio docs ++++++++++++++++++ DeveStudio Link to add project http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/vcrefaddprojectmethod.asp Link to Visual Studio Application Object http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_application_object.asp -------------- next part -------------- A non-text attachment was scrubbed... Name: Michael.L.Schneider.vcf Type: text/x-vcard Size: 184 bytes Desc: Card for Michael Schneider URL: From jeff at ccvcorp.com Tue Nov 27 17:59:37 2001 From: jeff at ccvcorp.com (Jeff Shannon) Date: Tue, 27 Nov 2001 14:59:37 -0800 Subject: lanching a "*.exe" from Python ? References: <9ts4o1$sd7$1@wanadoo.fr> Message-ID: <3C041AD9.490FA9E2@ccvcorp.com> stefff wrote: > Hello, > I am a new python user and I would like to know if it is possible to launch > an executable in python : ie I have a c compilled program (that I want run > as fast as it possible) and I intend using python for GUI and I/O managing. > And all my appologizes if it's in the tutorial ! > Thank in advance for any clue. > St?phane There are a couple of ways that you can do this. If you have the source of the program (and are authorized to change it...), then you can convert it into a Python extension module, and call your C functions directly from Python. See the docs on "Extending and Embedding" for lots of info about this. If you can't modify the program, then you may need to use pipes. Check the docs for os.popen2(). The short description is that you call popen2() with the program that you want to run, and it will return two file objects--a writeable one that's the stdin for the program, and a readable one that's the stdout from the program. You write commands to the input file, read results from the output file, and then do whatever you like with that data. Jeff Shannon Technician/Programmer Credit International From mwh at python.net Wed Nov 14 10:48:27 2001 From: mwh at python.net (Michael Hudson) Date: Wed, 14 Nov 2001 15:48:27 GMT Subject: Stackless, thread paradigm and C extensions References: <184fbd02.0110262039.74799675@posting.google.com> <9s65ko$3eh$1@bob.news.rcn.net> <3sddutsmod2ipdt4p6gsmqf24bculupf7g@4ax.com> <40TF7.3919$Sx.1553917@news1.elcjn1.sdca.home.com> <0ggH7.8327$Sx.3001801@news1.elcjn1.sdca.home.com> <6SvI7.12665$Sx.4243655@news1.elcjn1.sdca.home.com> Message-ID: "Frederic Giacometti" writes: > "Michael Hudson" wrote in message > news:u8zdaodu4.fsf at python.net... > > "Frederic Giacometti" writes: [...] > > So when Python code executes > > > > sock.recv(data) > > > > the interpreter would take a thread form the pool, and in effect say > > "here, run this function". Then the interpreter thread would go off > > and execute pending Python threads, and when the sock.recv call > > returned, it would add the thread that called it back to the set of > > pending interpreter threads? (I think this would be easier to discuss > > with paper and pencil...) > > > > What does this buy us again? It still makes writing C code that calls > > Python code a bit of a pain, doesn't it? Oh, maybe not. More > > thinking required... > > A possible implementation would consist in using the method flag to mark C > python methods/functions to run outside the interpreter thread. This way, > the entire function runs in a separate thread. method flag? > The programmer does not have to explicitely manipulate OS threads at any > point; the continuation/OS thread correspondance would be taken care of > automatically by the threaded stackless implementation. > One would have parallel threads of execution through just continuations. > C extensions would run entirely either in a parallel thread, or in the > interpreter thread. There would be no more interpreter lock; and when a C > thread needs some service by the interpreter, it would just post a > continuation to the interpreter scheduler. This is what I thought you meant. Good. I think you could write code that would use an OS thread for every other level of recursion (think of printing deeply nested data structures that have Python __str__ methods, for instance). I'm not sure that's a good idea. I also think of other situations in which you'd end up with a lot of OS threads sitting around. Is having a lot of blocked OS threads around a problem? > This will simplify programming when using Python callbacks, too; > since the currently active Python continuation would be the > continuation active in the thread. I think there are too many definite articles in that sentence for me to make head or tail of it. Interesting idea. I wonder if anyone has the time to implement it... Cheers, M. -- My hat is lined with tinfoil for protection in the unlikely event that the droid gets his PowerPoint presentation working. -- Alan W. Frame, alt.sysadmin.recovery From phr-n2001d at nightsong.com Sun Nov 11 16:46:08 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 11 Nov 2001 13:46:08 -0800 Subject: Benefits of moving from Python to Common Lisp? References: Message-ID: <7xlmhddlr3.fsf@ruckus.brouhaha.com> "Morten W. Petersen" writes: > I'm currently doing some research, to see if it could be an advantage to > use Common Lisp instead of Python (currently Python and Zope [1] are used > to build web applications). > > While doing this, Google has provided two interesting documents (search > for 'lisp vs python'): > > http://www.strout.net/python/pythonvslisp.html > http://www.norvig.com/python-lisp.html > > First off, to save everyone some time, I'm wondering if there are more > papers documenting the difference between the two; if there aren't any, > I'd like to continue the discussion and summarize the findings in a paper > accessible on the net. Norvig's article is pretty good; the Strout article is about a specific CL implementation and contains a number of errors and misleading statements, generally favoring Python. For example, he says MCL isn't free--however he doesn't mention that there are numerous free CL implementations. And he compares Python exceptions favorably to using catch/throw to simulate exceptions in CL, but he doesn't mention the Condition system that's been part of CL since 1989, that's more powerful (but more complicated) than Python exceptions. My own quick comparison: CL is a much more complete system. Writing Python code is often an exercise in figuring out how to combine Python features in some clever way that nobody has done before, to accomplish your task. In CL, you more often get the impression that the designers had anticipated your needs. On the other hand, CL contains several decades worth of accumulated junk. Just about every feature in Python is present in some form in CL, but Python has a cohesive, smooth design, while in CL the features feel somewhat bolted on. Someone once said "APL is like a perfect crytal--if you add anything to it, it becomes flawed. Lisp is like a ball of mud--you can throw anything you want into it, and it's still Lisp". Many very large applications have been written in CL. Zope is one of the biggest Python applications; by CL standards, it's medium sized (I think around 150K lines of code). There are few other Python programs that come close to being the size of Zope. Serious CL implementations have real native-code compilers that produce machine code that runs orders of magnitude faster than Python code. Someone might add a compiler like that to Python someday, of course. CL, however, doesn't seem to have changed much in the past decade or so. There's no standardization of runtime libraries for doing stuff like internet programming. CL feels hopelessly old-fashioned in some ways. And to program effectively in CL, you must absorb a lot of Lisp culture and idioms, almost like learning to speak a foreign human language. Programmers experienced in languages like C++ or Perl can generally read the Python docs and become productive immediately. Not many programmers are taking up Lisp these days. The experienced Lisp programmers have generally been around for a long time, and there are getting to be fewer and fewer of them. As Python matures, I think it will become more like CL in its capabilities and CL's current advantages will dimish even more. To sum up, if you're writing a web application, it's worth considering CL if the app will be very large or if Python will cause a big performance problem. Otherwise, Python is probably a better choice these days. You might like reading some of Richard Gabriel's essays on CL at www.dreamsongs.com. There's also a Java-to-Lisp comparison somewhere that you've probably seen. May of the things it says about Lisp can probably be applied to Python. From shriek at gmx.co.uk Mon Nov 12 20:59:19 2001 From: shriek at gmx.co.uk (Stephen) Date: 12 Nov 2001 17:59:19 -0800 Subject: How robust is SocketServer.py? Message-ID: <97ae44ee.0111121759.29027b7e@posting.google.com> Does anybody have an example of an application based on SocketServer that has run for an extended period of time under load? I suppose robustness is dependent on how robust the code is, and what else the socket server doing is doing, for example handling DB queries, but what are the limiting factors and is there a standard stress-testing or benchmarking package? Should I daemonize the process instead of just starting it in the background with "$ python simpleserver.py &" ? Stephen From laurent.pointal at laposte.net Wed Nov 21 16:03:57 2001 From: laurent.pointal at laposte.net (Laurent Pointal) Date: 21 Nov 2001 21:03:57 GMT Subject: who called a function? References: Message-ID: [posted and mailed] wrote in news:mailman.1005800061.13841.python-list at python.org: > How can I find out what object called a function and essentially step > back through that? At most I need to step back about 4 to 5 levels but > it would be very useful for me to find a particular object back up the > list and change behavior based on that. Mostly I just wants the self > var as I step back until I find the one I want. I have a module with functions dealing with this (Python 2.1): #========================================================================= def framerecextractfctmod (frame) : """return function name and module name from a frame record. Return a tuple (function name,module name). """ info = inspect.getframeinfo(frame) fctname = info[2] modfilename = info[0] if modfilename != None : modname = inspect.getmodulename (modfilename) else : modname = "" return (fctname,modname) And you call it with things like: frame = sys._getframe (1) name,module = framerecextractfctmod (frame) del frame See _getframe documentation: _getframe([depth]) Return a frame object from the call stack. If optional integer depth is given, return the frame object that many calls below the top of the stack. If that is deeper than the call stack, ValueError is raised. The default for depth is zero, returning the frame at the top of the call stack. This function should be used for internal and specialized purposes only. From usenet at thinkspot.net Sun Nov 25 15:56:21 2001 From: usenet at thinkspot.net (Sheila King) Date: Sun, 25 Nov 2001 20:56:21 GMT Subject: WINDOWS USERS???? References: <3C0152F1.6541D8C2@verizon.net> <3c015433.778200@news> Message-ID: <9tqppc.3vv6ki7.1@kserver.org> On Sun, 25 Nov 2001 20:30:55 GMT, __x__ll at yahoo.com (Fred Flintsone) wrote in comp.lang.python in article <3c015433.778200 at news>: :Someone :in this group also recommended to me :http://diveintopython.org/ :but the subtitle "For Experienced Programmers" has me trembling. Dive Into Python is not for newbie programmers. Here is a list of Python resources I put together last spring, when my high school students were first learning Python: http://www.thinkspot.net/materdei/apcompsci/python/index.html I would also recommend to you, the book Core Python Programming by Wesley Chun, if the Learning Python book isn't enough for you. (I haven't seen the Learning Python book.) But the Programming Python books is far too advanced for someone just starting out with the language. -- Sheila King http://www.thinkspot.net/sheila/ http://www.k12groups.org/ From sholden at holdenweb.com Fri Nov 16 09:46:10 2001 From: sholden at holdenweb.com (Steve Holden) Date: Fri, 16 Nov 2001 09:46:10 -0500 Subject: Python & cgi on win98--tinyweb problems, etc References: Message-ID: "Chris Stromberger" wrote in message news:p6p8vtk41q0dsf46tv00d60t2vuom3vmvd at 4ax.com... > I'm looking for a solution to this: > I want to run a personal web server to run python cgi scripts that > interact with a mysql database on a windows 98 pc that's connected to > the internet via cable modem. I would rather avoid all security > issues and only allow the web server to serve pages to localhost--this > setup will be for a single user of the pc, no remote users, etc. Very > simple. So, I don't need a fancy web server. Any advice? > > I have tried apache and it works fine, of course, but I think it's too > heavyweight for what I want here. > > I found tinyweb on the internet, and it looks promising, but I can't > get it to run a python cgi script. It will run a test windows > executable that I placed in the cgi-bin directory, so it's some > problem specific to python and tinyweb. Any clues? The tinyweb > documentation is pretty minimal. > > Any other recommendations for small simple web servers for this > project? > Run, do not walk, to www.xitami.com, and download the freeware load. It runs well, with a very small footprint, and besides allowing CGI scripting and having web-based administration it also lets you build long-running web processes in Python! Naturally you can specify which interfaces you want to use to serve web content (and naturally you will want to limit yourself to 127.0.0.1). I ditched PWS a year ago and have never looked back. regards Steve -- http://www.holdenweb.com/ From marc.engel at recif.com Tue Nov 20 04:20:39 2001 From: marc.engel at recif.com (Marc ENGEL) Date: 20 Nov 2001 01:20:39 -0800 Subject: Pproblems using Python, COM, Event (or Connection Point) and thread References: <6411841c.0111140134.48720bff@posting.google.com> Message-ID: <6411841c.0111200120.4cb6324c@posting.google.com> Hi, I found in example TestMarshal.py from win32com a beginning of solution using CoMarshalInterThreadInterfaceInStream but I still don't understand if it necessary to start 1 python interpeter for each thread. Is it possible to use CoMarshalInterThreadInterfaceInStream with thread started from the same interpreter instance? Marc ENGEL marc.engel at recif.com (Marc ENGEL) wrote in message news:<6411841c.0111140134.48720bff at posting.google.com>... > Dear all, > > I am trying to do a kind of Event Manager in Python. The architecture > I want is the following: > - A main python scripts start all the COM object needed by the > application with DispatchWithEvents and then wait for messages using > PumpMessage > - The EventManager registered to each COM object do litle processing: > it just delegates the event processing to a new thread and return (I > don't need to return a value for events) > - The Threaded Event Manager do the actual processing and mainly I > want it to > call the method that can process the event on other COM objects. The > Event manager may also do some additional processing depending on the > event. > > In order to test this, I started from the Excel event script example > and I modify it. See script source at the end of the message. It is > running on my computer > > I have 2 problems: > 1 - If I try to access the COM object in the Event Thread by > uncommenting Target.Column in classe ExcelEvents (line >>> print > "Column = "#, Target.Column), I get the following error: > > File "d:\program files\python21\win32com\client\__init__.py", line > 334, in _ApplyTypes_ > return self._get_good_object_(apply(self._oleobj_.InvokeTypes, > (dispid, 0, wFlags, retType, argTypes) + args), user, resultCLSID) > pywintypes.com_error: (-2147417842, "L'application a appel\xe9 une > interface qui \xe9tait maintenue en ordre pour une thread > diff\xe9rente.", None, None) > > Sorry the error message is in french (but actually I am french :)). It > means "Application has called an interface that was maintained in > order for a different thread" > > Any hint? > > 2 - I would like that class EventManager does not define all events it > can manage but dynamically create a function to be called for each > event that it is asked to manage. I thought it would be intersting to > use the magic method __getattr__ to create the method with the event > name dynamically. But as you will see if you execute the script, this > method is never called. > > Is there anything I did not understand about this method? > > Thanks for any hint, > > Marc ENGEL > > -----------------> Start Python script > import sys, time, msvcrt, win32com.client, win32gui, thread, win32ui, > win32api, win32con > > sys.coinit_flags = 0 #COINIT_MULTITHREADED > #COINIT_APARTMENTTHREADED = 0x02 > > import pythoncom > > class EventsManager : > def __getattr__(self, attr): > print "Trying to call event ", attr > args=self._prop_map_get_.get(attr) > if args is None: > raise AttributeError, attr > return apply(self._ApplyTypes_, args) > # Default handler for Event OnSheetBeforeDoubleClick > # Delegates treatment to class ExcelEvents into a new thread > def OnSheetBeforeDoubleClick(self, Sh, Target, Cancel): > thread.start_new_thread(ExcelEvents().OnSheetBeforeDoubleClick, (Sh, > Target, Cancel)) > return 0 > > class ExcelEvents: > def OnSheetBeforeDoubleClick(self, Sh, Target, Cancel): > pythoncom.CoInitializeEx(0) > print "Column = "#, Target.Column > time.sleep(5) > print "Finished processing event for column "#, Target.Column > pythoncom.CoUninitialize() > return 0 > > > def ThreadWaitingForUserInput() : > win32api.MessageBox(0, "Press OK when you want to stop the message > loop", "Info") > # Post message to dummy window in order to get out of the main event > loop PumpMessages > win32gui.PostMessage(MyDummyWindow, win32con.WM_QUIT, 0, 0) > return 0 > > # Create new Execel application > excel = win32com.client.DispatchWithEvents("Excel.Application", > EventsManager) > excel.Visible=1 > excel.Workbooks.Add() > > # Create a dummy window for posting WM_QUIT message > MyDummyWindow = win32gui.CreateWindow("BUTTON", "TestWindow", 0, 0, 0, > 100, 100, 0, 0, 0, None) > > # Start new thread to display the MessageBox to exit application > thread.start_new_thread(ThreadWaitingForUserInput, ()) > # Give it a chance to start > win32api.Sleep(100) > win32ui.PumpWaitingMessages() > > # Main event loop waiting for quit message posted from thread > ThreadWaitingForUserInput > pythoncom.PumpMessages() > print "Quitting script..." > > # Don't want dialog box for saving document before closing Excel > excel.DisplayAlerts = 0 > # Remove the workbook > excel.Workbooks.Close() > # Quit application > excel.Quit() > # Release excel object > excel = None > > # This is just a trick to have the script displaying error message if > any! > print "Press OK on Popup Message box to stop scipt..." > win32api.MessageBox(0, "Press OK to stop script", "Info") > > -----------------> End Python script From thomas.metz at gmx.net Fri Nov 30 09:05:36 2001 From: thomas.metz at gmx.net (Thomas Metz) Date: Fri, 30 Nov 2001 15:05:36 +0100 Subject: Newbie question --> Internet-Connection Message-ID: <9u83ng$i4v$05$1@news.t-online.com> Hi, how can I check the state of an internet-connection (connected/disconnected) with python? Thank you for helping! Thomas From sholden at holdenweb.com Wed Nov 28 22:41:47 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 22:41:47 -0500 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C046EB4.55B36D9D@cosc.canterbury.ac.nz> <3C0502B0.1F73497C@sympatico.ca> <3C05744D.D52CBBF0@cosc.canterbury.ac.nz> Message-ID: "Greg Ewing" wrote ... > "Colin J. Williams" wrote: > > > > What parsing problems would be created by: > > > > for 0 < i < 10, 3 > > > > to give 3, 6, 9? > > Probably it would be parsed as > > for 0 < i < (10, 3): > Wouldn't for ((0 < i < 10), 3) be more likely? I have to say I don't think this is one of your better ideas... > Besides, it's getting away from the self-evident > nature of my original suggestion, which is the > only thing it really had going for it. > Let it die ... :-) regards Steve From sholden at holdenweb.com Mon Nov 26 08:56:00 2001 From: sholden at holdenweb.com (Steve Holden) Date: Mon, 26 Nov 2001 08:56:00 -0500 Subject: Strange thing: file.close did not show error but work wrong References: <9tho04$2or14$1@ID-11957.news.dfncis.de> <83r8qovn88.fsf@panacea.canonical.org> Message-ID: "Kragen Sitaker" wrote ... > "Emile van Sebille" writes: > > > "wqhdebian" wrote in message > > news:db288b61.0111211822.2e903177 at posting.google.com... > > > fdw.close######################### When I use like this ,there is no > > > warning and > > > ##############any error message,but the file do not have been > > > writen.After I change back to fdw.close(),Then it work well. > > > > Yes, this is all as it should be. > > It's semantically consistent with the rest of Python, but it's > suboptimal from a human-factors perspective, IMHO; people who are used > to Perl or Delphi or Pascal will expect it to call fdw.close. It > would be nice if the interpreter were smart enough to issue a warning > in this case: a method is gotten and then immediately discarded. > > Unfortunately this would require special-casing the "expression-as-statement" construct. This would probably gobble up far more time than could be justified. How would you then have the statements treated in interactive interpreter sessions, where normally the method would be identified as the result of the expression? regards Steve -- http://www.holdenweb.com/ From tim at vegeta.ath.cx Fri Nov 16 07:42:08 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Fri, 16 Nov 2001 12:42:08 GMT Subject: OT: Mobile Internet Toolkit EULA References: <9snugr$bbc$06$1@news.t-online.com> <9sph0u$gj7$02$1@news.t-online.com> <9t1lr3$adu$1@newshost.accu.uu.nl> Message-ID: Martijn Faassen graced us by uttering: > [free software, open source, licenses, microsoft, oh my, oh my] > > Excellent work folks -- we're adding centuries to the lifetime of the > universe this way. > > The PSU thanks you. Would it help if I called Microsoft a bunch of fascists? Or would I actually have to call them nazis to end the thread? Tim Hammerquist -- A yacc is an unruly beast. -- Larry Wall in <199912012050.MAA06214 at kiev.wall.org> From brucehapman at hotmail.com Fri Nov 9 14:41:06 2001 From: brucehapman at hotmail.com (brucehapman at hotmail.com) Date: 9 Nov 2001 11:41:06 -0800 Subject: Strange __str__ behavior Message-ID: I am defining a class w/ method __str__. If I put a print statement inside __str__, and if I then use the print statement to display an instance of the class, I get an extra space in the output. Python 2.2b1 (#25, Oct 19 2001, 11:44:52) [MSC 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> class Test: ... def __str__(self): ... print "In method Test.__str__" ... return "String representation of instance." ... >>> test = Test() >>> print test # causes extra space problem In method Test.__str__ String representation of instance. Language reference section 6.6, "The print statement", says """ A space is written before each object is (converted and) written, unless the output system believes it is positioned at the beginning of a line. This is the case (1) when no characters have yet been written to standard output, (2) when the last character written to standard output is "\n", or (3) when the last write operation on standard output was not a print statement. (In some cases it may be functional to write an empty string to standard output for this reason.) """ I would think that case 1 applies here. Am I wrong? Does the print statement in __str__ somehow know that the print statement in the main program has or will print characters to stdout? Perhaps the "output system" knows that one print statement (the outer print statement) has executed or is executing, so the second (inner) print statement causes the output system to print a space.... Is this the expected behavior? I was surprised by this. TIA, b. P.S. I want to include a print statement in __str__ not for practical purposes, but for mostly didactic purposes when teaching someone inheritance. From slinkp23 at yahoo.com Fri Nov 9 23:51:11 2001 From: slinkp23 at yahoo.com (Paul Winkler) Date: Sat, 10 Nov 2001 04:51:11 GMT Subject: How much is set in stone? References: Message-ID: On Fri, 9 Nov 2001 16:49:17 -0800, Cliff Wells wrote: >On Friday 09 November 2001 16:39, Tim Peters wrote: > >> about 2.1.1 before, and I can assure you we didn't pay everyone on c.l.py > >Who's "we", Tim? I see you've finally shown yo > Why do people's posts keep getting cut off on this ng? Is there some kind of consp From philh at comuno.freeserve.co.uk Tue Nov 27 11:03:23 2001 From: philh at comuno.freeserve.co.uk (phil hunt) Date: Tue, 27 Nov 2001 16:03:23 +0000 Subject: function operators References: Message-ID: On Tue, 27 Nov 2001 01:43:34 +0000, James A. H. Skillen wrote: >Has anyone ever wished that Python had operators defined on functions? >For example, suppose you want the function f(x) = cos(x) + sin(x). >You could do: > > def f(x): > return cos(x) + sin(x) > >or > > f = lambda x: cos(x) + sin(x) > >but wouldn't: > > f = cos + sin > >be *much* nicer? No, it's horrible >Does this make sense, or have I been doing too much mathematics? ;-) The latter. -- *** Philip Hunt *** philh at comuno.freeserve.co.uk *** From marfadeu at gmx.de Thu Nov 8 03:54:55 2001 From: marfadeu at gmx.de (Markus Faust) Date: Thu, 8 Nov 2001 09:54:55 +0100 Subject: mayavi installation problem on Win NT Message-ID: <9sdh9v$hgq$01$1@news.t-online.com> Hi, I tried to install majavi on Windows NT SP 6. I have installed Python 2.1 and therefore used Les Schaffers DLL's for Python 2.x. I have added the paths to the system and PYTHONPATH (AUTOEXEC.BAT). However when I check vtkpython.dll with Dependency Walker 2 I get an error Error: At least one module has an unresolved import due to a missing export function in an implicitly dependent module. The module is VTKDLL.DLL with the routines void vtkDataArray::GetData(int,int,int,int,class vtkFloatArray *) void vtkDataArray::CreateDefaultLookupTable(void) void vtkDataArray::SetLookupTable(class vtkLookupTable *) void vtkDataArray::SetName(char const *) char const * vtkDataArray::GetName(void) . . . Has anybody encountered similar problems and knows what to do? Thanks in advance! Markus From barry at zope.com Fri Nov 16 14:31:01 2001 From: barry at zope.com (Barry A. Warsaw) Date: 16 Nov 2001 14:31:01 -0500 Subject: How much is set in stone? References: <7xadxv9wun.fsf@ruckus.brouhaha.com> <7xpu6plw08.fsf@ruckus.brouhaha.com> <7x8zddnroj.fsf@ruckus.brouhaha.com> <9sq94c$lim$1@slb1.atl.mindspring.net> Message-ID: Just to follow up on this thread while I'm waiting for the Python 2.2b2 test to complete... I've rewritten the pickle and cPickle documentation hopefully to both update them to the current state of the modules (they were woefully out-of-date and underdocumented), and to describe the security implications and how you might program defensively to avoid them. I did an update of copy_reg and marshal as well, but didn't get a chance to look at the Cookie docs. I'll do that before the next release. My own feeling is that, with enough pain, you could create unpicklers that are safe(r), but that to do so requires different approaches depending on whether you use pickle or cPickle, and exactly what you're trying to protect against! I don't see us making any substantive code changes for Python 2.2, including not changing the alias for Cookie.Cookie. I'd like to see a pickle PEP for Python 2.3 which would design a better protocol for letting the unpickling environment control exactly what gets called and what instances can be created. Also, I'd like to see pickle.py go away eventually, to be replaced with cPickle. The only reason pickle still exists is for subclassing; I'd like to tease out why people need to subclass pickle.Pickler and pickle.Unpickler and see if we can't provide similar functionality in a different way through cPickle. There's also the possibility of using new-style classes in cPickle to still allow subclassing. Anyway, I think we've addressed things as best we can for Python 2.2. Please take a look at the new documentation and let me know if you have any corrections or other suggestions. -Barry From wurmy at earthlink.net Sat Nov 24 19:48:14 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Sun, 25 Nov 2001 00:48:14 GMT Subject: File creation References: <1103_1006646455@t4q4p0> Message-ID: <3C003F9A.71D00181@earthlink.net> Aaron Sterling wrote: > > Hi, > > To create files, I am currently using: > > temp_file = os.open(file_name, O_CREAT) > temp_file.close() > open(file_name, 'w') > > Is this the cannonical way of doing it? If so, would it be usefull to have a function, create_file(file_name, mode, bufsize), linked to the interpreter, that > would create the file and return an associated file object? Is their a better way to do it, or is it something that shouldn't be done, and if so why? Why using os.open? It's best to use the built-in open function: f = open(filename, "wb") f.write("bla...\n") # etc f.close() HTH, --Hans From ballabio at mac.com Fri Nov 9 07:45:45 2001 From: ballabio at mac.com (Luigi Ballabio) Date: Fri, 09 Nov 2001 12:45:45 +0000 Subject: iters on ints? (reducing the need for range/xrange) In-Reply-To: References: Message-ID: <5.1.0.14.0.20011109124051.00a99d50@mail.mac.com> At 02:59 AM 11/9/01 +0000, Rainer Deyke wrote: > > A file *IS* a sequence -- although you could just as easily slice it > > by characters as lines -- or by any arbitrary object for binary files, > > as Pascal does. If the integer 10 suggests any sort of sequence, it's > > the singleton sequence containing: 10. > >The Pythons docs define "sequence" as something which supports the sequence >interface. If 's' is a sequence, then 's[i]' is a defined operation that >either returns a value or raises 'IndexError' (unless some other error >occurs). A file isn't that. We're talking iterators here, i.e., Python 2.2. iter(file) is a defined operation which returns an iterator and "for line in file" is a valid construct. This said, while it makes sense in english to say "do this for every line IN this file", it just doesn't sound right to me to say "do this for every number IN 10"---even though I've been once familiar with the definitions of the set of all integers. I'd rather say "for every number UP TO 10" but that would mean introducing a new keyword which I'm not going to suggest, not me, sir. Bye, Luigi From logiplexsoftware at earthlink.net Thu Nov 15 13:50:45 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Thu, 15 Nov 2001 10:50:45 -0800 Subject: What is "marshal data"? In-Reply-To: <01111510335000.21269@logiplex1.logiplex.net> References: <859c71be.0111151028.63227109@posting.google.com> <01111510335000.21269@logiplex1.logiplex.net> Message-ID: <01111510504501.21269@logiplex1.logiplex.net> On Thursday 15 November 2001 10:33, Cliff Wells wrote: > On Thursday 15 November 2001 10:28, Soren Ragsdale wrote: > > Possible sources of the problem: "uh.py" is imported from MANY > > programs on our network. It's being imported by Linux and Irix > > machines running 1.5.2 and 2.1.1 versions of Python. Could this be > > As mentioned in another thread, the bytecode between python versions is not > backward compatible, so you may be trying to execute 2.1.1 bytecode on a > 1.5.2 interpreter and that may be causing the problem. One way to get around this would be to keep your application modules in a directory named "modules", and then create two additional directories named "modules-1.5.2" and "modules-2.1.1" that contain links to uh.py and gh.py in the "modules" directory. Then in your application code, set your import path conditionally based upon the value of sys.version_info. This way they all import the same code, but write the .pyc files to separate directories. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From fperez528 at yahoo.com Mon Nov 26 07:01:26 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 11:29:26 +2328 Subject: Integer Overflow References: <3C03D04B.D89F97A2@earthlink.net> Message-ID: <9u0m3l$447$2@peabody.colorado.edu> Ursus Horibilis wrote: >> >> Use longs: >> > > Okay. My next project was to do the same thing with 64-bit > numbers. So how do I disable trapping for integer overflow? > > (And don't tell me to use very longs ;-) No. Python longs are not C longs, they are arbitrary length integers (think Mathematica/Maple/etc). They're therefore dog slow, but never overflow. Very handy when you really need them. Cheers, f From sdm7g at Virginia.EDU Fri Nov 2 14:07:36 2001 From: sdm7g at Virginia.EDU (Steven D. Majewski) Date: Fri, 2 Nov 2001 14:07:36 -0500 (EST) Subject: And Now for Something Completely Different! (was: Monty Python (was: Freeware Python editor)) In-Reply-To: Message-ID: On Thu, 1 Nov 2001, Tim Hammerquist wrote: > You mean "the humour is lost on _some of_ us Americans," right? > > Of course, I had a non-standard American growth in which I was exposed > to many things British, including but not > limited to: > Dr. Who (mainly Tom Baker) (recorded). > Red Dward (1st season, carrier did not renew) (recorded). > Monty Python's Flying Circus and any of the movies I could find. > How to Irritate People (John Cleese et al.; not "officially" Monty > Python). (purchased) > ...et cetera. > Peter Cushing horror movies. ;) > Susan Cooper's The Dark Is Rising sequence including dialects from > Cornwall and Wales. > A great many movies and series taking place in Yorkshire, probably > responsible for my ability to understand more dialects than > usual. :) > Neil Gaiman novels. :) > Far too many others to count. You're missing one important link that is well represented in the python-list archives: The Goon Show -- with Spike Milligan and Peter Sellars. The Goon Show was a BBC radio show that was the inspiration for Monty Python. Spike Milligan beat out John Cleese for 1st place in the BBC's millenium poll of the top 10 funniest people: He has written a lot of books, many of which are out of print -- my favorite (besides his children's poems) is "Hitler: My Part in his Downfall", which is the first of his series of WWII memoirs. ( Which continues with several volumes, including "Mussolini: His Part in My Downfall" ) [ List and description of his books on the "Cardboard and String Spike Milligan Home Page" : ] A google search will find you lot's of Goon Show pages (including the easiest to remember: ). And just in time for the invasion of Afghanistan, you can download an MP3 of "The Red Fort" from Robert Dickson's Goon Show Page: ( It's the "show of the week", so hurry! ) > Many foreigners call America's culture (or lack thereof) bland. Well, > from this American's perspective, they tend to be correct. Bland American Culture ??? -- how about (while we're on the subject of humor): the Firesigh Theatre Mad Magazine (the good old years) The Onion The Marx Brothers Abbott and Costello ( "Who's on First": ) Harry Shearer ( "Who's on First" -- (a tradition in American Humor!): [Don't blame me if you're not old enough to get this one!]) the Simpson's Robert Crumb the Coen Brothers George Bush (What other country has such a dedication to Humor!) .... -- Steve From phd at phd.pp.ru Wed Nov 28 08:32:48 2001 From: phd at phd.pp.ru (Oleg Broytmann) Date: Wed, 28 Nov 2001 16:32:48 +0300 Subject: windows to linux pickled objects? In-Reply-To: ; from stephen@theboulets.net on Wed, Nov 28, 2001 at 07:22:20AM -0600 References: Message-ID: <20011128163248.V4239@phd.pp.ru> On Wed, Nov 28, 2001 at 07:22:20AM -0600, Stephen Boulet wrote: > > outfile = open(filename, 'wb') > > outfile.write(pickle) > > outfile.close() > > > But is writing in binary mode supported under linux? On UNIX binary mode is exactly the same as text mode, 'b' is just ignored for compatibility. Oleg. -- Oleg Broytmann http://phd.pp.ru/ phd at phd.pp.ru Programmers don't die, they just GOSUB without RETURN. From sholden at holdenweb.com Wed Nov 28 10:45:06 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 10:45:06 -0500 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <000201c17796$08a02fc0$1d4bb43f@kens> Message-ID: "DeepBlue" wrote in message news:u0a0qpdf7npqa1 at corp.supernews.com... > > "Jonathan Gardner" wrote in message > news:mailman.1006958441.30706.python-list at python.org... > > Ken Seehof wrote: > > > > > > > > more. True, I think .NET is cool - but I'll only use it if MS keeps it > > > > promise and ports it too Linux and such. > > > > > > Odds of MS keeping any promises of this kind: 0.027% > > > > > > It has never been in MS's best interest to be compatible with the rest > of > > > the > > > computing world. > > > > > > > Look at Visual C++. Portability? Compatability? Ha. > > > > Look what they did to Java, HTTP, HTML, and JavaScript. > > > What did they do to Java, HTTP, HTML, and JavaScript? > > > Microsoft is in the business of making money, not software. > > > Is Sun and Netscape any different? Yes, in so far as they seem to feel that their best interests are served by adhering to standards and interoperating with other peopple's implementations. regards Steve -- http://www.holdenweb.com/ From nissim at math.ufl.edu Mon Nov 26 11:01:06 2001 From: nissim at math.ufl.edu (Nissim Broudo) Date: Mon, 26 Nov 2001 11:01:06 -0500 Subject: resuming execution Message-ID: <3C026742.EDBD95FA@math.ufl.edu> Hi, I'm running a script on linux by typing python -i myscript.py and then I hit Ctrl-C and I'm in Python at a prompt >>> How can I resume execution ? Thanks ! (Please cc: me if you post) Nissim Broudo From Steven.Scott at Synchrologic.com Fri Nov 9 12:44:00 2001 From: Steven.Scott at Synchrologic.com (Steven Scott) Date: Fri, 9 Nov 2001 12:44:00 -0500 Subject: python1.5.2 + nt services + COM Message-ID: Hi, I'm having a pretty infuriating problem here....keep in mind I don't know a whole lot about python and even less about com and whatnot. and if my text is wrapped incorrectly, sorry, I can't find the option to set line length in outlook. to my question...I'm running a script as an NT service, using xmlrpclib. I've got one method that crashes when run as a service (but not in an interactive python session). by removing all the content of the method and adding code back in line by line, I see that it's crashing on a win32com.client.Dispatch() call. here's what I get when I redirect stderr into a file: --------------------------------------------------------------- Traceback (innermost last): File "C:\Harness\machineInfoService.py", line 179, in getDriverVersion regUtility = win32com.client.Dispatch('SynchroQA.UTLRegistry') File "C:\Program Files\Python\win32com\client\__init__.py", line 94, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx) File "C:\Program Files\Python\win32com\client\dynamic.py", line 80, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Program Files\Python\win32com\client\dynamic.py", line 71, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) com_error: (-2147467259, 'Unspecified error', None, None) --------------------------------------------------------------- I'm not specifically using threads, although I am subclassing win32serviceutil.ServiceFramework as per the ntservice example that comes with win32all...I don't know if it does something with threads, but I'm led to believe that it's so. although I'd like to, upgrading to python2 isn't an option right now. the weirdest thing about this is that it works on a 2000 server machine and an XP pro machine, but none of the other machines I've tried (2000 server, adv server, NT4) will work. can anybody give me some insight into what's wrong? thanks From bedge at troikanetworks.com Tue Nov 20 16:22:20 2001 From: bedge at troikanetworks.com (Bruce Edge) Date: Tue, 20 Nov 2001 13:22:20 -0800 Subject: sscanf ? References: <3BFAA0FC.EB3CB91B@alcyone.com> <3BFAAD1E.9E9AF618@alcyone.com> <3BFAC45B.9D246137@alcyone.com> Message-ID: <2SzK7.605$px5.156976@newsfeed.slurp.net> In <3BFAC45B.9D246137 at alcyone.com>, Erik Max Francis wrote: > Bruce Edge wrote: > >> Additionally, after parsing with re, I still need to convert to >> integers, >> which is a PITA when you consider the "%x" case. The format string >> "knows" >> that this is in hex, using re, I get back say a string which I still >> need >> to dtermine the number base and convert. > > You can use the int-with-arg form for converting strings to integers > other than in base ten. > Ahh, OK, yes, that does it. Thanks. >> I'm not arguing :) >> It's just that in this one tiny case, scanf would have been the >> perfect >> tool. > > It wouldn't be hard to write a simple wrapping script that takes a > printf format string, converts it to a regular expression, does a match > against a string, then pulls out the arguments and converts them to > types as appropriate. But one might just as well be using regular > expressions directly in the first place. > Here's what I did to convert the format string to a regex. It's not pretty, and many types will break it, but it serves the purpose, for now: def fmtstr2regex( str ): regex = "" while len(str): if str[0] == '%': x = re.match( "%(?P\d*)(?P\w)(?P.*)$", str ) if not x: exc = CommandException() exc.reason = "Invalid print format specifier %s" % str raise exc length = int( x.group("len") ) type = x.group("type") # Some types need to be changed from printf to regexp world if type == 'x': type = '['+string.hexdigits+']' else: type = "\\%s" % type regex += "(%s" % type if length: regex += "{%d,%d})" % ( length, length ) else: regex += "+)" str = x.group('rest') else: regex += "\%s" % str[0] str = str[1:] return regex From the_jocker at hotmail.com Wed Nov 7 12:35:09 2001 From: the_jocker at hotmail.com (The Jocker) Date: Wed, 7 Nov 2001 09:35:09 -0800 Subject: Class References: <9sah0q$hki$1@newton3.pacific.net.sg> Message-ID: <9sarpl$uh1$1@neptun.beotel.net> Traceback (innermost last): File "test.py", line 19, in ? TypeError: __init__() not enough arguments; expected 5 got 1 def __init__(self, Plan, Domain, Email, Name): > if choice == 1: > print 'Adding New User\n' !!!!!>add = DataBase() //this one calls __init__ > add.UserPlan = input("Username: ") > add.UserDomain = raw_input("Domain: ") > add.UserEmail = raw_input("Email: ") > add.UserName = raw_input("Name: ") "Edy Lie" wrote in message news:9sah0q$hki$1 at newton3.pacific.net.sg... > Hi I have setup a class but in the code i could not use it. Anyone care to > explain ? > > #!/usr/local/bin/python > import sys > > class DataBase: > def __init__(self, Plan, Domain, Email, Name): > self.UserPlan = Plan > self.UserDomain = Domain > self.UserEmail = Email > self.UserName = Name > > print '1. Adding New User' > print '2. Search New User' > print '3. View All User' > print '4. Exit' > choice = input("Please choose an option: ") > > if choice == 1: > print 'Adding New User\n' > add = DataBase() > add.UserPlan = input("Username: ") > add.UserDomain = raw_input("Domain: ") > add.UserEmail = raw_input("Email: ") > add.UserName = raw_input("Name: ") > > elif choice == 2: > print 'Search New User\n' > > elif choice == 3: > print 'View All User\n' > > elif choice == 4: > print 'Exit program ...' > sys.exit() > > else: > print 'Wrong input' > sys.exit() > > > From tim.one at home.com Sat Nov 3 23:30:30 2001 From: tim.one at home.com (Tim Peters) Date: Sat, 3 Nov 2001 23:30:30 -0500 Subject: Underscore data hiding (was python development practices?) In-Reply-To: <7x4rocj4z3.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > I'd like to make the argument for removing the name mangling scheme > from the language specification document. It's fine to leave it in > the implementation and it can be described in an implementation note. > But if someone writes a new Python implementation they shouldn't be > required to do it the same way, if they can find some alternative way > to resolve collisions. "Portable" (across Python implementations) > applications shouldn't depend on name mangling working the way it does. Paul, I didn't see "an argument" here, apart from repetition of "it shouldn't". Guido intended that it should, and that's why the specifics of the name-mangling scheme are indeed documented in the Language Reference manual. It's intended that this code: >>> class C: ... __private = 1 ... >>> C._C__private 1 >>> print "1" across all implementations; no scheme in which it doesn't will make headway. the-backward-compatibility-camp-has-no-worries-on-this-one-ly y'rs - tim From oktay_safak at yahoo.com Mon Nov 12 10:25:28 2001 From: oktay_safak at yahoo.com (Oktay Safak) Date: Mon, 12 Nov 2001 17:25:28 +0200 Subject: Special celebration event for Orlijn? References: Message-ID: <028501c16b90$aef15a00$ee9c2bd5@b> "Mikael Olofsson" , wrote: > I was thinking more in the terms of Orlijn being a derived class with > two base classes... May his __doc__ be a good one and I hope he is not doomed to be a Singleton, it's very nice to have sister(or brother) instances of the same base classes :) Singleton van Rossum would make a very cool name though.(or Singlet for girls) (OK, after hanging around for a long time in this ng I've finally used my quota of 1 silly message per year. Sorry for the mailbox pollution this has undoubtedly caused.) Oktay _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com From ws-news at gmx.at Wed Nov 21 11:37:12 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Wed, 21 Nov 2001 17:37:12 +0100 Subject: dictionary-question References: Message-ID: <3bfbd8fd$1@brateggebdc5.br-automation.co.at> Hi, The get method of the dictonary returns the value stored at that position, not a reference to the 'slot' in the dictionary. Therefore, you cannot assign to the result of get. The simplest that came to my mind is >>> foo = {} >>> foo["bar"]=foo.get("bar",0)+1 >>> foo {'bar': 1} >>> foo["bar"]=foo.get("bar",0)+1 >>> foo {'bar': 2} >>> hth Werner "Bas van Gils" wrote in message news:mailman.1006352607.21127.python-list at python.org... Hi, I just found some dictionary-behavior that I don't quite understand: Python 2.1.1 (#1, Nov 3 2001, 19:19:22) [GCC 2.95.4 20011006 (Debian prerelease)] on linux2 Type "copyright", "credits" or "license" for more information. >>> foo = {} >>> type(foo.get("bar",0)) >>> foo.get("bar",0) += 1 SyntaxError: can't assign to function call My current "workaround" is this: >>> if foo.has_key("bar"): ... foo["bar"] += 1 ... else: ... foo["bar"] = 1 ... >>> foo {'bar': 1} (this is just an demonstration of the behavior I don't get ... I want to use it in a bigger script). Now, can someone please explain why the foo.get("bar",0) += 1 won't work ... and what might be a better sollution then my current workaround? many thanks in advance yours Bas -- Bas van Gils - http://members.home.nl/bas.vangils Build a system that even a fool can use, and only a fool will want to use it. From mkelly2002NOSPAM at earthlink.net Sat Nov 17 23:07:05 2001 From: mkelly2002NOSPAM at earthlink.net (Michael Kelly) Date: Sun, 18 Nov 2001 04:07:05 GMT Subject: Win32 COM question References: Message-ID: On Sun, 18 Nov 2001 03:30:58 GMT, "Scott Hathaway" wrote: >No, python works with all COM servers. Post your exact error and maybe we >can help. > Hi Scott. I noticed later that the particular one I was trying to use had no IDispatch interface. If python can also do custom interfaces do you know where I can find example code? If I can look at a python client using a COM server with a custom interface I think I can get going. I'm just not sure what I have to use. If I have to get the IUnknown ref. then do QueryInterface or whatnot. The little snippets in the COM html docs show like obj.QueryInterface but they don't show you how to get the initial object if it's not an OleAutomation object with a ProgName etc.. I did get an ActiveX .ocx I wrote working pretty easily so that's very cool. TIA Mike -- "I don't want to belong to any club that would have me as a member." -- Groucho Marx From peter at engcorp.com Wed Nov 28 22:50:10 2001 From: peter at engcorp.com (Peter Hansen) Date: Wed, 28 Nov 2001 22:50:10 -0500 Subject: how to call external functions from python References: <3C046A11.175B9FB5@engcorp.com> Message-ID: <3C05B072.1E5680D6@engcorp.com> weeang wrote: > > Peter Hansen wrote in message: > > weeang wrote: > > > > > > i need help on the following: > > > > > > 1) find all files in inbox directory and zip them > > > 2) move the zipped file to outbox > > > 3) copy the zipped file to a remote directory [...] > My general objectives are: > To zip all files in a directory and copy the zipped file to a remote > directory. > > The design is as follows, i.e. simulating a ms outlook functionality: I'm going to ignore that comment about Outlook, because while it does perform some functions that are in some ways similar to what you are talking about, it is an *email* program and you don't seem to be talking about email at all (right?). There are many ways to move files around, and email is only the most complicated (in this case at least, where you want to drop the files directly into a remote folder). > 1)Zip all the files in a local 'inbox' directory > 2)Move the zipped file to local 'outbox' directory > 3)Copy the zipped file to a remote directory > 4)Moving the zipped file to a local 'sent' directory > > I hope I have made myself clear?? I think so, but the terms "inbox" and "outbox" are so loaded with email-related meanings, and you mention MS Outlook but don't seem to really be talking about anything related to Outlook, that I'll just trust you really aren't talking about email at all. It sounds like you want to read about the following modules in the standard library: zipfile os possibly shutil possibly ftplib Note that by using os.system() you could perhaps simply call an external zip program and skip zipfile. How do you plan to get the files from the local machine to the remote directory? FTP? SSH? Copying across a local area network? (Or did you really plan to use email for this? In which case you want smtplib too.) -- ---------------------- Peter Hansen, P.Eng. peter at engcorp.com From skip at pobox.com Wed Nov 14 04:30:15 2001 From: skip at pobox.com (Skip Montanaro) Date: Wed, 14 Nov 2001 10:30:15 +0100 Subject: PEP 276 Simple Iterator for ints In-Reply-To: <15346.13388.182098.148832@beluga.mojam.com> References: <9ss7jo$iu9$1@tyfon.itea.ntnu.no> <15346.13388.182098.148832@beluga.mojam.com> Message-ID: <15346.14759.677657.485664@beluga.mojam.com> Skip> for i in 10: Skip> i = -i # for i in range(0, -10, -1) ... Skip> Taking that one gruesome step farther, one could envision a further Skip> extension to for loops: Skip> for i=-i in 10: Skip> ... Though after reading the remainder of the thread, I like the Haskell syntax best. S From michael at rcp.co.uk Fri Nov 30 11:32:22 2001 From: michael at rcp.co.uk (Michael Abbott) Date: Fri, 30 Nov 2001 16:32:22 +0000 (UTC) Subject: Non-Indented python References: Message-ID: Nicholas FitzRoy-Dale wrote in news:mailman.1007130761.13071.python-list at python.org: > This isn't directed at Marcin, but I don't understand why people keep > going on about this, because it's not accomplishing anything. > > * Most tab-indent users won't become space users > * Most space-indent users won't magically change into tab users > * The above quoted para won't convince anyone who uses 4-char tabs > to switch over, especially since 8-char tabs is only demonstrably the > "standard" when you're dealing with the Python interpreter. > > Nobody has presented a convincing argument for tabs-only, spaces-only, > or 8-char tabs only, because there isn't one. Everyone's smart enough to > recognise a vi/Emacs holy war when they see one; why is the tab/space > war any different? I'm sure you're right, and if I'm fanning an unwanted fire, I'll stop. However, until you ask me to stop (or we get bored), I want to continue to say: Hard tabs in source files serve no useful purpose and cause trouble. Please don't use them! This is a self evident +holy truth+ :^) From montanaro at tttech.com Thu Nov 8 13:18:05 2001 From: montanaro at tttech.com (Skip Montanaro) Date: Thu, 08 Nov 2001 19:18:05 +0100 Subject: Reading a comma delimited file In-Reply-To: References: Message-ID: Kristen> Does the %f work just like in C? Kristen> %.2f,var Close. Try this: >>> val = 1.1 >>> val 1.1000000000000001 >>> "%.2f" % val '1.10' In the common case (the one most like C), it takes a string containing typical %-format stuff on the left and a tuple of strings on the right: >>> "%.2f %.3f %.4f" % (val, val, val) '1.10 1.100 1.1000' The one-element case can be reduced to a string on the right as in my first example. The cooler case takes a dict on the right and slightly different format characters on the left: >>> "%(val).2f %(val).3f %(val).4f" % {"val": val} '1.10 1.100 1.1000' This is generally helpful where you are interpolating a large string with many %-expressions and would find it difficult to match up the %-format elements with the index positions of the tuple. Normally, the values you want to interpolate are local variables, so you see it often spelled as >>> "%(val).2f %(val).3f %(val).4f" % locals() '1.10 1.100 1.1000' People have also developed tricks for interpolating with multiple dictionaries at once and interpolating expressions on-the-fly. Search the recent archives of the list (last two months or so) for "interpolat" to find example code. Skip From pj at sgi.com Wed Nov 28 19:17:34 2001 From: pj at sgi.com (Paul Jackson) Date: 29 Nov 2001 00:17:34 GMT Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C056DF5.F9EE5D13@ccvcorp.com> <3C0575F4.9A23C894@cosc.canterbury.ac.nz> Message-ID: <9u3uqu$bvfku$1@fido.engr.sgi.com> Greg wrote: > ... unless "i in 5" on its own were valid and > had a rather unintuitive meaning. But "i in 5" does have exactly the meaning needed here, for: 0 is the nul set 1 is the set containing 0 2 is the set containing 0 and 1 ... 5 is the set containing 0 through 4 ... n is the set containing 0 through n-1. Well ... to the 3 dozen people on the planet who majored in set theory this is all quite intuitive. I will grant that I'm in a distinct minority . -- I won't rest till it's the best ... Manager, Linux Scalability Paul Jackson 1.650.933.1373 From sholden at holdenweb.com Wed Nov 28 10:23:18 2001 From: sholden at holdenweb.com (Steve Holden) Date: Wed, 28 Nov 2001 10:23:18 -0500 Subject: Should we trust .NET? (was Re: PHP vs. Python/comp.lang.php?) References: <9tia10$43o$1@dahlia.singnet.com.sg> <3bfe9816.152519843@news.cortland.com> Message-ID: "Oleg Broytmann" wrote ... > On Wed, Nov 28, 2001 at 01:18:48AM +0000, Tim Hammerquist wrote: > > Ken Seehof graced us by uttering: > > [ snip ] > > > It has never been in MS's best interest to be compatible with the > > > rest of the computing world. > > > > More precisely, it's never been in Bill's pocketbook's best interest > > to be compatible with the rest of the world. > > > > It's _always_ been in MS's best interest to be compatible. There's > > more than enough money in the industry to support Microsoft and any > > other vendors. > > There are other merits, not only money. Corporations want power even > more than money. Down with non-free software. :-) But seriously, the only advantage of more power is its ability to generate greater revenues. Any other ultimate goal would be un-American. regards Steve -- http://www.holdenweb.com/ From kseehof at neuralintegrator.com Wed Nov 14 17:40:26 2001 From: kseehof at neuralintegrator.com (Ken Seehof) Date: Wed, 14 Nov 2001 14:40:26 -0800 Subject: Non-obvious name bindings References: <9s63i4$11mom8$1@ID-11957.news.dfncis.de> <3BF1BB43.6B4E667B@bgb.cc> <9ssf3h$dfh$1@peabody.colorado.edu> <3BF2D8CE.7CC12F87@ccvcorp.com> Message-ID: <014601c16d77$b388b020$7a93b23f@kens> Jeff Shannon wrote: > . . . > If I'm reading the bug report right, then it *is* expected behavior that list > comp variables are function-local variables, not true "temporary" variables. > > C++ (IIRC) treats loop indices as being limited to the scope of the loop only, > and invalid once the loop ends. Python, however, has a much simpler scoping > scheme, and doesn't use a separate scope for loops (and list comps are just > syntax sugar for a for-loop). > > . . . > Jeff Shannon > Technician/Programmer > Credit International Actually, the index has the scope that contains the 'for' statement, so it does persist after the loop. int main(int argc, char* argv[]) { for (int i=0; i<10; i++) { printf("%d ", i); } printf("\n\n i = %d", i); } ------------------------ 0 1 2 3 4 5 6 7 8 9 i = 9 - Ken From tboyle at NoSMAProsehill.net Thu Nov 22 19:35:09 2001 From: tboyle at NoSMAProsehill.net (Todd Boyle) Date: Fri, 23 Nov 2001 00:35:09 GMT Subject: PHP vs. Python/comp.lang.php? References: <9tia10$43o$1@dahlia.singnet.com.sg> Message-ID: <3bfe9816.152519843@news.cortland.com> I am an amateur at programming and I have almost the same questions. My questions are: 1. PHP is attractive to me because after playing aroudn with it a short while I was able to implement my own simple stuff, and some other PHP applications from open source. Also--the leading independent webledger in my industry is Intacct (not connection to me) and it's written in PHP, which proves this is a very capable system. 2. I also need something practical to get away from the borg; I made a big mistake during the 1990s and moved from Clipper to Visual Basic, which is a great platform but they churn the hell out of it, and nothing you can write will ever be an asset to the programmer for longer than 1-2 years. So I am using Python for day-2-day little programming tasks... But, what is the best way to build web-based database applications like accounting systems, on Python? i.e. what is the equivalent of ASP pages or PHP pages or JSP pages, for Python?? Shouldn't we be learning THAT instead of PHP??? Todd Boyle www.gldialtone.com On Thu, 22 Nov 2001 06:17:46 -0000, "the Spinning Spider" wrote: >I'm finding learning Java is quite a tough challenge, like wading through a >swamp. So I'm exploring PHP and Python as possible alternatives. > >I notice there doesn't seem to be much mention about PHP by Python people >whenever they mention other languages, >e.g.,see http://www.python.org/doc/Comparisons.html. > >Or is it because PHP is incomparable against Python? > >Could it be the news servers I have access to, or is there no comp.lang.php >newsgroup? Is PHP too insignificant? > >Will Python be too intellectually challenging, like Java? > From cjensen at bioeng.ucsd.edu Thu Nov 15 13:32:46 2001 From: cjensen at bioeng.ucsd.edu (Curtis Jensen) Date: Thu, 15 Nov 2001 10:32:46 -0800 Subject: initializing private members via exec Message-ID: <3BF40A4E.CC498C2D@bioeng.ucsd.edu> Why session below give me an error? Is there some rule against initializing private data members inside an exec function? Is there an equivalant way of initializing private members? Thanks. Python 1.5.2 (#4, Sep 5 2000, 10:29:12) [C] on irix646 Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>> class Foo: ... def __init__( self ): ... self.__bar = 0 ... exec( 'self.barnone = 2' ) ... exec( 'self.__monty = 3' ) ... print 'bar:',self.__bar ... print 'barnone:',self.barnone ... print 'monty:',self.__monty ... >>> >>> jim = Foo() bar: 0 barnone: 2 monty: Traceback (innermost last): File "", line 1, in ? File "", line 8, in __init__ AttributeError: _Foo__monty -- Curtis Jensen cjensen at bioeng.ucsd.edu http://www-bioeng.ucsd.edu/~cjensen/ FAX (425) 740-1451 From kragen at canonical.org Sun Nov 25 20:33:32 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 25 Nov 2001 20:33:32 -0500 Subject: Does rotor follow a cross-language encryption algorithm ? References: <97ae44ee.0111231225.22760e5c@posting.google.com> <3bfecd77@brateggebdc5.br-automation.co.at> <97ae44ee.0111232129.550244cd@posting.google.com> Message-ID: <833d32uxhv.fsf@panacea.canonical.org> shriek at gmx.co.uk (Stephen) writes: > Lance Ellinghouse (who wrote rotormodule.c) also writes that the > output "is considered BINARY data" so a CRLF, LF or CR are not > possible output. This seems like a dubious interpretation of 'binary data' to me, and testing reveals that you are wrong; here's an abbreviated session: Python 2.1.1 (#1, Oct 24 2001, 10:59:24) [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2 Type "copyright", "credits" or "license" for more information. >>> import rotor >>> x = rotor.newrotor("x", 1) >>> x.encrypt("x" * 100) '\xda\xa9\xab\xa2\xc6\xed\xc7|\r\xb9]KM\xb0\xc8\\\t\xdd\x16\x00("\xd3S3\xe3\xe2\x9b-\xa7\x94\x0e\x1er\x9e\x06cI\x8a\x7f=\xd0\x14\xd4\xe1\x15F\xb7\x85W_9\x93k\xceg\xc1e\x87\xc5\xf36\xbc\xaf)s\xf0\xc2vz\xe8\xfdTf\xa5\x96m\xea\xacb\xb4\xca{<@BC\xf7\x19\x03.G\xec\xbd\x10\xd9\xf8\xa1\xff\xaa' >>> longstring = x.encrypt("x" * 2048) >>> longstring.find("\n") 104 >>> longstring.find("\r") 8 > Reading his comments, this does not seem to be a "standard" > rotor. However, having the C and Java equivalents will suffice > at the moment. Makes me wonder why more people don't use the > rotor when they need "just enough" encryption without going > the full hog with PKI. Triple-DES or Blowfish are much better choices if you need encryption but don't want to hassle with PKI. They will keep your data secret, and the rotor module is vulnerable to cryptanalysis. > Just to clear up my own understanding, is it fair to say that > a "built-in" module can be defined as one that is included in > the core Python distributed, and is written in C as oppopsed > to Python, but which still needs to be imported before use ? A module that is written in C is called an 'extension module'. A built-in module is one that is linked into the Python executable rather than stored as a DLL; you can turn any extension module into a built-in module. The modules that are included in the core Python distribution are the 'standard library'. All modules need to be imported before use, except for __builtins__. From emile at fenx.com Sun Nov 4 08:36:04 2001 From: emile at fenx.com (Emile van Sebille) Date: Sun, 4 Nov 2001 05:36:04 -0800 Subject: passing parameters to generators ? References: Message-ID: <9s3gh1$vh2fi$1@ID-11957.news.dfncis.de> "Jan Samohyl" wrote in message news:mailman.1004878271.8696.python-list at python.org... > Hello, > I would like to pass different parameters to a generator while it's generating, is there some simple way to do that? > I want to write a synchronous server, that would go through all the active connections and when the client response is > available, it would call a generator with the client response, and resume the conversation with the client exactly at the > point it yielded out to let other talk. I think it would be very cool to do it this way, but unfortunately, current generator > implementation doesn't allow to do it that simply. Why is a function with yield *always* a generator factory? Why it isn't > simply the generator, and generator factory or iterator would be done as a function factory returning generator next()? And > when you would call generator again with different parameters, they would be different inside the generator (but the locals > would stay the same and you would enter behind the last yield statement). > This came up earlier this week. Here's my response to the earlier question: You can share mutable objects to pass in information: def gf(args): while 1: yield args[0]*args[1] a = [2,3] g = gf(a) print g.next() a[1]=4 print g.next() Is this what you're looking for? -- Emile van Sebille emile at fenx.com --------- From vcomic at speed.sender.com Fri Nov 23 14:01:00 2001 From: vcomic at speed.sender.com (vcomic at speed.sender.com) Date: 24 Nov 2001 03:01:00 +0800 Subject: ±¬Ð¦Ê±ÊÂÂþ»­ 11-23 Message-ID: <0f98f55001917b1GOWCHINASERVER@www.gowchina.com> An HTML attachment was scrubbed... URL: From emile at fenx.com Wed Nov 21 21:39:12 2001 From: emile at fenx.com (Emile van Sebille) Date: Wed, 21 Nov 2001 18:39:12 -0800 Subject: Strange thing: file.close did not show error but work wrong References: <9tho04$2or14$1@ID-11957.news.dfncis.de> Message-ID: <9thoq0$2ni27$1@ID-11957.news.dfncis.de> "Emile van Sebille" wrote in message news:9tho04$2or14$1 at ID-11957.news.dfncis.de... > > "wqhdebian" wrote in message > news:db288b61.0111211822.2e903177 at posting.google.com... > > f='d:\\d.txt' > > fdw='d:\\matlabdata.txt' > > import string > > fd=open(f,'r') > > fdw=open(fdw,'w+') > > b=fd.readlines() > > num=len(b) > > print 'num=' > > print num > > #print b > > print type(b) > > #a=string.split(b,' ') > > print len(b) > > #for i in b[:]: > > # print i > > fdw.write('i') > > fd.close########################### > > fdw.close######################### When I use like this ,there is no > > warning and > > ##############any error message,but the file do not have been > > writen.After I change back to fdw.close(),Then it work well. > > > > > Yes, this is all as it should be. > > Python simply recognizes the name without error. In console mode the same > line would have responded as though you had typed in print fdw.close which > would then respond with something like "method close of file object". > Sorry, didn't catch the comment on the file not being written. I suspect there you're running into an os specific issue. It did write on my win2k box, and the expectation is that you shouldn't have to close() a file before exiting, but I have heard people suggest that you flush() and close() to ensure that the data is written. Emile From rogerha at ifi.uio.no Wed Nov 21 05:55:37 2001 From: rogerha at ifi.uio.no (Roger Hansen) Date: 21 Nov 2001 11:55:37 +0100 Subject: Basic question about SWIG References: <9tehji$b02$1@watserv3.uwaterloo.ca> Message-ID: * Joe Mason SNIP Have you tried putting the typedef in the interface file. Then it will show up in the foo_wrap.c file. That could fix your problem. BTW, there is a mailing list for SWIG, see , where D. Beazley and others are very helpful. HTH -- Roger From j.c.mcnulty at open.ac.uk Thu Nov 1 04:27:37 2001 From: j.c.mcnulty at open.ac.uk (James) Date: 1 Nov 2001 01:27:37 -0800 Subject: Compiling python error References: <6e761479.0110310111.454ee89e@posting.google.com> Message-ID: <6e761479.0111010127.18a5e8ed@posting.google.com> "Fredrik Lundh" wrote in message news:... > James" wrote: > > When I try to configure python i get the following errors. > > what platform? what Python version? what compiler version? > (etc) > > > checking whether the C++ compiler (c++ ) is a cross-compiler... yes > > this usually means that your compiler failed to compile a trivial C > program into something that could be executed on your machine. > usual causes are bad licenses or botched compiler installations. > > check the config.log file for more clues. > > Hi, I am trying to compile python 2.1.1 on Solaris 8 Sparc with the latest gcc. Here is a copy of config.log. bash-2.03# more config.log This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. configure:631: checking MACHDEP configure:673: checking for --without-gcc configure:734: checking for --with-cxx= configure:764: checking for c++ configure:799: checking whether the C++ compiler (c++ ) works configure:815: c++ -o conftest conftest.C 1>&5 configure:841: checking whether the C++ compiler (c++ ) is a cross-compiler configure:858: checking for gcc configure:971: checking whether the C compiler (gcc ) works configure:987: gcc -o conftest conftest.c 1>&5 configure:1013: checking whether the C compiler (gcc ) is a cross-compiler configure:1018: checking whether we are using GNU C configure:1027: gcc -E conftest.c configure:1046: checking whether gcc accepts -g configure:1078: checking for Cygwin environment configure:1094: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:1090: `__CYGWIN32__' undeclared (first use in this function) configure:1090: (Each undeclared identifier is reported only once configure:1090: for each function it appears in.) configure: failed program was: #line 1083 "configure" #include "confdefs.h" int main() { #ifndef __CYGWIN__ #define __CYGWIN__ __CYGWIN32__ #endif return __CYGWIN__; ; return 0; } configure:1111: checking for mingw32 environment configure:1123: gcc -c -g -O2 conftest.c 1>&5 configure: In function `main': configure:1119: `__MINGW32__' undeclared (first use in this function) configure:1119: (Each undeclared identifier is reported only once configure:1119: for each function it appears in.) configure: failed program was: #line 1116 "configure" #include "confdefs.h" int main() { return __MINGW32__; ; return 0; } configure:1142: checking for executable suffix configure:1152: gcc -o conftest -g -O2 conftest.c 1>&5 configure:1173: checking for --with-suffix configure:1215: checking LIBRARY configure:1237: checking LINKCC configure:1253: checking LDLIBRARY configure:1284: checking for ranlib configure:1317: checking for ar configure:1387: checking for a BSD compatible install configure:1484: checking how to run the C preprocessor configure:1505: gcc -E conftest.c >/dev/null 2>conftest.out configure:1564: checking for AIX configure:1589: checking for minix/config.h configure:1599: gcc -E conftest.c >/dev/null 2>conftest.out configure:1595: minix/config.h: No such file or directory configure: failed program was: #line 1594 "configure" #include "confdefs.h" #include configure:1638: checking whether gcc accepts -OPT:Olimit=0 Any ideas would be greatly appreciated. James From loewis at informatik.hu-berlin.de Mon Nov 26 04:49:11 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 26 Nov 2001 10:49:11 +0100 Subject: Which Version for Absolut Beginner? References: <3c013d0d.26717374@news> <9trfct$llh$1@norfair.nerim.net> Message-ID: "Gillou" writes: > You can use the latest stable "official" python from BeOpen (official) > http://www.python.org Taking 2.1.1 from www.python.org is good advice, but it ain't from BeOpen anymore. Instead, it is really PythonLabs who makes the release; they are now part of Zope Corporation. Regards, Martin From simonb at webone.com.au Tue Nov 27 10:15:28 2001 From: simonb at webone.com.au (simonb at webone.com.au) Date: Wed, 28 Nov 2001 02:15:28 +1100 Subject: wavelet References: <3C028962.D467D83D@gol.ge> Message-ID: <3C03AE10.4070207@webone.com.au> well, i don't know of such a module. but i'm a wavelet fan, and am likely to implement such a thing for python. do you need 2D or is 1D enough? im mainly interested in 1D transforms (sound) -Simon. Giorgi Lekishvili wrote: >Dear all! > >I am sorry to waste your time. > >Perhaps, here is someone who knows where can I get the python module(s) >for wavelet transforms? > >Thank you. >Best wishes, >Giorgi > From fperez528 at yahoo.com Mon Nov 26 11:47:04 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 16:15:04 +2328 Subject: module.__path__ References: Message-ID: <9u16r4$h2f$1@peabody.colorado.edu> Ken Seehof wrote: > Why is the __file__ attribute (of a module) a relative filename rather than > a fully qualified filename? One would think that the __file__ attribute > might be used for the purpose of locating and opening a source file, right? > If somebody wants a relative filename couldn't they split it themselves? > By making module.__file__ relative, information is lost. What was Guido > thinking??? Perhaps a __fullpath__ should be added. > > Don't tell me about the fact that .pyc files might be moved along with .py > file from a different computer, thereby rendering the full pathnames > incorrect. That's a silly argument not worth addressing. :-) > > Is there a good general way to determine the full pathname of a module file, > or is the best approach to search sys.path for module.__file__? I don't know what Guido was thinking, my telepathy cap broke yesterday. But as far as finding full, correct pathnames, use the inspect module (standard with python >=2.1). It can get you filenames, code, function headers, just about anything you want about an object. An example: In [21]: ranlib ? Details for: ranlib Type: module String Form: Namespace: Local - IPython Session File: /usr/lib/python2.1/site-packages/Numeric/ranlib.so > > If the module is an extension module, how do I find the full pathname of the > source code file (preferably platform independent)? > You can't. It may have been compiled to binary and the source may not even be on your computer at all. So it's inherently impossible to get it. In the above example, I don't have the ranlib source (in this case I could get it, b/c the original Numeric distribution is open source, but that's besides the point). All python sees is the binary module ranlib.so, and that's all you'll ever get. Cheers, f From db3l at fitlinxx.com Wed Nov 14 20:42:50 2001 From: db3l at fitlinxx.com (David Bolen) Date: 14 Nov 2001 20:42:50 -0500 Subject: Threading References: Message-ID: Thomas Jensen writes: > That's very interesting, I'm usually quite paranoid about wrapping such > stuff in locks. When in doubt, that's the right approach. You might be able to eeek a little more performance out of hand tuning some "safe" scenarios, but I don't think the potential downsides are worth it in general. > Is there any "rule-of-thumb" (or doc) regarding which operations are > atomic, for example is the following safe: An operation would be atomic with respect to Python interpreter threads if it executes while holding onto the GIL (global interpreter lock). Generally speaking this must (a) be something written in C, either as part of the interpreter or an extension module, and (b) not release the GIL to provide for threading execution around a long running or blocked activity, such as I/O. This typically includes most builtin operations on native types that are implemented in C. However, I don't know of any general rule to recognize this without actually looking at a specific implementation, and suspect that any approach tried would be very implementation specific. Plus, even if you examined a particular type to determine how it behaved, if your code ever got used with a replacement class implemented in Python itself, the rules would change again. Generally, it's just safer to lock more conservatively. > thread 1: > mylist.reverse() > > thread 2: > for item in mylist: > ... > > (silly example perhaps) This doesn't appear as it would be safe if the goal of thread 2 was to iterate through every item in the list consistently. If mylist was a builtin list type object (and at least in the CPython implementation) then you are guaranteed that once it begins, the reverse() method call in thread 1 will run to completion before any other Python thread continues execution. What you aren't guaranteed is how that reverse call's timing will occur with respect to thread 2. So if thread 1 managed to transfer control to the reverse() method prior to thread 2 hitting that for loop, you'd get a consistent (reverse) list. But if thread 1 didn't make it into the call until thread 2 was partially through the loop, then the list would be reversed, and it would be equivalent to having Python code that mutated the list within the for loop, in which case behavior is non-deterministic (at least in general, since it depends on the type of mutation). Since the mutation in this case keeps the list the same length but just reverses the contents, I expect you'd have entries processed in the for loop up until the thread context switch, and then you'd get the entries in the remaining positions of the list but for the reversed copy. I'd definitely protect something like this - you've clearly got higher level processing (the iteration over the list) that needs the list to remain intact during the work. Either that, or protect the act of making a copy of the list, and then iterate over that copy. The copying is one of those potential tuning points - I'd have to double check, but I bet that an operation like "newlist = mylist[:]" would be atomic, so you could probably get away with not protecting that. At least until mylist happened to end up a user class with its own __getslice__. -- -- 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 stewart at sig.com Mon Nov 12 09:08:52 2001 From: stewart at sig.com (Rob Stewart) Date: 12 Nov 2001 06:08:52 -0800 Subject: How Can I Capture the Class Object for a Python Class Derived From My C API Metatype? References: <3a5a7d54.0111091305.70bad186@posting.google.com> Message-ID: <3a5a7d54.0111120608.1f9833b2@posting.google.com> stewart at sig.com (Rob Stewart) wrote in message news:<3a5a7d54.0111091305.70bad186 at posting.google.com>... > I need to create a metatype, using the C API, that can save the class > objects for Python classes derived from it. I need to be able to use > the class object to instantiate objects of that class under C (C++) > program control, and to discover the methods that have been defined to > override default behavior so C++ virtual function calls can be > forwarded to Python methods. I should mention that, as I understand it, the common metatype of the bases of the class declared in Python is called to create the Python class object. That means the type of my metatype, which would be the base for the Python class I wish to capture, is called. It is the type of my metatype that then creates the class object for the declared Python class. Since I'm sure that's as clear as mud, let me illustrate: Let M be my metatype. Let T be the type of my metatype. Let P be a Python class. # Some Python code: class P(M): pass As I understand the mechanism, T's tp_call slot function is invoked to instantiate a class object describing P. If T is PyType_Type, then tp_call is defined to call the tp_new slot on the type of the new object, which ultimately should call tp_new on T (since the derived type's tp_new should call the base's tp_new. At that point, T can save the PyObject * for the class object being created for later use by the C++ code. At that point, it should, I think, also be possible to capture the methods implemented or inherited by P. For each method of an expected, predetermined name, I can capture the PyObject * for that method for subsequent invocation by the C++ code. The notion here, is that if the method hasn't been overridden, then I can provide the default behavior in C++ rather than always forwarding to a method in the metatype. This is merely a performance optimization. > My current, flailing (and failing) attempt was to create a metatype, > for which ob_type is set to the address of a PyTypeObject which starts > out being a copy (via memcpy()) of PyType_Type. I set the tp_new slot > of that type object (the meta-metatype, if you will) to a function > that can capture the class object and inspect it for methods. I've > been tweaking the tp_bases and tp_mro fields of that type object, but > haven't found the right combination of values to get things working. > > For example, type_new() was complaining at first because my > meta-metatype wasn't its own supertype. I tried setting tp_mro to > NULL, but that wreaked havoc elsewhere. So, I created a tuple > containing just the meta-metatype. That got me farther, but I then > found that I needed to put &PyType_Type in the tuple. Unfortunately, > having done that, I merely stumble upon other problems. > > The point is, the approach I'm taking is a hack, and it's brittle, > assuming I can even make it work. That makes it highly undesirable. > Hopefully, then, there's a better way to go about this. > > Thanks for any help you can offer. > > Rob From fperez528 at yahoo.com Mon Nov 26 17:44:04 2001 From: fperez528 at yahoo.com (Fernando =?ISO-8859-1?Q?P=E9rez?=) Date: Tue, 27 Nov 2001 22:12:04 +2328 Subject: windows to linux pickled objects? References: Message-ID: <9u1rog$31l$1@peabody.colorado.edu> Stephen Boulet wrote: > I pickled a list in windows but couldn't open it in linux without > first running the handy dos2unix program on it. > ... > On linux at home I rejoined the parts with cat and gunzipped it. It > went from 1.6 MB to 8.2 MB. Those pickles can get big. > > -- Stephen I suspect the solution is just to pickle in binary. Otherwise you run into the usual mess of 'what's a newline' between unix and windows. Besides, if your pickles are that big binary is the way to go anyways. cheers, f From palaste at cc.helsinki.fi Wed Nov 21 17:03:20 2001 From: palaste at cc.helsinki.fi (Joona I Palaste) Date: 21 Nov 2001 22:03:20 GMT Subject: how to express the following regular expression? References: <9tft7a$30$1@helix.cs.uoregon.edu> Message-ID: <9th8b8$d57$5@oravannahka.helsinki.fi> Carl Howells scribbled the following on comp.lang.java.programmer: > "Stephen" wrote... >> I want to search the following formats: >> >> ([1234567890]*)R >> or >> P([1234567890]*) >> >> this means there must be a 'P' before the number or a 'R' after the >> number. However, I think I can't use this: >> P?([1234567890]*)R? >> because the number without P and R is also matched! >> >> How can I express it? > Exactly you you'd expect... One or the other: > (P\d*)|(\d*R) > You could also use [0-9] in place of \d, if you were really set on using the > [] notation. But there's no reason to use [1234567890]. This is indeed the only way. Regular expressions don't remember things. When the regular expression "gets" to the R part, it forgets what it did when it "was" in the P part. This is the main reason why a criterion such as: (((1234))) where the number of left parantheses is equal to the number of right parantheses cannot be expressed as a regular expression. Noam Chomsky has written a definition of languages which addresses this problem. Context-free grammars are more powerful than regular expressions. For example my criterion above can be expressed as the following grammar (BNF notation): TARGET ::= STRING STRING ::= '(' STRING ')' | DIGITS DIGITS ::= | ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') DIGITS The OP's criterion can be expressed as follows: TARGET ::= STRING STRING ::= 'P' DIGITS | DIGITS 'R' DIGITS ::= | ('0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9') DIGITS -- /-- Joona Palaste (palaste at cc.helsinki.fi) ---------------------------\ | Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++| | http://www.helsinki.fi/~palaste W++ B OP+ | \----------------------------------------- Finland rules! ------------/ "All that flower power is no match for my glower power!" - Montgomery Burns From tim at vegeta.ath.cx Tue Nov 13 22:16:14 2001 From: tim at vegeta.ath.cx (Tim Hammerquist) Date: Wed, 14 Nov 2001 03:16:14 GMT Subject: IsPython really O-O? References: <3BEE09CD.FFC433CC@alcyone.com> <359f85cd.0111131158.1520ea32@posting.google.com> Message-ID: Roy Smith graced us by uttering: > ianb at colorstudy.com (Ian Bicking) wrote: >> If you look under the hood, Python is much more like Smalltalk than >> Java. > > I'm having trouble parsing that. Which of the following did you mean? > > 1) Python is more like Smalltalk that Python is like Java > 2) Python is more like Smalltalk than Java is like Smalltalk I grokked it as meaning case 2. That's what we get for using English. Now if we used Latin, we wouldn't have to rely on the relative location of words in a sentence to determine meaning... ;) On that note: http://search.cpan.org/doc/DCONWAY/Lingua-Romana-Perligata-0.50/README Sorry 'bout the OT, but it seems Mr. Conway is both quite adept and very much a masochistic hacker. Tim Hammerquist -- I'll keep him as an insurance policy, since, unfortunately, I can't kill him twice. -- Scaroth From s713221 at student.gu.edu.au Wed Nov 28 04:26:26 2001 From: s713221 at student.gu.edu.au (Joal Heagney) Date: Wed, 28 Nov 2001 19:26:26 +1000 Subject: Exec across multiple platforms. Message-ID: <3C04ADC2.51C57C69@student.gu.edu.au> I noticed a bug in a python package involving exec and dos-created files. Basically, if a file was created in the dos-world then shipped over to the linux world a-la tar.gz archive, the resulting /r/n endlines caused problems in the program. Now I managed to get around this by adding the following error-checking in the code. file = open("a_file", "r") a_value = file.readline() if a_value[-2:] == "/r/n": a_value == a_value[:-2] exec "doing something nasty to %s" % a_value Now I'd like to contact the author of the program with a fix, but I'm uncertain as how to ensure this solution is cross-platform. I.e. will cutting the /r/n off the end of a string in the dos world render a string un-exec-able, the same way not cutting the /r/n off does in the unix world? If it doesn't matter, I'll submit as is. Otherwise, is there a cross-platform solution? P.S. Pick the person so linuxified that he can't remember how the dosworld works. :). -- Joal Heagney is: _____ _____ /\ _ __ __ _ | | _ ___ | /__\|\ || ||__ |\ || |___|/_\|___] | / \ \_||__ ||___| \_|! | | \ \ ! From aa at bb.cc Mon Nov 5 08:41:02 2001 From: aa at bb.cc (Károly Ladvánszky) Date: Mon, 5 Nov 2001 14:41:02 +0100 Subject: Question: Error or misconcept References: <3be65da4$1_3@corp-goliath.newsgroups.com> <9s62qa$11k821$1@ID-11957.news.dfncis.de> Message-ID: <3be69395_1@corp-goliath.newsgroups.com> Thank you for your answer. > You've just created a class level shared object a1. Ok, but then I'd expect the same behaviour when a1 is a number. Try this: class c: a1=0 def f1(self,a): self.a1=a Now: o1=c() o1.f1(99) o1.a1 ==> 99 o2=c() o2.a1 ==> 0 ! Shouldn't it reflect the change in the class level object's value just like in the case a1 is a list? Cheers, K?roly ______________________________________________________________________________ Posted Via Binaries.net = SPEED+RETENTION+COMPLETION = http://www.binaries.net From phr-n2001d at nightsong.com Thu Nov 15 19:19:33 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 15 Nov 2001 16:19:33 -0800 Subject: what happened to Python Cryptography Toolkit? References: Message-ID: <7x4rnvy3ca.fsf@ruckus.brouhaha.com> Peter Wang writes: > i find quite a few references to Andrew Kuchling's Python Cryptography > Toolkit on the web, but all the links to actual sources/distributions > are broken. also, there doesn't seem to be any mention of it past > 1995... > > has it been supplanted by something else? all i want is to easily do > RSA, preferrably in a platform-independent manner. (if platform > dependence is unavoidable, unix is preferable.) Look for mxCrypto. Note that both AMK's package and mxCrypto use external C libraries, so they aren't pure Python. I don't know if that's platform-independent enough for you. See http://www.nightsong.com/phr/python/crypto.txt for a description of something I've been doing. It doesn't support RSA at the moment but I can add that if there's a reason to do so. It's in pure Python. Can you say what your precise application is, that requires RSA? From jgitomer at erols.com Wed Nov 14 23:47:37 2001 From: jgitomer at erols.com (Jerry Gitomer) Date: Wed, 14 Nov 2001 23:47:37 -0500 Subject: GUI toolkit References: Message-ID: <9svhc8$74k$1@bob.news.rcn.net> Cary Coulter wrote: > While I've learned a lot of Python in the last year, all my > scripts > have run from the command line or as CGI programs. I'm very > happy with it all. > > I am interested in developing gui wrappers for a couple of my > command > line scripts to make them easier to use, especially under > Windows. I > don't have any experience with the gui toolkits yet. I'm > looking for > some hints on the pros/cons to help make a good choice. I'm > really looking at just learning one of them. > > I have looked at the demos for wxPython. Have to say I like > what I see, but I haven't tried to develop anything yet. > > Platforms would be Linux (primary), Windows, and AIX (didn't > see any prebuilt code for wxPython). > > Your help/ideas are greatly appreciated. > > TIA > Cary > Given that you want to port to AIX as well as Linux and Windows I believe that you are best off sticking to plain vanilla Tkinter (with the PMW widgets). -- Jerry Gitomer Once I learned how to spell DBA, I became one From gward at python.net Fri Nov 16 10:24:06 2001 From: gward at python.net (Greg Ward) Date: Fri, 16 Nov 2001 10:24:06 -0500 Subject: Latest Optik developments Message-ID: <20011116102406.A29998@gerg.ca> Hi all -- (This is addressed to everyone who has sent me mail about Optik, cc'd to python-list so the rest of the Python world can see it too. For those on python-list/c.l.py who don't know what I'm talking about, Optik is my new command-line parsing library for Python; see optik.sourceforge.net.) 1) I have created a mailing list for general discussion of Optik: optik-users at lists.sourceforge.net. Please visit http://lists.sourceforge.net/lists/listinfo/optik-users to join 2) The current CVS code has the feature that several of you asked for (John, I can't remember if you asked for it, but I know you want it): the ability for one option to suck in multiple arguments. See CHANGES.txt in CVS for an example. This is tested, but not yet documented. Any future questions about Optik should be directed to the optik-users list, so that everyone interested can see the question and the answer -- and so that both are archived! Thanks all for your interest -- Greg -- Greg Ward - Linux weenie gward at python.net http://starship.python.net/~gward/ Condense soup, not books! From mertz at gnosis.cx Sun Nov 11 04:23:41 2001 From: mertz at gnosis.cx (Dr. David Mertz) Date: Sun, 11 Nov 2001 04:23:41 -0500 Subject: A Python GUI Book. (fwd) Message-ID: Michael 'Mickey' Lauer wrote: |I'm currently writing a Python GUI book, where several toolkits |think should be a _must_ in such a book? Anygui! see anygui.sourceforge.net From cfelling at iae.nl Sun Nov 25 18:47:23 2001 From: cfelling at iae.nl (Carel Fellinger) Date: Sun, 25 Nov 2001 23:47:23 GMT Subject: GUI toolkit References: <9tb6ke$1evoq$3@ID-89274.news.dfncis.de> <9td9lv$c8p$1@tyfon.itea.ntnu.no> Message-ID: Courageous wrote: : Correct. As the author of a GPLed work, you can GPL your code, derive : new code from this GPLed code, and release that new code under something : other than the GPL. While you cannot retract your older versions from Beware, that the big assumption here is that your the sole copyright holder of the original code. E.g. things change drastically if someone contributed to the code base in a somehow significant way. From prabhu at aero.iitm.ernet.in Sat Nov 10 23:35:13 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Sun, 11 Nov 2001 10:05:13 +0530 Subject: [Python-Dev] Proposal for a modified import mechanism. In-Reply-To: <3BED6CB8.27669.78864436@localhost> References: <15340.58785.94412.122093@monster.linux.in> <3BED6CB8.27669.78864436@localhost> Message-ID: <15342.1.830165.25074@monster.linux.in> >>>>> "GMcM" == Gordon McMillan writes: GMcM> [Prabhu works on knee.py] >> it also fixes a bug where the parent package is an extension >> module. GMcM> Python provides no support for an extension module being a GMcM> package parent module. More precisely, I think the fact that GMcM> an extension module can be made to behave like a package GMcM> parent module is an accident. There is special code in GMcM> import for modules named __init__, and the code is bypassed GMcM> for extension modules. GMcM> I suspect you'd have to provide a pretty strong GMcM> justification before this would become supported behavior. I guess this was unclear. My addition is extremely simple and does not do anything new. Here is an illustration >>> import knee >>> import Numeric.array Traceback (most recent call last): File "", line 1, in ? File "/usr/local/lib/python2.1/knee.py", line 17, in import_hook m = load_tail(q, tail) File "/usr/local/lib/python2.1/knee.py", line 68, in load_tail m = import_module(head, mname, m) File "/usr/local/lib/python2.1/knee.py", line 97, in import_module parent and parent.__path__) AttributeError: 'Numeric' module has no attribute '__path__' >>> Point is, there is a line in knee.py (line 97 that assumes that there is a __path__ attribute for the passed parent. However, if parent is an extension module there is none. So I simply modified it. Here is the diff. $ diff knee.py /usr/local/lib/python2.1/knee.py 98,101c98 < except (ImportError, AttributeError): < # extension modules dont have a __path__ attribute. < # caching failures. < sys.modules[fqname] = None --- > except ImportError: In fact that is all I changed in knee.py! Which is why I said the changes are very small. Maybe I should have shown a patch but the mail was already long. prabhu From tatebll at aol.com Thu Nov 15 11:11:40 2001 From: tatebll at aol.com (Bill Tate) Date: 15 Nov 2001 08:11:40 -0800 Subject: Optimizing sockets to 1000 requests/sec? (Was: Sockets and messaging services) References: <3BF2C715.7050400@bigfoot.com> <97ae44ee.0111150043.4382fe2f@posting.google.com> Message-ID: shriek at gmx.co.uk (Stephen) wrote in message news:<97ae44ee.0111150043.4382fe2f at posting.google.com>... > Thanks for the help, Cezary > > > >>But when NUMTHREADS = 20, half the threads die with this error : > > >>Unhandled exception in thread: > > >>Traceback (most recent call last): > > >> File "", line 6, in send_request > > >> File "", line 1, in connect > > >>socket.error: (10061, 'Connection refused') > > > > If you are has clients and a server on the same machine, it is possible, > > that server it does not have enough time to accept connections on a > > listen socket. > > If I understand you correctly, then the server receives a > request, creates a thread to deal with it. But the server > is so busy creating threads to deal with incoming requests, > that some other requests are ignored. > > > By default only 5 connections can wait to be accepted - > > if more appears, they are refused by your operating system. You can > > raise this number, but there are limits on some OS-es. > > > > So, for really testing server you should launch clients from another > > machine(s). > > Sorry, you've lost me here. If the server can't generate > threads quick enough to deal with the incoming connections, > how will moving the clients to another machine give the > server more time (except perhaps in introducing a network > delay) ? > > > > For building high-performance server check: > > http://www.nightmare.com/medusa/ > > > > Medusa combines asyncore with threads for optimal performance. > > I had found the asyncore/asynchat method a little strange > but just downloaded the medusa package and there's a lot of > good documentation in the source. The included chat_server > example looks like a good starting point. Will try that. > > Sam also provides a great page of reference material. Excellent. > > Stephen. Stephen, You may also want to consider using stackless. Gordon has written a lot of code using stackless with continuations & non-blocking sockets. You may want to check out some of the material on his site for useful examples. From donn at drizzle.com Thu Nov 29 16:36:43 2001 From: donn at drizzle.com (Donn Cave) Date: Thu, 29 Nov 2001 21:36:43 -0000 Subject: popen with separete stdout/stderr deadlock. References: <3c069454@news.bezeqint.net> Message-ID: <1007069798.96988@yabetcha.sttl.drizzle.com> Quoth Eyal Lotem : | When running popen with a separate stdout/stderr, can I use read() on the | resulting stdout file? it seems to 'hang', and I'm assuming stderr's buffer | is stuck on write (as it is all filled up), and my stdout read() is stuck | on waiting for EOF, which will never come. Deadlock. | | Is this really what's happening and how can it be avoided? Deadlock is real. I don't know about popen with separate stdout/stderr, but otherwise the circumstances you describe are conceivable. - When you use file.read(), you will wait for EOF before anything returns, regardless of what else might be going on. - When you use posix.read(fileno), you will immediately get anything that has been flushed to the pipe. - Nothing will retrieve data that has not been flushed to the pipe, whether because the application is blocking on stderr write or simply due to normal block buffering. A pty device in place of the pipe may help with the latter, but can have its own problems. - When the application is writing to two separate pipes, use select(), on the file descriptor, to know which one has data. - When trying to do something like this on Windows, say so, preferably in the Subject so we don't have to read about your troubles. Donn Cave, donn at drizzle.com From logiplexsoftware at earthlink.net Fri Nov 2 15:50:51 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Fri, 2 Nov 2001 12:50:51 -0800 Subject: simple eval question In-Reply-To: <1f5252d4.0111021241.643efe1e@posting.google.com> References: <1f5252d4.0111021241.643efe1e@posting.google.com> Message-ID: <01110212505106.09296@logiplex1.logiplex.net> On Friday 02 November 2001 12:41, N Becker wrote: > What is wrong with this? > > eval ("print \"hello\"') > Traceback (most recent call last): > File "", line 1, in ? > File "", line 1 > print "hello" > ^ > SyntaxError: invalid syntax > > I expected that eval takes a string an evaluates it as input to the > interpreter, as if it had been typed into the command line. Was I wrong? Try exec rather than eval. -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From kzander at hot.rr.com Thu Nov 8 12:46:56 2001 From: kzander at hot.rr.com (Kristen Zander) Date: Thu, 08 Nov 2001 17:46:56 GMT Subject: Reading a comma delimited file References: Message-ID: Well, I thought I had it but the last thing I did with the fpformat made them string again. Does the %f work just like in C? %.2f,var Skip Montanaro wrote in message news:mailman.1005235753.29219.python-list at python.org... > > Kristen> Here's what it looks like when I'm done: > > Kristen> [('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 2.0, 11.1, > Kristen> 20.0, 0.0, 167.30000000000001), > Kristen> ('Cotulla', 28.449999999999999, 99.216700000000003, 1960.0, 3.0, > Kristen> 6.0999999999999996, 13.9, 0.0, 239.0)] > > Kristen> Just what I need except I don't want all those decimal places. > > You're being victimized by floating point (im)precision. Details here: > > http://python.sourceforge.net/devel-docs/tut/node14.html > http://www.python.org/cgi-bin/faqw.py?req=show&file=faq04.098.htp > > -- > Skip Montanaro (skip at pobox.com) > http://www.mojam.com/ > http://www.musi-cal.com/ > From dale at riverhall.NOTHANKS.co.uk Tue Nov 20 04:19:25 2001 From: dale at riverhall.NOTHANKS.co.uk (Dale Strickland-Clark) Date: Tue, 20 Nov 2001 09:19:25 +0000 Subject: String formatting char Message-ID: The string formatting operator, %, is a mighty powerful beastie when used in mapping mode if the map is an object of your own. You can even get substitution values from a database. However, the %(x)y syntax isn't appropriate if there are already '%' characters in the string or if, for some reason, you need to run the substition twice on two different mapping objects. You can get around it by substituting '%' for '%%' or translating to another char and translating back afterwards but what a pain! Is there some way to alter the format escape character from % to something else? -- Dale Strickland-Clark Riverhall Systems Ltd From leon at leonwebster.com Thu Nov 29 22:36:20 2001 From: leon at leonwebster.com (Leon Webster) Date: Thu, 29 Nov 2001 21:36:20 -0600 Subject: floating Pt. Division errors in Windows 2000 Message-ID: <05DN7.34897$H7.4336901@ruti.visi.com> I am just learning Python using the book Learning Python. Here's a sample problem from the book: >>>a = 3 >>>b =4 >>>b/(2.0 + a) When I execute this on my laptop (win2k machine, pentium III), I get the following answer: 0.80000000000000004 The same program on Linux provides the right answer (0.8), as does a program written in Java. Does anyone know why this happens? Is this a problem with Python on Windows or Win 2k? Thanks much Leon From greg at cosc.canterbury.ac.nz Wed Nov 28 18:40:36 2001 From: greg at cosc.canterbury.ac.nz (Greg Ewing) Date: Thu, 29 Nov 2001 12:40:36 +1300 Subject: PEP 276 Simple Iterator for ints (fwd) References: <3C056DF5.F9EE5D13@ccvcorp.com> Message-ID: <3C0575F4.9A23C894@cosc.canterbury.ac.nz> Jeff Shannon wrote: > > David Eppstein wrote: > > > I don't care for it -- is it really natural and intuitive > > that "x in y" should be equivalent to "0 <= x < y" when x and y are both > > ints? > > PEP 276 does not make an integer equivalent to the > list of natural numbers ending below it; I think the point Mr. Eppstein was making is that "for i in seq" can be read as "for all values of i such that i in seq is true". PEP 276 would break that, because "for i in 5" couldn't sensibly be read as "for all values of i such that i in 5 is true", unless "i in 5" on its own were valid and had a rather unintuitive meaning. -- 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 prabhu at aero.iitm.ernet.in Wed Nov 21 14:43:25 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Thu, 22 Nov 2001 01:13:25 +0530 Subject: Tinkering With Tkinter In-Reply-To: <5.1.0.14.0.20011121110847.00a44010@thewebsons.com> References: <5.1.0.14.0.20011121110847.00a44010@thewebsons.com> Message-ID: <15356.989.695045.78659@monster.linux.in> >>>>> "BO" == Ben Ocean writes: BO> Hi; I can't get tkinter installed. I'm running 2 different BO> versions of python and I need to install it with 2.1. [snip] BO> I've tried the -nodeps flag but that gives me a BO> non-operational tkinter! Why dont you simply install Tcl 8.3 and Tk 8.3? On my Debian machine I have both Tcl/Tk 8.0.x and 8.3.x. python 1.5.2 was installed from debs and python 2.1 from source. 1.5.2 used to use tcl/tk 8.0.x (a newer version uses 8.3.x) and Python 2.1 with 8.3.x. It all works perfectly well. BO> How do I specify which python to build with when I install BO> this rpm? TIA, BenO You cant specify that when you install a binary RPM - you could build the SRPM and re-build it. prabhu From gmcm at hypernet.com Fri Nov 16 08:32:50 2001 From: gmcm at hypernet.com (Gordon McMillan) Date: 16 Nov 2001 13:32:50 GMT Subject: Prob with Freeze.py References: <7396d2b2.0111152154.79f1dc6d@posting.google.com> Message-ID: [posted and mailed] Lemniscate wrote: > I am having a problem converting a python script into an exe. The > script works fine/great when run normally, but when I try to Freeze it > I get the following error. Anybody have any recommendations? Thanks > a bunch. Later. [snip] > C:\WINDOWS\Desktop\py2exe>UniLocString Hmm, despite the directory name, it looks like you're using Installer, not py2exe. > Traceback (most recent call last): ... > ImportError: No module named win32api Did you use the -win32 flag to Freeze? (If not, you can edit the cfg file and remove the exclude of pywintypes and win32api). >From your other post, I see you're using COM. If you're using win32com.client.Dynamic, you should be all set. If you're using the genpy stuff, please read the the last section of doc/faq.html. - Gordon From nospam at nosite.zzz Wed Nov 28 03:02:18 2001 From: nospam at nosite.zzz (Paul Lutus) Date: Wed, 28 Nov 2001 08:02:18 GMT Subject: a question of using regular expression References: Message-ID: "Stephen" wrote in message news:b551ef53.0111272346.68222906 at posting.google.com... > I am now using org.apache.regexp as the regular expression library in > my Java code. I meet a difficulty in implementating the following > regular expression, I don't know how to describe it (because of my > poor English), so I take an example: > > String sText0 = "good morning!"; > String sText1 = "morning! you are very good!"; > > RE r = new RE("???????????"); // I have no idea in this > > actually, I just want to get the string which has string "good" at the > start. Therefore, in this case, sText0 can be got only. How can I do > this? Thanks! Why don't you read up on how to write regular expressions? This information is available on the Internet, in textbooks, and in articles. http://www.google.com/search?q=writing+regular+expressions -- Paul Lutus www.arachnoid.com From ws-news at gmx.at Thu Nov 22 15:10:38 2001 From: ws-news at gmx.at (Werner Schiendl) Date: Thu, 22 Nov 2001 21:10:38 +0100 Subject: string.join() syntax quirky? References: <3BFD49D8.F7A4C6CC@earthlink.net> Message-ID: <3bfd5c83@brateggebdc5.br-automation.co.at> Hi, "Marcin 'Qrczak' Kowalczyk" wrote in message news:slrn9vqk7s.6rc.qrczak at qrnik.zagroda... .... > > It seems backwards for me - the sequence is more important than the > separator - but I wouldn't treat it as a list method either. More > as a global function. > This option does exist anyway, you can just use the string module. It has a join function, which ends up calling the delimiters strings join method. > But I'm strange in that I don't believe in OOP as a universal way > of life. -- snip -- Hm, seems I'm strange then, too :-). best regards Werner From brueckd at tbye.com Tue Nov 6 13:29:13 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Tue, 6 Nov 2001 10:29:13 -0800 (PST) Subject: Teaching python (programming) to children In-Reply-To: <8ef9bea6.0111060838.24996280@posting.google.com> Message-ID: On 6 Nov 2001, Hung Jung Lu wrote: > How soon does a beginner run into the following problem? (see also the > "How much is set in stone?" thread) [snip] Unfortunately for your argument, most people are not morons. They are fully capable of learning, and few, if any, will really struggle with this problem for very long. I don't think anyone is suggesting Python as a first language because it is a perfect language - you can find a problem with any choice. But given the set of languages to choose from, Python's positives outweigh its negatives as a good choice for beginners. -Dave From brueckd at tbye.com Fri Nov 30 00:13:09 2001 From: brueckd at tbye.com (brueckd at tbye.com) Date: Thu, 29 Nov 2001 21:13:09 -0800 (PST) Subject: Python evangelists unite! In-Reply-To: <9u6fnl$b343@news1.gtech.com> Message-ID: On Fri, 30 Nov 2001, Peter Milliken wrote: > I use Python as a good, quick and dirty hacking language. For real (read > production) stuff that I expect a customer to run or will require more than > a single person working for a couple of hours, I look elsewhere :-). Sure > there are examples of Python being used for "large" jobs - and very > successful they have been too - but these people are masochists (IMO) :-). > They could have been more productive with other languages that provide > better support for generic software engineering principles/standards. I am *so* glad that there are people in the world that share your opinion because you hand me a competitive advantage on a silver platter. I don't even have to work for it! Keep up the good work; many, many thanks! -Dave From phr-n2001d at nightsong.com Wed Nov 7 04:16:07 2001 From: phr-n2001d at nightsong.com (Paul Rubin) Date: 07 Nov 2001 01:16:07 -0800 Subject: Teaching python (programming) to children References: <3BE82570.D76DCAE9@juno.com> Message-ID: <7xwv13kkko.fsf@ruckus.brouhaha.com> Brian Elmegaard writes: > I have to check out logo. Here's a Logo FAQ: http://www.erzwiss.uni-hamburg.de/Sonstiges/Logo/logofaqx.htm From BPettersen at NAREX.com Thu Nov 1 19:15:02 2001 From: BPettersen at NAREX.com (Bjorn Pettersen) Date: Thu, 1 Nov 2001 17:15:02 -0700 Subject: List transpose method Message-ID: <60FB8BB7F0EFC7409B75EEEC13E20192158C13@admin56.narex.com> > From: Gerhard H?ring [mailto:gh_pythonlist at gmx.de] > > On Thu, Nov 01, 2001 at 08:51:27PM -0200, Gustavo Niemeyer wrote: > > > Suppose I have a list like ((1,2), (3,4), (5,6)). Can some > > > functional guru tell me a one liner to transpose this to the form > > > ((1,3,5),(2,4,6))? I can only come up with an ugly multiliner. > > > > >>> zip((1,2),(3,4),(5,6)) > > [(1, 3, 5), (2, 4, 6)] > > Hmm. How would I apply zip if I have a variable already, like > > l = ((1,2),(3,4),(5,6)) >>> x = ((1,2),(3,4),(5,6)) >>> zip(*x) [(1, 3, 5), (2, 4, 6)] >>> -- bjorn From tjreedy at home.com Wed Nov 21 02:35:04 2001 From: tjreedy at home.com (Terry Reedy) Date: Wed, 21 Nov 2001 07:35:04 GMT Subject: nice python solution References: <9t95gu$ab7l1$1@hades.rz.uni-sb.de> <9t9h3j$7r9$1@tyfon.itea.ntnu.no> <3BFB237B.3FC46A84@astro.cornell.edu> Message-ID: "Tom Loredo" wrote in message news:3BFB237B.3FC46A84 at astro.cornell.edu... > Steve Holden wrote: > > > > > > locals()[['a','b'][idx]] = val > > > > > This is absolutely verboten. I quote from Section 2.3 of the 2.0 manual, but > > I don't think anything has changed since: """locals () > > Return a dictionary representing the current local symbol table. Warning: > > The contents of this dictionary should not be modified; changes may not > > affect the values of local variables used by the interpreter. > > """ 'verboten' is not quite right. The statement is legal, but may not do what one expects -- ie, it may be equivalent to 'pass'. > But the code only modifies one of the references "a" or "b", I am not quite sure what you mean by this. > not the locals dictionary. Or am I missing something? Look again. The statement above is equivalent to adict = locals() key = ['a','b'][idx] adict[key] = value del adict, key Unless adict *is* the local namespace (which it will not be inside a function), the above is equivalent to 'pass' and not if not idx": a = value else: b = value as intended. Terry J. Reedy From prabhu at aero.iitm.ernet.in Tue Nov 13 14:06:40 2001 From: prabhu at aero.iitm.ernet.in (Prabhu Ramachandran) Date: Wed, 14 Nov 2001 00:36:40 +0530 Subject: Problem installing VTKPython In-Reply-To: <3BF153BA.77D0566C@cicei.ulpgc.es> References: <3BF153BA.77D0566C@cicei.ulpgc.es> Message-ID: <15345.28480.586905.717956@monster.linux.in> >>>>> "EC" == Enrique writes: EC> MS-Windows PC I have downloaded VTKcore.exe and VTKPython.exe. EC> Installation of VTKcore.exe simply copies vtkdll.dll into EC> c:\windows\system. I guess you downloaded these from the VTK site? These were built for Python 1.5.2 and not for 2.1. I suggest that you check out Les Schaffer's DLL's for Python 2.1: http://basic.astrian.net/godzilla/ Mark Hadfield made some notes on his installation on Win32. His message is here: http://www.geocrawler.com/archives/3/12167/2001/6/0/5915914/ If you have more problems mail the mayavi-users list that I've CC'd to here. prabhu From kerstin.dressler at web.de Fri Nov 9 09:08:46 2001 From: kerstin.dressler at web.de (Kerstin) Date: 9 Nov 2001 06:08:46 -0800 Subject: Calling Ghostscript from Python Message-ID: Hi, I'm trying to call the ghostscript to convert some PS to PDF. I'm working on Win95, so the os.system() always returns '0'. When the cmd is running, the DOS-Box opens and I get the error message "File or directory not found". I also checked if the PS are readable; and when I change the cmd to something else (like "md new_dir") it works. ghost_dir = 'c:\ghost\gs\gs7.00\lib' cmd = ghost_dir + '\ps2pdf13.bat ' + ps_file + ' ' + pdf_file os.system(cmd) I think there must be something wrong with the pathname or rather the ghost environment. How can I check this? I'm using full pathnames for 'ps_file' and 'pdf_file' too! Might this cause problems? Can anybody help me? Thanx, Kerstin From blagrang at ulb.ac.be Wed Nov 7 06:00:24 2001 From: blagrang at ulb.ac.be (Benoit Lagrange) Date: Wed, 07 Nov 2001 12:00:24 +0100 Subject: Disk explorer from python with COM Message-ID: <3BE91448.5020809@ulb.ac.be> Hi all I am wondering wether it is possible to browse the disk from a python application by using COM. And if it is possible, how to use it? Any help would be great. Thanks Benoit Lagrange From quickdry at users.sourceforge.net Mon Nov 19 23:24:10 2001 From: quickdry at users.sourceforge.net (Quick Dry) Date: Tue, 20 Nov 2001 15:24:10 +1100 Subject: displaying an Image using PIL w/o Image.show References: <3sjjvt0c8rnq3iuhtnlqvb1a3ekpr4ac0d@4ax.com> Message-ID: <3bf9d934$0$10227$afc38c87@news.optusnet.com.au> "Tech" wrote in message news:3sjjvt0c8rnq3iuhtnlqvb1a3ekpr4ac0d at 4ax.com... > How do to show an Image in PIL without calling the Image.Show() > Method? I tried to use Image.Show() but I don't have some lib that I > need. Anyway the online docs seemed to suggest the there may be a > better way but did not say what it was. you could display the image on a Canvas, thus showing it all via Python heres a quick hack I used to show an updated image from a webcam, its probably got all sorts of bad style, but shows an image on a canvas, and updates it every so often ------------ code starts here ------------ from Tkinter import * import Image, ImageTk import webcam # has methods to get images from a webcam Width, Height = 320, 240 ADDRESS="127.0.0.1" PORT="8081" REFRESH=500 class Camera(Frame): def __init__(self, parent=None, title='eHome', address=ADDRESS, port=PORT, msecs=1000, **args): Frame.__init__(self, parent, args) self.title=title self.address=address self.port=port self.makeWidgets() self.pack(expand=YES, fill=BOTH) self.width=WIDTH self.height=HEIGHT self.image_store = None self.msecs = msecs self.confirmQuit = 0 self.drawn = None self.fit = 1 def makeWidgets(self): self.canvas = Canvas(self, bg='white', height=Height, width=Width) self.canvas.pack(side=LEFT, fill=BOTH, expand=YES) self.onoff = Button(self, text='Start', command=self.onStart) self.onoff.pack(fill=X) Button(self, text='Quit', command=self.onQuit).pack(fill=X) def onStart(self): self.loop = 1 self.onoff.config(text='Stop', command=self.onStop) self.canvas.config(height=self.height, width=self.width) self.onTimer() def onStop(self): self.loop = 0 self.onoff.config(text='Start', command=self.onStart) def onQuit(self): self.onStop() self.update() if not self.confirmQuit: self.quit() else: if askyesno(self.title, 'Really quit now?'): self.quit() def onTimer(self): if self.loop: self.drawNext() self.after(self.msecs, self.onTimer) def drawNext(self): if self.drawn: self.canvas.delete(self.drawn) name = "campic" img = self.getCamPic() img1=ImageTk.PhotoImage(image=img) self.drawn = self.canvas.create_image(2, 2, image=img1, anchor=NW) self.image = name, img1 self.canvas.update() def getCamPic(self): img=ImageTk.PhotoImage(data=webcam.read(self.address+":"+self.port)) return img if __name__ == '__main__': root = Tk() root.title('CamView 1.0') Label(root, text="Cameras").pack() Camera(root, bd=3, address=ADDRESS, port=PORT, msecs=REFRESH, relief=SUNKEN).pack() root.mainloop() From mjackson at wrc.xerox.com Fri Nov 9 09:18:55 2001 From: mjackson at wrc.xerox.com (Mark Jackson) Date: 9 Nov 2001 14:18:55 GMT Subject: iters on ints? (reducing the need for range/xrange) References: Message-ID: <9sgokf$j1o$1@news.wrc.xerox.com> "Rainer Deyke" writes: > "Luigi Ballabio" wrote in message > news:mailman.1005305487.25887.python-list at python.org... > > This said, while it makes sense in english to say "do this for every line > > IN this file", it just doesn't sound right to me to say "do this for every > > number IN 10"---even though I've been once familiar with the definitions > of > > the set of all integers. I'd rather say "for every number UP TO 10" but > > that would mean introducing a new keyword which I'm not going to suggest, > > not me, sir. > > I consider that a fairly weak argument. Programming languages should be > simple, internally consistent, fairly easy to learn, well defined, and able > to express programs with minimum redundacy. English is none of these, so > English should not be used a basis for creating a programming language. As > an example, the for-else construct in Python is a good language construct, > even if it has no equivalent in English. I agree with the general point but not with the example. The sense in which else is used with for and while in Python has always struck me as *inconsistent* with the way it is used with if. (I realize that if you look at it the "right" way it's consistent, but that way seems unnatural to me.) -- Mark Jackson - http://www.alumni.caltech.edu/~mjackson After a recent trip to New York one French journalist remarked that leafing through a copy of /Forbes/ or /Fortune/ is like reading the operating manual of a strangely sanctimonious pirate ship. - Adam Gopnik From jtdubs at eos.ncsu.edu Wed Nov 14 17:40:18 2001 From: jtdubs at eos.ncsu.edu (Justin Dubs) Date: Wed, 14 Nov 2001 17:40:18 -0500 Subject: does \1 in re work? References: Message-ID: <9surpa$eek$1@uni00nw.unity.ncsu.edu> "Michael P. Soulier" wrote in message news:slrn9v5qvc.u31.msoulier at pmerd071.ca.nortel.com... > Hello. > > Looking at the documentation for python 1.5.2, the now aging version that > I'm using, in the re module it states that the standard \1, \2 keys that > reference that matched value in parenthesis in the pattern do in fact work, as > do \g<1>, \g<2>, etc. > > So, I tried this: > > new = re.sub("^(-?\d+)(\d{3})", '\1,\2', amount) > > new always ended up being '\001,\002'. Not what I wanted. > > So, I used the alternate... > > new = re.sub("^(-?\d+)(\d{3})", '\g<1>,\g<2>', amount) > > Which worked perfectly, giving me, for example, > > '100000,000' where amount was '100000000'. > > So, my question is, what was wrong with my first pattern? > > Thanks very much, > > Mike > > -- > Michael P. Soulier, TD12, SKY Tel: 613-765-4699 (ESN: 39-54699) > Optical Networks, Nortel Networks, SDE Pegasus > "...the word HACK is used as a verb to indicate a massive amount > of nerd-like effort." -Harley Hahn, A Student's Guide to Unix Python is getting to your strings before re.sub() is. It's changing the \1 and \2 into the corresponding characters before re.sub() ever sees the string because the \'s are escape characters. Two easy solutions, offhand: re.sub(...., r"\1,\2", ...) Notice the r in front of the quotation marks. This will stop python from messing with those \'s. re.sub(...., "\\1,\\2", ...) In this case, the change is the double \'s which will be processed by Python and turned into the single \'s that you wanted originally. Either way, it'll work. Have fun and good luck, Justin From gh_pythonlist at gmx.de Tue Nov 13 07:52:38 2001 From: gh_pythonlist at gmx.de (Gerhard =?iso-8859-1?Q?H=E4ring?=) Date: Tue, 13 Nov 2001 13:52:38 +0100 Subject: ISP with Python script hosting In-Reply-To: <3BF11003.20941.6D8133@localhost> References: <3BF11003.20941.6D8133@localhost> Message-ID: <20011113135236.A1138@lilith.hqd-internal> On Tue, Nov 13, 2001 at 12:20:19PM +0100, A wrote: > Hi, > Does anyone know about > 1.an ISP who hosts Python scripts? http://www.corrt.com/info/pyisp-list.html Gerhard -- mail: gerhard bigfoot de registered Linux user #64239 web: http://www.cs.fhm.edu/~ifw00065/ OpenPGP public key id 86AB43C0 public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0 reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b'))) From loewis at informatik.hu-berlin.de Fri Nov 9 08:08:48 2001 From: loewis at informatik.hu-berlin.de (Martin von Loewis) Date: 09 Nov 2001 14:08:48 +0100 Subject: Defining inheritance in C extensions References: Message-ID: Timo Savola writes: > Now I'm doing an extension module, or rather a system that I want to > control via Python. I have a C++ class hierarchy that I want to be > accessible from Python. I can't figure out how to make a type object a > subclass of another type object, so that I can do type checking in the > Python wrappers of my methods. In Python 2.1 and earlier, type objects don't inherit from each other, unless you use the ExtensionClasses package. However, I'd argue that you don't need to reflect the C++ hierarchy in the Python types at all: just make the Python types completely unrelated to each other. Regards, Martin From jesper at strindberg.maisel.enst-bretagne.fr Sat Nov 10 06:52:16 2001 From: jesper at strindberg.maisel.enst-bretagne.fr (Jesper Holmberg) Date: 10 Nov 2001 12:52:16 +0100 Subject: XML Schema Message-ID: <87vggivo5r.fsf@strindberg.maisel.enst-bretagne.fr> Hi All, I'm trying to get some overview of xml tools in Python, but I'm a little overwhelmed by the large number of sometimes half-finished, often poorly documented, libraries and toolkits. I guess this in part is due to XML being a relatively new technology. However, I'm more specifically looking for Python implementations of XML Schema-validating parser. Does anyone here know of any tool-kit/parser that supports XML Schema? TIA Jesper From db3l at fitlinxx.com Thu Nov 22 00:32:05 2001 From: db3l at fitlinxx.com (David Bolen) Date: 22 Nov 2001 00:32:05 -0500 Subject: Indenting with tabs vs spaces References: Message-ID: "Peoter Veili" writes: > > >Tabs are wrong, because different editors will treat them differently. > > > > > >Spaces are right, because a space is a space is a space, everywhere you > > >go. > > Indenting with tabs can be done such that it will look the same on every > editor that uses fixed-width fonts, meaning everything will line up > correctly, it least in the sense that really matters. Um, that's only true if your visual display uses the same indentation for tabs as someone else's. E.g., if your fixed-width editor has "tab stops" at 4 spaces, and someone else's has it at 8, then obviously what lines up on yoru screen won't on theirs and vice versa. It just gets worse if you include a mixture of tabs and spaces, since then it probably won't even be aligned in general on the other system. The above only works if you both agree on the visual display of the tab character. > Besides this I know of no problems with using tabs. I find them > cleaner and more efficient. I'd rather tab 10 times than hit the If only we could all agree on how tabs in a file should be displayed there wouldn't be a problem (technically, there's no parser problem anyway it's all visual but then that's part of coding). But clearly as past discussions have shown we can't, so the general rule of sticking with spaces makes it easier for everyone to see the same visual representation of source. Your example code is a good example - it showed up in my newsreader (fixed font) as: function helloThere("hello", "there"){ } so I'm not quite sure what it was supposed to look like, but I expect it certainly didn't look like that on your screen :-) > cleaner and more efficient. I'd rather tab 10 times than hit the > space bar 40 times. I never have to go through a whole file and > manually line things up because at one place in the file I > accidentally didn't indent with the right amount of spaces and half > the file needs fixing. Auto-indent helps, but still.... As someone else pointed out, we do need to keep distinct the concept of pressing the tab key, and using a tab character within the source. There are many ways to minimize input while not requiring hard tabs in the source. There's absolutely nothing wrong with using the tab key to indicate that you want some sort of logical indentation, but it's probably best if the tool decides to do it with spaces. For example, Python mode in emacs will auto-indent a line on tab, but if it guesses wrong, a single backspace will step back a full indentation level (4 spaces) so it can still be very efficient to key in even though spaces are being used. -- -- 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 wurmy at earthlink.net Tue Nov 27 21:29:57 2001 From: wurmy at earthlink.net (Hans Nowak) Date: Wed, 28 Nov 2001 02:29:57 GMT Subject: module.__path__ References: Message-ID: <3C044C1E.10B14A12@earthlink.net> > Ken Seehof wrote: > > Why is the __file__ attribute (of a module) a relative filename rather > than a fully qualified filename? One would think that the __file__ > attribute might be used for the purpose of locating and opening a > source file, right? If somebody wants a relative filename couldn't > they split it themselves? By making module.__file__ relative, > information is lost. What was Guido thinking??? Perhaps a > __fullpath__ should be added. > > Don't tell me about the fact that .pyc files might be moved along with > .py file from a different computer, thereby rendering the full > pathnames incorrect. That's a silly argument not worth addressing. > :-) > > Is there a good general way to determine the full pathname of a module > file, or is the best approach to search sys.path for module.__file__? Hmmm... os.path.abspath(module.__file__) should return the absolute pathname... --Hans From grahamd at dscpl.com.au Wed Nov 28 04:10:26 2001 From: grahamd at dscpl.com.au (Graham Dumpleton) Date: 28 Nov 2001 01:10:26 -0800 Subject: Sockets and messaging services References: <97ae44ee.0111112119.e8f42d2@posting.google.com> Message-ID: shriek at gmx.co.uk (Stephen) wrote in message news:<97ae44ee.0111112119.e8f42d2 at posting.google.com>... > I have a CGI script which takes a HTTP request then sends > a message to a custom server built on top of SocketServer.ThreadingTCPServer. > Not that there is much chance of webserver CGI saturating the latter, > but does Python have a messaging framework, similar to JMS for Java ? > http://developer.java.sun.com/developer/technicalArticles/Networking/messaging/ As far as messaging frameworks go, for something a bit different, have a look at OSE. The web site is: http://ose.sourceforge.net It contains Python interfaces for a HTTP servlet framework, and a distributed messaging framework. Thus, you can have a service in one process which you send requests to from the HTTP servlet in a different process, using the response to generate your HTML etc. From logiplexsoftware at earthlink.net Tue Nov 20 16:06:50 2001 From: logiplexsoftware at earthlink.net (Cliff Wells) Date: Tue, 20 Nov 2001 13:06:50 -0800 Subject: How to marshal a function? In-Reply-To: <83itc5mawu.fsf@panacea.canonical.org> References: <83itc5mawu.fsf@panacea.canonical.org> Message-ID: <01112013065003.01362@logiplex1.logiplex.net> On Tuesday 20 November 2001 12:42, Kragen Sitaker wrote: > Well, it probably won't introduce any significant new insecurities, > anyway (assuming ssh is letting him run arbitrary commands, which he > says it is.) But using ssh for remote execution is neither necessary > nor sufficient for security. I believe, from the information he gave me, that he is using it in a fashion similar to the way X is routed over ssh. From the ssh man page: "Forwarding of arbitrary TCP/IP connections over the secure channel can be specified either on command line or in a configuration file. One possible application of TCP/IP forwarding is a secure connection to an electronic purse; another is going through firewalls." As far as whether this will provide sufficient security, that's obviously more difficult to say. It was merely my original intention to point out the possibility of a security hole (there was no information regarding how he was using this application in the first few posts), it seeming likely to me that more information regarding his particular application would be forthcoming, but the discussion didn't continue in this vein, so this was never addressed. This may have been my fault, and I have already apologized to Fran?ois for this. > > > Additionally, since his attitude was similar to yours (annoying), I > > decided to end it by agreeing with him, which I find to be the > > quickest way to avoid wasting my time with people who flame rather > > than discuss. > > > > You are absolutely right: no one can decide except him whether his > > security is sufficient, hence everyone should avoid offering advice on > > the subject in case someone may disagree with you. > > I disagree with your above statements; they are not what I said in my > post. I said you need to know more information than he posted to > evaluate whether or not a particular trust relationship represents a > security vulnerability. True. I was merely pointing out that execution of arbitrary code on a server opens a potential security hole. I don't think anyone would disagree with that. > I wouldn't have bothered to follow up (I'm not fond of flaming either) > if you hadn't misstated my position above. (If that's what you > thought my position was, it's no wonder you were annoyed.) If I misunderstood you, I apologize. I didn't find your opinion on security annoying so much as the words "irk" and "glib", which I found to be sort of rude. Anyway, this type of thing happens, so please, no hard feelings. Regards, -- Cliff Wells Software Engineer Logiplex Corporation (www.logiplex.net) (503) 978-6726 x308 (800) 735-0555 x308 From ChuckEsterbrook at yahoo.com Thu Nov 15 11:28:13 2001 From: ChuckEsterbrook at yahoo.com (Chuck Esterbrook) Date: Thu, 15 Nov 2001 08:28:13 -0800 Subject: pinglib? Message-ID: <20011115162814.WFRB622.femail18.sdc1.sfba.home.com@there> Does anyone have a pinglib module for Python? All I can find is Jeremy Hylton's "ping and traceroute", but the link to the tar file gives a 404 Not Found. Also, ActiveState has something in this area, but only for Perl. -Chuck From kragen at canonical.org Mon Nov 26 17:18:14 2001 From: kragen at canonical.org (Kragen Sitaker) Date: 26 Nov 2001 17:18:14 -0500 Subject: smtplib help References: <83wv0ds4pk.fsf@panacea.canonical.org> Message-ID: <83g071rxax.fsf@panacea.canonical.org> Oleg Broytmann writes: > On Mon, Nov 26, 2001 at 02:38:15PM -0500, Kragen Sitaker wrote: > > Have you tried running the code on an operating system that doesn't suck? > > Have you ever saw a piece of software that does not suck? :( I guess you have a point there. So I should ask: Even though Linux sucks, I don't think it sucks in that particular way. Have you tried running the code on Linux? From tim.one at home.com Sun Nov 4 18:27:19 2001 From: tim.one at home.com (Tim Peters) Date: Sun, 4 Nov 2001 18:27:19 -0500 Subject: Q: Feature Wish: "%" Extension In-Reply-To: <7xsnbu9qc4.fsf@ruckus.brouhaha.com> Message-ID: [Paul Rubin] > Knuth says to use floor_mod? Where? [Tim] > Knuth *defines* x mod y as being x - y * floor(x/y), way back > in volume 1. [Paul] > Yes, x mod y is usually defined that way. However, "x remainder y" > doesn't necessarily mean the same thing. The question then is whether > % in a programming language should denote "mod" or "remainder". The question was "what does Knuth say?" -- as you just quoted yourself asking . Luckily, the answer to that turns out to be the same as the answer to what % in a programming like should do: a negative modulus is exceedingly rare in real life (I believe I've never used one, apart from writing compiler conformance tests), and floor-mod is gobs more useful for positive modulus. Some languages supply more than one operator. > ... > All integer division instructions I've seen give separate quotient > and remainder results, with remainder==trunc_mod. I agree that's most common. The RISC trend is to supply no integer division instruction at all; Intel's Itanium is a prominent current example: Why do it in hardware when you can explain how to fake it in a 131-page document ? From geek+ at andrew.cmu.edu Mon Nov 26 15:49:49 2001 From: geek+ at andrew.cmu.edu (Brian E Gallew) Date: Mon, 26 Nov 2001 15:49:49 -0500 Subject: postgresql triggers to update GUI? In-Reply-To: References: <20011126.145234.816620091.2222@localhost.localdomain> Message-ID: <200111262049.fAQKnnda005432@lin2.andrew.cmu.edu> "Robert Nikander" wrote ... > I am writing a python program that uses a postgresql db backend. I would > like to update the gui whenever a change in certain tables occurs, so it > would be nice to use triggers rather than generating the 'events' when I > update the db. That way I get cascading changes. Does anyone know of a > python module that supports postresql triggers? ie: you can create a > trigger that calls a python function? Is there another solution here > that I am missing? What you are looking for are asynchronous requests. Basically, you make an async request, then in your GUI mainloop you peridically check to see if you got any results (updating the GUI if necessary). There is no way to make a database trigger talk to your GUI UNLESS you are willing to open up a socket in the GUI, listen/process requests on it and have your database trigger write to that socket (don't forget to have error handling in there so that it doesn't crash when there's no one listening). -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 266 bytes Desc: not available URL: From pete at shinners.org Fri Nov 30 12:59:31 2001 From: pete at shinners.org (Pete Shinners) Date: Fri, 30 Nov 2001 09:59:31 -0800 Subject: What's the value of "None" between 2.1.1 and 1.5.2 References: <3C06FB65.B27A6A12@earthlink.net> Message-ID: <3C07C903.8080605@shinners.org> Ozone Hole near South Pole wrote: >I have written a simulation in python 1.5.2.... It used to work fine. > >When I logged on a new machine which has Python 2.1.1 installed, my >simulation has gone wild. Later on, I figured that out one weird thing >about the value of "None": not sure how 'kosher' this is, but it's perfectly legal python. just do something like "None = 0" at the start of any script where you want to do numerical comparisons on None :] of course, you will run into problems with other modules passing you "None" and trying to compare it to the None in your module. still, if you are just trying to get some old code up and running, this may be a quick fix for you From nospam at bigfoot.com Mon Nov 26 17:38:35 2001 From: nospam at bigfoot.com (Gillou) Date: Mon, 26 Nov 2001 23:38:35 +0100 Subject: vCard parser anywhere ? References: <9trh93$o1e$1@norfair.nerim.net><9tu7ue$75m$1@norfair.nerim.net> Message-ID: <9tufsu$ff3$1@norfair.nerim.net> Of course, my headache copyright notice is actually ruled by the GPL ;-) I'll make a tarball of it and offer for download to everybody. All I know today about Lisp is its acronym : Lots of Insipid and Stupid Parenthesis... Think I'll do the pythonic job from scatch and from RFC specs. "Fran?ois Pinard" a ?crit dans le message news: mailman.1006808555.28521.python-list at python.org... > [Gillou] > > > I'm gonna take some aspirin, learn some lisp and make it pythonic. > > Just make sure you make the result of your works available to others! :-) > > -- > Fran?ois Pinard http://www.iro.umontreal.ca/~pinard > > From maxwell at ldc.upenn.edu Mon Nov 19 12:19:08 2001 From: maxwell at ldc.upenn.edu (Mike Maxwell) Date: Mon, 19 Nov 2001 12:19:08 -0500 Subject: context-sensitive help from editor Message-ID: <9tbetv$e92$1@netnews.upenn.edu> Excuse me if this has been asked, but I didn't see anything in the FAQ, the archive of this newsgroup (except for a 1995 msg), etc. My editor (Visual SlickEdit, on Win2k) has context-sensitive help for a number of programming languages. Normally, this calls a Windows Help (.HLP, or nowadays .CHM) file with a keyword. I would like to be able to do this with Python, but all I can find are .html, .PDF, and .PS files, and I don't know how to open one of these at a given keyword (or make it jump to a new keyword if it's already open). I can of course drill down through the links, but that misses the point of having context-sensitive help. Is there a .HLP or .CHM file out there somewhere? Or is there an easy way to turn a .HTML file into a .CHM file? (Or a way of passing a keyword to Adobe Reader or GhostView, so it goes directly to the relevant place in the doc.) -- Mike Maxwell Linguistic Data Consortium maxwell at ldc.upenn.edu From bwinton at tor.dhs.org Wed Nov 14 09:44:42 2001 From: bwinton at tor.dhs.org (Blake Winton) Date: Wed, 14 Nov 2001 14:44:42 GMT Subject: IsPython really O-O? References: <87f44f44.0111121306.426c8e4f@posting.google.com> <87f44f44.0111131022.5ab1b6f@posting.google.com> Message-ID: On Tue, 13 Nov 2001 13:21:09 -0800, Paul Prescod wrote: >Adam Spitz wrote: >> In Python, it feels like I'm sneakily hacking an >> extra method into a class against its will. >You are doing something sneaky in *any* language because if anyone else >defines newMethod in any other module anywhere in the system you'll >overwrite each other. Classes are more or less global variables and so >are their methods. I wonder if this has to be the case. Perhaps a Class could be made module-specific, so that any changes to the Class would only occur in the module they were changed in. (As an implementation, I'm thinking of something like the "__spam" changing to "_classname__spam"... So if something in module "eggs" adds the method "bacon" to the class "spam", it would actually go in as "_eggs__bacon", with the interpreter checking for the module version of the function first, and if it didn't find it, checking for the base version. This could also generalize to nested modules as "_eggs_ham__bacon" for the "eggs.ham" module, with the interpreter checking for the method in the order "_eggs_ham__bacon" followed by "_eggs__bacon" followed by "bacon".) >Python would probably not have first-class syntax to do this until there >were a way to do it that scaled well to large programs written by people >who do not necessarily communicate with each other. Something like throwing a "Method Already Defined" exception if you step on someone else's toes? Or more like the module syntax I described above? Or something else entirely? Caveat: I've never found a need to define a method on an object I didn't own, so all of this is mere speculation. For that matter, I really haven't taken much advantage of Python's dynamic nature at all. Later, Blake. -- 9:40pm up 52 days, 21:07, 2 users, load average: 0.02, 0.09, 0.07 From brian at rk-speed-rugby.dk Tue Nov 6 02:21:35 2001 From: brian at rk-speed-rugby.dk (Brian Elmegaard) Date: 06 Nov 2001 08:21:35 +0100 Subject: Teaching python (programming) to children References: <7xsnbs65ke.fsf@ruckus.brouhaha.com> Message-ID: Paul Rubin writes: > What age of children are you talking about? I think not everyone here > is thinking of "children" as meaning the same thing. True, and I find your first answer about logo very interesting. I think ages 9-12, I guess. After they have learned to read and write their native language, but they don't necessarily have to have learned a high level of abstract thinking. My idea is that programming your own utilities could be taught at close to the same age as where you begin to learn word processing, power point,... -- Brian (remove the sport for mail) http://www.rk-speed.dk http://fiduso.dk http://sunsite.auc.dk/dk-tug \TeX, tak. From kalipygian at hotmail.com Thu Nov 22 05:57:40 2001 From: kalipygian at hotmail.com (Kali Kim) Date: 22 Nov 2001 02:57:40 -0800 Subject: Getting the class of a method in Python 2.2 (semantic change from 2.1) References: Message-ID: <64a28082.0111220257.22e463f6@posting.google.com> Martin von Loewis wrote in message news:... > "Kali Kim" writes: > > > Can anyone help me? > > I think this is not possible in 2.2. Why do you need that? > > Regards, > Martin In order to analyze class relationships and informations (something like pydoc) dynamically, for example, in a class browser or code analyzer. Thanks, anyway. From d_blade8 at hotmail.com Tue Nov 27 18:26:57 2001 From: d_blade8 at hotmail.com (Lemniscate) Date: 27 Nov 2001 15:26:57 -0800 Subject: python vs ecmascript References: <3BF5657F.802474EE@earthlink.net> Message-ID: <7396d2b2.0111271526.795b510c@posting.google.com> Ron Stephens wrote in message news:<3BF5657F.802474EE at earthlink.net>... > Hello !! ;-))) > > JavaScript is nice because you can embed it in web browsers and use it to do > input/putupt interfaces over the web. JavaScript and its cousins (ecmascript et > al) are somewhat unique in working almost all the time in almost all web > browsers in this regards. > > The above is an advantage of JavaScript over Python. True, true. You can embed JS on the web and it is supported by "almost all web browsers in this regards(sic)" but you can, theoretically, do the same thing with Python. You can embed Python script the same way you would embed JavaScript ot VBScript (